Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions testcases/smoke.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import http from 'k6/http';
import { sleep } from 'k6';
import { check } from 'k6';
import exec from 'k6/execution';
import encoding from 'k6/encoding';
import { randomString, randomItem, randomIntBetween, uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js'
Expand Down Expand Up @@ -131,18 +130,15 @@ function generateJSON(schema) {
return json;
}

function generateEvents() {
function generateEvents(num = 5) {
const events = [];
let numberOfSchemas = schemas();

if (!numberOfSchemas) {
numberOfSchemas = 5
}

let listOfSchema = generateOverlappingSchemas(numberOfSchemas);

// generate event of random schema from the list
events.push(generateJSON(listOfSchema[Math.floor(Math.random() * listOfSchema.length)]))
// generate event of random schema from the list
for (let index = 0; index < num; index++) {
events.push(generateJSON(listOfSchema[Math.floor(Math.random() * listOfSchema.length)]));
}

return events
}
Expand All @@ -163,15 +159,20 @@ export default function () {
}
}

let batch_requests = JSON.stringify(generateEvents());
let events = generateEvents(5);

let response = http.post(url, batch_requests, params);
// send a request per event
let responses = http.batch(events.map(event => ['POST', url, JSON.stringify(event), params]))

if (
!check(response, {
'status code MUST be 200': (res) => res.status == 200,
})
) {
exec.test.abort("Failed to send event.. status != 200. Last response was: " + response.error);
if (responses.some(res => res.status != 200)) {
exec.test.abort("Failed to send event.. status != 200");
}

// send all events batched
let batched_request = JSON.stringify(events);
let response = http.post(url, batched_request, params);

if (response.status != 200) {
exec.test.abort("Failed to send event.. status != 200");
}
}
2 changes: 1 addition & 1 deletion testcases/smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ username=$3
password=$4

log_events=50
k6_log_events=6000
k6_log_events=60000
expectedCount=$((k6_log_events + log_events))

input_file=$PWD/input.json
Expand Down