Skip to content
Snippets Groups Projects
Commit 6c9a5c6c authored by Arseniy Volynets's avatar Arseniy Volynets Committed by ms.evilhat
Browse files

test(k6): fix errors and add rate metric to track the number of successful requests in stress-test

parent b4c503be
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -3,8 +3,8 @@
1. Run [test application](../test_app)
```bash
cd ../test_app && cartridge start
```
```
If the cluster is not configured then use the the web-based administrative panel or run the following command to configure it:
```bash
cartridge replicasets setup --file replicasets.yml --bootstrap-vshard
......@@ -13,17 +13,16 @@
```bash
./init.lua 1000
```
1. Clone `asbest` repository to an arbitrary local directory
```
git clone git@gitlab.com:picodata/arenadata/asbest.git
cd asbest
```
1. Build [k6](https://k6.io/docs/getting-started/running-k6/) with the [dtm module](https://gitlab.com/picodata/arenadata/asbest/-/tree/master/xk6-plugin-dtm)
```
xk6 build v0.32.0 --with xk6-plugin-dtm="$(pwd)/xk6-plugin-dtm" --with github.com/hackfeed/xk6-tarantool
1. Build [k6](https://k6.io/docs/getting-started/running-k6/)
```bash
xk6 build --with github.com/WeCodingNow/xk6-tarantool
```
1. Run the [k6](https://k6.io/docs/getting-started/running-k6/) script
1. Run the [k6](https://k6.io/docs/getting-started/running-k6/) script
```bash
./k6 run -u 10 -d 1m k6.js
```
**Note:**
If you run stress tests sequentially, you may need to do `cartridge clean` before next test run because tests might have
conflicting schemas.
import tarantool from "k6/x/tarantool";
import {uuidv4} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
import { updateSuccessRate } from '../metrics.js';
const clients = [
tarantool.connect("localhost:3301", {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect("localhost:3306", {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect("localhost:3307", {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect("localhost:3308", {"user": "admin", pass: "app-cluster-cookie"})
tarantool.connect(["localhost:3301"], {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect(["localhost:3306"], {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect(["localhost:3307"], {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect(["localhost:3308"], {"user": "admin", pass: "app-cluster-cookie"})
]
export let current_server = 0
......@@ -22,5 +23,6 @@ function get_client() {
let pattern = `INSERT INTO "t" ("id", "name", "product_units") VALUES (?, ?, ?)`
export default () => {
tarantool.call(get_client(), "sbroad.execute", [pattern, [uuidv4(), "123", 1]]);
var resp = tarantool.call(get_client(), "sbroad.execute", [pattern, [uuidv4(), "123", 1]]);
updateSuccessRate(resp);
}
import { Rate } from 'k6/metrics';
export const successRate = new Rate('success');
export function updateSuccessRate(resp) {
if (resp.data[0][0] === null ) {
successRate.add(false);
} else {
successRate.add(true);
}
}
\ No newline at end of file
import tarantool from "k6/x/tarantool";
import {randomItem} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
import { updateSuccessRate } from '../metrics.js';
const client = tarantool.connect("localhost:3301", {"user": "admin", pass: "app-cluster-cookie"})
const client = tarantool.connect(["localhost:3301"], {"user": "admin", pass: "app-cluster-cookie"})
let ids = Array.from(
{
......@@ -23,5 +24,6 @@ let pattern = `SELECT *
WHERE "id" = ?`
export default () => {
tarantool.call(client, "sbroad.execute", [pattern, [randomItem(ids)]]);
var resp = tarantool.call(client, "sbroad.execute", [pattern, [randomItem(ids)]]);
updateSuccessRate(resp);
}
\ No newline at end of file
import tarantool from "k6/x/tarantool";
import {randomItem} from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
import { updateSuccessRate } from '../metrics.js';
const clients = [
tarantool.connect("localhost:3301", {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect("localhost:3306", {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect("localhost:3307", {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect("localhost:3308", {"user": "admin", pass: "app-cluster-cookie"})
tarantool.connect(["localhost:3301"], {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect(["localhost:3306"], {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect(["localhost:3307"], {"user": "admin", pass: "app-cluster-cookie"}),
tarantool.connect(["localhost:3308"], {"user": "admin", pass: "app-cluster-cookie"})
]
export let current_server = 0
......@@ -37,5 +38,6 @@ const pattern = `SELECT *
WHERE "reestrid" = ?`
export default () => {
tarantool.call(get_client(), "sbroad.execute", [pattern, [randomItem(ids)]]);
var resp = tarantool.call(get_client(), "sbroad.execute", [pattern, [randomItem(ids)]]);
updateSuccessRate(resp);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment