4141
4242       - name : Run integration test 
4343        run : | 
44+           # Start a test container for backup 
45+           echo "Starting a test Docker container..." 
46+           docker run -d --name test-container nginx:alpine 
47+           echo "Test container started." 
48+ 
4449          # Start the callback handler application in the background 
4550          nohup ./myapp > app.log 2>&1 & 
4651
@@ -55,11 +60,12 @@ jobs:
5560          done 
5661
5762          # Prepare and send a simulated external callback (POST request) 
58-           SIGNATURE=$(echo -n '{"args":[]}' | openssl dgst -sha256 -hmac "my-test-secret" | sed 's/^.* //') 
63+           # Include the test container name in the args 
64+           SIGNATURE=$(echo -n '{"args":["test-container"]}' | openssl dgst -sha256 -hmac "my-test-secret" | sed 's/^.* //') 
5965          RESPONSE=$(curl -s -w "\n%{http_code}" -X POST http://localhost:8080/backup \ 
6066              -H "Content-Type: application/json" \ 
6167              -H "X-Signature: sha256=$SIGNATURE" \ 
62-               -d '{"args":[]}') 
68+               -d '{"args":["test-container" ]}') 
6369
6470          # Extract response body and status code 
6571          RESPONSE_BODY=$(echo "$RESPONSE" | head -n -1) 
@@ -69,19 +75,36 @@ jobs:
6975          if [ "$STATUS_CODE" != "200" ]; then 
7076              echo "Test failed: Expected status code 200, got $STATUS_CODE" 
7177              echo "Response: $RESPONSE_BODY" 
78+               # Output app logs for debugging 
79+               echo "=== App logs ===" 
80+               cat app.log 
81+               echo "=== End of app logs ===" 
82+               # Output Docker logs for the test container 
83+               echo "=== Test container logs ===" 
84+               docker logs test-container || true  
85+               echo "=== End of test container logs ===" 
7286              exit 1 
7387          fi 
7488
7589          if [[ "$RESPONSE_BODY" != *"Backup initiated successfully"* ]]; then 
7690              echo "Test failed: Expected response body to contain 'Backup initiated successfully'" 
7791              echo "Response: $RESPONSE_BODY" 
92+               # Output app logs for debugging 
93+               echo "=== App logs ===" 
94+               cat app.log 
95+               echo "=== End of app logs ===" 
96+               # Output Docker logs for the test container 
97+               echo "=== Test container logs ===" 
98+               docker logs test-container || true  
99+               echo "=== End of test container logs ===" 
78100              exit 1 
79101          fi 
80102
81103          echo "Callback handler test passed" 
82104
83105          # Cleanup 
84106          killall myapp || true  
107+           docker rm -f test-container || true  
85108
86109       - name : Output application logs 
87110        if : always() 
94117          # List directories that match the backup pattern created by docker-backup.sh 
95118          echo "Backup directories:" 
96119          ls -la /tmp/docker-backups/ 2>/dev/null || echo "No backup directory found at /tmp/docker-backups/" 
97-            
120+ 
98121          # If backup directories exist, show their contents 
99122          if [[ -d "/tmp/docker-backups" ]]; then 
100123            for backup_dir in /tmp/docker-backups/*/; do 
0 commit comments