README.md 2.52 KB
Newer Older
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
1
**Abstract**: This repository contains tests for API. All API tests are currently 
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
2 3 4 5
  grouped for these served by hived  and these served by hivemind. The goal is to 
  have flat list of the tests and start their subsets separatly by hived and 
  hivemind CI processes.

Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
6
# Usage:
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Installing pyrest test framework
### By `pip3`
`pip3 install pyresttest`

### From sources
```
git clone https://github.com/svanoort/pyresttest.git
cd pyresttest
python3 setupt.py build
python3 setup.py install --user
```

### Remarks
If you are not installing by `pip3` make sure that you have installed `pyyaml`, `future`, `pycurl`
in your system. Also you will need developer libs for `libcurl4-openssl`, `libssl` (for Ubuntu `libcurl4-openssl-dev` and `libssl-dev`)
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
22 23 24

## Usage with `hived`:
### Python API tests:
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
25
Runnable with `ctest` (TODO)
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
26 27

### PyRest API tests:
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
28
Node address is defined inside bash script.
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
29

Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
30 31 32 33 34 35
a) API tests with `equal` comparator (using strict equal on query result and pattern):
`./run_api_tests.sh equal`

b) API tests with `contain` comparator (check if result contain pattern):
`./run_api_tests.sh contain`

Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
36 37
## Usage with `hivemind`:
### Python API tests:
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
38 39
Runnable with `ctest` (TODO)

Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
40 41 42 43
## PyRest API tests:
In tests directory we have two bash scripts:
* `run_api_tests.sh` - for running api tests,
* `run_api_benchmarks.sh` - for running benchmarks
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
44

Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
45 46 47 48 49 50 51 52 53
Examples of running tests:

a) API tests in directory `full_sync` with `equal` comparator (using strict equal on query result and pattern):
`./run_api_tests.sh https://api.hive.blog full_sync equal`

b) API tests in directory `full_sync` with `contain` comparator (check if result contain pattern):
`./run_api_tests.sh https://api.hive.blog full_sync contain`

Examples of running benchmarks:
Dariusz Kędzierski's avatar
Dariusz Kędzierski committed
54 55 56

`./run_api_benchmarks.sh https://api.hive.blog`

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
## Tavern API tests:
To run tavern test:
1. Enter `tavern` directory
2. Edit `common.yaml` and set variables to desired values
3. Install tavern/pytest `python3 -m pip install tavern[pytest]`
4. Run all tests:
```
export HIVEMIND_ADDRESS=127.0.0.1
export HIVEMIND_PORT=8080
PYTHONPATH=$PYTHONPATH:$(pwd) pytest -v -n auto --durations=0 .
```
5. Run tests from given directory
```
PYTHONPATH=$PYTHONPATH:$(pwd) pytest -v -n auto --durations=0 <directory_name>
```

Remarks:
- To increase verbosity use `-vv` option instead of `-v`.
- `durations` option gives time measurement for tests, set to `0` will show durations of all tests. `Number` greater than zero will show only `number` slowest tests.
- `-n` option allows to run tests on multiple cores, `auto` will use all available cores