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

Cherry pick assisted ztp changes 4.16 #228

Merged
Show file tree
Hide file tree
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
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
20 changes: 16 additions & 4 deletions tests/assisted/ztp/operator/tests/aci-dualstack-ipv4-first.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,22 @@ var _ = Describe(
agentClusterInstallBuilder := createDualstackSpokeClusterResources()

By("Waiting for specific error message from SpecSynced condition")
err = agentClusterInstallBuilder.WaitForConditionMessage(v1beta1.ClusterSpecSyncedCondition,
"The Spec could not be synced due to an input error: First machine network has to be IPv4 subnet", time.Second*10)
Expect(err).NotTo(HaveOccurred(), "didn't get the expected message from SpecSynced condition")

Eventually(func() (string, error) {
agentClusterInstallBuilder.Object, err = agentClusterInstallBuilder.Get()
if err != nil {
return "", err
}

for _, condition := range agentClusterInstallBuilder.Object.Status.Conditions {
if condition.Type == v1beta1.ClusterSpecSyncedCondition {
return condition.Message, nil
}
}

return "", nil
}).WithTimeout(time.Minute*2).Should(
Equal("The Spec could not be synced due to an input error: First machine network has to be IPv4 subnet"),
"didn't get the expected message from SpecSynced condition")
})

})
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
18 changes: 15 additions & 3 deletions tests/assisted/ztp/operator/tests/platform-selection-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,21 @@ var _ = Describe(
} else {
Expect(err).ToNot(HaveOccurred(), "error creating agentclusterinstall")
By("Waiting for condition to report expected failure message")
err = testAgentClusterInstall.WaitForConditionMessage(v1beta1.ClusterSpecSyncedCondition,
"The Spec could not be synced due to an input error: "+message, time.Second*10)
Expect(err).NotTo(HaveOccurred(), "got unexpected message from SpecSynced condition")
Eventually(func() (string, error) {
testAgentClusterInstall.Object, err = testAgentClusterInstall.Get()
if err != nil {
return "", err
}

for _, condition := range testAgentClusterInstall.Object.Status.Conditions {
if condition.Type == v1beta1.ClusterSpecSyncedCondition {
return condition.Message, nil
}
}

return "", nil
}).WithTimeout(time.Minute*2).Should(Equal("The Spec could not be synced due to an input error: "+message),
"got unexpected message from SpecSynced condition")
}
},
Entry("that is SNO with VSphere platform", v1beta1.VSpherePlatformType, true, 1, 0,
Expand Down
Loading