Skip to content

Commit

Permalink
MGMT-6411 Discovery image deleted on cluster removal
Browse files Browse the repository at this point in the history
When removing a cluster, its discovery-image should be deleted as well.

Signed-off-by: Moti Asayag <[email protected]>
  • Loading branch information
masayag committed May 12, 2021
1 parent e594351 commit 8e4407d
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions subsystem/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3150,6 +3150,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)
Expand Down

0 comments on commit 8e4407d

Please sign in to comment.