Debian Codegraph @

ansible_collections/containers/podman/tests/integration/targets/connection_podman_advanced/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -o pipefail
4 set -eux
5
6 # Enhanced Podman Connection Plugin Tests
7 # Tests for new features and configuration options
8
9 function run_ansible {
10 ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_advanced_features.yml -i "test_connection.inventory" \
11 -e target_hosts="podman_advanced" \
12 "$@"
13 }
14
15 function run_configuration_test {
16 local config_name="$1"
17 local extra_vars="$2"
18 echo "Testing configuration: $config_name"
19
20 ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_advanced_features.yml -i "test_connection.inventory" \
21 -e target_hosts="podman_advanced" \
22 -e "$extra_vars" \
23 "$@"
24 }
25
26 echo "=== Running Enhanced Podman Connection Tests ==="
27
28 # Create a container
29 ${SUDO} podman run -d --name "podman-container" python:3.10-alpine sleep 1d
30
31 # Test 1: Basic functionality with new features
32 echo "Test 1: Basic advanced features"
33 run_ansible "$@"
34
35 # Test 2: Mount detection disabled
36 echo "Test 2: Mount detection disabled"
37 run_configuration_test "mount_disabled" "ansible_podman_mount_detection=false" "$@"
38
39 # Test 3: Different timeout settings
40 echo "Test 3: Short timeout"
41 run_configuration_test "short_timeout" "ansible_podman_timeout=5" "$@"
42
43 # Test 4: Different retry settings
44 echo "Test 4: More retries"
45 run_configuration_test "more_retries" "ansible_podman_retries=5" "$@"
46
47 # Test 5: Different user context
48 echo "Test 5: Root user context"
49 run_configuration_test "root_user" "ansible_user=root" "$@"
50
51 # Test 6: Custom environment variables
52 echo "Test 6: Custom environment variables"
53 run_configuration_test "custom_env" "ansible_podman_extra_env={'CUSTOM_TEST': 'value', 'DEBUG': 'true'}" "$@"
54
55 # Test 7: Verify plugin identification
56 echo "Test 7: Plugin identification verification"
57 ANSIBLE_VERBOSITY=4 run_ansible "$@" | tee check_log
58 ${SUDO:-} grep -q "Using podman connection from collection" check_log
59 ${SUDO:-} rm -f check_log
60
61 # Test 8: Error handling with invalid executable
62 echo "Test 8: Error handling test"
63 set +o pipefail
64 ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" 2>&1 | grep "Could not find fakepodman in PATH"
65 test_result=$?
66 set -o pipefail
67
68 if [ $test_result -eq 0 ]; then
69 echo "Error handling test passed"
70 else
71 echo "Error handling test failed - error message not found"
72 exit 1
73 fi
74
75 # Test 9: Performance test with multiple operations
76 echo "Test 9: Performance test"
77 time run_ansible "$@" > /tmp/performance_test.log 2>&1
78 echo "Performance test completed - check /tmp/performance_test.log for timing"
79
80 echo "Test 10: Missing container exec"
81 ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_exec.yml -i "test_connection.inventory"
82
83 echo "Test 11: Removed between exec"
84 ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_removed_between_exec.yml -i "test_connection.inventory"
85
86 echo "Test 12: Missing container put"
87 ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_put.yml -i "test_connection.inventory"
88
89 echo "Test 13: Missing container fetch"
90 ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} test_missing_container_fetch.yml -i "test_connection.inventory"
91
92 echo "=== All Enhanced Podman Connection Tests Completed Successfully ==="