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

cnf ran: improve style consistency across suites #252

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions tests/cnf/ran/containernshide/tests/containernshide.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import (
)

var _ = Describe("Container Namespace Hiding", Label(tsparams.LabelContainerNSHideTestCases), func() {
It("should not have kubelet and crio using the same inode as systemd", reportxml.ID("53681"), func() {
By("Getting systemd inodes on cluster nodes")
It("verifies kubelet and crio are not using the same inode as systemd", reportxml.ID("53681"), func() {
By("getting systemd inodes on cluster nodes")
systemdInodes, err := cluster.ExecCmdWithStdoutWithRetries(Spoke1APIClient,
ranparam.RetryCount, ranparam.RetryInterval, "readlink /proc/1/ns/mnt")
Expect(err).ToNot(HaveOccurred(), "Failed to check systemd inodes")

By("Getting kubelet inodes on cluster nodes")
By("getting kubelet inodes on cluster nodes")
kubeletInodes, err := cluster.ExecCmdWithStdoutWithRetries(
Spoke1APIClient, ranparam.RetryCount, ranparam.RetryInterval,
"readlink /proc/$(pidof kubelet)/ns/mnt")
Expect(err).ToNot(HaveOccurred(), "Failed to check kubelet inodes")

By("Getting crio inodes on cluster nodes")
By("getting crio inodes on cluster nodes")
crioInodes, err := cluster.ExecCmdWithStdoutWithRetries(Spoke1APIClient, ranparam.RetryCount,
ranparam.RetryInterval, "readlink /proc/$(pidof crio)/ns/mnt")
Expect(err).ToNot(HaveOccurred(), "Failed to check crio inodes")
Expand All @@ -38,7 +38,7 @@ var _ = Describe("Container Namespace Hiding", Label(tsparams.LabelContainerNSHi
"Collected systemd inodes from different number of nodes than crio inodes")

for host, systemdInode := range systemdInodes {
By(fmt.Sprintf("Checking inodes on host %s", host))
By(fmt.Sprintf("checking inodes on host %s", host))
kubeletInode, ok := kubeletInodes[host]
Expect(ok).To(BeTrue(), "Found systemd inode but not kubelet inode on node %s", host)

Expand Down
7 changes: 2 additions & 5 deletions tests/cnf/ran/gitopsztp/tests/ztp-argocd-acm-crs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import (
)

var _ = Describe("ZTP Argo CD ACM CR Tests", Label(tsparams.LabelArgoCdAcmCrsTestCases), func() {
var (
acmPolicyGeneratorImage string
// oldAcmPolicyGeneratorContainer corev1.Container
)
var acmPolicyGeneratorImage string

BeforeEach(func() {
By("verifying that ZTP meets the minimum version")
Expand Down Expand Up @@ -53,7 +50,7 @@ var _ = Describe("ZTP Argo CD ACM CR Tests", Label(tsparams.LabelArgoCdAcmCrsTes

// 54236 - Evaluating use of ACM's version of PolicyGenTemplates with our ZTP flow. This enables user created
// content that does not depend on our ZTP container but works "seamlessly" with it.
It("should use ACM CRs to template a policy, deploy it, and validate it succeeded", reportxml.ID("54236"), func() {
It("uses ACM CRs to template a policy, deploy it, and validate it succeeded", reportxml.ID("54236"), func() {
exists, err := gitdetails.UpdateArgoCdAppGitPath(tsparams.ArgoCdPoliciesAppName, tsparams.ZtpTestPathAcmCrs, true)
if !exists {
Skip(err.Error())
Expand Down
7 changes: 3 additions & 4 deletions tests/cnf/ran/gitopsztp/tests/ztp-argocd-clusters-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var _ = Describe("ZTP Argo CD Clusters Tests", Label(tsparams.LabelArgoCdCluster
if !versionInRange {
Skip("ZTP Argo CD clusters app tests require ZTP 4.11 or later")
}

})

AfterEach(func() {
Expand All @@ -34,7 +33,7 @@ var _ = Describe("ZTP Argo CD Clusters Tests", Label(tsparams.LabelArgoCdCluster
})

// 54238 - User modification of klustletaddonconfig via gitops
It("should override the KlusterletAddonConfiguration and verify the change", reportxml.ID("54238"), func() {
It("overrides the KlusterletAddonConfiguration and verifies the change", reportxml.ID("54238"), func() {
exists, err := gitdetails.UpdateArgoCdAppGitPath(
tsparams.ArgoCdClustersAppName, tsparams.ZtpTestPathClustersApp, true)
if !exists {
Expand All @@ -52,7 +51,7 @@ var _ = Describe("ZTP Argo CD Clusters Tests", Label(tsparams.LabelArgoCdCluster
})

// 60619 - Image creation fails when NMstateConfig CR is empty
It("should not have NMStateConfig CR when nodeNetwork section not in siteConfig", reportxml.ID("60619"), func() {
It("does not have NMStateConfig CR when nodeNetwork section not in siteconfig", reportxml.ID("60619"), func() {
// Update the git path manually so we can potentially skip the test before checking if the NM State
// Config exists.
gitDetails := tsparams.ArgoCdAppDetails[tsparams.ArgoCdClustersAppName]
Expand Down Expand Up @@ -81,7 +80,7 @@ var _ = Describe("ZTP Argo CD Clusters Tests", Label(tsparams.LabelArgoCdCluster
true)
Expect(err).ToNot(HaveOccurred(), "Failed to update the Argo CD app with new git details")

By("validate the NM state config is gone on hub")
By("validating the NM state config is gone on hub")
nmStateConfigList, err = assisted.ListNmStateConfigsInAllNamespaces(HubAPIClient)
Expect(err).ToNot(HaveOccurred(), "Failed to list NM state configs")
Expect(nmStateConfigList).To(BeEmpty(), "Found NM state config when it should be gone")
Expand Down
8 changes: 5 additions & 3 deletions tests/cnf/ran/gitopsztp/tests/ztp-argocd-hub-templating.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var _ = Describe("ZTP Argo CD Hub Templating Tests", Label(tsparams.LabelArgoCdH
})

// 54240 - Hub-side ACM templating with TALM
It("should report an error for using autoindent function where not allowed", reportxml.ID("54240"), func() {
It("reports an error for using autoindent function where not allowed", reportxml.ID("54240"), func() {
setupHubTemplateTest(tsparams.ZtpTestPathTemplatingAutoIndent)

By("validating TALM reported a policy error")
Expand All @@ -81,7 +81,7 @@ var _ = Describe("ZTP Argo CD Hub Templating Tests", Label(tsparams.LabelArgoCdH

When("supported ACM hub side templating is used", func() {
// 54240 - Hub-side ACM templating with TALM
It("should create the policy successfully with a valid template", reportxml.ID("54240"), func() {
It("creates the policy successfully with a valid template", reportxml.ID("54240"), func() {
By("checking the ZTP version")
versionInRange, err := version.IsVersionStringInRange(RANConfig.ZTPVersion, "4.16", "")
Expect(err).ToNot(HaveOccurred(), "Failed to check if ZTP version is in range")
Expand Down Expand Up @@ -167,6 +167,8 @@ func assertTalmPodLog(client *clients.Settings, expectedSubstring string) {
}

return podLog
}, tsparams.ArgoCdChangeTimeout, tsparams.ArgoCdChangeInterval).
}).
WithTimeout(tsparams.ArgoCdChangeTimeout).
WithPolling(tsparams.ArgoCdChangeInterval).
Should(ContainSubstring(expectedSubstring), "Failed to assert TALM pod log contains %s", expectedSubstring)
}
2 changes: 1 addition & 1 deletion tests/cnf/ran/gitopsztp/tests/ztp-argocd-node-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ = Describe("ZTP Argo CD Node Deletion Tests", Label(tsparams.LabelArgoCdNo
})

// 72463 - Delete and re-add a worker node from cluster
It("should delete a worker node from the cluster", reportxml.ID("72463"), func() {
It("deletes a worker node from the cluster", reportxml.ID("72463"), func() {
By("updating the Argo CD git path to apply crAnnotation")
exists, err := gitdetails.UpdateArgoCdAppGitPath(
tsparams.ArgoCdClustersAppName, tsparams.ZtpTestPathNodeDeleteAddAnnotation, true)
Expand Down
6 changes: 3 additions & 3 deletions tests/cnf/ran/gitopsztp/tests/ztp-argocd-policies-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("ZTP Argo CD Policies Tests", Label(tsparams.LabelArgoCdPolicie

When("overriding the PGT policy's compliance and non-compliance intervals", func() {
// 54241 - User override of policy intervals
It("should specify new intervals and verify they were applied", reportxml.ID("54241"), func() {
It("specifies new intervals and verifies they were applied", reportxml.ID("54241"), func() {
By("updating Argo CD policies app")
exists, err := gitdetails.UpdateArgoCdAppGitPath(
tsparams.ArgoCdPoliciesAppName, tsparams.ZtpTestPathCustomInterval, true)
Expand Down Expand Up @@ -86,7 +86,7 @@ var _ = Describe("ZTP Argo CD Policies Tests", Label(tsparams.LabelArgoCdPolicie
})

// 54242 - Invalid time duration string for user override of policy intervals
It("should specify an invalid interval format and verify the app error", reportxml.ID("54242"), func() {
It("specifies an invalid interval format and verifies the app error", reportxml.ID("54242"), func() {
By("updating Argo CD policies app")
exists, err := gitdetails.UpdateArgoCdAppGitPath(
tsparams.ArgoCdPoliciesAppName, tsparams.ZtpTestPathInvalidInterval, false)
Expand Down Expand Up @@ -279,7 +279,7 @@ var _ = Describe("ZTP Argo CD Policies Tests", Label(tsparams.LabelArgoCdPolicie
})

// 63516 - Reference non-existence source CR yaml file
It("verifies a proper error is returned in ArgoCD app when a non-existent "+
It("verifies a proper error is returned in Argo CD app when a non-existent "+
"source-cr is used in PGT", reportxml.ID("63516"), func() {
By("checking the ZTP version")
versionInRange, err := version.IsVersionStringInRange(RANConfig.ZTPVersion, "4.14", "")
Expand Down
44 changes: 10 additions & 34 deletions tests/cnf/ran/gitopsztp/tests/ztp-bios-day-zero.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,29 @@ import (
)

var _ = Describe("ZTP BIOS Configuration Tests", Label(tsparams.LabelBiosDayZeroTests), func() {
var (
spokeClusterName string
nodeNames []string
)

// 75196 - Check if spoke has required BIOS setting values applied
It("Verifies SNO spoke has required BIOS setting values applied", reportxml.ID("75196"), func() {
It("verifies SNO spoke has required BIOS setting values applied", reportxml.ID("75196"), func() {
versionInRange, err := version.IsVersionStringInRange(RANConfig.ZTPVersion, "4.17", "")
Expect(err).ToNot(HaveOccurred(), "Failed to check if ZTP version is in range")

if !versionInRange {
Skip("ZTP BIOS configuration tests require ZTP version of least 4.17")
}

spokeClusterName, err = GetSpokeClusterName(HubAPIClient, Spoke1APIClient)
spokeClusterName, err := GetSpokeClusterName(HubAPIClient, Spoke1APIClient)
Expect(err).ToNot(HaveOccurred(), "Failed to get SNO cluster name")
glog.V(tsparams.LogLevel).Infof("cluster name: %s", spokeClusterName)
glog.V(tsparams.LogLevel).Infof("Cluster name: %s", spokeClusterName)

nodeNames, err = GetNodeNames(Spoke1APIClient)
nodeNames, err := GetNodeNames(Spoke1APIClient)
Expect(err).ToNot(HaveOccurred(), "Failed to get node names")
glog.V(tsparams.LogLevel).Infof("Node names: %v", nodeNames)

By("getting HFS for spoke")
hfs, err := bmh.PullHFS(HubAPIClient, nodeNames[0], spokeClusterName)
Expect(err).ToNot(
HaveOccurred(),
"Failed to get HFS for spoke %s in cluster %s",
nodeNames[0],
spokeClusterName,
)
Expect(err).ToNot(HaveOccurred(), "Failed to get HFS for spoke %s in cluster %s", nodeNames[0], spokeClusterName)

hfsObject, err := hfs.Get()
Expect(err).ToNot(
HaveOccurred(),
"Failed to get HFS Obj for spoke %s in cluster %s",
nodeNames[0],
spokeClusterName,
)
Expect(err).ToNot(HaveOccurred(), "Failed to get HFS Obj for spoke %s in cluster %s", nodeNames[0], spokeClusterName)

By("comparing requsted BIOS settings to actual BIOS settings")
hfsRequestedSettings := hfsObject.Spec.Settings
Expand All @@ -65,10 +50,7 @@ var _ = Describe("ZTP BIOS Configuration Tests", Label(tsparams.LabelBiosDayZero
Skip("hfs.spec.settings map is empty")
}

Expect(hfsCurrentSettings).ToNot(
BeEmpty(),
"hfs.spec.settings map is not empty, but hfs.status.settings map is empty",
)
Expect(hfsCurrentSettings).ToNot(BeEmpty(), "hfs.spec.settings map is not empty but hfs.status.settings map is empty")

allSettingsMatch := true
for param, value := range hfsRequestedSettings {
Expand All @@ -84,16 +66,13 @@ var _ = Describe("ZTP BIOS Configuration Tests", Label(tsparams.LabelBiosDayZero
glog.V(tsparams.LogLevel).Infof("Requested setting matches current: %s=%s", param, setting)
} else {
glog.V(tsparams.LogLevel).Infof(
"Requested setting %s value %s does not match current value %s",
param,
requestedSetting,
setting)
"Requested setting %s value %s does not match current value %s", param, requestedSetting, setting)
allSettingsMatch = false
}

}

Expect(allSettingsMatch).To(BeTrueBecause("One or more requested settings does not match current settings"))
Expect(allSettingsMatch).To(BeTrue(), "One or more requested settings does not match current settings")
})

})
Expand Down Expand Up @@ -124,10 +103,7 @@ func GetSpokeClusterName(hubAPIClient, spokeAPIClient *clients.Settings) (string

// GetNodeNames gets node names in cluster.
func GetNodeNames(spokeAPIClient *clients.Settings) ([]string, error) {
nodeList, err := nodes.List(
spokeAPIClient,
)

nodeList, err := nodes.List(spokeAPIClient)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions tests/cnf/ran/gitopsztp/tests/ztp-cluster-instance-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var _ = Describe("ZTP Siteconfig Operator's Cluster Instance Delete Tests",
if !versionInRange {
Skip("ZTP Siteconfig operator tests require ZTP 4.17 or later")
}

})

AfterEach(func() {
Expand Down Expand Up @@ -75,7 +74,7 @@ var _ = Describe("ZTP Siteconfig Operator's Cluster Instance Delete Tests",
})

// 75374 - Detaching the AI multi-node openshift (MNO) spoke cluster.
It("Validate detaching the AI multi-node openshift spoke cluster", reportxml.ID("75374"), func() {
It("validates detaching the AI multi-node openshift spoke cluster", reportxml.ID("75374"), func() {
By("checking spoke cluster type")
spokeClusterType, err := rancluster.CheckSpokeClusterType(RANConfig.Spoke1APIClient)
Expect(err).ToNot(HaveOccurred(), "Failed to fetch spoke cluster type")
Expand Down Expand Up @@ -169,7 +168,7 @@ var _ = Describe("ZTP Siteconfig Operator's Cluster Instance Delete Tests",
})

// 75376 - Detaching the AI single-node openshift (SNO) spoke cluster.
It("Validate detaching the AI single-node openshift spoke cluster", reportxml.ID("75376"), func() {
It("validates detaching the AI single-node openshift spoke cluster", reportxml.ID("75376"), func() {
By("checking spoke cluster type")
spokeClusterType, err := rancluster.CheckSpokeClusterType(RANConfig.Spoke1APIClient)
Expect(err).ToNot(HaveOccurred(), "Failed to fetch spoke cluster type")
Expand Down
Loading
Loading