Skip to content

Commit

Permalink
vcore: refactoring for the redis and odf nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
elenagerman committed Aug 11, 2024
1 parent 54a61e6 commit 0fa99d2
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ additionalAffinities:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
- key: node-role.kubernetes.io/master
operator: Exists

securityContext:
Expand Down
12 changes: 5 additions & 7 deletions tests/system-tests/vcore/internal/vcorecommon/odf.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func VerifyODFSuite() {
It("Verify ODF console enabled",
Label("odf"), reportxml.ID("74917"), VerifyODFConsoleConfig)

It("Verify localvolumediscovery instance exists",
Label("odf"), reportxml.ID("74920"), VerifyLocalVolumeDiscovery)
//It("Verify localvolumediscovery instance exists",

Check failure on line 65 in tests/system-tests/vcore/internal/vcorecommon/odf.go

View workflow job for this annotation

GitHub Actions / build

commentFormatting: put a space between `//` and comment text (gocritic)
// Label("odf"), reportxml.ID("74920"), VerifyLocalVolumeDiscovery)

It("Verify localvolumeset instance exists",
Label("odf"), reportxml.ID("74918"), VerifyLocalVolumeSet)
Expand Down Expand Up @@ -178,7 +178,7 @@ func VerifyLocalVolumeDiscovery(ctx SpecContext) {
MatchExpressions: []corev1.NodeSelectorRequirement{{
Key: "kubernetes.io/hostname",
Operator: "In",
Values: []string{"worker-4", "worker-5", "worker-6"},
Values: []string{"worker-2", "worker-3", "worker-4"},
}}},
}}

Expand Down Expand Up @@ -216,7 +216,7 @@ func VerifyLocalVolumeSet(ctx SpecContext) {
MatchExpressions: []corev1.NodeSelectorRequirement{{
Key: "kubernetes.io/hostname",
Operator: "In",
Values: []string{"worker-4", "worker-5", "worker-6"},
Values: []string{"worker-2", "worker-3", "worker-4"},
}}},
}}

Expand All @@ -232,7 +232,7 @@ func VerifyLocalVolumeSet(ctx SpecContext) {
Effect: "NoSchedule",
}}

localVolumeSetObj, err = localVolumeSetObj.WithNodeSelector(nodeSelector).
_, err = localVolumeSetObj.WithNodeSelector(nodeSelector).
WithStorageClassName(vcoreparams.ODFStorageClassName).
WithVolumeMode(lsov1.PersistentVolumeBlock).
WithFSType("ext4").
Expand All @@ -242,8 +242,6 @@ func VerifyLocalVolumeSet(ctx SpecContext) {
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to create localvolumeset %s in namespace %s "+
"due to %v", vcoreparams.ODFLocalVolumeSetName, vcoreparams.LSONamespace, err))

_, _ = localVolumeSetObj.Create()

pvLabel := fmt.Sprintf("storage.openshift.com/owner-name=%s", vcoreparams.ODFLocalVolumeSetName)

