From 07e5e781cf555fb5373df6b6fbd653bee2c6c42f Mon Sep 17 00:00:00 2001 From: Elena German Date: Sat, 17 Aug 2024 09:25:17 -0400 Subject: [PATCH] vcore: separate lso from the odf (#164) --- .../vcorecommon/local-storage-operator.go | 62 +++++++++++++++- .../internal/vcorecommon/loki-operator.go | 4 +- .../vcore/internal/vcorecommon/odf.go | 73 ++----------------- .../vcore/internal/vcoreparams/const.go | 6 +- 4 files changed, 75 insertions(+), 70 deletions(-) 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 9f268d73b..fdb969cd5 100644 --- a/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go +++ b/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go @@ -4,6 +4,13 @@ import ( "fmt" "time" + "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" + lsov1alpha1 "github.com/openshift/local-storage-operator/api/v1alpha1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/openshift-kni/eco-goinfra/pkg/pod" "github.com/openshift-kni/eco-goinfra/pkg/reportxml" @@ -19,12 +26,15 @@ import ( func VerifyLSOSuite() { Describe( "LSO validation", - Label(vcoreparams.LabelVCoreOdf), func() { + Label(vcoreparams.LabelVCoreLSO), func() { It(fmt.Sprintf("Verifies %s namespace exists", vcoreparams.LSONamespace), Label("lso"), VerifyLSONamespaceExists) It("Verify Local Storage Operator successfully installed", Label("lso"), reportxml.ID("59491"), VerifyLSODeployment) + + It("Verify localvolumeset instance exists", + Label("lso"), reportxml.ID("74918"), VerifyLocalVolumeSet) }) } @@ -64,3 +74,53 @@ func VerifyLSODeployment(ctx SpecContext) { lsoPodName, vcoreparams.LSONamespace, lsoPodLog) } } // func VerifyLSODeployment (ctx SpecContext) + +// VerifyLocalVolumeSet asserts localvolumeset instance exists. +func VerifyLocalVolumeSet(ctx SpecContext) { + glog.V(vcoreparams.VCoreLogLevel).Infof("Create localvolumeset instance %s in namespace %s if not found", + vcoreparams.ODFLocalVolumeSetName, vcoreparams.LSONamespace) + + var err error + + localVolumeSetObj := lso.NewLocalVolumeSetBuilder(APIClient, + vcoreparams.ODFLocalVolumeSetName, + vcoreparams.LSONamespace) + + nodeSelector := corev1.NodeSelector{NodeSelectorTerms: []corev1.NodeSelectorTerm{{ + MatchExpressions: []corev1.NodeSelectorRequirement{{ + Key: "kubernetes.io/hostname", + Operator: "In", + Values: odfNodesList, + }}}, + }} + + deviceInclusionSpec := lsov1alpha1.DeviceInclusionSpec{ + DeviceTypes: []lsov1alpha1.DeviceType{lsov1alpha1.RawDisk}, + DeviceMechanicalProperties: []lsov1alpha1.DeviceMechanicalProperty{lsov1alpha1.NonRotational}, + } + + tolerations := []corev1.Toleration{{ + Key: "node.ocs.openshift.io/storage", + Operator: "Equal", + Value: "true", + Effect: "NoSchedule", + }} + + _, err = localVolumeSetObj.WithNodeSelector(nodeSelector). + WithStorageClassName(vcoreparams.StorageClassName). + WithVolumeMode(lsov1.PersistentVolumeBlock). + WithFSType("ext4"). + WithMaxDeviceCount(int32(42)). + WithDeviceInclusionSpec(deviceInclusionSpec). + WithTolerations(tolerations).Create() + Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to create localvolumeset %s in namespace %s "+ + "due to %v", vcoreparams.ODFLocalVolumeSetName, vcoreparams.LSONamespace, err)) + + pvLabel := fmt.Sprintf("storage.openshift.com/owner-name=%s", vcoreparams.ODFLocalVolumeSetName) + + err = await.WaitUntilPersistentVolumeCreated(APIClient, + 3, + 15*time.Minute, + metav1.ListOptions{LabelSelector: pvLabel}) + Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to create persistentVolumes due to %v", err)) +} // func VerifyLocalVolumeSet (ctx SpecContext) diff --git a/tests/system-tests/vcore/internal/vcorecommon/loki-operator.go b/tests/system-tests/vcore/internal/vcorecommon/loki-operator.go index 972c43f1c..cba34fd7c 100644 --- a/tests/system-tests/vcore/internal/vcorecommon/loki-operator.go +++ b/tests/system-tests/vcore/internal/vcorecommon/loki-operator.go @@ -32,7 +32,7 @@ import ( func VerifyLokiSuite() { Describe( "LokiStack and Cluster Logging validation", - Label(vcoreparams.LabelVCoreOperators), func() { + Label(vcoreparams.LabelVCoreODF), func() { It(fmt.Sprintf("Verifies %s namespace exists", vcoreparams.CLONamespace), Label("loki"), VerifyCLONamespaceExists) @@ -49,7 +49,7 @@ func VerifyLokiSuite() { Label("loki"), reportxml.ID("74914"), CreateObjectBucketClaim) It("Create LokiStack instance", - Label("debug"), reportxml.ID("74915"), CreateLokiStackInstance) + Label("loki"), reportxml.ID("74915"), CreateLokiStackInstance) It(fmt.Sprintf("Verify Cluster Logging instance %s is running in namespace %s", vcoreparams.CLOInstanceName, vcoreparams.CLONamespace), diff --git a/tests/system-tests/vcore/internal/vcorecommon/odf.go b/tests/system-tests/vcore/internal/vcorecommon/odf.go index a175474e7..dbd9f323e 100644 --- a/tests/system-tests/vcore/internal/vcorecommon/odf.go +++ b/tests/system-tests/vcore/internal/vcorecommon/odf.go @@ -7,25 +7,18 @@ import ( "github.com/openshift-kni/eco-goinfra/pkg/mco" + "time" + "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" "github.com/openshift-kni/eco-gotests/tests/system-tests/vcore/internal/ocpcli" - lsov1 "github.com/openshift/local-storage-operator/api/v1" - lsov1alpha1 "github.com/openshift/local-storage-operator/api/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "time" - - "github.com/openshift-kni/eco-goinfra/pkg/lso" - - "github.com/openshift-kni/eco-goinfra/pkg/nodes" - "github.com/openshift-kni/eco-goinfra/pkg/reportxml" - "github.com/openshift-kni/eco-gotests/tests/system-tests/internal/await" "github.com/openshift-kni/eco-goinfra/pkg/console" "github.com/openshift-kni/eco-goinfra/pkg/deployment" + "github.com/openshift-kni/eco-goinfra/pkg/nodes" "github.com/openshift-kni/eco-goinfra/pkg/pod" + "github.com/openshift-kni/eco-goinfra/pkg/reportxml" ocsoperatorv1 "github.com/red-hat-storage/ocs-operator/api/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -54,7 +47,7 @@ var ( func VerifyODFSuite() { Describe( "ODF validation", - Label(vcoreparams.LabelVCoreOdf), func() { + Label(vcoreparams.LabelVCoreODF), func() { It(fmt.Sprintf("Verifies %s namespace exists", vcoreparams.ODFNamespace), Label("odf"), VerifyODFNamespaceExists) @@ -64,9 +57,6 @@ func VerifyODFSuite() { It("Verify ODF console enabled", Label("odf"), reportxml.ID("74917"), VerifyODFConsoleConfig) - It("Verify localvolumeset instance exists", - Label("odf"), reportxml.ID("74918"), VerifyLocalVolumeSet) - It("Apply taints to the ODF nodes", Label("odf"), reportxml.ID("74916"), VerifyODFTaints) @@ -138,57 +128,10 @@ func VerifyODFConsoleConfig(ctx SpecContext) { Expect(slices.Contains(*newPluginsList, odfConsolePlugin), fmt.Sprintf("Failed to add new plugin %s to the consoleOperator plugins list: %v", odfConsolePlugin, newPluginsList)) -} // func VerifyODFConsoleConfig (ctx SpecContext) - -// VerifyLocalVolumeSet asserts localvolumeset instance exists. -func VerifyLocalVolumeSet(ctx SpecContext) { - glog.V(vcoreparams.VCoreLogLevel).Infof("Create localvolumeset instance %s in namespace %s if not found", - vcoreparams.ODFLocalVolumeSetName, vcoreparams.LSONamespace) - - var err error - - localVolumeSetObj := lso.NewLocalVolumeSetBuilder(APIClient, - vcoreparams.ODFLocalVolumeSetName, - vcoreparams.LSONamespace) - nodeSelector := corev1.NodeSelector{NodeSelectorTerms: []corev1.NodeSelectorTerm{{ - MatchExpressions: []corev1.NodeSelectorRequirement{{ - Key: "kubernetes.io/hostname", - Operator: "In", - Values: odfNodesList, - }}}, - }} - - deviceInclusionSpec := lsov1alpha1.DeviceInclusionSpec{ - DeviceTypes: []lsov1alpha1.DeviceType{lsov1alpha1.RawDisk}, - DeviceMechanicalProperties: []lsov1alpha1.DeviceMechanicalProperty{lsov1alpha1.NonRotational}, - } - - tolerations := []corev1.Toleration{{ - Key: "node.ocs.openshift.io/storage", - Operator: "Equal", - Value: "true", - Effect: "NoSchedule", - }} - - _, err = localVolumeSetObj.WithNodeSelector(nodeSelector). - WithStorageClassName(vcoreparams.StorageClassName). - WithVolumeMode(lsov1.PersistentVolumeBlock). - WithFSType("ext4"). - WithMaxDeviceCount(int32(42)). - WithDeviceInclusionSpec(deviceInclusionSpec). - WithTolerations(tolerations).Create() - Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to create localvolumeset %s in namespace %s "+ - "due to %v", vcoreparams.ODFLocalVolumeSetName, vcoreparams.LSONamespace, err)) - - pvLabel := fmt.Sprintf("storage.openshift.com/owner-name=%s", vcoreparams.ODFLocalVolumeSetName) - - err = await.WaitUntilPersistentVolumeCreated(APIClient, - 3, - 15*time.Minute, - metav1.ListOptions{LabelSelector: pvLabel}) - Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to create persistentVolumes due to %v", err)) -} // func VerifyLocalVolumeSet (ctx SpecContext) + glog.V(vcoreparams.VCoreLogLevel).Infof("Wait for the console enablement") + time.Sleep(5 * time.Minute) +} // func VerifyODFConsoleConfig (ctx SpecContext) // VerifyODFTaints asserts ODF nodes taints configuration. func VerifyODFTaints(ctx SpecContext) { diff --git a/tests/system-tests/vcore/internal/vcoreparams/const.go b/tests/system-tests/vcore/internal/vcoreparams/const.go index 5c68c3895..d16f80c9c 100644 --- a/tests/system-tests/vcore/internal/vcoreparams/const.go +++ b/tests/system-tests/vcore/internal/vcoreparams/const.go @@ -8,8 +8,10 @@ const ( // LabelVCoreOperators is used to select all vCore initial-deployment deployment and configuration tests // excluding odf part. LabelVCoreOperators = "vcoreoperators" - // LabelVCoreOdf is used to select odf configuration tests. - LabelVCoreOdf = "vcoreodf" + // LabelVCoreLSO is used to select lso configuration tests. + LabelVCoreLSO = "vcorelso" + // LabelVCoreODF is used to select odf configuration tests. + LabelVCoreODF = "vcoreodf" // LabelUserCases is used to select all vCore user-cases tests. LabelUserCases = "vcoreusercases" // LabelVCoreRequirements is used to select all vCore requirements tests.