From dd9c0091deb5cd68b87f7cb7595a8ee45e02b65e Mon Sep 17 00:00:00 2001 From: Moti Asayag Date: Wed, 12 May 2021 18:05:13 +0300 Subject: [PATCH] MGMT-6411 Discovery image deleted on cluster removal When removing a cluster, its discovery-image should be deleted as well. Signed-off-by: Moti Asayag --- subsystem/cluster_test.go | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/subsystem/cluster_test.go b/subsystem/cluster_test.go index fbf7820e20f..5f79041458f 100644 --- a/subsystem/cluster_test.go +++ b/subsystem/cluster_test.go @@ -3239,6 +3239,58 @@ var _ = Describe("Update cluster with OLM operators", func() { }) }) +var _ = Describe("Verify ISO is deleted on cluster de-registration", func() { + var ( + ctx context.Context = context.Background() + clusterID strfmt.UUID + ) + + BeforeEach(func() { + var err error + clusterID, err = registerCluster(ctx, userBMClient, "test-deregister-cluster", pullSecret) + Expect(err).NotTo(HaveOccurred()) + }) + + AfterEach(func() { + clearDB() + }) + + Context("Deregister cluster deletes cluster resources test", func() { + It("Deregister cluster deletes discovery image from Filesystem test", func() { + By("Generate discovery image for cluster") + imageType := models.ImageTypeMinimalIso + _, err := userBMClient.Installer.GenerateClusterISO(ctx, &installer.GenerateClusterISOParams{ + ClusterID: clusterID, + ImageCreateParams: &models.ImageCreateParams{ + ImageType: imageType, + }, + }) + + Expect(err).NotTo(HaveOccurred()) + verifyEventExistence(clusterID, fmt.Sprintf("Image type is \"%s\"", imageType)) + + By("verify discovery-image existence") + file, err := ioutil.TempFile("", "tmp") + if err != nil { + log.Fatal(err) + } + defer os.Remove(file.Name()) + _, err = userBMClient.Installer.DownloadClusterISO(ctx, &installer.DownloadClusterISOParams{ClusterID: clusterID}, file) + Expect(err).NotTo(HaveOccurred()) + + By("deregister cluster") + _, err = userBMClient.Installer.DeregisterCluster(ctx, &installer.DeregisterClusterParams{ + ClusterID: clusterID, + }) + Expect(err).NotTo(HaveOccurred()) + + By("verify discovery-image cannot be downloaded") + _, err = userBMClient.Installer.DownloadClusterISO(ctx, &installer.DownloadClusterISOParams{ClusterID: clusterID}, file) + Expect(err).To(HaveOccurred()) + }) + }) +}) + func registerHostsAndSetRoles(clusterID strfmt.UUID, numHosts int) []*models.Host { ctx := context.Background() hosts := make([]*models.Host, 0)