Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Momotoculteur/f905195f5034d52e657e1230ca0d0401 to your computer and use it in GitHub Desktop.
Save Momotoculteur/f905195f5034d52e657e1230ca0d0401 to your computer and use it in GitHub Desktop.
k6 load charge testing with kafka extension to an Microsoft Azure Event Hub v0.8.0
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 = writer(bootstrapServers, kafkaTopic, auth);
export default function () {
const messages = [
{
key: JSON.stringify({
correlationId: "un"
}),
time: new Date().getTime(),
value: JSON.stringify({
data: "test"
}),
}
];
let 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