-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added cli validators test in pytest and CI for localnet dependent tests. #454
Open
cristure
wants to merge
73
commits into
main
Choose a base branch
from
validators_pytest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 66 commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
c32d328
Added cli validators test in pytest and CI for localnet dependent tests.
cristure 84efeb2
Added fixture for proxy polling.
cristure 1685f02
try different endpoint for polling.
cristure f4e9c73
adding debug command.
cristure 315e3b0
more debugging.
cristure 39be1b4
make localnet run in background.
cristure 18d6c71
added Dockerfile and integrated CI with docker.
cristure 3f825a2
add checkout.
cristure 99a198d
install python dependencies in order to trigger the tests.
cristure 3d2be36
rename to localhost. possible issue with the loopback interface.
cristure beef139
debug commands
cristure 95f1a15
more debugging.
cristure 23b9961
add a sleep for debugging.
cristure ef9cdb2
trying to debug docker publishing in GHA.
cristure 5043947
cosmetic changes
cristure 4953eaa
move sleep above.
cristure a5ccb03
more debugging.
cristure 7e889f1
increase timeout to 10 mins.
cristure 0af4d95
check logs of docker localnet inside worker.
cristure 05a7e57
fix CI and dockerfile by installing build-essential in the docker con…
cristure ec17dda
adding verbose command.
cristure 1a4fe12
Fix deploy localnet job.
cristure 900530f
fix whitespaces in multi-line command.
cristure 17a08cf
fixing docker image and localnet setup.
cristure 8359cbb
adding separate validators json file for docker tests.
cristure b43c31a
fixing Dockerfile
cristure bbe93e7
fix paths for validators_docker.json
cristure ad7e421
fix paths in validators_docker.json
cristure bfe909f
fix validators_docker.json
cristure 83b76aa
fix yaml file.
cristure 8804754
fix yaml file, round 2.
cristure d3d0d5c
add debug commands.
cristure 9f9b8c0
debug home directory inside runner.
cristure 79392ad
fix paths.
cristure d3f707d
more debugging.
cristure adaf45a
fix more paths.
cristure 28fa958
add debug sleep.
cristure 0e46464
cosmetic changes.
cristure 7045c32
fix yaml file.
cristure 5f0f807
remove docker
cristure 7a1c8cb
fix mxpy commands in CI.
cristure 6d2888e
cosmetic changes.
cristure 685ca9e
debug strings
cristure 7bdab1a
more debug commands.
cristure 343ba6b
fix CI tests and remove docker naming.
cristure bf164f6
remove polling.
cristure e8137fa
cosmetic changes.
cristure 3fb2a0e
fix unused fixture.
cristure af2c955
remove polling fixture.
cristure c7d799f
more debugging.
cristure 5a274c4
show log in CI.
cristure 42c1260
more debugging in CI.
cristure 1ba5d85
more debugging in CI.
cristure 25760e9
check logs in CI.
cristure fe180f0
rewrite setting up commands.
cristure 61bf291
debug.
cristure 4ce863e
more commands.
cristure 380c08b
make nohup run in background.
cristure 58e29a0
debug localnet config.
cristure 31b6563
more debugging paths.
cristure 92e6386
fix paths for ci validator keys file.
cristure e8c89e1
clean remaining commented code.
cristure 0080690
added conftest and strict markers.
cristure 69404f0
modified skip on windows marker.
cristure c2adbf2
fix skip_on_windows marker
cristure 1b1a414
fix windows build
cristure 4067411
remove duplicated bash tests and added teardown for localnet tests.
cristure 572725d
Revert "remove duplicated bash tests and added teardown for localnet …
cristure eb42289
bring back bash tests as they are used in other tests.
cristure 10ffa3c
added teardown for localnet.
cristure d382db0
clean unused bash tests.
cristure 7ab16ba
remove cli tests for windows.
cristure ca1d4fd
remove deleted shell scripts.
cristure File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Test localnet-dependent tests | ||
|
||
on: | ||
pull_request: | ||
branches: [main, feat/*] | ||
workflow_dispatch: | ||
|
||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
localnet: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
python-version: [3.11] | ||
|
||
steps: | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install -r requirements.txt | ||
pip3 install -r ./requirements-dev.txt --upgrade | ||
|
||
- name: Set up MultiversX localnet | ||
run: | | ||
mkdir -p ~/multiversx-sdk | ||
export PYTHONPATH=. | ||
python3 -m multiversx_sdk_cli.cli localnet prerequisites --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml | ||
python3 -m multiversx_sdk_cli.cli localnet build --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml | ||
|
||
# "Go" and artifacts from "GOPATH/pkg/mod" are not needed anymore. | ||
sudo rm -rf ~/multiversx-sdk/golang | ||
|
||
python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml | ||
python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml | ||
nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid | ||
sleep 120 | ||
|
||
- name: Test localnet dependent tests | ||
run: | | ||
pytest -m require_localnet . | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
Check failure on line 1 in multiversx_sdk_cli/tests/conftest.py GitHub Actions / runner / mypy
|
||
|
||
|
||
# function executed right after test items collected but before test run | ||
def pytest_collection_modifyitems(config, items): | ||
if not config.getoption('-m'): | ||
skip_me = pytest.mark.skip(reason="require_localnet will only run if explicitly set to with -m") | ||
for item in items: | ||
if "require_localnet" in item.keywords: | ||
item.add_marker(skip_me) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
import pytest | ||
|
||
from pathlib import Path | ||
|
||
from multiversx_sdk_cli.cli import main | ||
|
||
testdata_path = Path(__file__).parent / "testdata" | ||
testdata_out = Path(__file__).parent / "testdata-out" | ||
|
||
proxy_url = "http://localhost:7950/network/config" | ||
alice_pem = testdata_path / "alice.pem" | ||
reward_address = "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" | ||
bls_key = "e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_stake(): | ||
validators_json = testdata_path / "validators_ci.json" | ||
|
||
# Stake with recall nonce | ||
return_code = main([ | ||
"validator", "stake", | ||
"--pem", str(alice_pem), | ||
"--value", "2500000000000000000000", | ||
"--validators-file", str(validators_json), | ||
"--reward-address", reward_address, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
# Stake with provided nonce | ||
return_code = main([ | ||
"validator", "stake", | ||
"--pem", str(alice_pem), | ||
"--value", "2500000000000000000000", | ||
"--validators-file", str(validators_json), | ||
"--reward-address", reward_address, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--nonce=0" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_stake_top_up(): | ||
# Stake with topUp | ||
return_code = main([ | ||
"validator", "stake", "--top-up", | ||
"--pem", str(alice_pem), | ||
"--value", "2711000000000000000000", | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_unstake(): | ||
# Unstake | ||
return_code = main([ | ||
"validator", "unstake", | ||
"--pem", str(alice_pem), | ||
"--nodes-public-key", bls_key, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_unbond(): | ||
# Unbond | ||
return_code = main([ | ||
"validator", "unbond", | ||
"--pem", str(alice_pem), | ||
"--nodes-public-key", bls_key, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_unjail(): | ||
# Unjail | ||
return_code = main([ | ||
"validator", "unjail", | ||
"--pem", str(alice_pem), | ||
"--value", "2500000000000000000000", | ||
"--nodes-public-key", bls_key, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_change_reward_address(): | ||
# Change reward address | ||
return_code = main([ | ||
"validator", "change-reward-address", | ||
"--pem", str(alice_pem), | ||
"--reward-address", reward_address, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_unstake_nodes(): | ||
# Unstake Nodes | ||
return_code = main([ | ||
"validator", "unstake-nodes", | ||
"--pem", str(alice_pem), | ||
"--nodes-public-key", bls_key, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_unstake_tokens(): | ||
# Unstake Tokens | ||
return_code = main([ | ||
"validator", "unstake-tokens", | ||
"--pem", str(alice_pem), | ||
"--unstake-value", "11000000000000000000", | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_unbond_nodes(): | ||
# Unbond nodes | ||
return_code = main([ | ||
"validator", "unbond-nodes", | ||
"--pem", str(alice_pem), | ||
"--nodes-public-keys", bls_key, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_unbond_tokens(): | ||
# Unbond nodes | ||
return_code = main([ | ||
"validator", "unbond-tokens", | ||
"--pem", str(alice_pem), | ||
"--unbond-value", "20000000000000000000", | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_clean_registration_data(): | ||
# Clean registration data | ||
return_code = main([ | ||
"validator", "clean-registered-data", | ||
"--pem", str(alice_pem), | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 | ||
|
||
|
||
@pytest.mark.require_localnet | ||
def test_re_stake_unstaked_nodes(): | ||
# Clean registration data | ||
return_code = main([ | ||
"validator", "restake-unstaked-nodes", | ||
"--pem", str(alice_pem), | ||
"--nodes-public-keys", bls_key, | ||
"--chain", "localnet", | ||
"--proxy", "http://127.0.0.1:7950", | ||
"--estimate-gas", "--recall-nonce" | ||
]) | ||
assert return_code == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"validators": [ | ||
{ | ||
"pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator00/config/validatorKey.pem" | ||
}, | ||
{ | ||
"pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator01/config/validatorKey.pem" | ||
}, | ||
{ | ||
"pemFile": "~/work/mx-sdk-py-cli/mx-sdk-py-cli/localnet/validator02/config/validatorKey.pem" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
[pytest] | ||
markers = | ||
skip_on_windows: marks tests as being skiped when running on windows (deselect with '-m "skip_on_windows"') | ||
skip_on_windows: marks tests as being skipped when running on windows (deselect with '-m "skip_on_windows"') | ||
only: only run a specific test (run using: pytest -m "only") | ||
require_localnet: marks tests that require a localnet (select with '-m "require_localnet"') | ||
|
||
log_cli = True |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should stop the localnet as well?
https://github.com/multiversx/mx-sdk-js-core/blob/main/.github/workflows/test-localnet.yml#L61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the runner dies immediately after the test if finished from what I know. I don't think there is a need to teardown