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

test: remove redundant running spec #771

Merged
merged 1 commit into from
Feb 8, 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
20 changes: 4 additions & 16 deletions controllers/redis_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ var _ = Describe("Redis standalone test", func() {
})

Context("When creating a redis standalone CR", func() {
It("should create a statefulset", func() {
var sts *appsv1.StatefulSet
It("should create a statefulset, service", func() {
sts := &appsv1.StatefulSet{}
svc := &corev1.Service{}

Eventually(func() error {
sts = &appsv1.StatefulSet{}
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisCRName,
Namespace: ns,
Expand All @@ -62,12 +63,8 @@ var _ = Describe("Redis standalone test", func() {

Expect(*sts.Spec.Replicas).To(BeEquivalentTo(1))
Expect(sts.Spec.ServiceName).To(Equal(redisCRName + "-headless"))
})

It("should create a service", func() {
var svc *corev1.Service
Eventually(func() error {
svc = &corev1.Service{}
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisCR.Name,
Namespace: ns,
Expand All @@ -79,12 +76,8 @@ var _ = Describe("Redis standalone test", func() {
"redis_setup_type": "standalone",
"role": "standalone",
}))
})

It("should create a headless service", func() {
var svc *corev1.Service
Eventually(func() error {
svc = &corev1.Service{}
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisCR.Name + "-headless",
Namespace: ns,
Expand All @@ -96,12 +89,7 @@ var _ = Describe("Redis standalone test", func() {
"redis_setup_type": "standalone",
"role": "standalone",
}))
})

It("should create additional service", func() {
var svc *corev1.Service
Eventually(func() error {
svc = &corev1.Service{}
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisCR.Name + "-additional",
Namespace: ns,
Expand Down
14 changes: 3 additions & 11 deletions controllers/rediscluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ var _ = Describe("Redis cluster test", func() {
})

Context("When creating a redis cluster CR", func() {
It("should create a statefulset", func() {
It("should create a statefulset, service", func() {
sts := &appsv1.StatefulSet{}
svc := &corev1.Service{}

Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisClusterCRName + "-leader",
Expand All @@ -67,10 +69,7 @@ var _ = Describe("Redis cluster test", func() {

Expect(*sts.Spec.Replicas).To(BeEquivalentTo(3))
Expect(sts.Spec.ServiceName).To(Equal(redisClusterCRName + "-leader-headless"))
})

It("should create a service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisClusterCRName + "-leader",
Expand All @@ -83,10 +82,7 @@ var _ = Describe("Redis cluster test", func() {
"redis_setup_type": "cluster",
"role": "leader",
}))
})

It("should create a headless service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisClusterCRName + "-leader-headless",
Expand All @@ -99,10 +95,6 @@ var _ = Describe("Redis cluster test", func() {
"redis_setup_type": "cluster",
"role": "leader",
}))
})

It("should create additional service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisClusterCRName + "-leader-additional",
Expand Down
14 changes: 4 additions & 10 deletions controllers/redisreplication_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ var _ = Describe("Redis replication test", func() {
})

Context("When creating a redis replication CR", func() {
It("should create a statefulset", func() {
It("should create a statefulset, service", func() {

svc := &corev1.Service{}
sts := &appsv1.StatefulSet{}

Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisReplicationCRName,
Expand All @@ -60,10 +62,7 @@ var _ = Describe("Redis replication test", func() {

Expect(*sts.Spec.Replicas).To(BeEquivalentTo(3))
Expect(sts.Spec.ServiceName).To(Equal(redisReplicationCRName + "-headless"))
})

It("should create a service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisReplicationCRName,
Expand All @@ -76,10 +75,7 @@ var _ = Describe("Redis replication test", func() {
"redis_setup_type": "replication",
"role": "replication",
}))
})

It("should create a headless service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisReplicationCRName + "-headless",
Expand All @@ -92,10 +88,7 @@ var _ = Describe("Redis replication test", func() {
"redis_setup_type": "replication",
"role": "replication",
}))
})

It("should create additional service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisReplicationCRName + "-additional",
Expand All @@ -108,6 +101,7 @@ var _ = Describe("Redis replication test", func() {
"redis_setup_type": "replication",
"role": "replication",
}))

})

Context("then deleting the redis replication CR", func() {
Expand Down
13 changes: 3 additions & 10 deletions controllers/redissentinel_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ var _ = Describe("Redis sentinel test", func() {
})

Context("When creating a redis sentinel CR", func() {
It("should create a statefulset", func() {
It("should create a statefulset, service", func() {
sts := &appsv1.StatefulSet{}
svc := &corev1.Service{}

Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisSentinelCRName + "-sentinel",
Expand All @@ -58,10 +60,7 @@ var _ = Describe("Redis sentinel test", func() {

Expect(*sts.Spec.Replicas).To(BeEquivalentTo(3))
Expect(sts.Spec.ServiceName).To(Equal(redisSentinelCRName + "-sentinel-headless"))
})

It("should create a service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisSentinelCRName + "-sentinel",
Expand All @@ -74,10 +73,7 @@ var _ = Describe("Redis sentinel test", func() {
"redis_setup_type": "sentinel",
"role": "sentinel",
}))
})

It("should create a headless service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisSentinelCRName + "-sentinel-headless",
Expand All @@ -90,10 +86,7 @@ var _ = Describe("Redis sentinel test", func() {
"redis_setup_type": "sentinel",
"role": "sentinel",
}))
})

It("should create additional service", func() {
svc := &corev1.Service{}
Eventually(func() error {
return k8sClient.Get(context.TODO(), types.NamespacedName{
Name: redisSentinelCRName + "-sentinel-additional",
Expand Down
Loading