|
|
|
# Preparing testing environment
|
|
|
|
|
|
|
|
1. Create directory in which you will store your testing environment, for simplicity I'll use `/tmp`
|
|
|
|
2. In this solution we will be using `hived` docker image as a source of block data for hivemind
|
|
|
|
3. If you don't like docker "because of reasons" you can use [this](https://gitlab.syncad.com/hive/hivemind/-/wikis/Testing-hivemind#preparing-hived-node) howto instead
|
|
|
|
|
|
|
|
## Preparing `hived` node
|
|
|
|
1. Clone latest sources of the `hivemind`
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ cd /tmp #note this should be your testing environment directory
|
|
|
|
$ git clone git@gitlab.syncad.com:hive/hivemind.git
|
|
|
|
$ cd hivemind
|
|
|
|
$ git checkout develop
|
|
|
|
$ git submodule update --init --recursive
|
|
|
|
```
|
|
|
|
|
|
|
|
## Preparing `postgresql` database
|
|
|
|
|
|
|
|
1. Install `postgresql` package
|
|
|
|
1. Configure and run `postgresql`
|
|
|
|
1. Create `user` and `database` to hold `hivemind` data (i.e. user `hive` database `hive`)
|
|
|
|
|
|
|
|
## Preparing `hivemind`
|
|
|
|
|
|
|
|
1. Build and install your `hivemind`
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ python3 setup.py build
|
|
|
|
$ python3 setup.py install --user
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Sync your `hivemind` service with running `hived` node
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ time hive sync --steemd-url '{"default":"http://127.0.0.1:8090"}' --database-url postgresql://hive@localhost:5432/hive --test-max-block 5000017 --exit-after-sync --mock-block-data-path mock_data/block_data/follow_op/mock_block_data_follow.json 2>&1 | tee -i hivemind-sync.log
|
|
|
|
```
|
|
|
|
|
|
|
|
3. After sync is done run `hivemind` server
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ hive server --steemd-url '{"default":"http://127.0.0.1:8090"}' --database-url postgresql://hive@localhost:5432/hive
|
|
|
|
```
|
|
|
|
|
|
|
|
4. Leave `hivemind` server working
|
|
|
|
|
|
|
|
# Running tavern tests
|
|
|
|
|
|
|
|
Tavern tests are located in `<hivemind-src>/tests/tests_api/hivemind/tavern` directory. It is a set of `yaml` files with accompanying `pat.json` files. Test is defined in `yaml` file, its expected result is defined in `pat.json` file. Call with parameters defined in `yaml` file is made to `hivemind` instance, and the result is compared with `pat.json`. Test fails when differences between pattern and response is detected. In that case an `out.json` file is created for manual inspection by the user.
|
|
|
|
|
|
|
|
To run `tavern` tests enter `hivemind` source directory and run tests using `run_tests.sh` script
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ cd /tmp/hivemind
|
|
|
|
$ scripts/run_tests.sh 127.0.0.1 8080
|
|
|
|
```
|
|
|
|
|
|
|
|
Where `127.0.0.1` is hivemind instance IP, and `8080` is hivemind instance port.
|
|
|
|
|
|
|
|
# Running benchmarks
|
|
|
|
|
|
|
|
Benchmarks are based on requests defined in tavern test `yaml` files. Each request is called `n` times, execution times are gathered and then basend on that data the mean/min/max values are calculated. The benchmak test produce `tavern_benchmarks_report.html` with summary. In this summary calls with execution time greater than 1s are marked in red.
|
|
|
|
|
|
|
|
To run benchmarks enter `hivemind` source directory and run benchmarks using `ci_start_api_benchmarks.sh` script
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ cd /tmp/hivemind
|
|
|
|
$ scripts/ci_start_api_benchmarks.sh 127.0.0.1 8080 3
|
|
|
|
```
|
|
|
|
|
|
|
|
Where `127.0.0.1` is hivemind instance IP, and `8080` is hivemind instance port. `3` is the number of iterations for benchmarks. |
|
|
|
\ No newline at end of file |