Skip to content

Commit

Permalink
improve e2e firewall creation/deletion error handling and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ykim-akamai committed Jul 25, 2024
1 parent 022ff7b commit 847d490
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,42 @@ gendocs:
# ansible-test integration $(TEST_ARGS) --tags never
integration-test: create-integration-config create-e2e-firewall
@echo "Running Integration Test(s)..."
ansible-test integration $(TEST_ARGS)
OUTPUT=$$(ansible-test integration $(TEST_ARGS) 2>&1); \
TEST_EXIT_CODE=$$?; \
echo "$$OUTPUT" \
@echo "Running Cleanup for E2E firewall..." \
make delete-e2e-firewall; \
if [ $$TEST_EXIT_CODE -ne 0 ]; then \
echo "Integration tests failed, check RECAP above for more details..."; \
fi; \
exit $$TEST_EXIT_CODE

create-e2e-firewall:
@echo "Running create e2e firewall playbook..."
@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. Please update the cloud firewall scripts using `git submodule update --init` if yaml file doesn't exist"; \
@OUTPUT=$$(ansible-playbook e2e_scripts/cloud_security_scripts/cloud_e2e_firewall/ansible_linode/create_e2e_cloud_firewall.yaml 2>&1); \
FAILED_COUNT=$$(echo "$$OUTPUT" | grep "failed=" | awk -F 'failed=' '{print $$2}' | awk '{print $$1}'); \
if [ "$$FAILED_COUNT" -gt 0 ]; then \
echo "Playbook execution failed:"; \
echo "$$OUTPUT"; \
exit 1; \
else \
echo "E2E Cloud firewall created successfully."; \
fi


delete-e2e-firewall:
@echo "Running delete e2e firewall playbook..."
@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"; \
@OUTPUT=$$(ansible-playbook e2e_scripts/cloud_security_scripts/cloud_e2e_firewall/ansible_linode/delete_e2e_cloud_firewall.yaml 2>&1); \
FAILED_COUNT=$$(echo "$$OUTPUT" | grep "failed=" | awk -F 'failed=' '{print $$2}' | awk '{print $$1}'); \
if [ "$$FAILED_COUNT" -gt 0 ]; then \
echo "Playbook execution failed:"; \
echo "$$OUTPUT"; \
exit 1; \
else \
echo "Failed to delete e2e firewall"; \
fi
echo "E2E Cloud firewall deleted successfully."; \
fi

test: integration-test delete-e2e-firewall
test: integration-test

testall:
./scripts/test_all.sh
Expand Down

0 comments on commit 847d490

Please sign in to comment.