Skip to content

Commit

Permalink
cnf ran: siteconfig-operator:ready-for-review: adding ocp-75376 test …
Browse files Browse the repository at this point in the history
…case
  • Loading branch information
mpmaruthu committed Sep 17, 2024
1 parent 37d6fdb commit 6388573
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/cnf/ran/gitopsztp/internal/tsparams/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const (
LabelMachineConfigTestCases = "ztp-machine-config"
// LabelSpokeCheckerTests is the label for a particular set of test cases.
LabelSpokeCheckerTests = "ztp-spoke-checker"
// LabelSiteconfigOperatorTestCases is the label for the Siteconfig operator test cases.
LabelSiteconfigOperatorTestCases = "ztp-siteconfig-operator"

// MultiClusterHubOperator is the name of the multi cluster hub operator.
MultiClusterHubOperator = "multiclusterhub-operator"
Expand Down Expand Up @@ -81,6 +83,8 @@ const (
ZtpTestPathCustomSourceNoCrFile = "ztp-test/custom-source-crs/no-cr-file"
// ZtpTestPathCustomSourceSearchPath is the git path for the policies app custome source search path test.
ZtpTestPathCustomSourceSearchPath = "ztp-test/custom-source-crs/search-path"
// ZtpTestPathDetachAISNO is the git path for the siteconfig operator detach AI SNO cluster instance test.
ZtpTestPathDetachAISNO = "ztp-test/siteconfig-operator/detach-ai-sno/"
// ZtpKustomizationPath is the path to the kustomization file in the ztp test.
ZtpKustomizationPath = "/kustomization.yaml"

Expand Down
110 changes: 110 additions & 0 deletions tests/cnf/ran/gitopsztp/tests/ztp-siteconfig-operator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package tests

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/assisted"
"github.com/openshift-kni/eco-goinfra/pkg/bmh"
"github.com/openshift-kni/eco-goinfra/pkg/hive"
"github.com/openshift-kni/eco-goinfra/pkg/ocm"
"github.com/openshift-kni/eco-goinfra/pkg/reportxml"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/gitopsztp/internal/gitdetails"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/gitopsztp/internal/tsparams"
. "github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/raninittools"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/version"
)

var _ = Describe("ZTP Siteconfig Operator Tests", Label(tsparams.LabelSiteconfigOperatorTestCases), func() {
// These tests use the hub and spoke architecture
BeforeEach(func() {
By("verifying that ZTP meets the minimum version")
versionInRange, err := version.IsVersionStringInRange(RANConfig.ZTPVersion, "4.17", "")
Expect(err).ToNot(HaveOccurred(), "Failed to compare ZTP version string")

if !versionInRange {
Skip("ZTP Siteconfig operator tests require ZTP 4.17 or later")
}

})

AfterEach(func() {
By("resetting the clusters app back to the original settings")
err := gitdetails.SetGitDetailsInArgoCd(
tsparams.ArgoCdClustersAppName, tsparams.ArgoCdAppDetails[tsparams.ArgoCdClustersAppName], true, false)
Expect(err).ToNot(HaveOccurred(), "Failed to reset clusters app git details")
})

// 75376 - Detaching the AI single-node openshift (SNO) spoke cluster.
It("Validate detaching the AI SNO spoke cluster", reportxml.ID("75376"), func() {
// Update the ztp-test git path to detach site resources in root level kustimozation.yaml.
By("updating the Argo CD clusters app with the detach AI SNO cluster instance git path")
exists, err := gitdetails.UpdateArgoCdAppGitPath(tsparams.ArgoCdClustersAppName,
tsparams.ZtpTestPathDetachAISNO, true)
if !exists {
Skip(err.Error())
}

Expect(err).ToNot(HaveOccurred(), "Failed to update Argo CD clusters app with new git path")

// Test expected results validation.
By("checking the infra env manifests removed on hub")
_, err = assisted.PullInfraEnvInstall(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).To(HaveOccurred(), "Found spoke infra env manifests but expected to be removed")

By("checking the bare metal host manifests removed on hub")
_, err = bmh.Pull(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).To(HaveOccurred(), "Found spoke bmh manifests but expected to be removed")

By("checking the cluster deployment manifests removed on hub")
_, err = hive.PullClusterDeployment(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).To(HaveOccurred(), "Found spoke cluster deployment manifests but expected to be removed")

By("checking the NM state config manifests removed on hub")
nmStateConfigList, err := assisted.ListNmStateConfigs(HubAPIClient, RANConfig.Spoke1Name)
Expect(err).ToNot(HaveOccurred(), "Failed to list NM state config manifests")
Expect(nmStateConfigList).To(BeEmpty(), "Found spoke NM state config manifests but expected to be removed")

By("checking the klusterlet addon config manifests removed on hub")
_, err = ocm.PullKAC(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).To(HaveOccurred(), "Found spoke kac manifests but expected to be removed")

By("checking the agent cluster install manifests removed on hub")
_, err = assisted.PullAgentClusterInstall(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).To(HaveOccurred(), "Found spoke ACI manifests but expected to be removed")

By("verifying installed spoke cluster should still be functional")
_, err = version.GetOCPVersion(Spoke1APIClient)
Expect(err).ToNot(HaveOccurred(), "Failed to get OCP version from spoke and verify spoke cluster access")

// Test_Teardown and expected results validation.
By("resetting the clusters app back to the original settings")
err = gitdetails.SetGitDetailsInArgoCd(
tsparams.ArgoCdClustersAppName, tsparams.ArgoCdAppDetails[tsparams.ArgoCdClustersAppName], true, false)
Expect(err).ToNot(HaveOccurred(), "Failed to reset clusters app git details")

By("checking the infra env manifests exists on hub")
_, err = assisted.PullInfraEnvInstall(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).ToNot(HaveOccurred(), "Failed to find spoke infra env manifests")

By("checking the bare metal host manifests exists on hub")
_, err = bmh.Pull(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).ToNot(HaveOccurred(), "Failed to find spoke bmh manifests")

By("checking the cluster deployment manifests exists on hub")
_, err = hive.PullClusterDeployment(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).ToNot(HaveOccurred(), "Failed to find spoke cluster deployment manifests")

By("checking the NM state config manifests exists on hub")
nmStateConfigList, err = assisted.ListNmStateConfigs(HubAPIClient, RANConfig.Spoke1Name)
Expect(err).ToNot(HaveOccurred(), "Failed to list NM state config manifests")
Expect(nmStateConfigList).ToNot(BeEmpty(), "Failed to find NM state config manifests")

By("checking the klusterlet addon config manifests exists on hub")
_, err = ocm.PullKAC(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).ToNot(HaveOccurred(), "Failed to find spoke kac manifests")

By("checking the agent cluster install manifests exists on hub")
_, err = assisted.PullAgentClusterInstall(HubAPIClient, RANConfig.Spoke1Name, RANConfig.Spoke1Name)
Expect(err).ToNot(HaveOccurred(), "Failed to find spoke agent cluster install manifests")
})
})

0 comments on commit 6388573

Please sign in to comment.