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: refactoring for the redis and odf nodes #149

Merged
merged 1 commit into from
Aug 11, 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 @@ -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",
// 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
80 changes: 62 additions & 18 deletions tests/system-tests/vcore/internal/vcorecommon/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"strings"
"time"

"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"

"github.com/openshift-kni/eco-gotests/tests/system-tests/internal/remote"

"github.com/openshift-kni/eco-goinfra/pkg/reportxml"
Expand All @@ -15,7 +19,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 +38,55 @@ func VerifyRedisSuite() {
Describe(
"Redis validation",
Label(vcoreparams.LabelVCoreOperators), func() {
It("Verify redis localvolumeset instance exists",
Label("redis"), 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 +209,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 +241,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
Loading