2.Сгенерировать тестовые данные с помощью скрипта:
2.Generate test data and define the number of records:
```bash
./data_generator.lua 1000
```
в параметре передается кол-во записей для генерации
3. Запустить скрипт [k6](https://k6.io/docs/getting-started/running-k6/) c [dtm модулем](https://gitlab.com/picodata/arenadata/asbest/-/tree/master/xk6-plugin-dtm)([как собрать](https://k6.io/blog/extending-k6-with-xk6/))
3. 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)
(`vshard-storage`, `vshard-router` and `metrics`).
## Architecture
You can add your own role, but don't forget to register in using
`cartridge.cfg` call.
The application includes two roles:
## Instances configuration
-`api`
-`storage`
Configuration of instances that can be used to start application
locally is places in [instances.yml](./instances.yml).
It is used by `cartridge start`.
The `api` role has two functions:
## Topology configuration
-`query(sql)`
-`insert_record(space, values_map)`
Topology configuration is described in [`replicasets.yml`](./replicasets.yml).
It is used by `cartridge replicasets setup`.
The `query` function executes the sql query from the `sql` parameter.
## Tests
The `insert_record` function detects the bucket from `values_map` parameter and calls `insert_map` function on the bucket storage.
Simple unit and integration tests are placed in [`test`](./test) directory.
The `storage` role has the `insert_map(space, values_map)` function, which inserts map of values `values_map` into `space`.
First, we need to install test dependencies:
## General observations
```bash
./deps.sh
```
As the `sbroad` library caches the cluster cartridge schema internally, any `sbroad` function that is called checks the internal cluster schema, and if that is empty it loads the schema from the main app. If the app schema was updated then the internal cache needs to be cleared. To clear the cache we need to add the `invalidate_caching_schema` call to the `apply_config` cartridge function.
Then, run linter:
## Local load testing
```bash
.rocks/bin/luacheck .
```
Now we can run tests:
```bash
cartridge stop # to prevent "address already in use" error
.rocks/bin/luatest -v
```
## Admin
Application has admin function [`probe`](./app/admin.lua) configured.
You can use it to probe instances:
```bash
cartridge start -d# if you've stopped instances
cartridge admin probe \
--name test_app \
--run-dir ./tmp/run \
--uri localhost:3302
```
More information in [stress-test](../stress-test) folder.