Skip to content

Commit

Permalink
Add handler error for aio test
Browse files Browse the repository at this point in the history
  • Loading branch information
fcaffieri committed Dec 27, 2024
1 parent 9e40495 commit 6a1acdf
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/Test_installation_assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ jobs:
echo "$ansible_host ansible_port=$ansible_port ansible_user=$ansible_user ansible_ssh_private_key_file=$ansible_ssh_private_key_file ansible_ssh_common_args='$ansible_ssh_common_args'" >> $ALLOCATOR_PATH/inventory
- name: Execute provision playbook
id: provision_instance
if: success() && steps.allocator_instance.outcome == 'success'
run: |
set +e
INSTALL_DEPS=true
INSTALL_PYTHON=true
INSTALL_PIP_DEPS=true
Expand All @@ -170,9 +173,17 @@ jobs:
-e "install_python=$INSTALL_PYTHON" \
-e "install_pip_deps=$INSTALL_PIP_DEPS" \
"${{ inputs.VERBOSITY }}"
EXIT_CODE=$?
echo "provision_instance=$EXIT_CODE" >> $GITHUB_OUTPUT
if [ $EXIT_CODE != 0 ]; then
exit 1
fi
- name: Execute AIO installation playbook
id: install_aio
if: success() && steps.provision_instance.outcome == 'success'
run: |
set +e
ansible-playbook .github/workflows/ansible-playbooks/aio.yml \
-i $ALLOCATOR_PATH/inventory \
-l all \
Expand All @@ -181,8 +192,15 @@ jobs:
-e "test_name=$TEST_NAME" \
-e "pkg_repository=$PKG_REPOSITORY" \
"${{ inputs.VERBOSITY }}"
EXIT_CODE=$?
echo "install_aio=$EXIT_CODE" >> $GITHUB_OUTPUT
if [ $EXIT_CODE != 0 ]; then
exit 1
fi
- name: Execute Python test playbook
id: execute_test
if: success() && steps.install_dashboard.outcome == 'success'
run: |
TEST_NAME="test_installation_assistant"
ansible-playbook .github/workflows/ansible-playbooks/aio_tests.yml \
Expand All @@ -192,6 +210,11 @@ jobs:
-e "logs_path=$LOGS_PATH" \
-e "test_name=$TEST_NAME" \
"${{ inputs.VERBOSITY }}"
EXIT_CODE=$?
echo "execute_test=$EXIT_CODE" >> $GITHUB_OUTPUT
if [ $EXIT_CODE != 0 ]; then
exit 1
fi
- name: Compress Allocator VM directory
id: compress_allocator_files
Expand All @@ -210,3 +233,28 @@ jobs:
if: always() && steps.allocator_instance.outcome == 'success' && inputs.DESTROY == true
run: python3 wazuh-automation/deployability/modules/allocation/main.py --action delete --track-output $ALLOCATOR_PATH/track.yml

- name: Set final workflow status
if: always()
shell: bash
run: |
PROVISION_INSTANCE="${{ steps.provision_instance.outputs.provision_instance }}"
INSTALL_AIO="${{ steps.install_aio.outputs.install_aio }}"
EXECUTE_TEST="${{ steps.execute_test.outputs.execute_test }}"
if [ "$PROVISION_INSTANCE" != "0" ] ; then
echo "::error :: Failed provisioning instances"
exit 1
fi
if [ "$INSTALL_AIO" != "0" ] ; then
echo "::error :: Failed installing wiht AIO"
exit 1
fi
if [ "$EXECUTE_TEST" != "0" ]; then
echo "::warning ::Test completed successfully but some errors detected"
exit 0
fi
echo "All test completed successfully"
exit 0
4 changes: 2 additions & 2 deletions .github/workflows/Test_installation_assistant_distributed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ jobs:
fi
if [ "$EXECUTE_TEST" != "0" ]; then
echo "::warning ::Installation had issues but tests passed"
echo "::warning ::Test completed successfully but some errors detected"
exit 0
fi
echo "All steps completed successfully"
echo "All test completed successfully"
exit 0
2 changes: 1 addition & 1 deletion tests/install/test_installation_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def test_check_indexer_cluster_status_not_yellow():

@pytest.mark.dashboard
def test_check_dashboard_status():
assert get_dashboard_status() == 201
assert get_dashboard_status() == 200

@pytest.mark.wazuh
def test_check_wazuh_api_status():
Expand Down

0 comments on commit 6a1acdf

Please sign in to comment.