From 1286d4f92a0786945df042fee94e8e4f11282334 Mon Sep 17 00:00:00 2001 From: Elena German Date: Sat, 17 Aug 2024 09:00:01 -0400 Subject: [PATCH] vcore: separate lso from the odf --- .../vcorecommon/local-storage-operator.go | 61 +++++++++++++++- .../internal/vcorecommon/loki-operator.go | 4 +- .../vcore/internal/vcorecommon/odf.go | 70 ++----------------- .../vcore/internal/vcoreparams/const.go | 6 +- 4 files changed, 72 insertions(+), 69 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..1d8b44c24 100644 --- a/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go +++ b/tests/system-tests/vcore/internal/vcorecommon/local-storage-operator.go @@ -2,6 +2,12 @@ package vcorecommon import ( "fmt" + "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" "time" "github.com/openshift-kni/eco-goinfra/pkg/pod" @@ -19,12 +25,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 +73,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..e1adcdd7d 100644 --- a/tests/system-tests/vcore/internal/vcorecommon/odf.go +++ b/tests/system-tests/vcore/internal/vcorecommon/odf.go @@ -11,21 +11,13 @@ import ( "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 +46,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 +56,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 +127,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.