test: support TABBY_API_HOST in k6 tests
parent
a60e765a1d
commit
614d993344
4
Makefile
4
Makefile
|
|
@ -19,8 +19,8 @@ $(PRE_COMMIT_HOOK):
|
||||||
|
|
||||||
setup-development-environment: install-poetry $(PRE_COMMIT_HOOK)
|
setup-development-environment: install-poetry $(PRE_COMMIT_HOOK)
|
||||||
|
|
||||||
test-smoke:
|
smoke:
|
||||||
k6 run tests/*.smoke.js
|
k6 run tests/*.smoke.js
|
||||||
|
|
||||||
test-loadtest:
|
loadtest:
|
||||||
k6 run tests/*.loadtest.js
|
k6 run tests/*.loadtest.js
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
import http from 'k6/http';
|
import http from "k6/http";
|
||||||
import { check, group, sleep } from 'k6';
|
import { check, group, sleep } from "k6";
|
||||||
|
|
||||||
export const options = {
|
export const options = {
|
||||||
stages: [
|
stages: [
|
||||||
{ duration: '5s', target: 10 }, // simulate ramp-up of traffic from 1 to 10 users over 30s.
|
{ duration: "5s", target: 10 }, // simulate ramp-up of traffic from 1 to 10 users over 30s.
|
||||||
{ duration: '30s', target: 10 }, // stay at 10 users for 10 minutes
|
{ duration: "30s", target: 10 }, // stay at 10 users for 10 minutes
|
||||||
{ duration: '5s', target: 0 }, // ramp-down to 0 users
|
{ duration: "5s", target: 0 }, // ramp-down to 0 users
|
||||||
],
|
],
|
||||||
|
hosts: {
|
||||||
|
"api.tabbyml.com": __ENV.TABBY_API_HOST || "localhost:5000",
|
||||||
|
},
|
||||||
thresholds: {
|
thresholds: {
|
||||||
'http_req_duration': ['p(99)<1000'], // 99% of requests must complete below 1000ms
|
http_req_duration: ["p(99)<1000"], // 99% of requests must complete below 1000ms
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -17,7 +20,7 @@ export default () => {
|
||||||
prompt: "def binarySearch(arr, left, right, x):\n mid = (left +",
|
prompt: "def binarySearch(arr, left, right, x):\n mid = (left +",
|
||||||
});
|
});
|
||||||
const headers = { "Content-Type": "application/json" };
|
const headers = { "Content-Type": "application/json" };
|
||||||
const res = http.post("http://localhost:5000/v1/completions", payload, {
|
const res = http.post("http://api.tabbyml.com/v1/completions", payload, {
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
check(res, { success: (r) => r.status === 200 });
|
check(res, { success: (r) => r.status === 200 });
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,24 @@
|
||||||
import http from "k6/http";
|
import http from "k6/http";
|
||||||
import { check } from "k6";
|
import { check, sleep } from "k6";
|
||||||
|
|
||||||
|
export const options = {
|
||||||
|
stages: [
|
||||||
|
{duration: '3s', target: 5},
|
||||||
|
],
|
||||||
|
hosts: {
|
||||||
|
'api.tabbyml.com': __ENV.TABBY_API_HOST || "localhost:5000"
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const SLEEP_DURATION = 1;
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const payload = JSON.stringify({
|
const payload = JSON.stringify({
|
||||||
prompt: "def binarySearch(arr, left, right, x):\n mid = (left +",
|
prompt: "def binarySearch(arr, left, right, x):\n mid = (left +",
|
||||||
});
|
});
|
||||||
const headers = { "Content-Type": "application/json" };
|
const headers = { "Content-Type": "application/json" };
|
||||||
const res = http.post("http://localhost:5000/v1/completions", payload, {
|
const res = http.post("http://api.tabbyml.com/v1/completions", payload, {
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
check(res, { success: (r) => r.status === 200 });
|
check(res, { success: (r) => r.status === 200 });
|
||||||
|
sleep(SLEEP_DURATION)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue