Skip to content
Snippets Groups Projects
Verified Commit 229e6a42 authored by Denis Smirnov's avatar Denis Smirnov
Browse files

test: implement insertion bench (core dump)

parent d10a414b
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -9,7 +9,7 @@
```bash
cartridge replicasets setup --file replicasets.yml --bootstrap-vshard
```
1. Generate test data and define the number of records:
1. Open a folder with a stress test. Generate data and define the number of records:
```bash
./data_generator.lua 1000
```
......
#!/usr/bin/env tarantool
local nb = require("net.box")
local fiber = require("fiber")
local yaml = require('yaml')
local clock = require("clock")
local start_time = clock.time();
local api = nb.connect("admin:app-cluster-cookie@localhost:3301")
api:eval("function set_schema(s) local cartridge = require('cartridge'); cartridge.set_schema(s) end")
local config = {
spaces = {
t = {
format = {
{
name = "id",
type = "string",
is_nullable = false,
},
{
name = "name",
type = "string",
is_nullable = false,
},
{
name = "product_units",
type = "integer",
is_nullable = false,
},
{
name = "bucket_id",
type = "unsigned",
is_nullable = true,
},
},
temporary = false,
engine = "memtx",
indexes = {
{
unique = true,
parts = {
{
path = "id",
type = "string",
is_nullable = false,
},
},
type = "TREE",
name = "id",
},
{
unique = false,
parts = {
{
path = "bucket_id",
type = "unsigned",
is_nullable = true,
},
},
type = "TREE",
name = "bucket_id",
},
},
is_local = false,
sharding_key = { "id" },
},
}
}
api:call("set_schema", { yaml.encode(config) })
print("table was created")
fiber.sleep(3)
print("truncate the table on storages")
local storage1 = nb.connect("admin:app-cluster-cookie@localhost:3302")
local storage2 = nb.connect("admin:app-cluster-cookie@localhost:3304")
storage1:eval("return box.space.t:truncate();")
storage2:eval("return box.space.t:truncate();")
api:close()
storage1:close()
storage2:close()
print("truncation finished")
fiber.sleep(3)
print(string.format("Execution time: %f s", (clock.time() - start_time) ))
import tarantool from "k6/x/tarantool";
import {uuidv4} from 'https://jslib.k6.io/k6-utils/1.1.0/index.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"})
]
export let current_server = 0
function get_client() {
let c = clients[current_server]
current_server += 1
if (current_server >= clients.length) {
current_server = 0
}
return c
}
let pattern = `INSERT INTO "t" ("id", "name", "product_units") VALUES (?, ?, ?)`
export default () => {
tarantool.call(get_client(), "sbroad.execute", [pattern, [uuidv4(), "123", 1]]);
}
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