err = await.WaitUntilPersistentVolumeCreated(APIClient,
Expand Down
79 changes: 61 additions & 18 deletions tests/system-tests/vcore/internal/vcorecommon/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package vcorecommon

import (
"fmt"
"github.com/openshift-kni/eco-goinfra/pkg/lso"
lsov1 "github.com/openshift/local-storage-operator/api/v1"
lsov1alpha1 "github.com/openshift/local-storage-operator/api/v1alpha1"
"os"
"path/filepath"
"strings"
Expand All @@ -15,7 +18,6 @@ import (

"github.com/openshift-kni/eco-goinfra/pkg/statefulset"

"github.com/openshift-kni/eco-goinfra/pkg/mco"
"github.com/openshift-kni/eco-goinfra/pkg/namespace"
"github.com/openshift-kni/eco-goinfra/pkg/pod"
"github.com/openshift-kni/eco-goinfra/pkg/secret"
Expand All @@ -35,11 +37,55 @@ func VerifyRedisSuite() {
Describe(
"Redis validation",
Label(vcoreparams.LabelVCoreOperators), func() {
It("Verify redis localvolumeset instance exists",
Label("redis2"), VerifyRedisLocalVolumeSet)

It("Verify Redis deployment procedure",
Label("redis"), reportxml.ID("59503"), VerifyRedisDeploymentProcedure)
})
}

// VerifyRedisLocalVolumeSet asserts redis localvolumeset instance exists.
func VerifyRedisLocalVolumeSet(ctx SpecContext) {
glog.V(vcoreparams.VCoreLogLevel).Infof("Create redis localvolumeset instance %s in namespace %s if not found",
vcoreparams.RedisLocalVolumeSetName, vcoreparams.LSONamespace)

var err error

localVolumeSetObj := lso.NewLocalVolumeSetBuilder(APIClient,
vcoreparams.RedisLocalVolumeSetName,
vcoreparams.LSONamespace)

if localVolumeSetObj.Exists() {
err = localVolumeSetObj.Delete()
Expect(err).ToNot(HaveOccurred(),
fmt.Sprintf("failed to delete localvolumeset %s from namespace %s; %v",
vcoreparams.RedisLocalVolumeSetName, vcoreparams.LSONamespace, err))
}

nodeSelector := corev1.NodeSelector{NodeSelectorTerms: []corev1.NodeSelectorTerm{{
MatchExpressions: []corev1.NodeSelectorRequirement{{
Key: "kubernetes.io/hostname",
Operator: "In",
Values: []string{"master-0", "master-1", "master-2"},
}}},
}}

deviceInclusionSpec := lsov1alpha1.DeviceInclusionSpec{
DeviceTypes: []lsov1alpha1.DeviceType{lsov1alpha1.RawDisk},
DeviceMechanicalProperties: []lsov1alpha1.DeviceMechanicalProperty{lsov1alpha1.NonRotational},
}

_, err = localVolumeSetObj.WithNodeSelector(nodeSelector).
WithStorageClassName(vcoreparams.RedisStorageClassName).
WithVolumeMode(lsov1.PersistentVolumeBlock).
WithFSType("ext4").
WithMaxDeviceCount(int32(10)).
WithDeviceInclusionSpec(deviceInclusionSpec).Create()
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to create localvolumeset %s in namespace %s "+
"due to %v", vcoreparams.RedisLocalVolumeSetName, vcoreparams.LSONamespace, err))
} // func VerifyLocalVolumeSet (ctx SpecContext)

// VerifyRedisDeploymentProcedure asserts Redis deployment procedure.
//
//nolint:funlen
Expand Down Expand Up @@ -162,7 +208,7 @@ func VerifyRedisDeploymentProcedure(ctx SpecContext) {
varsToReplace["ImageRepository"] = imageURL
varsToReplace["ImageTag"] = redisImageTag
varsToReplace["RedisSecret"] = redisSecretName
varsToReplace["StorageClass"] = vcoreparams.ODFStorageClassName
varsToReplace["StorageClass"] = vcoreparams.RedisStorageClassName
varsToReplace["RunAsUser"] = runAsUser
varsToReplace["FsGroup"] = fsGroup

Expand Down Expand Up @@ -194,23 +240,20 @@ func VerifyRedisDeploymentProcedure(ctx SpecContext) {
fmt.Sprintf("redis is not properly configured: %s", result))
}

odfMcp := mco.NewMCPBuilder(APIClient, VCoreConfig.OdfMCPName)
if odfMcp.Exists() {
glog.V(vcoreparams.VCoreLogLevel).Info("Wait for the statefulset ready")
glog.V(vcoreparams.VCoreLogLevel).Info("Wait for the statefulset ready")

redisStatefulset, err := statefulset.Pull(APIClient, redisStatefulsetName, redisNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("statefulset %s not found in namespace %s; %v",
redisStatefulsetName, redisNamespace, err))
Expect(redisStatefulset.IsReady(5*time.Minute)).To(Equal(true),
fmt.Sprintf("statefulset %s in namespace %s is not ready after 5 minutes",
redisStatefulsetName, redisNamespace))
redisStatefulset, err = statefulset.Pull(APIClient, redisStatefulsetName, redisNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("statefulset %s not found in namespace %s; %v",
redisStatefulsetName, redisNamespace, err))
Expect(redisStatefulset.IsReady(5*time.Minute)).To(Equal(true),
fmt.Sprintf("statefulset %s in namespace %s is not ready after 5 minutes",
redisStatefulsetName, redisNamespace))

glog.V(vcoreparams.VCoreLogLevel).Info("Verify redis server pods count")
glog.V(vcoreparams.VCoreLogLevel).Info("Verify redis server pods count")

podsList, err := pod.ListByNamePattern(APIClient, redisAppName, redisNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("pods %s not found in namespace %s; %v",
redisAppName, redisNamespace, err))
Expect(len(podsList)).To(Equal(3), fmt.Sprintf("not all redis servers pods %s found in namespace %s;"+
"expected: 3, found: %d", redisAppName, redisNamespace, len(podsList)))
}
podsList, err := pod.ListByNamePattern(APIClient, redisAppName, redisNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("pods %s not found in namespace %s; %v",
redisAppName, redisNamespace, err))
Expect(len(podsList)).To(Equal(3), fmt.Sprintf("not all redis servers pods %s found in namespace %s;"+
"expected: 3, found: %d", redisAppName, redisNamespace, len(podsList)))
} // func VerifyRedisDeploymentProcedure (ctx SpecContext)
6 changes: 6 additions & 0 deletions tests/system-tests/vcore/internal/vcoreparams/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ const (
// CLOInstanceName is a clusterlogging instance name.
CLOInstanceName = "instance"

// RedisStorageClassName is a redis storage class name.
RedisStorageClassName = "standard"

// RedisLocalVolumeSetName is a redis localVolumeSetName name.
RedisLocalVolumeSetName = "redis-deviceset"

// DTPONamespace is a distributed tracing platform operator namespace.
DTPONamespace = "openshift-distributed-tracing"

Expand Down

0 comments on commit 0fa99d2

Please sign in to comment.