From 0266eb8dc4c4c1ecf87e0b94278eb260cfef68e3 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 5 Jun 2025 15:44:10 +0100 Subject: [PATCH 01/33] Create run-E2E-tests.yml Try out Github actions. --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..77f345b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Dockerized App Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + integration-tests: + runs-on: ubuntu-latest + + services: + docker: + image: docker:20.10.16 + options: --privileged + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build containers + run: docker compose build + + - name: Start app + test stack + run: docker compose up --abort-on-container-exit --exit-code-from ea_test + + - name: Copy test results from container + run: | + mkdir -p test-results + docker cp eatest:/src/EAAppTest/TestResults test-results + + - name: Upload test results + uses: actions/upload-artifact@v4 + with: + name: test-results + path: test-results/TestResults/*.trx From 179816d8fc8f80122615bb253fe934f005e48c67 Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 16:02:07 +0100 Subject: [PATCH 02/33] Fix actions not finding the test dll. --- EAAppTest/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EAAppTest/Dockerfile b/EAAppTest/Dockerfile index da251c3..f73df0e 100644 --- a/EAAppTest/Dockerfile +++ b/EAAppTest/Dockerfile @@ -21,4 +21,4 @@ RUN dotnet build "EAAppTest.csproj" -c Release # Run the tests FROM build AS test-runner WORKDIR "/src/EAAppTest" -CMD ["dotnet", "test", "--no-build", "--logger:trx"] +CMD ["dotnet", "test", "EAAppTest.csproj", "--no-build", "--logger:trx;LogFileName=test-results.trx"] From cb8b10029f8c61d293acf89da21a751fa4cd5d6c Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 16:27:58 +0100 Subject: [PATCH 03/33] Put in some debug and ensure the release build is ran. --- EAAppTest/Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/EAAppTest/Dockerfile b/EAAppTest/Dockerfile index f73df0e..d9c1b25 100644 --- a/EAAppTest/Dockerfile +++ b/EAAppTest/Dockerfile @@ -21,4 +21,10 @@ RUN dotnet build "EAAppTest.csproj" -c Release # Run the tests FROM build AS test-runner WORKDIR "/src/EAAppTest" -CMD ["dotnet", "test", "EAAppTest.csproj", "--no-build", "--logger:trx;LogFileName=test-results.trx"] + +# Debug: list contents of build output directory +RUN ls -l /src/EAAppTest/bin/Release/net6.0/ + +# Run the tests using the .csproj and explicitly set Release config +CMD ["dotnet", "test", "EAAppTest.csproj", "--configuration", "Release", "--logger:trx;LogFileName=test-results.trx"] + From a77dc7c57fdbf5d23e1abbeaaff8c369b969780a Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 16:48:01 +0100 Subject: [PATCH 04/33] Wait for a while and see if selenium hub comes up. --- .github/workflows/main.yml | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 77f345b..b236678 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Dockerized App Tests +name: Dockerized App Tests on: push: @@ -10,11 +10,6 @@ jobs: integration-tests: runs-on: ubuntu-latest - services: - docker: - image: docker:20.10.16 - options: --privileged - steps: - name: Checkout code uses: actions/checkout@v4 @@ -26,7 +21,22 @@ jobs: run: docker compose build - name: Start app + test stack - run: docker compose up --abort-on-container-exit --exit-code-from ea_test + run: docker compose up -d + + - name: Wait for selenium-hub to become ready + run: | + echo "Waiting for selenium-hub to be ready..." + for i in {1..30}; do + if curl -s http://localhost:4444/wd/hub/status | grep -q '"ready":true'; then + echo "✅ Selenium hub is ready." + break + fi + echo "⏳ Not ready yet..." + sleep 2 + done + + - name: Run tests in eatest + run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release - name: Copy test results from container run: | @@ -38,3 +48,11 @@ jobs: with: name: test-results path: test-results/TestResults/*.trx + + - name: Show test container logs on failure + if: failure() + run: docker logs eatest + + - name: Show selenium hub logs on failure + if: failure() + run: docker logs selenium-hub From 8ba479ce627588fc5c9a0cceb4f66de0260ee3c6 Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 18:12:47 +0100 Subject: [PATCH 05/33] Up the waiting time for selenium hub to come up. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b236678..fccc7b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: - name: Wait for selenium-hub to become ready run: | echo "Waiting for selenium-hub to be ready..." - for i in {1..30}; do + for i in {1..50}; do if curl -s http://localhost:4444/wd/hub/status | grep -q '"ready":true'; then echo "✅ Selenium hub is ready." break From 040d7129f5b1b6c152aa73ab0c0172e609d2aa10 Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 21:37:39 +0100 Subject: [PATCH 06/33] add healthcheck to selenium hub. --- .github/workflows/main.yml | 12 ------------ docker-compose.yml | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fccc7b2..e983d69 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,18 +23,6 @@ jobs: - name: Start app + test stack run: docker compose up -d - - name: Wait for selenium-hub to become ready - run: | - echo "Waiting for selenium-hub to be ready..." - for i in {1..50}; do - if curl -s http://localhost:4444/wd/hub/status | grep -q '"ready":true'; then - echo "✅ Selenium hub is ready." - break - fi - echo "⏳ Not ready yet..." - sleep 2 - done - - name: Run tests in eatest run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release diff --git a/docker-compose.yml b/docker-compose.yml index 273fdfa..2408bb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -61,6 +61,12 @@ services: - "4442:4442" - "4443:4443" - "4444:4444" + healthcheck: + test: ["CMD-SHELL", "curl -s http://localhost:4444/status | grep '\"ready\": true'"] + interval: 5s + timeout: 2s + retries: 10 + start_period: 10s networks: - ea_network @@ -71,9 +77,12 @@ services: context: . dockerfile: EAAppTest/Dockerfile restart: on-failure - depends_on: - - selenium-hub - - ea_webapp + depends_on: + selenium-hub: + condition : service_healthy + ea_webapp: + condition : service_started + networks: - ea_network From c9bc109c5a4e7f67fbeb8fe5b1ff816b876bd3d0 Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 22:03:03 +0100 Subject: [PATCH 07/33] increase timeout and use wget --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2408bb6..7164914 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,11 +62,11 @@ services: - "4443:4443" - "4444:4444" healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost:4444/status | grep '\"ready\": true'"] + test: ["CMD-SHELL", "wget -q -O - http://localhost:4444/status | grep '\"ready\": true'"] interval: 5s timeout: 2s retries: 10 - start_period: 10s + start_period: 25s networks: - ea_network From b5a0618c5a747f8f3d512f1b727f61c5ee78335d Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 22:10:59 +0100 Subject: [PATCH 08/33] try explicit ip address --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7164914..41efc3a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,7 +62,7 @@ services: - "4443:4443" - "4444:4444" healthcheck: - test: ["CMD-SHELL", "wget -q -O - http://localhost:4444/status | grep '\"ready\": true'"] + test: ["CMD-SHELL", "wget -q -O - http://172.18.0.3:4444/status | grep '\"ready\": true'"] interval: 5s timeout: 2s retries: 10 From b9efd42e5fad257c83690a65b7a191ebf4df8caa Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 22:24:06 +0100 Subject: [PATCH 09/33] try no cache --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 41efc3a..4745150 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,7 +62,7 @@ services: - "4443:4443" - "4444:4444" healthcheck: - test: ["CMD-SHELL", "wget -q -O - http://172.18.0.3:4444/status | grep '\"ready\": true'"] + test: ["CMD-SHELL", "wget --no-cache -q -O - http://localhost:4444/status | grep '\"ready\": true'"] interval: 5s timeout: 2s retries: 10 From 6f8479e9b00e90244b4599868d898cc25a95da30 Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 22:47:58 +0100 Subject: [PATCH 10/33] check healthy status --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e983d69..e191995 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,12 +17,34 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + - name: Build containers run: docker compose build - name: Start app + test stack run: docker compose up -d + - name: Wait for selenium-hub to be ready + run: | + echo "Waiting for selenium-hub to report healthy status..." + for i in {1..40}; do + STATUS=$(docker inspect --format='{{json .State.Health.Status}}' selenium-hub) + echo "Health status: $STATUS" + if [ "$STATUS" = "\"healthy\"" ]; then + echo "Selenium Hub is healthy!" + break + fi + sleep 3 + done + + if [ "$STATUS" != "\"healthy\"" ]; then + echo "Selenium Hub never became healthy" + docker logs selenium-hub + exit 1 + fi + - name: Run tests in eatest run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release @@ -44,3 +66,7 @@ jobs: - name: Show selenium hub logs on failure if: failure() run: docker logs selenium-hub + + - name: Inspect selenium-hub healthcheck result + if: failure() + run: docker inspect --format='{{json .State.Health}}' selenium-hub | jq . From 5af50b5710828d0f000bd7169e2536a868b6f38e Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 23:07:07 +0100 Subject: [PATCH 11/33] remove healthcheck --- .github/workflows/main.yml | 23 ++++++++--------------- docker-compose.yml | 6 ------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e191995..6685180 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,22 +28,15 @@ jobs: - name: Wait for selenium-hub to be ready run: | - echo "Waiting for selenium-hub to report healthy status..." - for i in {1..40}; do - STATUS=$(docker inspect --format='{{json .State.Health.Status}}' selenium-hub) - echo "Health status: $STATUS" - if [ "$STATUS" = "\"healthy\"" ]; then - echo "Selenium Hub is healthy!" - break - fi - sleep 3 - done + echo "Waiting for selenium-hub to be ready..." + for i in {1..50}; do + if docker logs selenium-hub 2>&1 | grep -q "Selenium Grid ready"; then + echo "Selenium Hub is ready!" + break + fi + sleep 2 + done - if [ "$STATUS" != "\"healthy\"" ]; then - echo "Selenium Hub never became healthy" - docker logs selenium-hub - exit 1 - fi - name: Run tests in eatest run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release diff --git a/docker-compose.yml b/docker-compose.yml index 4745150..33f4b53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -61,12 +61,6 @@ services: - "4442:4442" - "4443:4443" - "4444:4444" - healthcheck: - test: ["CMD-SHELL", "wget --no-cache -q -O - http://localhost:4444/status | grep '\"ready\": true'"] - interval: 5s - timeout: 2s - retries: 10 - start_period: 25s networks: - ea_network From 90c632b25ec3363273fe801bef72fe8fe780f00d Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 23:10:07 +0100 Subject: [PATCH 12/33] remove healthcheck from compose file. --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 33f4b53..b54eb29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -72,8 +72,6 @@ services: dockerfile: EAAppTest/Dockerfile restart: on-failure depends_on: - selenium-hub: - condition : service_healthy ea_webapp: condition : service_started From a24b177949c8a3b2dd373ccbcf8ed10d53ec46d8 Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 23:27:38 +0100 Subject: [PATCH 13/33] increase the wait --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6685180..3852918 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: - name: Wait for selenium-hub to be ready run: | echo "Waiting for selenium-hub to be ready..." - for i in {1..50}; do + for i in {1..100}; do if docker logs selenium-hub 2>&1 | grep -q "Selenium Grid ready"; then echo "Selenium Hub is ready!" break From e1d73a72f1260087457038e58e2884ca5f32c9bd Mon Sep 17 00:00:00 2001 From: noinsight Date: Thu, 5 Jun 2025 23:43:08 +0100 Subject: [PATCH 14/33] check for different selenium hub text --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3852918..57dd608 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: run: | echo "Waiting for selenium-hub to be ready..." for i in {1..100}; do - if docker logs selenium-hub 2>&1 | grep -q "Selenium Grid ready"; then + if docker logs selenium-hub 2>&1 | grep -q "Started Selenium Hub"; then echo "Selenium Hub is ready!" break fi From 7080be8f6f3eb6469733369195c26ed98b2dc370 Mon Sep 17 00:00:00 2001 From: noinsight Date: Fri, 6 Jun 2025 10:55:35 +0100 Subject: [PATCH 15/33] Add some more debugging --- .github/workflows/main.yml | 11 +++++++++++ EAAppTest/DriverFixture.cs | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57dd608..882d60a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,17 @@ jobs: sleep 2 done + - name: Inspect selenium-hub healthcheck result + run: docker inspect --format='{{json .State.Health}}' selenium-hub | jq . + + - name: Show Docker networks + run: docker network ls && docker network inspect bridge + + - name: Show Docker container status before tests + run: docker ps -a + + - name: Test network connectivity from test container to selenium-hub + run: docker exec eatest ping -c 4 selenium-hub - name: Run tests in eatest run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release diff --git a/EAAppTest/DriverFixture.cs b/EAAppTest/DriverFixture.cs index 08f3fb2..b8cc71d 100644 --- a/EAAppTest/DriverFixture.cs +++ b/EAAppTest/DriverFixture.cs @@ -13,11 +13,13 @@ public class DriverFixture : IDisposable public void Setup(BrowserType browserType) { - driver = new RemoteWebDriver(new Uri("http://selenium-hub:4444/"), GetBrowserOptions(browserType)); + driver = new RemoteWebDriver( + new Uri("http://selenium-hub:4444/"), + GetBrowserOptions(browserType)); if (driver == null) { - // Do something here + throw new InvalidOperationException("Driver is not initialized. Setup failed"); } } From 5057c543d6b6f475b6235ae02eb821f5f2a4f5c5 Mon Sep 17 00:00:00 2001 From: noinsight Date: Fri, 6 Jun 2025 11:09:22 +0100 Subject: [PATCH 16/33] install ping --- EAAppTest/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/EAAppTest/Dockerfile b/EAAppTest/Dockerfile index d9c1b25..950ba44 100644 --- a/EAAppTest/Dockerfile +++ b/EAAppTest/Dockerfile @@ -7,6 +7,9 @@ WORKDIR /app FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src +# Install ping utility +RUN apt-get update && apt-get install -y iputils-ping + # Copy only the test first for layer caching COPY ["EAAppTest/EAAppTest.csproj", "EAAppTest/"] RUN dotnet restore "EAAppTest/EAAppTest.csproj" From 8e76828e819a14f456163da5040881b073da8acc Mon Sep 17 00:00:00 2001 From: noinsight Date: Fri, 6 Jun 2025 11:40:05 +0100 Subject: [PATCH 17/33] Add retries and rename hub uri. Don't ping for now --- .github/workflows/main.yml | 4 ++-- EAAppTest/DriverFixture.cs | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 882d60a..e716ebb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,8 +46,8 @@ jobs: - name: Show Docker container status before tests run: docker ps -a - - name: Test network connectivity from test container to selenium-hub - run: docker exec eatest ping -c 4 selenium-hub + # - name: Test network connectivity from test container to selenium-hub + # run: docker exec eatest ping -c 4 selenium-hub - name: Run tests in eatest run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release diff --git a/EAAppTest/DriverFixture.cs b/EAAppTest/DriverFixture.cs index b8cc71d..4f039d4 100644 --- a/EAAppTest/DriverFixture.cs +++ b/EAAppTest/DriverFixture.cs @@ -13,15 +13,26 @@ public class DriverFixture : IDisposable public void Setup(BrowserType browserType) { - driver = new RemoteWebDriver( - new Uri("http://selenium-hub:4444/"), - GetBrowserOptions(browserType)); + int retries = 5; + Exception? lastException = null; - if (driver == null) + for (int i = 0; i < retries; i++) { - throw new InvalidOperationException("Driver is not initialized. Setup failed"); + try + { + driver = new RemoteWebDriver( + new Uri("http://selenium-hub:4444/wd/hub"), + GetBrowserOptions(browserType)); + return; // Exit if driver is successfully initialized + } + catch (Exception ex) + { + lastException = ex; + System.Threading.Thread.Sleep(5000); // Wait before retrying + } } + throw new InvalidOperationException("Driver initialization failed after retries", lastException); } // This solution provided by co-pilot. From 9e85b383b3d27b40b41a3270a704df44aad23683 Mon Sep 17 00:00:00 2001 From: noinsight Date: Fri, 6 Jun 2025 11:56:51 +0100 Subject: [PATCH 18/33] up retries --- EAAppTest/DriverFixture.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EAAppTest/DriverFixture.cs b/EAAppTest/DriverFixture.cs index 4f039d4..6e28dde 100644 --- a/EAAppTest/DriverFixture.cs +++ b/EAAppTest/DriverFixture.cs @@ -13,7 +13,7 @@ public class DriverFixture : IDisposable public void Setup(BrowserType browserType) { - int retries = 5; + int retries = 9; Exception? lastException = null; for (int i = 0; i < retries; i++) @@ -28,7 +28,7 @@ public void Setup(BrowserType browserType) catch (Exception ex) { lastException = ex; - System.Threading.Thread.Sleep(5000); // Wait before retrying + System.Threading.Thread.Sleep(8000); // Wait before retrying } } From 51b3759ac8d96499d3e4d8d593d5a68ed60a3679 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sat, 7 Jun 2025 08:38:24 +0100 Subject: [PATCH 19/33] Check node readiness Only use chrome Take out video recording. --- .github/workflows/main.yml | 18 ++++++++++++++++++ EAAppTest/Dockerfile | 2 +- EAAppTest/DriverFixture.cs | 2 +- EAAppTest/UnitTest2.cs | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e716ebb..eabda6d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,6 +26,24 @@ jobs: - name: Start app + test stack run: docker compose up -d + - name: Wait for Selenium Grid and nodes to be ready + run: | + echo "Waiting for Selenium Grid and nodes to be ready..." + for i in {1..60}; do + STATUS=$(curl -s http://localhost:4444/status) + HUB_READY=$(echo $STATUS | jq -r '.value.ready') + CHROME_NODES=$(echo $STATUS | jq -r '.value.nodes[] | select(.slots[].stereotype.browserName=="chrome") | .id' | wc -l) + if [[ "$HUB_READY" == "true" && "$CHROME_NODES" -gt 0 ]]; then + echo "Selenium Grid is ready and Chrome node(s) are available!" + break + fi + if [[ $i -eq 60 ]]; then + echo "Timed out waiting for Selenium nodes to be ready" + exit 1 + fi + sleep 2 + done + - name: Wait for selenium-hub to be ready run: | echo "Waiting for selenium-hub to be ready..." diff --git a/EAAppTest/Dockerfile b/EAAppTest/Dockerfile index 950ba44..2fe5ac1 100644 --- a/EAAppTest/Dockerfile +++ b/EAAppTest/Dockerfile @@ -8,7 +8,7 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src # Install ping utility -RUN apt-get update && apt-get install -y iputils-ping +#RUN apt-get update && apt-get install -y iputils-ping # Copy only the test first for layer caching COPY ["EAAppTest/EAAppTest.csproj", "EAAppTest/"] diff --git a/EAAppTest/DriverFixture.cs b/EAAppTest/DriverFixture.cs index 6e28dde..4f27fd0 100644 --- a/EAAppTest/DriverFixture.cs +++ b/EAAppTest/DriverFixture.cs @@ -55,7 +55,7 @@ private dynamic GetBrowserOptions(BrowserType browserType) case BrowserType.Chrome: { var chromeOption = new ChromeOptions(); - chromeOption.AddAdditionalOption("se:recordVideo", true); + //chromeOption.AddAdditionalOption("se:recordVideo", true); return chromeOption; } default: diff --git a/EAAppTest/UnitTest2.cs b/EAAppTest/UnitTest2.cs index bf92021..f6a1362 100644 --- a/EAAppTest/UnitTest2.cs +++ b/EAAppTest/UnitTest2.cs @@ -9,7 +9,7 @@ public class UnitTest2 : IClassFixture public UnitTest2(DriverFixture driverFixture) { - driverFixture.Setup(BrowserType.Firefox); + driverFixture.Setup(BrowserType.Chrome); this.driverFixture = driverFixture; } From f046616205d7985473c6a4a44e06a731410ec060 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sat, 7 Jun 2025 08:45:22 +0100 Subject: [PATCH 20/33] remove node check --- .github/workflows/main.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eabda6d..e716ebb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,24 +26,6 @@ jobs: - name: Start app + test stack run: docker compose up -d - - name: Wait for Selenium Grid and nodes to be ready - run: | - echo "Waiting for Selenium Grid and nodes to be ready..." - for i in {1..60}; do - STATUS=$(curl -s http://localhost:4444/status) - HUB_READY=$(echo $STATUS | jq -r '.value.ready') - CHROME_NODES=$(echo $STATUS | jq -r '.value.nodes[] | select(.slots[].stereotype.browserName=="chrome") | .id' | wc -l) - if [[ "$HUB_READY" == "true" && "$CHROME_NODES" -gt 0 ]]; then - echo "Selenium Grid is ready and Chrome node(s) are available!" - break - fi - if [[ $i -eq 60 ]]; then - echo "Timed out waiting for Selenium nodes to be ready" - exit 1 - fi - sleep 2 - done - - name: Wait for selenium-hub to be ready run: | echo "Waiting for selenium-hub to be ready..." From 11bd94d05441df6c91253e04af746ad901de5bf9 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sat, 7 Jun 2025 22:35:22 +0100 Subject: [PATCH 21/33] add grid status info. --- .github/workflows/main.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e716ebb..e10a208 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,8 +37,15 @@ jobs: sleep 2 done - - name: Inspect selenium-hub healthcheck result - run: docker inspect --format='{{json .State.Health}}' selenium-hub | jq . + - name: Log Selenium Grid Status + run: | + echo "Grid status:" + curl -s http://localhost:4444/status | jq . + echo "Grid API hub:" + curl -s http://localhost:4444/grid/api/hub | jq . + + - name: Print environment variables + run: env - name: Show Docker networks run: docker network ls && docker network inspect bridge From 4f664b63d224d1f73bdd4dbdf8545290f5676d3c Mon Sep 17 00:00:00 2001 From: noinsight Date: Sat, 7 Jun 2025 23:19:06 +0100 Subject: [PATCH 22/33] comment out assets directory --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index b54eb29..8e2db98 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,7 +43,7 @@ services: node-docker: image: selenium/node-docker:4.1.0-20211209 volumes: - - ./assets:/opt/selenium/assets +# - ./assets:/opt/selenium/assets - ./config.toml:/opt/bin/config.toml depends_on: - selenium-hub From 44c53035600245ada8d8da1d0dc05c0660b0b94d Mon Sep 17 00:00:00 2001 From: noinsight Date: Sat, 7 Jun 2025 23:50:53 +0100 Subject: [PATCH 23/33] show node-docker logs. --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e10a208..7cfe5bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -78,6 +78,6 @@ jobs: if: failure() run: docker logs selenium-hub - - name: Inspect selenium-hub healthcheck result - if: failure() - run: docker inspect --format='{{json .State.Health}}' selenium-hub | jq . + - name: Show node-docker logs + if: failure() + run: docker logs node-docker From 16fb6caafd9a0de6aa6c7caa6a0c8f5dd170d3b5 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 00:11:02 +0100 Subject: [PATCH 24/33] use correct docker node name --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cfe5bd..050c326 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,4 +80,5 @@ jobs: - name: Show node-docker logs if: failure() - run: docker logs node-docker + run: docker logs selenium-grid-docker-node-docker-1 + From 3ad61c44af6b68ec487f1dbcd1cc451d1ed291b8 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 18:08:05 +0100 Subject: [PATCH 25/33] do not use docker node use chrome and firefox services directly instead. --- docker-compose.yml | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8e2db98..47c3800 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,11 +40,25 @@ services: networks: - ea_network - node-docker: - image: selenium/node-docker:4.1.0-20211209 - volumes: -# - ./assets:/opt/selenium/assets - - ./config.toml:/opt/bin/config.toml + # selenium-hub: + # image: selenium/hub:4.1.0-20211209 + # container_name: selenium-hub + # ports: + # - "4442:4442" + # - "4443:4443" + # - "4444:4444" + # networks: + # - ea_network + + selenium-hub: + image: selenium/hub:4.1.0 + ports: + - "4444:4444" + networks: + - ea_network + + chrome: + image: selenium/node-chrome:4.1.0 depends_on: - selenium-hub environment: @@ -54,13 +68,14 @@ services: networks: - ea_network - selenium-hub: - image: selenium/hub:4.1.0-20211209 - container_name: selenium-hub - ports: - - "4442:4442" - - "4443:4443" - - "4444:4444" + firefox: + image: selenium/node-firefox:4.1.0 + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 networks: - ea_network From 61e8882a828d4e0306daa792fbf57fee6556592b Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 18:24:33 +0100 Subject: [PATCH 26/33] remove docker node logs and use correct hub name --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 050c326..b12aea1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,9 +76,5 @@ jobs: - name: Show selenium hub logs on failure if: failure() - run: docker logs selenium-hub - - - name: Show node-docker logs - if: failure() - run: docker logs selenium-grid-docker-node-docker-1 + run: docker logs selenium-grid-docker-selenium-hub-1 From 73d7e87b127e1974e5446255df642d65d99147b2 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 19:08:48 +0100 Subject: [PATCH 27/33] use updated selenium hub name. copy test results if available --- .github/workflows/main.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b12aea1..8d4288f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: run: | echo "Waiting for selenium-hub to be ready..." for i in {1..100}; do - if docker logs selenium-hub 2>&1 | grep -q "Started Selenium Hub"; then + if docker logs selenium-grid-docker-selenium-hub-1 2>&1 | grep -q "Started Selenium Hub"; then echo "Selenium Hub is ready!" break fi @@ -59,10 +59,14 @@ jobs: - name: Run tests in eatest run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release - - name: Copy test results from container + - name: Copy test results from container (if running) run: | mkdir -p test-results - docker cp eatest:/src/EAAppTest/TestResults test-results + if docker ps -a --format '{{.Names}}' | grep -q '^eatest$'; then + docker cp eatest:/src/EAAppTest/TestResults test-results || echo "Could not copy test results; container may have exited." + else + echo "eatest container is not running or has exited. Skipping docker cp." + fi - name: Upload test results uses: actions/upload-artifact@v4 From d297406af65b2ca54628073e925b7d939d672823 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 19:45:02 +0100 Subject: [PATCH 28/33] show memory usage --- .github/workflows/main.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8d4288f..7dc3cff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,12 +53,15 @@ jobs: - name: Show Docker container status before tests run: docker ps -a - # - name: Test network connectivity from test container to selenium-hub - # run: docker exec eatest ping -c 4 selenium-hub + - name: Show Docker container memory usage + run: docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}" - name: Run tests in eatest run: docker exec eatest dotnet test /src/EAAppTest/EAAppTest.csproj --logger:trx --no-build --configuration Release + - name: Show Docker container memory usage + run: docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}" + - name: Copy test results from container (if running) run: | mkdir -p test-results @@ -82,3 +85,7 @@ jobs: if: failure() run: docker logs selenium-grid-docker-selenium-hub-1 + - name: Show Docker container memory usage on failure + if: failure() + run: docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}" + From c7fae30891e72f4330f81f47a79ba13eabf0a404 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 19:56:23 +0100 Subject: [PATCH 29/33] keep ea test running --- EAAppTest/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EAAppTest/Dockerfile b/EAAppTest/Dockerfile index 2fe5ac1..48ecf2f 100644 --- a/EAAppTest/Dockerfile +++ b/EAAppTest/Dockerfile @@ -29,5 +29,6 @@ WORKDIR "/src/EAAppTest" RUN ls -l /src/EAAppTest/bin/Release/net6.0/ # Run the tests using the .csproj and explicitly set Release config -CMD ["dotnet", "test", "EAAppTest.csproj", "--configuration", "Release", "--logger:trx;LogFileName=test-results.trx"] +# CMD ["dotnet", "test", "EAAppTest.csproj", "--configuration", "Release", "--logger:trx;LogFileName=test-results.trx"] +CMD ["/bin/sh", "-c", "dotnet test EAAppTest.csproj --configuration Release --logger:trx;LogFileName=test-results.trx; tail -f /dev/null"] From f7e7a35b85e70d176e79e2bb08f502b3ae58461c Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 20:15:54 +0100 Subject: [PATCH 30/33] publish the test results --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7dc3cff..ebe5e91 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,6 +77,11 @@ jobs: name: test-results path: test-results/TestResults/*.trx + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: 'test-results/TestResults/*.trx' + - name: Show test container logs on failure if: failure() run: docker logs eatest From 7f877119bf9b6525b6b8d4381f060acd3a8570f8 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 20:29:36 +0100 Subject: [PATCH 31/33] enable test results to be written --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebe5e91..845b4ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [ main ] +permissions: + checks: write + contents: read + jobs: integration-tests: runs-on: ubuntu-latest @@ -41,8 +45,6 @@ jobs: run: | echo "Grid status:" curl -s http://localhost:4444/status | jq . - echo "Grid API hub:" - curl -s http://localhost:4444/grid/api/hub | jq . - name: Print environment variables run: env From cbd3cf64462ef22399103601add31a7ac096976e Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 20:36:20 +0100 Subject: [PATCH 32/33] add issues permission --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 845b4ae..fd7cf3e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,7 @@ on: permissions: checks: write contents: read + issues: write jobs: integration-tests: From 6a41724451c80eeb9dc954f4922cf2b4a7ca6005 Mon Sep 17 00:00:00 2001 From: noinsight Date: Sun, 8 Jun 2025 20:47:31 +0100 Subject: [PATCH 33/33] more permissions --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd7cf3e..f1d61ca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,8 @@ on: permissions: checks: write contents: read - issues: write + issues: read + pull-requests: write jobs: integration-tests: