Skip to content

Commit

Permalink
vcore: separate lso from the odf
Browse files Browse the repository at this point in the history
  • Loading branch information
elenagerman committed Aug 17, 2024
1 parent 41ac393 commit 1286d4f
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
})
}

Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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),
Expand Down
70 changes: 6 additions & 64 deletions tests/system-tests/vcore/internal/vcorecommon/odf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions tests/system-tests/vcore/internal/vcoreparams/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1286d4f

Please sign in to comment.