From 70dda822191630db96c2bf602fc3bcd1a9d589e6 Mon Sep 17 00:00:00 2001 From: Elena German Date: Sat, 17 Aug 2024 22:20:01 -0400 Subject: [PATCH] vcore: fix verification statement (#166) * vcore: fix verification statement * vcore: move mcp creation and odf node labeling to the upper level --- .../vcore/internal/config-files/odf-mcp.yaml | 2 +- .../vcorecommon/local-storage-operator.go | 68 ------------------- .../vcore/internal/vcorecommon/odf.go | 24 +++++++ 3 files changed, 25 insertions(+), 69 deletions(-) diff --git a/tests/system-tests/vcore/internal/config-files/odf-mcp.yaml b/tests/system-tests/vcore/internal/config-files/odf-mcp.yaml index d792bb596..8c199ef5f 100644 --- a/tests/system-tests/vcore/internal/config-files/odf-mcp.yaml +++ b/tests/system-tests/vcore/internal/config-files/odf-mcp.yaml @@ -1,7 +1,7 @@ apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfigPool metadata: - name: "{{ .MCPName }}" + name: '{{ .MCPName }}' spec: machineConfigSelector: matchExpressions: diff --git a/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go b/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go index 3b97de16b..fdb969cd5 100644 --- a/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go +++ b/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go @@ -2,15 +2,8 @@ package vcorecommon import ( "fmt" - "os" - "path/filepath" "time" - "github.com/openshift-kni/eco-goinfra/pkg/mco" - "github.com/openshift-kni/eco-goinfra/pkg/nodes" - "github.com/openshift-kni/eco-gotests/tests/system-tests/internal/remote" - "github.com/openshift-kni/eco-gotests/tests/system-tests/vcore/internal/ocpcli" - "github.com/openshift-kni/eco-goinfra/pkg/lso" "github.com/openshift-kni/eco-gotests/tests/system-tests/internal/await" lsov1 "github.com/openshift/local-storage-operator/api/v1" @@ -42,9 +35,6 @@ func VerifyLSOSuite() { It("Verify localvolumeset instance exists", Label("lso"), reportxml.ID("74918"), VerifyLocalVolumeSet) - - It("Apply taints to the ODF nodes", - Label("lso"), reportxml.ID("74916"), LabelODFNodesAndSetTaints) }) } @@ -134,61 +124,3 @@ func VerifyLocalVolumeSet(ctx SpecContext) { metav1.ListOptions{LabelSelector: pvLabel}) Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to create persistentVolumes due to %v", err)) } // func VerifyLocalVolumeSet (ctx SpecContext) - -// LabelODFNodesAndSetTaints asserts ODF nodes taints configuration. -func LabelODFNodesAndSetTaints(ctx SpecContext) { - glog.V(vcoreparams.VCoreLogLevel).Infof("Create new mcp %s", VCoreConfig.OdfMCPName) - odfMcp := mco.NewMCPBuilder(APIClient, VCoreConfig.OdfMCPName) - - if !odfMcp.Exists() { - odfMCPTemplateName := "odf-mcp.yaml" - varsToReplace := make(map[string]interface{}) - varsToReplace["MCPName"] = VCoreConfig.OdfMCPName - - workingDir, err := os.Getwd() - Expect(err).ToNot(HaveOccurred(), err) - - templateDir := filepath.Join(workingDir, vcoreparams.TemplateFilesFolder) - - err = ocpcli.ApplyConfig( - filepath.Join(templateDir, odfMCPTemplateName), - filepath.Join(vcoreparams.ConfigurationFolderPath, odfMCPTemplateName), - varsToReplace) - Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Failed to create mcp %s", VCoreConfig.OdfMCPName)) - - err = odfMcp.WaitForUpdate(3 * time.Minute) - Expect(err).To(BeNil(), fmt.Sprintf("Failed to create mcp %s", VCoreConfig.OdfMCPName)) - } - - for _, odfNode := range odfNodesList { - currentODFNode, err := nodes.Pull(APIClient, odfNode) - Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to retrieve node %s object due to %v", - odfNode, err)) - - glog.V(vcoreparams.VCoreLogLevel).Infof("Change node %s role to the %s", odfNode, VCoreConfig.OdfMCPName) - - _, err = currentODFNode. - WithNewLabel("custom-label/used", ""). - WithNewLabel("cluster.ocs.openshift.io/openshift-storage", ""). - WithNewLabel("node-role.kubernetes.io/infra", ""). - WithNewLabel("node-role.kubernetes.io/odf", ""). - RemoveLabel("node-role.kubernetes.io/worker", "").Update() - Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to update labels for the node %s due to %v", - odfNode, err)) - - glog.V(vcoreparams.VCoreLogLevel).Infof("Insure taints applyed to the %s node", odfNode) - - applyTaintsCmd := fmt.Sprintf( - "oc adm taint node %s node.ocs.openshift.io/storage=true:NoSchedule --overwrite=true --kubeconfig=%s", - odfNode, VCoreConfig.KubeconfigPath) - _, err = remote.ExecCmdOnHost(VCoreConfig.Host, VCoreConfig.User, VCoreConfig.Pass, applyTaintsCmd) - Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to execute %s script due to %v", - applyTaintsCmd, err)) - } - - glog.V(vcoreparams.VCoreLogLevel).Infof("Wait for the mcp %s to update", VCoreConfig.OdfMCPName) - time.Sleep(3 * time.Second) - - err := odfMcp.WaitForUpdate(3 * time.Minute) - Expect(err).To(BeNil(), fmt.Sprintf("Failed to create mcp %s", VCoreConfig.OdfMCPName)) -} // func LabelODFNodesAndSetTaints (ctx SpecContext) diff --git a/tests/system-tests/vcore/internal/vcorecommon/odf.go b/tests/system-tests/vcore/internal/vcorecommon/odf.go index 7244e6c7a..aa3854b85 100644 --- a/tests/system-tests/vcore/internal/vcorecommon/odf.go +++ b/tests/system-tests/vcore/internal/vcorecommon/odf.go @@ -4,6 +4,8 @@ import ( "fmt" "time" + "github.com/openshift-kni/eco-goinfra/pkg/nodes" + "github.com/openshift-kni/eco-goinfra/pkg/configmap" "github.com/openshift-kni/eco-goinfra/pkg/storage" "github.com/openshift-kni/eco-gotests/tests/system-tests/internal/remote" @@ -51,6 +53,9 @@ func VerifyODFSuite() { It("Verify ODF console enabled", Label("odf"), reportxml.ID("74917"), VerifyODFConsoleConfig) + It("Apply taints to the ODF nodes", + Label("odf"), reportxml.ID("74916"), VerifyODFTaints) + It("Verify ODF operator StorageSystem configuration procedure", Label("odf"), reportxml.ID("59487"), VerifyODFStorageSystemConfig) @@ -124,6 +129,25 @@ func VerifyODFConsoleConfig(ctx SpecContext) { time.Sleep(5 * time.Minute) } // func VerifyODFConsoleConfig (ctx SpecContext) +// VerifyODFTaints asserts ODF nodes taints configuration. +func VerifyODFTaints(ctx SpecContext) { + glog.V(vcoreparams.VCoreLogLevel).Infof("Apply taints to the ODF nodes") + + for _, odfNodeName := range odfNodesList { + odfNode, err := nodes.Pull(APIClient, odfNodeName) + Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to retrieve node %s object due to %v", + odfNodeName, err)) + + glog.V(vcoreparams.VCoreLogLevel).Infof("Insure taints applyed to the %s node", odfNode.Definition.Name) + applyTaintsCmd := fmt.Sprintf( + "oc adm taint node %s node.ocs.openshift.io/storage=true:NoSchedule --overwrite=true --kubeconfig=%s", + odfNode.Definition.Name, VCoreConfig.KubeconfigPath) + _, err = remote.ExecCmdOnHost(VCoreConfig.Host, VCoreConfig.User, VCoreConfig.Pass, applyTaintsCmd) + Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to execute %s script due to %v", + applyTaintsCmd, err)) + } +} // func VerifyODFTaints (ctx SpecContext) + // VerifyODFStorageSystemConfig asserts ODF storage cluster system successfully configured. func VerifyODFStorageSystemConfig(ctx SpecContext) { glog.V(vcoreparams.VCoreLogLevel).Infof("Cleanup StorageSystem and StorageCluster config")