Skip to content

Commit

Permalink
Problem: integration tests CI spend a lot of time (backport #1271) (#…
Browse files Browse the repository at this point in the history
…1277)

* Problem: integration tests CI spend a lot of time (#1271)

* Problem: integration tests CI spend a lot of time

Solution:
- run in parallel using markers and job matrix

* fix matrix

* flock is not nesserary

* fix marker

* break up ibc test cases

* separate gov test cases

* split out some slow test cases

* split more ibc test

* Update .github/workflows/test.yml

Signed-off-by: yihuang <[email protected]>

* fix pytest lint

* more balance

---------

Signed-off-by: yihuang <[email protected]>

* Update integration_tests/conftest.py

Co-authored-by: yihuang <[email protected]>
Signed-off-by: mmsqe <[email protected]>

---------

Signed-off-by: yihuang <[email protected]>
Signed-off-by: mmsqe <[email protected]>
Co-authored-by: yihuang <[email protected]>
  • Loading branch information
mmsqe and yihuang authored Dec 22, 2023
1 parent 28b116b commit 4f16397
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
integration_tests:
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
matrix:
tests: [unmarked, ibc, ibc_timeout, ibc_update_client, upgrade, slow]
env:
TESTS_TO_RUN: ${{ matrix.tests }}
steps:
- uses: actions/checkout@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ test-sim-profile:
### Integration Test ###
###############################################################################

# possible values:
# - all: run all integration tests
# - unmarked: run integration tests that are not marked
# - marker1,marker2: markers separated by comma, run integration tests that are marked with any of the markers
TESTS_TO_RUN ?= all

run-integration-tests:
@nix-shell ./integration_tests/shell.nix --run ./scripts/run-integration-tests

Expand Down
11 changes: 11 additions & 0 deletions integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@


def pytest_configure(config):
config.addinivalue_line("markers", "unmarked: fallback mark for unmarked tests")
config.addinivalue_line("markers", "slow: marks tests as slow")
config.addinivalue_line("markers", "gravity: gravity bridge test cases")
config.addinivalue_line("markers", "upgrade: marks upgrade tests")
config.addinivalue_line("markers", "ibc: marks default ibc tests")
config.addinivalue_line("markers", "ibc_timeout: marks ibc timeout tests")
config.addinivalue_line("markers", "ibc_update_client: marks ibc updateclient test")


def pytest_collection_modifyitems(items, config):
for item in items:
if not any(item.iter_markers()):
item.add_marker("unmarked")


@pytest.fixture(scope="session")
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_exported_genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from .network import setup_custom_cronos
from .utils import ADDRS, CONTRACTS

pytestmark = pytest.mark.slow


@pytest.fixture(scope="module")
def custom_cronos(tmp_path_factory):
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_ibc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
wait_for_new_blocks,
)

pytestmark = pytest.mark.ibc


@pytest.fixture(scope="module", params=[True, False])
def ibc(request, tmp_path_factory):
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_ibc_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
)
from .utils import ADDRS, eth_to_bech32, wait_for_fn

pytestmark = pytest.mark.ibc_timeout


@pytest.fixture(scope="module")
def ibc(request, tmp_path_factory):
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_ibc_update_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from .ibc_utils import prepare_network

pytestmark = pytest.mark.ibc_update_client


@pytest.fixture(scope="module")
def ibc(request, tmp_path_factory):
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
wait_for_new_blocks,
)

pytestmark = pytest.mark.slow


@pytest.fixture(scope="module")
def cronos_mempool(tmp_path_factory):
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_pruned_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
wait_for_new_blocks,
)

pytestmark = pytest.mark.slow


@pytest.fixture(scope="module")
def cronos(request, tmp_path_factory):
Expand Down
4 changes: 3 additions & 1 deletion integration_tests/test_replay_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from .network import setup_custom_cronos
from .utils import ADDRS, CONTRACTS, KEYS, deploy_contract, sign_transaction

pytestmark = pytest.mark.slow


@pytest.fixture(scope="module")
def custom_cronos(tmp_path_factory):
Expand All @@ -17,7 +19,7 @@ def custom_cronos(tmp_path_factory):
)


def test_replay_block(custom_cronos):
def test_block_overflow(custom_cronos):
w3: web3.Web3 = custom_cronos.w3
contract = deploy_contract(
w3,
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
wait_for_port,
)

pytestmark = pytest.mark.upgrade


def init_cosmovisor(home):
"""
Expand Down
12 changes: 10 additions & 2 deletions scripts/run-integration-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e
cd "$(dirname "$0")"

Expand All @@ -10,4 +10,12 @@ cd ../integration_tests/contracts
HUSKY_SKIP_INSTALL=1 npm install
npm run typechain
cd ..
nix-shell --run "pytest -vv -s"
TESTS_TO_RUN="${TESTS_TO_RUN:-all}"
if [[ "$TESTS_TO_RUN" == "all" ]]; then
echo "run all tests"
cmd="pytest -vv -s"
else
echo "run tests matching $TESTS_TO_RUN"
cmd="pytest -vv -s -m '$TESTS_TO_RUN'"
fi
nix-shell --run "$cmd"

0 comments on commit 4f16397

Please sign in to comment.