Skip to content

Commit

Permalink
Remove unneeded endpoints from load test client, pull in existing loa…
Browse files Browse the repository at this point in the history
…d test dashboard
  • Loading branch information
pianohacker committed Aug 30, 2021
1 parent bdd45cf commit 46e9db4
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 17 deletions.
File renamed without changes.
83 changes: 83 additions & 0 deletions devenv/loadtest/fixtures/image-renderer-perf-dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"uid": "image-renderer-perf-dashboard",
"panels": [
{
"datasource": "k6-image-renderer-testdata",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"title": "test-panel",
"type": "timeseries"
}
],
"schemaVersion": 30,
"time": {
"from": "now-6h",
"to": "now"
},
"title": "image-renderer-perf-dashboard"
}
12 changes: 0 additions & 12 deletions devenv/loadtest/modules/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export const DatasourcesEndpoint = class DatasourcesEndpoint {
update(id, payload) {
return this.httpClient.put(`/datasources/${id}`, JSON.stringify(payload));
}

delete(id) {
return this.httpClient.delete(`/datasources/${id}`);
}
};

export const DashboardsEndpoint = class DashboardsEndpoint {
Expand All @@ -42,10 +38,6 @@ export const DashboardsEndpoint = class DashboardsEndpoint {
upsert(payload) {
return this.httpClient.post(`/dashboards/db`, JSON.stringify(payload));
}

delete(id) {
return this.httpClient.delete(`/dashboards/uid/${id}`);
}
};

export const OrganizationsEndpoint = class OrganizationsEndpoint {
Expand All @@ -67,10 +59,6 @@ export const OrganizationsEndpoint = class OrganizationsEndpoint {
};
return this.httpClient.post(`/orgs`, JSON.stringify(payload));
}

delete(id) {
return this.httpClient.delete(`/orgs/${id}`);
}
};

export const UIEndpoint = class UIEndpoint {
Expand Down
4 changes: 2 additions & 2 deletions devenv/loadtest/modules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const createTestOrgIfNotExists = (client) => {
return res.json().id;
};

export const upsertTestdataDatasource = (client) => {
export const upsertTestdataDatasource = (client, name) => {
const payload = {
access: 'proxy',
isDefault: false,
name: 'k6-image-renderer-testdata',
name,
type: 'testdata',
};

Expand Down
4 changes: 2 additions & 2 deletions devenv/loadtest/render_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export let options = {

let endpoint = __ENV.URL || 'http://localhost:3000';
const client = createClient(endpoint);
const dashboard = JSON.parse(open('fixtures/image-renderer-perf-dashboard.json'));
const dashboard = JSON.parse(open('fixtures/graph_panel.json'));

export const setup = () => {
let grafanaSession;
Expand All @@ -27,7 +27,7 @@ export const setup = () => {

const orgId = createTestOrgIfNotExists(client);
client.withOrgId(orgId);
upsertTestdataDatasource(client);
upsertTestdataDatasource(client, dashboard.panels[0].datasource);
upsertTestdataDashboard(client, dashboard);

return {
Expand Down
12 changes: 11 additions & 1 deletion devenv/loadtest/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ run() {
done
shift $((OPTIND-1))

docker run -t --network=host -v $PWD:/src -e URL=$url --rm -i loadimpact/k6:master run --vus $vus --duration $duration $iterationsOption /src/render_test.js
docker run \
-it \
--network=host \
--mount type=bind,source=$PWD,destination=/src \
-e URL=$url \
--rm \
loadimpact/k6:master run \
--vus $vus \
--duration $duration \
$iterationsOption \
/src/render_test.js
}

run "$@"

0 comments on commit 46e9db4

Please sign in to comment.