Skip to content

Commit

Permalink
add wait condition for pod replica count
Browse files Browse the repository at this point in the history
Signed-off-by: Jinli Liang <paul.liang@rokt.com>
  • Loading branch information
PaulLiang1 committed Dec 20, 2021
1 parent 527b461 commit 68650ca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/scalers/kafka.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ test.serial('Latest Scale object should scale with new messages', t => {
}
})

test.serial('cleanup after latest policy test', t=> {
test.serial('Cleanup after latest policy test', t=> {
t.is(
0,
sh.exec(`kubectl delete -f ${scaledObjectLatestYamlFile.name} --namespace ${defaultNamespace}`).code,
Expand Down Expand Up @@ -233,16 +233,18 @@ test.serial('Applying ScaledObject with multiple topics should scale up pods', t

// produce a single msg to the default topic should not scale
sh.exec(`kubectl exec --namespace ${defaultNamespace} ${defaultKafkaClient} -- sh -exc 'echo "{\"text\": \"foo\"}" | kafka-console-producer --broker-list ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092 --topic ${defaultTopic}'`)
sh.exec(`sleep 5s`)
sh.exec(`sleep 20s`)
waitForReplicaCount(0, commandToCheckReplicas)
t.is('0', sh.exec(commandToCheckReplicas).stdout, 'Replica count should be 0.')

// produce one more msg to the different topic should trigger scale
sh.exec(`kubectl exec --namespace ${defaultNamespace} ${defaultKafkaClient} -- sh -exc 'echo "{\"text\": \"foo\"}" | kafka-console-producer --broker-list ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092 --topic ${defaultTopic2}'`)
sh.exec(`sleep 10s`)
sh.exec(`sleep 20s`)
waitForReplicaCount(1, commandToCheckReplicas)
t.is('1', sh.exec(commandToCheckReplicas).stdout, 'Replica count should be 1.')
})

test.serial('cleanup after multiple topics test', t=> {
test.serial('Cleanup after multiple topics test', t=> {
t.is(
0,
sh.exec(`kubectl delete -f ${scaledObjectMultipleTopicsYamlFile.name} --namespace ${defaultNamespace}`).code,
Expand Down

0 comments on commit 68650ca

Please sign in to comment.