Skip to content

Commit

Permalink
added a job verification during eager job test
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <[email protected]>
  • Loading branch information
JorTurFer committed Oct 30, 2024
1 parent 924b6c6 commit 171727c
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/assert"
"k8s.io/client-go/kubernetes"

"github.com/kedacore/keda/v2/tests/helper"
. "github.com/kedacore/keda/v2/tests/helper" // For helper methods
. "github.com/kedacore/keda/v2/tests/scalers/rabbitmq"
)
Expand Down Expand Up @@ -100,8 +101,11 @@ func TestScalingStrategy(t *testing.T) {
})

RMQInstall(t, kc, rmqNamespace, user, password, vhost, WithoutOAuth())
CreateKubernetesResources(t, kc, testNamespace, data, templates)
// Publish 0 messges but create the queue
RMQPublishMessages(t, rmqNamespace, connectionString, queueName, 0)
helper.WaitForAllJobsSuccess(t, kc, rmqNamespace, 60, 1)

CreateKubernetesResources(t, kc, testNamespace, data, templates)
testEagerScaling(t, kc)
}

Expand All @@ -121,14 +125,17 @@ func getTemplateData() (templateData, []Template) {
func testEagerScaling(t *testing.T, kc *kubernetes.Clientset) {
iterationCount := 20
RMQPublishMessages(t, rmqNamespace, connectionString, queueName, 4)
helper.WaitForAllJobsSuccess(t, kc, rmqNamespace, 60, 1)
assert.True(t, WaitForScaledJobCount(t, kc, scaledJobName, testNamespace, 4, iterationCount, 1),
"job count should be %d after %d iterations", 4, iterationCount)

RMQPublishMessages(t, rmqNamespace, connectionString, queueName, 4)
helper.WaitForAllJobsSuccess(t, kc, rmqNamespace, 60, 1)
assert.True(t, WaitForScaledJobCount(t, kc, scaledJobName, testNamespace, 8, iterationCount, 1),
"job count should be %d after %d iterations", 8, iterationCount)

RMQPublishMessages(t, rmqNamespace, connectionString, queueName, 4)
RMQPublishMessages(t, rmqNamespace, connectionString, queueName, 8)
helper.WaitForAllJobsSuccess(t, kc, rmqNamespace, 60, 1)
assert.True(t, WaitForScaledJobCount(t, kc, scaledJobName, testNamespace, 10, iterationCount, 1),
"job count should be %d after %d iterations", 10, iterationCount)
}

0 comments on commit 171727c

Please sign in to comment.