Skip to content

Commit

Permalink
add: run e2e tests workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rsporny committed Sep 18, 2024
1 parent 28e6578 commit ea8c5a3
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 5 deletions.
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"
13 changes: 8 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 @@ -14,7 +14,7 @@ jobs:
local-environment-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout master
- name: Checkout master
uses: actions/checkout@v4
with:
path: ./partner-chains-master
Expand Down Expand Up @@ -57,11 +57,14 @@ 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: Run e2e tests
runs-on: ubuntu-latest
steps:
- uses: ./partner-chains-master/.github/workflows/modules/run-e2e-tests.yml
secrets: inherit

- name: Stop partner-chains-demo
run: docker compose down --volumes
117 changes: 117 additions & 0 deletions .github/workflows/modules/run-e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Run e2e tests against local environment

on:
workflow_call:
inputs:
image:
description: "Node Image"
required: true
tag:
description: "PC Artifact Tag"
required: true

jobs:
run-e2e-tests:
runs-on: ubuntu-latest
env:
TEST_ENVIRONMENT: demo
steps:
- 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 }}

0 comments on commit ea8c5a3

Please sign in to comment.