Skip to content

Commit 89d6c80

Browse files
chore: add variables benchmark (#304)
<!-- The PR description should answer 2 (maybe 3) important questions: --> ### What Noticed we're not reusing connections in variable queries. Making a benchmark for it before making the fix. ### How Add a benchmark that does a query with 5 variables, meaning 5 queries.
1 parent 3b50c69 commit 89d6c80

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { check } from "k6";
2+
import http from "k6/http";
3+
import { newSummaryHandler } from "../common.js";
4+
5+
const testid = "select_variables";
6+
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
7+
const url = `http://${agentSocket}/query`;
8+
const data = {
9+
collection: "Album",
10+
query: {
11+
fields: {
12+
Title: {
13+
type: "column",
14+
column: "Title",
15+
arguments: {},
16+
},
17+
},
18+
where: {
19+
type: "binary_comparison_operator",
20+
column: {
21+
type: "column",
22+
name: "Title",
23+
path: [],
24+
},
25+
operator: {
26+
type: "other",
27+
name: "_like",
28+
},
29+
value: {
30+
type: "variable",
31+
name: "search",
32+
},
33+
},
34+
},
35+
arguments: {},
36+
collection_relationships: {},
37+
variables: [
38+
{
39+
search: "%Garage%",
40+
},
41+
{
42+
search: "%Good%",
43+
},
44+
{
45+
search: "%Rock%",
46+
},
47+
{
48+
search: "%Dog%",
49+
},
50+
{
51+
search: "%Log%",
52+
},
53+
],
54+
};
55+
56+
export default function () {
57+
const response = http.post(url, JSON.stringify(data), {
58+
headers: {
59+
"Content-Type": "application/json",
60+
},
61+
});
62+
63+
check(response, {
64+
"status is 200": (r) => r.status == 200,
65+
});
66+
}
67+
68+
export const handleSummary = newSummaryHandler(testid);
69+
70+
export const options = {
71+
tags: {
72+
testid,
73+
},
74+
scenarios: {
75+
short_sustained: {
76+
executor: "constant-vus",
77+
vus: 100,
78+
duration: "10s",
79+
},
80+
},
81+
thresholds: {
82+
checks: [
83+
{
84+
threshold: "rate == 1",
85+
abortOnFail: true,
86+
},
87+
],
88+
},
89+
};

0 commit comments

Comments
 (0)