Skip to content

Commit

Permalink
fixup! Load images in e2e tests with openstackimage controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mdbooth committed Jul 17, 2024
1 parent 756842d commit 07e514a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 6 additions & 1 deletion test/e2e/shared/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ const (
// Timeout for both creation and deletion.
imageTimeout = 15 * time.Minute

// The base URL of the CAPO staging artifacts bucket
stagingArtifactBase = "https://storage.googleapis.com/artifacts.k8s-staging-capi-openstack.appspot.com/test/"

// The name of the credentials secret
credentialsSecretName = "openstack-credentials" //nolint:gosec // these aren't hard-coded credentials

// A tag which will be added to all glances images created by these tests
E2EImageTag = "capo-e2e"
)

type DownloadImage struct {
Expand Down Expand Up @@ -243,7 +248,7 @@ func generateOpenStackImage(e2eCtx *E2EContext, name, glanceName, url string, do
},
},
},
Tags: []infrav1alpha1.ImageTag{"capo-e2e"},
Tags: []infrav1alpha1.ImageTag{E2EImageTag},
IdentityRef: infrav1.OpenStackIdentityReference{
Name: credentialsSecretName,
CloudName: e2eCtx.E2EConfig.GetVariable("OPENSTACK_CLOUD"),
Expand Down
13 changes: 7 additions & 6 deletions test/e2e/suites/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ var _ = SynchronizedBeforeSuite(func(ctx context.Context) []byte {
Expect(err).NotTo(HaveOccurred())
initialVolumes, err = shared.DumpOpenStackVolumes(e2eCtx, volumes.ListOpts{})
Expect(err).NotTo(HaveOccurred())

// There can be a lot of public images on an existing cloud, so filter
// on only the ones created by this test.
initialImages, err = shared.DumpOpenStackImages(e2eCtx, images.ListOpts{Tags: []string{"capo-e2e"}})
Expect(err).NotTo(HaveOccurred())
})

// CheckResourceCleanup checks if all resources created during the test are cleaned up by comparing the resources
Expand Down Expand Up @@ -125,7 +120,13 @@ var _ = SynchronizedAfterSuite(func() {
CheckResourceCleanup(shared.DumpOpenStackSecurityGroups, groups.ListOpts{}, initialSecurityGroups),
CheckResourceCleanup(shared.DumpOpenStackLoadBalancers, loadbalancers.ListOpts{}, initialLoadBalancers),
CheckResourceCleanup(shared.DumpOpenStackVolumes, volumes.ListOpts{}, initialVolumes),
CheckResourceCleanup(shared.DumpOpenStackImages, images.ListOpts{Tags: []string{"capo-e2e"}}, initialImages),

// Unlike other resources created during tests images are
// created in Node1BeforeSuite, which is before we dump
// resources. This means that we don't have an opportunity to
// measure the 'before' state. Instead, we filter on images we
// created and assert that they have all been deleted.
CheckResourceCleanup(shared.DumpOpenStackImages, images.ListOpts{Tags: []string{shared.E2EImageTag}}, []images.Image{}),
} {
if error != nil {
GinkgoWriter.Println(*error)
Expand Down

0 comments on commit 07e514a

Please sign in to comment.