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

vcore: separate lso from the odf #164

Merged
merged 1 commit into from
Aug 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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"

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

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

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

Expand Down Expand Up @@ -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) {
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
Loading