mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 14:35:45 +00:00
Simplified unit tests (#294)
* adjusted make test * 1st improvments to ease testing * simplified gh actions * adjusted gh action file * removed deps * added sudo to apt calls * removed predefined pytest module definitions * added installing planetmint into the unit test container * give time to the db container * added environment variables to unit-test.yml * removed acceptances tests from test executions Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
eee5ae3d91
commit
1909330971
59
.github/workflows/unit-test-abci.yml
vendored
59
.github/workflows/unit-test-abci.yml
vendored
@ -1,59 +0,0 @@
|
|||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
|
||||||
# Planetmint and IPDB software contributors.
|
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
||||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
||||||
|
|
||||||
name: Unit tests - with direct ABCI
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Build container
|
|
||||||
run: |
|
|
||||||
docker-compose -f docker-compose.yml build --no-cache --build-arg abci_status=enable planetmint
|
|
||||||
|
|
||||||
- name: Save image
|
|
||||||
run: docker save -o planetmint.tar planetmint_planetmint
|
|
||||||
|
|
||||||
- name: Upload image
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: planetmint-abci
|
|
||||||
path: planetmint.tar
|
|
||||||
retention-days: 5
|
|
||||||
|
|
||||||
|
|
||||||
test-with-abci:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- db: "Tarantool with ABCI"
|
|
||||||
host: "tarantool"
|
|
||||||
port: 3303
|
|
||||||
abci: "enabled"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Download planetmint
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: planetmint-abci
|
|
||||||
|
|
||||||
- name: Load planetmint
|
|
||||||
run: docker load -i planetmint.tar
|
|
||||||
|
|
||||||
- name: Start containers
|
|
||||||
run: docker-compose -f docker-compose.yml up -d planetmint
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: docker exec planetmint_planetmint_1 pytest -v -m abci
|
|
||||||
60
.github/workflows/unit-test-no-abci.yml
vendored
60
.github/workflows/unit-test-no-abci.yml
vendored
@ -1,60 +0,0 @@
|
|||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
|
||||||
# Planetmint and IPDB software contributors.
|
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
||||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
||||||
|
|
||||||
name: Unit tests - with Planemint
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Build container
|
|
||||||
run: |
|
|
||||||
docker-compose -f docker-compose.yml build --no-cache planetmint
|
|
||||||
|
|
||||||
- name: Save image
|
|
||||||
run: docker save -o planetmint.tar planetmint_planetmint
|
|
||||||
|
|
||||||
- name: Upload image
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: planetmint
|
|
||||||
path: planetmint.tar
|
|
||||||
retention-days: 5
|
|
||||||
|
|
||||||
|
|
||||||
test-without-abci:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- db: "Tarantool without ABCI"
|
|
||||||
host: "tarantool"
|
|
||||||
port: 3303
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Download planetmint
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: planetmint
|
|
||||||
|
|
||||||
- name: Load planetmint
|
|
||||||
run: docker load -i planetmint.tar
|
|
||||||
|
|
||||||
- name: Start containers
|
|
||||||
run: docker-compose -f docker-compose.yml up -d bdb
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: docker exec planetmint_planetmint_1 pytest -v --cov=planetmint --cov-report xml:htmlcov/coverage.xml
|
|
||||||
|
|
||||||
- name: Upload Coverage to Codecov
|
|
||||||
uses: codecov/codecov-action@v3
|
|
||||||
42
.github/workflows/unit-tests.yml
vendored
Normal file
42
.github/workflows/unit-tests.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
|
# Planetmint and IPDB software contributors.
|
||||||
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
|
name: Unit tests
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
unified-unit-tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
PLANETMINT_DATABASE_BACKEND: tarantool_db
|
||||||
|
PLANETMINT_DATABASE_HOST: localhost
|
||||||
|
PLANETMINT_DATABASE_PORT: 3303
|
||||||
|
PLANETMINT_SERVER_BIND: 0.0.0.0:9984
|
||||||
|
PLANETMINT_WSSERVER_HOST: 0.0.0.0
|
||||||
|
PLANETMINT_WSSERVER_ADVERTISED_HOST: localhost
|
||||||
|
PLANETMINT_TENDERMINT_HOST: localhost
|
||||||
|
PLANETMINT_TENDERMINT_PORT: 26657
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: 3.9
|
||||||
|
|
||||||
|
- name: Prepare OS
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y git zsh curl tarantool-common vim build-essential cmake
|
||||||
|
|
||||||
|
- name: Get Tendermint
|
||||||
|
run: wget https://github.com/tendermint/tendermint/releases/download/v0.34.15/tendermint_0.34.15_linux_amd64.tar.gz && tar zxf tendermint_0.34.15_linux_amd64.tar.gz
|
||||||
|
|
||||||
|
- name: Install Planetmint
|
||||||
|
run: pip install -e '.[dev]'
|
||||||
|
|
||||||
|
|
||||||
|
- name: Execute Tests
|
||||||
|
run: make test
|
||||||
13
Makefile
13
Makefile
@ -77,11 +77,18 @@ lint: check-py-deps ## Lint the project
|
|||||||
format: check-py-deps ## Format the project
|
format: check-py-deps ## Format the project
|
||||||
black -l 119 .
|
black -l 119 .
|
||||||
|
|
||||||
test: check-deps test-unit test-acceptance ## Run unit and acceptance tests
|
test: check-deps test-unit #test-acceptance ## Run unit and acceptance tests
|
||||||
|
|
||||||
test-unit: check-deps ## Run all tests once or specify a file/test with TEST=tests/file.py::Class::test
|
test-unit: check-deps ## Run all tests once or specify a file/test with TEST=tests/file.py::Class::test
|
||||||
@$(DC) up -d bdb
|
@$(DC) up -d tarantool
|
||||||
@$(DC) exec planetmint pytest ${TEST}
|
#wget https://github.com/tendermint/tendermint/releases/download/v0.34.15/tendermint_0.34.15_linux_amd64.tar.gz
|
||||||
|
#tar zxf tendermint_0.34.15_linux_amd64.tar.gz
|
||||||
|
pytest -m "not abci"
|
||||||
|
rm -rf ~/.tendermint && ./tendermint init && ./tendermint node --consensus.create_empty_blocks=false --rpc.laddr=tcp://0.0.0.0:26657 --proxy_app=tcp://localhost:26658&
|
||||||
|
pytest -m abci
|
||||||
|
@$(DC) down
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test-unit-watch: check-deps ## Run all tests and wait. Every time you change code, tests will be run again
|
test-unit-watch: check-deps ## Run all tests and wait. Every time you change code, tests will be run again
|
||||||
@$(DC) run --rm --no-deps planetmint pytest -f
|
@$(DC) run --rm --no-deps planetmint pytest -f
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
testpaths = tests/
|
testpaths = tests/
|
||||||
norecursedirs = .* *.egg *.egg-info env* devenv* docs
|
norecursedirs = .* *.egg *.egg-info env* devenv* docs
|
||||||
addopts = -m "not abci"
|
#addopts = -m "not abci"
|
||||||
looponfailroots = planetmint tests
|
looponfailroots = planetmint tests
|
||||||
asyncio_mode = strict
|
asyncio_mode = strict
|
||||||
markers =
|
markers =
|
||||||
|
|||||||
@ -19,7 +19,7 @@ def config(request, monkeypatch):
|
|||||||
config = {
|
config = {
|
||||||
"database": {
|
"database": {
|
||||||
"backend": backend,
|
"backend": backend,
|
||||||
"host": "tarantool",
|
"host": "localhost",
|
||||||
"port": 3303,
|
"port": 3303,
|
||||||
"name": "bigchain",
|
"name": "bigchain",
|
||||||
"replicaset": "bigchain-rs",
|
"replicaset": "bigchain-rs",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user