Skip to content

Commit

Permalink
assisted ztp: change wait for discovery iso to eventually
Browse files Browse the repository at this point in the history
  • Loading branch information
trewest committed Sep 27, 2024
1 parent 6b809e5 commit 9cc348e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
// ReporterCRDsToDump tells to the reporter what CRs to dump.
ReporterCRDsToDump = []k8sreporter.CRData{
{Cr: &corev1.SecretList{}},
{Cr: &agentInstallV1Beta1.AgentServiceConfigList{}},
{Cr: &hivev1.ClusterDeploymentList{}},
{Cr: &hiveextV1Beta1.AgentClusterInstallList{}},
{Cr: &agentInstallV1Beta1.InfraEnvList{}},
Expand Down
23 changes: 18 additions & 5 deletions tests/assisted/ztp/operator/tests/additional-trust-bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ var _ = Describe(
testSecret.Definition.Name)
infraenv.Definition.Spec.AdditionalTrustBundle = additionalTrustCertificate
_, err = infraenv.Create()
Expect(err).ToNot(HaveOccurred(), "error creating infraenv")
_, err := infraenv.WaitForDiscoveryISOCreation(time.Second * 20)
Expect(err).ToNot(HaveOccurred(), "error creating discovery iso")
Eventually(func() (string, error) {
infraenv.Object, err = infraenv.Get()
if err != nil {
return "", err
}

return infraenv.Object.Status.ISODownloadURL, nil
}).WithTimeout(time.Minute*3).ProbeEvery(time.Second*3).
Should(Not(BeEmpty()), "error waiting for download url to be created")
By("Checking additionalTrustBundle equal to additionalTrustCertificate")
Expect(infraenv.Object.Spec.AdditionalTrustBundle).
To(Equal(additionalTrustCertificate), "infraenv was created with wrong certificate")
Expand All @@ -154,8 +160,15 @@ var _ = Describe(
infraenv.Definition.Spec.AdditionalTrustBundle = additionalTrustCertificateEmpty
_, err = infraenv.Create()
Expect(err).ToNot(HaveOccurred(), "error creating infraenv")
_, err := infraenv.WaitForDiscoveryISOCreation(time.Second * 20)
Expect(err).To(HaveOccurred(), "error: infraenv successfully created with empty additionalTrustBundle")
Eventually(func() (string, error) {
infraenv.Object, err = infraenv.Get()
if err != nil {
return "", err
}

return infraenv.Object.Status.ISODownloadURL, nil
}).WithTimeout(time.Minute*3).ProbeEvery(time.Second*3).
Should(BeEmpty(), "error waiting for download url to be created")
By("Getting Infraenv")
infraenv, err = assisted.PullInfraEnvInstall(HubAPIClient, "testinfraenv", trustBundleTestNS)
Expect(err).ToNot(HaveOccurred(), "error in retrieving infraenv")
Expand Down
11 changes: 9 additions & 2 deletions tests/assisted/ztp/operator/tests/build-artifacts-rootfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ var _ = Describe(
WithDefaultIPv4AgentClusterInstall().WithDefaultInfraEnv().Create()
Expect(err).ToNot(HaveOccurred(), "error creating %s spoke resources", rootfsSpokeName)

_, err = rootfsSpokeResources.InfraEnv.WaitForDiscoveryISOCreation(time.Minute * 3)
Expect(err).ToNot(HaveOccurred(), "error waiting for download url to be created")
Eventually(func() (string, error) {
rootfsSpokeResources.InfraEnv.Object, err = rootfsSpokeResources.InfraEnv.Get()
if err != nil {
return "", err
}

return rootfsSpokeResources.InfraEnv.Object.Status.ISODownloadURL, nil
}).WithTimeout(time.Minute*3).ProbeEvery(time.Second*3).
Should(Not(BeEmpty()), "error waiting for download url to be created")

if _, err = os.Stat(rootfsDownloadDir); err != nil {
err = os.RemoveAll(rootfsDownloadDir)
Expand Down
13 changes: 11 additions & 2 deletions tests/assisted/ztp/operator/tests/infraenv-multiarch-image.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ func createSpokeClusterNamespace() {

// createSpokeClusterResources is a helper function that creates
// spoke cluster resources required for the test.
//
//nolint:funlen
func createSpokeClusterResources(cpuArch string, mismatchCPUArchitecture ...string) {
By("Create pull-secret in the new namespace")

Expand Down Expand Up @@ -365,8 +367,15 @@ func createSpokeClusterResources(cpuArch string, mismatchCPUArchitecture ...stri
if len(mismatchCPUArchitecture) == 0 {
By("Wait until the discovery iso is created for the infraenv")

_, err = infraEnvBuilder.WaitForDiscoveryISOCreation(300 * time.Second)
Expect(err).ToNot(HaveOccurred(), "error waiting for the discovery iso creation")
Eventually(func() (string, error) {
infraEnvBuilder.Object, err = infraEnvBuilder.Get()
if err != nil {
return "", err
}

return infraEnvBuilder.Object.Status.ISODownloadURL, nil
}).WithTimeout(time.Minute*3).ProbeEvery(time.Second*3).
Should(Not(BeEmpty()), "error waiting for download url to be created")
} else {
By("Wait until infraenv shows an error for the mismatching image architecture")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ var _ = Describe(
WithClusterRef(osImageClusterImageSetName, osImageClusterImageSetName).Create()
Expect(err).ToNot(HaveOccurred(), "error creating infraenv")

_, err = osImageClusterImageSetInfraEnv.WaitForDiscoveryISOCreation(time.Second * 20)
Expect(err).ToNot(HaveOccurred(), "error waiting for discovery iso to be generated")
Eventually(func() (string, error) {
osImageClusterImageSetInfraEnv.Object, err = osImageClusterImageSetInfraEnv.Get()
if err != nil {
return "", err
}

return osImageClusterImageSetInfraEnv.Object.Status.ISODownloadURL, nil
}).WithTimeout(time.Minute*3).ProbeEvery(time.Second*3).
Should(Not(BeEmpty()), "error waiting for download url to be created")
})

AfterAll(func() {
Expand Down

0 comments on commit 9cc348e

Please sign in to comment.