Skip to content

Commit

Permalink
final version of e2e test for kafka scaler latest offset policy
Browse files Browse the repository at this point in the history
Signed-off-by: grassiale <alessandro.grassi01@gmail.com>
  • Loading branch information
grassiale committed Sep 3, 2020
1 parent 22a1061 commit 67598d7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/scalers/kafka.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ test.serial('cleanup after earliest policy test', t=> {
})

test.serial('Applying ScaledObject latest policy should not scale up pods', t => {

//Make the consumer commit the first offset for each partition.
sh.exec(`kubectl exec --namespace ${defaultNamespace} ${defaultKafkaClient} -- sh -c 'kafka-console-consumer --bootstrap-server ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092 --topic ${defaultTopic} --group latest --from-beginning --consumer-property enable.auto.commit=true --timeout-ms 15000'`)

fs.writeFileSync(kafkaApplicationLatestYamlFile.name, kafkaApplicationLatestYaml)
t.is(
0,
Expand All @@ -165,19 +169,14 @@ test.serial('Applying ScaledObject latest policy should not scale up pods', t =>
)
sh.exec(`sleep 5s`)
waitForReplicaCount(1, commandToCheckReplicas)
t.is('1', sh.exec(commandToCheckReplicas).stdout, 'Replica count should be 1.')
//Make the consumer commit the first offset for each partition.
for (let r = 1; r <= 3; r++) {
sh.exec(`kubectl exec --namespace ${defaultNamespace} ${defaultKafkaClient} -- sh -c 'echo "{\"text\": \"foo\"}" | kafka-console-producer --broker-list ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092 --topic ${defaultTopic}'`)
}
sh.exec(`kubectl exec --namespace ${defaultNamespace} ${defaultKafkaClient} -- sh -c 'kafka-console-consumer --bootstrap-server ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092 --topic ${defaultTopic} --group latest --from-beginning --consumer-property enable.auto.commit=true --timeout-ms 15000'`)
t.is('0', sh.exec(commandToCheckReplicas).stdout, 'Replica count should be 0.')

})


test.serial('Latest Scale object should scale with new messages', t => {

for (let r = 2; r <= 3; r++) {
for (let r = 1; r <= 3; r++) {

sh.exec(`kubectl exec --namespace ${defaultNamespace} ${defaultKafkaClient} -- sh -c 'echo "{\"text\": \"foo\"}" | kafka-console-producer --broker-list ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092 --topic ${defaultTopic}'`)
sh.exec(`sleep 5s`)
Expand Down

0 comments on commit 67598d7

Please sign in to comment.