-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_ansible_tests.sh
More file actions
46 lines (37 loc) · 1.01 KB
/
run_ansible_tests.sh
File metadata and controls
46 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -e
# Install Ansible and test dependencies
pip install -r requirements.txt
pip install -r tests/requirements-test.txt
# Wait for services to be ready
max_retries=10
retry_interval=5
# Wait for MQTT
for i in $(seq 1 $max_retries); do
if nc -z mqtt 1883; then
echo "MQTT broker is ready"
break
fi
echo "Waiting for MQTT broker... (attempt $i/$max_retries)"
sleep $retry_interval
done
# Wait for HTTP mock
for i in $(seq 1 $max_retries); do
if curl -s http://http-mock:1080/status >/dev/null; then
echo "HTTP mock server is ready"
break
fi
echo "Waiting for HTTP mock server... (attempt $i/$max_retries)"
sleep $retry_interval
done
# Set up test environment
export ANSIBLE_FORCE_COLOR=1
export PYTHONUNBUFFERED=1
# Run Ansible tests
cd /app/ansible
# Run molecule tests
molecule test -s default
# Run integration tests
ansible-playbook playbooks/integration_test.yml --syntax-check
ansible-playbook playbooks/integration_test.yml --diff
echo "All tests completed successfully"