Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGMT-6411 Discovery image deleted on cluster removal #1720

Merged
merged 1 commit into from
May 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions subsystem/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down