Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ username=$3
password=$4
schema_count=$5
: "${schema_count:=20}"
vus=$6
: "${vus:=10}"
duration=$7
: "${duration:="5m"}"

stream_name=$(head /dev/urandom | tr -dc a-z | head -c10)

Expand All @@ -31,7 +35,7 @@ run_smoke_test () {
}

run_load_test () {
./testcases/load_test.sh "$endpoint" "$stream_name" "$username" "$password" "$schema_count"
./testcases/load_test.sh "$endpoint" "$stream_name" "$username" "$password" "$schema_count" "$vus" "$duration"
return $?
}

Expand Down
22 changes: 10 additions & 12 deletions testcases/load.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import http from 'k6/http';
import { sleep } from 'k6';
// import check from 'k6';
// import exec from 'k6/execution';
import { check, sleep } 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 All @@ -11,8 +10,7 @@ export const options = {
contacts: {
executor: 'constant-vus',
vus: 10,
//iterations: 200,
//maxDuration: '10m',
duration: "5m",
},
},
};
Expand Down Expand Up @@ -174,11 +172,11 @@ export default function () {

let response = http.post(url, batch_requests, params);

//if (
// !check(response[0], {
// 'status code MUST be 200': (res) => res.status == 200,
// })
//) {
// exec.test.abort("Failed to send event.. status != 200");
//}
if (
!check(response, {
'status code MUST be 200': (res) => res.status == 200,
})
) {
exec.test.abort("Failed to send event.. status != 200");
}
}
4 changes: 3 additions & 1 deletion testcases/load_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ stream_name=$2
username=$3
password=$4
count=$5
vus=$6
duration=$7

curl_std_opts=( -sS --header 'Content-Type: application/json' -w '\n\n%{http_code}' -u "$username":"$password" )

Expand Down Expand Up @@ -81,7 +83,7 @@ delete_stream () {
}

run_k6() {
k6 run -e P_URL="$parseable_url" -e P_STREAM="$stream_name" -e P_USERNAME="$username" -e P_PASSWORD="$password" -e P_SCHEMA_COUNT="$count" "/tests/testcases/load.js"
k6 run -e P_URL="$parseable_url" -e P_STREAM="$stream_name" -e P_USERNAME="$username" -e P_PASSWORD="$password" -e P_SCHEMA_COUNT="$count" "/tests/testcases/load.js" --vus="$vus" --duration="$duration"
}

printf "======= Starting load tests with k6 =======\n"
Expand Down