Created
June 8, 2022 10:01
-
-
Save Momotoculteur/253f4bc3373ca171bda5183e771cbfde to your computer and use it in GitHub Desktop.
k6 load charge testing with kafka extension to an Microsoft Azure Event Hub v0.10.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { writer, produce, reader, consume, createTopic,listTopics } from 'k6/x/kafka'; | |
import { check, sleep } from 'k6'; | |
const bootstrapServers = ['myServer:9093'] | |
const kafkaTopic = 'aircraft-hub'; | |
const auth = JSON.stringify({ | |
username: '$ConnectionString', | |
password: 'myConnectionString', | |
}); | |
const [producer, _writerError] = writer(bootstrapServers, kafkaTopic, auth); | |
export default function () { | |
const messages = [ | |
{ | |
key: JSON.stringify({ | |
correlationId: "un" | |
}), | |
time: new Date().getTime(), | |
value: JSON.stringify({ | |
data: "test" | |
}), | |
} | |
]; | |
const error = produce(producer, messages); | |
check(error, { | |
'is sent': (err) => err == undefined, | |
}); | |
sleep(1) | |
} | |
export function teardown(data) { | |
producer.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment