Skip to content
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

Run e2e tests on local env #85

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/run-e2e-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Run e2e tests'
description: 'Activate python venv and run e2e tests'

inputs:
env:
description: 'Test environment'
required: true
keyword:
description: 'Run tests by keyword (-k)'
required: false
default: 'test_'
markers:
description: 'Run tests by markers (-m)'
required: false
default: 'not active_flow and not passive_flow and not probability'
mc_epoch:
description: 'MC epoch to test (committee tests)'
required: false
log_level:
description: 'Log CLI level'
required: false
default: 'info'
init_timestamp:
description: 'MC initialization timestamp in seconds'
required: false
default: '0'

runs:
using: composite
steps:
- name: Run tests
shell: bash
run: |
if [ -n "${{ inputs.mc_epoch }}" ]; then
mc_epoch_switch="--mc-epoch ${{ inputs.mc_epoch }}"
fi

cd e2e-tests
source venv/bin/activate
pytest --blockchain substrate \
--env ${{ inputs.env }} \
--stack ${{ inputs.env }} \
--log-cli-level ${{ inputs.log_level }} \
-k "${{ inputs.keyword }}" \
-m "${{ inputs.markers }}" \
--init-timestamp ${{ inputs.init_timestamp }} \
$mc_epoch_switch \
--decrypt \
--json-report \
--json-report-summary \
--junitxml=junit_report.xml
21 changes: 21 additions & 0 deletions .github/wait-for-epoch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Wait for epoch'
description: 'Wait for epoch in local environment'

inputs:
epoch:
description: 'Expected epoch'
required: true

runs:
using: composite
steps:
- name: Wait for epoch
shell: bash
run: |
epoch=$(docker exec cardano-node-1 cardano-cli query tip --testnet-magic 42 | jq -r .epoch)
while [ $epoch -lt ${{ inputs.epoch }} ]; do \
echo "Epoch: $epoch" && \
sleep 10 && \
epoch=$(docker exec cardano-node-1 cardano-cli query tip --testnet-magic 42 | jq -r .epoch); \
done
echo "Epoch: $epoch"
109 changes: 104 additions & 5 deletions .github/workflows/modules/local-environment-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy and test aganst local-environment
name: Deploy and test against local-environment

on:
workflow_call:
Expand All @@ -13,8 +13,10 @@ on:
jobs:
local-environment-tests:
runs-on: ubuntu-latest
env:
TEST_ENVIRONMENT: demo
steps:
- name: Checkout master
- name: Checkout master
uses: actions/checkout@v4
with:
path: ./partner-chains-master
Expand Down Expand Up @@ -57,11 +59,108 @@ jobs:
cp -r ./partner-chains-node-* ./partner-chains-master/dev/local-environment/configurations/partner-chains-cli/overrides/partner-chains-node
cp -r ./partner-chains-smart-contracts*/* ./partner-chains-master/dev/local-environment/configurations/sidechain-release-bundle/overrides/
cd ./partner-chains-master/dev/local-environment
bash setup.sh --non-interactive --overrides --postgres-password=postgres --node-image=${{ inputs.image }}
bash setup.sh --non-interactive --overrides --postgres-password=azMpOp4mTqhlKDmgCVQr --node-image=${{ inputs.image }}
docker compose up -d

- name: Run tests
run: #TODO i.e. python ./tests.py
- name: Checkout e2e tests
uses: actions/checkout@v4
with:
repository: input-output-hk/sidechains-tests
token: ${{ secrets.ACTIONS_PAT }}
ref: ETCM-8119/run-tests-on-ci
path: e2e-tests

- name: Setup python and dependencies
run: |
cd e2e-tests
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.10 python3.10-venv python3.10-dev
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
curl -L --silent https://github.com/getsops/sops/releases/download/v3.7.3/sops_3.7.3_amd64.deb > sops.deb && sudo dpkg -i sops.deb && rm sops.deb
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

- name: Wait for the PC node 1 to start
run: |
while ! docker exec cardano-node-1 [ -e /shared/cardano.ready ]; do sleep 1; done
echo "Cardano network is ready! Waiting for Partner Chain first node to start..."
INIT_TIMESTAMP=$(docker exec cardano-node-1 cat /shared/cardano.start)
echo "INIT_TIMESTAMP=$INIT_TIMESTAMP" >> $GITHUB_ENV
while ! docker exec partner-chains-node-1 [ -e /shared/partner-chains-node-1.ready ]; do \
epoch=$(docker exec cardano-node-1 cardano-cli query tip --testnet-magic 42 | jq -r .epoch) && \
echo "Epoch: $epoch" && \
sleep 10; \
done

- name: Run smoke tests
uses: ./partner-chains-master/.github/run-e2e-tests
with:
env: ${{ env.TEST_ENVIRONMENT }}
keyword: "test_get_status or test_get_params"

- name: Wait for epoch 3
uses: ./partner-chains-masters/.github/wait-for-epoch
with:
epoch: 3

- name: Run registration tests
uses: ./partner-chains-master/.github/run-tests
with:
env: ${{ env.TEST_ENVIRONMENT }}
keyword: "test_register_candidate or test_deregister_candidate or test_add_permissioned_candidate or test_remove_permissioned_candidate"
init_timestamp: ${{ env.INIT_TIMESTAMP }}

- name: Wait for epoch 4
uses: ./partner-chains-master/.github/wait-for-epoch
with:
epoch: 4

- name: Run registration tests
uses: ./partner-chains-master/.github/run-tests
with:
env: ${{ env.TEST_ENVIRONMENT }}
keyword: "test_register_candidate or test_deregister_candidate or test_add_permissioned_candidate or test_remove_permissioned_candidate"
init_timestamp: ${{ env.INIT_TIMESTAMP }}

- name: Wait for epoch 5
uses: ./partner-chains-master/.github/wait-for-epoch
with:
epoch: 5

- name: Run all tests
uses: ./partner-chains-master/.github/run-tests
with:
env: ${{ env.TEST_ENVIRONMENT }}
mc_epoch: 4
init_timestamp: ${{ env.INIT_TIMESTAMP }}

- name: Wait for epoch 6
uses: ./partner-chains-master/.github/wait-for-epoch
with:
epoch: 6

- name: Run all tests
uses: ./partner-chains-master/.github/run-tests
with:
env: ${{ env.TEST_ENVIRONMENT }}
mc_epoch: 5
init_timestamp: ${{ env.INIT_TIMESTAMP }}

- name: Wait for epoch 7
uses: ./partner-chains-master/.github/wait-for-epoch
with:
epoch: 7

- name: Run all tests
uses: ./partner-chains-master/.github/run-tests
with:
env: ${{ env.TEST_ENVIRONMENT }}
mc_epoch: 6
init_timestamp: ${{ env.INIT_TIMESTAMP }}

- name: Stop partner-chains-demo
run: docker compose down --volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"activeSlotsCoeff": 0.2,
"activeSlotsCoeff": 0.8,
"epochLength": 120,
"genDelegs": {
"4090c4d9554ab626a30a393ae3dd1fde40336e0515b1d4f430d6ae92": {
Expand Down
10 changes: 5 additions & 5 deletions dev/local-environment/modules/partner-chains-nodes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
GENESIS_COMMITTEE_UTXO: "781cb948a37c7c38b43872af9b1e22135a94826eafd3740260a6db0a303885d8#0"
GOVERNANCE_AUTHORITY: "e8c300330fe315531ca89d4a2e7d0c80211bc70b473b1ed4979dff2b"
CARDANO_SECURITY_PARAMETER: "5"
CARDANO_ACTIVE_SLOTS_COEFF: "0.2"
CARDANO_ACTIVE_SLOTS_COEFF: "0.4"
MC__FIRST_EPOCH_NUMBER: "0"
MC__FIRST_SLOT_NUMBER: "0"
MC__EPOCH_DURATION_MILLIS: "120000"
Expand Down Expand Up @@ -49,7 +49,7 @@
GENESIS_COMMITTEE_UTXO: "781cb948a37c7c38b43872af9b1e22135a94826eafd3740260a6db0a303885d8#0"
GOVERNANCE_AUTHORITY: "e8c300330fe315531ca89d4a2e7d0c80211bc70b473b1ed4979dff2b"
CARDANO_SECURITY_PARAMETER: "5"
CARDANO_ACTIVE_SLOTS_COEFF: "0.2"
CARDANO_ACTIVE_SLOTS_COEFF: "0.4"
MC__FIRST_EPOCH_NUMBER: "0"
MC__FIRST_SLOT_NUMBER: "0"
MC__EPOCH_DURATION_MILLIS: "120000"
Expand Down Expand Up @@ -84,7 +84,7 @@
CHAIN_ID: "0"
GENESIS_COMMITTEE_UTXO: "781cb948a37c7c38b43872af9b1e22135a94826eafd3740260a6db0a303885d8#0"
CARDANO_SECURITY_PARAMETER: "5"
CARDANO_ACTIVE_SLOTS_COEFF: "0.2"
CARDANO_ACTIVE_SLOTS_COEFF: "0.4"
MC__FIRST_EPOCH_NUMBER: "0"
MC__FIRST_SLOT_NUMBER: "0"
MC__EPOCH_DURATION_MILLIS: "120000"
Expand Down Expand Up @@ -121,7 +121,7 @@
CHAIN_ID: "0"
GENESIS_COMMITTEE_UTXO: "781cb948a37c7c38b43872af9b1e22135a94826eafd3740260a6db0a303885d8#0"
CARDANO_SECURITY_PARAMETER: "5"
CARDANO_ACTIVE_SLOTS_COEFF: "0.2"
CARDANO_ACTIVE_SLOTS_COEFF: "0.4"
MC__FIRST_EPOCH_NUMBER: "0"
MC__FIRST_SLOT_NUMBER: "0"
MC__EPOCH_DURATION_MILLIS: "120000"
Expand Down Expand Up @@ -158,7 +158,7 @@
CHAIN_ID: "0"
GENESIS_COMMITTEE_UTXO: "781cb948a37c7c38b43872af9b1e22135a94826eafd3740260a6db0a303885d8#0"
CARDANO_SECURITY_PARAMETER: "5"
CARDANO_ACTIVE_SLOTS_COEFF: "0.2"
CARDANO_ACTIVE_SLOTS_COEFF: "0.4"
MC__FIRST_EPOCH_NUMBER: "0"
MC__FIRST_SLOT_NUMBER: "0"
MC__EPOCH_DURATION_MILLIS: "120000"
Expand Down