Skip to content

Commit

Permalink
add e2e test for redis-lists* activation
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
  • Loading branch information
JorTurFer committed Jul 23, 2022
1 parent 78e81e2 commit 5c209f4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
11 changes: 11 additions & 0 deletions tests/scalers_go/redis_cluster_lists/redis_cluster_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ spec:
addressesFromEnv: REDIS_ADDRESSES
listName: {{.RedisList}}
listLength: "5"
activationListLength: "10"
authenticationRef:
name: {{.TriggerAuthenticationName}}
`
Expand Down Expand Up @@ -177,6 +178,7 @@ func TestScaler(t *testing.T) {
data, templates := getTemplateData()
CreateKubernetesResources(t, kc, testNamespace, data, templates)

testActivation(t, kc, data)
testScaleUp(t, kc, data)
testScaleDown(t, kc)

Expand All @@ -185,6 +187,15 @@ func TestScaler(t *testing.T) {
DeleteKubernetesResources(t, kc, testNamespace, data, templates)
}

func testActivation(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing activation ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
data.ItemsToWrite = 5
KubectlApplyMultipleWithTemplate(t, data, templateTriggerJob)

AssertReplicaCountNotChangeDuringTimePeriod(t, kc, deploymentName, testNamespace, minReplicaCount, 60)
}

func testScaleUp(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing scale up ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
Expand Down
11 changes: 11 additions & 0 deletions tests/scalers_go/redis_sentinel_lists/redis_sentinel_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ spec:
listName: {{.RedisList}}
sentinelMaster: mymaster
listLength: "5"
activationListLength: "10"
authenticationRef:
name: {{.TriggerAuthenticationName}}
`
Expand Down Expand Up @@ -185,6 +186,7 @@ func TestScaler(t *testing.T) {
data, templates := getTemplateData()
CreateKubernetesResources(t, kc, testNamespace, data, templates)

testActivation(t, kc, data)
testScaleUp(t, kc, data)
testScaleDown(t, kc)

Expand All @@ -193,6 +195,15 @@ func TestScaler(t *testing.T) {
DeleteKubernetesResources(t, kc, testNamespace, data, templates)
}

func testActivation(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing activation ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
data.ItemsToWrite = 5
KubectlApplyMultipleWithTemplate(t, data, templateTriggerJob)

AssertReplicaCountNotChangeDuringTimePeriod(t, kc, deploymentName, testNamespace, minReplicaCount, 60)
}

func testScaleUp(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing scale up ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ spec:
portFromEnv: REDIS_PORT
listName: {{.RedisList}}
listLength: "5"
activationListLength: "10"
authenticationRef:
name: {{.TriggerAuthenticationName}}
`
Expand Down Expand Up @@ -173,6 +174,7 @@ func TestScaler(t *testing.T) {
data, templates := getTemplateData()
CreateKubernetesResources(t, kc, testNamespace, data, templates)

testActivation(t, kc, data)
testScaleUp(t, kc, data)
testScaleDown(t, kc)

Expand All @@ -181,6 +183,15 @@ func TestScaler(t *testing.T) {
DeleteKubernetesResources(t, kc, testNamespace, data, templates)
}

func testActivation(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing activation ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
data.ItemsToWrite = 5
KubectlApplyMultipleWithTemplate(t, data, templateTriggerJob)

AssertReplicaCountNotChangeDuringTimePeriod(t, kc, deploymentName, testNamespace, minReplicaCount, 60)
}

func testScaleUp(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing scale up ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func TestScaler(t *testing.T) {
assert.True(t, WaitForDeploymentReplicaReadyCount(t, kc, deploymentName, testNamespace, 1, 60, 3),
"replica count should be %d after 3 minutes", 1)

// testActivation(t, kc, data)
testScaleUp(t, kc, data)
testScaleDown(t, kc)

Expand All @@ -185,15 +184,6 @@ func TestScaler(t *testing.T) {
DeleteKubernetesResources(t, kc, testNamespace, data, templates)
}

func testActivation(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing activation ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
data.ItemsToWrite = 5
KubectlApplyMultipleWithTemplate(t, data, templateTriggerJob)

AssertReplicaCountNotChangeDuringTimePeriod(t, kc, deploymentName, testNamespace, minReplicaCount, 60)
}

func testScaleUp(t *testing.T, kc *kubernetes.Clientset, data templateData) {
t.Log("--- testing scale up ---")
templateTriggerJob := templateValues{"insertJobTemplate": insertJobTemplate}
Expand Down

0 comments on commit 5c209f4

Please sign in to comment.