From 58a7c1a1b996adeec3246d6e79b90522b9960d69 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Thu, 28 Nov 2024 10:07:22 +0530 Subject: [PATCH] [TEST] --- .github/scripts/wait_for_docker_server.sh | 34 +++++++++++++++++++++++ .github/workflows/ci_checks.yml | 11 ++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 .github/scripts/wait_for_docker_server.sh diff --git a/.github/scripts/wait_for_docker_server.sh b/.github/scripts/wait_for_docker_server.sh new file mode 100755 index 00000000000..4eebdcc874b --- /dev/null +++ b/.github/scripts/wait_for_docker_server.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +CONTAINER_ID=$(docker ps -q -f "name=simple-server") +echo "--- inspect --" +docker inspect "$CONTAINER_ID" +echo "--- process --" +docker exec -it "$CONTAINER_ID" bash +echo "-- logs --" +docker logs "$CONTAINER_ID" + +url="http://$DOCKER_IP:8420" +timeout_in_seconds=900 # 15 minutes in seconds + +start_time=$(date +%s) + +while true; do + response_code=$(curl -s -o /dev/null -w "%{http_code}" "$url") + + if [ "$response_code" -eq 200 ]; then + echo "Success! Received 200 OK response." + break + else + echo "Failed, got $response_code as response code. Retrying..." + sleep 5 + + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + + if [ "$elapsed_time" -ge "$timeout_in_seconds" ]; then + echo "Timeout reached. Exiting." + exit 1 + fi + fi +done diff --git a/.github/workflows/ci_checks.yml b/.github/workflows/ci_checks.yml index f6680d63fa1..a630db5ab55 100644 --- a/.github/workflows/ci_checks.yml +++ b/.github/workflows/ci_checks.yml @@ -149,8 +149,14 @@ jobs: echo "Docker container IP address is: $IP_ADDRESS" echo "DOCKER_IP=$IP_ADDRESS" >> $GITHUB_ENV + - name: Replace IP address in network security config - run: sed -i 's/localhost/$DOCKER_IP/g' app/src/main/res/xml/network_config.xml + run: | + sed -i "s/localhost/$DOCKER_IP/g" app/src/main/res/xml/network_config.xml + cat app/src/main/res/xml/network_config.xml + + - name: Wait for Docker server to be available + run: .github/scripts/wait_for_docker_server.sh - name: Cache AVD uses: actions/cache@v4 @@ -186,7 +192,7 @@ jobs: - name: Build QA Test Artifacts id: build-instrumented-tests run: | - ./gradlew --build-cache --no-daemon -PmanifestEndpoint=http://$DOCKER_IP:8420/api/ assembleQaDebug assembleQaDebugAndroidTest + ./gradlew --build-cache --no-daemon -PmanifestEndpoint=http://$DOCKER_IP/api/ assembleQaDebug assembleQaDebugAndroidTest - name: QA Android Tests id: run-instrumented-tests @@ -199,6 +205,7 @@ jobs: disable-animations: true disk-size: 8G script: | + echo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' simple-server adb root mkdir -p app/build/outputs/test-artifacts adb install app/build/outputs/apk/qa/debug/app-qa-debug.apk