Skip to content

Commit

Permalink
test: Use single instance of integration_config.yaml when running tes…
Browse files Browse the repository at this point in the history
…tall command (linode#528)

* gha test run 1

* stabilize test build by using one single instance of config yaml file when running testall script

* replace submodule and add some safety to test_all.sh script

* address pr comment, checkout repo recursively for submodule

* disable too many retries

* gha test 1

* gha test 2 with limited retries
  • Loading branch information
ykim-akamai authored Jun 25, 2024
1 parent 2b5225b commit 9f86e3e
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 254 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/integration-tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
with:
ref: ${{ inputs.sha }}
path: .ansible/collections/ansible_collections/linode/cloud
fetch-depth: 0
submodules: 'recursive'

# Install deps
- name: update packages
Expand Down Expand Up @@ -77,7 +79,7 @@ jobs:
- name: Apply Calico Rules to LKE
if: always()
run: |
cd scripts && ./lke_calico_rules_e2e.sh
cd e2e_scripts/cloud_security_scripts/lke_calico_rules/ && ./lke_calico_rules_e2e.sh
env:
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Apply Calico Rules to LKE
if: always()
run: |
cd scripts && ./lke_calico_rules_e2e.sh
cd e2e_scripts/cloud_security_scripts/lke_calico_rules/ && ./lke_calico_rules_e2e.sh
env:
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}

Expand Down Expand Up @@ -109,12 +109,12 @@ jobs:
- name: Merge all test xmls in output directory
run: |
ls -R tests/output/junit
python tod_scripts/merge_ansible_results.py
python e2e_scripts/tod_scripts/xml_to_obj_storage/ansible_tests/merge_ansible_results.py
- name: Add additional information to XML report
run: |
filename=$(ls | grep -E '^[0-9]{12}_ansible_merged\.xml$')
python tod_scripts/add_to_xml_test_report.py \
python e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
--branch_name "${GITHUB_REF#refs/*/}" \
--gha_run_id "$GITHUB_RUN_ID" \
--gha_run_number "$GITHUB_RUN_NUMBER" \
Expand All @@ -123,7 +123,7 @@ jobs:
- name: Upload test results to the bucket
run: |
filename=$(ls | grep -E '^[0-9]{12}_ansible_merged\.xml$')
python3 tod_scripts/test_report_upload_script.py "${filename}"
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "tod_scripts"]
path = tod_scripts
url = https://github.com/linode/TOD-test-report-uploader.git
[submodule "e2e_scripts"]
path = e2e_scripts
url = https://github.com/linode/dx-e2e-test-scripts
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ integration-test: create-integration-config create-e2e-firewall

create-e2e-firewall:
@echo "Running create e2e firewall playbook..."
@if ansible-playbook scripts/create_e2e_cloud_firewall.yaml > /dev/null; then \
@if ansible-playbook e2e_scripts/cloud_security_scripts/cloud_e2e_firewall/ansible_linode/create_e2e_cloud_firewall.yaml > /dev/null; then \
echo "Successfully created e2e firewall"; \
else \
echo "Failed to create e2e firewall"; \
fi

delete-e2e-firewall:
@echo "Running delete e2e firewall playbook..."
@if ansible-playbook scripts/delete_e2e_cloud_firewall.yaml > /dev/null; then \
@if ansible-playbook e2e_scripts/cloud_security_scripts/cloud_e2e_firewall/ansible_linode/delete_e2e_cloud_firewall.yaml > /dev/null; then \
echo "Successfully deleted e2e firewall"; \
else \
echo "Failed to delete e2e firewall"; \
fi

test: integration-test delete-e2e-firewall

testall: create-integration-config
testall:
./scripts/test_all.sh

unittest:
Expand Down
1 change: 1 addition & 0 deletions e2e_scripts
Submodule e2e_scripts added at 2cb11f
66 changes: 0 additions & 66 deletions scripts/create_e2e_cloud_firewall.yaml

This file was deleted.

36 changes: 0 additions & 36 deletions scripts/delete_e2e_cloud_firewall.yaml

This file was deleted.

78 changes: 0 additions & 78 deletions scripts/lke-policy.yaml

This file was deleted.

60 changes: 0 additions & 60 deletions scripts/lke_calico_rules_e2e.sh

This file was deleted.

22 changes: 20 additions & 2 deletions scripts/test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@
PARALLEL_JOBS="${PARALLEL_JOBS:=3}"

run_test() {
make TEST_ARGS="$1" test
ansible-test integration $1
}

cleanup() {
if [[ -z "$CLEANUP_DONE" ]]; then
make delete-e2e-firewall
CLEANUP_DONE=1
fi
}

trap cleanup EXIT

CLEANUP_DONE=0

make create-integration-config || exit 1
make create-e2e-firewall || exit 1

export -f run_test

parallel -j $PARALLEL_JOBS --group --keep-order run_test ::: $(ls tests/integration/targets)
parallel -j $PARALLEL_JOBS --group --keep-order --retries 3 run_test ::: $(ls tests/integration/targets)
TEST_EXIT_CODE=$?


exit $TEST_EXIT_CODE
1 change: 0 additions & 1 deletion tod_scripts
Submodule tod_scripts deleted from e8c8e1

0 comments on commit 9f86e3e

Please sign in to comment.