Skip to content

Commit

Permalink
test: leader/follower endpoint(svc)
Browse files Browse the repository at this point in the history
Signed-off-by: wkd-woo <[email protected]>
  • Loading branch information
wkd-woo committed Mar 4, 2024
1 parent 4c09ac2 commit 16fcf61
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
84 changes: 84 additions & 0 deletions k8sutils/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,90 @@ func TestGenerateServiceDef(t *testing.T) {
},
},
},
{
name: "Test redis-replication-leader with ClusterIP service type and metrics enabled",
serviceMeta: metav1.ObjectMeta{
Name: "test-redis-replication-leader",
Labels: map[string]string{
"redis-role": "master",
},
},
enableMetrics: defaultExporterPortProvider,
headless: false,
serviceType: "ClusterIP",
port: redisPort,
expected: &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-redis-replication-leader",
Labels: map[string]string{
"redis-role": "master",
},
OwnerReferences: []metav1.OwnerReference{
{},
},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: "redis-client",
Port: redisPort,
TargetPort: intstr.FromInt(int(redisPort)),
Protocol: corev1.ProtocolTCP,
},
*enableMetricsPort(redisExporterPort),
},
Selector: map[string]string{"redis-role": "master"},
ClusterIP: "",
Type: corev1.ServiceTypeClusterIP,
},
},
},
{
name: "Test redis-replication-follower with ClusterIP service type and metrics enabled",
serviceMeta: metav1.ObjectMeta{
Name: "test-redis-replication-follower",
Labels: map[string]string{
"redis-role": "slave",
},
},
enableMetrics: defaultExporterPortProvider,
headless: false,
serviceType: "ClusterIP",
port: redisPort,
expected: &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-redis-replication-follower",
Labels: map[string]string{
"redis-role": "slave",
},
OwnerReferences: []metav1.OwnerReference{
{},
},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Name: "redis-client",
Port: redisPort,
TargetPort: intstr.FromInt(int(redisPort)),
Protocol: corev1.ProtocolTCP,
},
*enableMetricsPort(redisExporterPort),
},
Selector: map[string]string{"redis-role": "slave"},
ClusterIP: "",
Type: corev1.ServiceTypeClusterIP,
},
},
},
}

for _, tt := range tests {
Expand Down
16 changes: 16 additions & 0 deletions wkd-woo/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
redisOperator:
name: redis-operator
imageName: wkdwoo/redis-operator
imageTag: "replication-endpoint"
imagePullPolicy: IfNotPresent

podAnnotations: {}
podLabels:
duty: operator

extraArgs: []

watch_namespace: "redis-operator"
env: []
webhook: false

0 comments on commit 16fcf61

Please sign in to comment.