Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0266eb8
Create run-E2E-tests.yml
HappyPathsOnly Jun 5, 2025
179816d
Fix actions not finding the test dll.
HappyPathsOnly Jun 5, 2025
cb8b100
Put in some debug and ensure the release build is ran.
HappyPathsOnly Jun 5, 2025
a77dc7c
Wait for a while and see if selenium hub comes up.
HappyPathsOnly Jun 5, 2025
8ba479c
Up the waiting time for selenium hub to come up.
HappyPathsOnly Jun 5, 2025
040d712
add healthcheck to selenium hub.
HappyPathsOnly Jun 5, 2025
c9bc109
increase timeout and use wget
HappyPathsOnly Jun 5, 2025
b5a0618
try explicit ip address
HappyPathsOnly Jun 5, 2025
b9efd42
try no cache
HappyPathsOnly Jun 5, 2025
6f8479e
check healthy status
HappyPathsOnly Jun 5, 2025
5af50b5
remove healthcheck
HappyPathsOnly Jun 5, 2025
90c632b
remove healthcheck from compose file.
HappyPathsOnly Jun 5, 2025
a24b177
increase the wait
HappyPathsOnly Jun 5, 2025
e1d73a7
check for different selenium hub text
HappyPathsOnly Jun 5, 2025
7080be8
Add some more debugging
HappyPathsOnly Jun 6, 2025
5057c54
install ping
HappyPathsOnly Jun 6, 2025
8e76828
Add retries and rename hub uri. Don't ping for now
HappyPathsOnly Jun 6, 2025
9e85b38
up retries
HappyPathsOnly Jun 6, 2025
51b3759
Check node readiness
HappyPathsOnly Jun 7, 2025
f046616
remove node check
HappyPathsOnly Jun 7, 2025
11bd94d
add grid status info.
HappyPathsOnly Jun 7, 2025
4f664b6
comment out assets directory
HappyPathsOnly Jun 7, 2025
44c5303
show node-docker logs.
HappyPathsOnly Jun 7, 2025
16fb6ca
use correct docker node name
HappyPathsOnly Jun 7, 2025
3ad61c4
do not use docker node use chrome and firefox services directly instead.
HappyPathsOnly Jun 8, 2025
61e8882
remove docker node logs and use correct hub name
HappyPathsOnly Jun 8, 2025
73d7e87
use updated selenium hub name.
HappyPathsOnly Jun 8, 2025
d297406
show memory usage
HappyPathsOnly Jun 8, 2025
c7fae30
keep ea test running
HappyPathsOnly Jun 8, 2025
f7e7a35
publish the test results
HappyPathsOnly Jun 8, 2025
7f87711
enable test results to be written
HappyPathsOnly Jun 8, 2025
cbd3cf6
add issues permission
HappyPathsOnly Jun 8, 2025
6a41724
more permissions
HappyPathsOnly Jun 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Dockerized App Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
checks: write
contents: read
issues: read
pull-requests: write

jobs:
integration-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- 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 be ready..."
for i in {1..100}; do
if docker logs selenium-grid-docker-selenium-hub-1 2>&1 | grep -q "Started Selenium Hub"; then
echo "Selenium Hub is ready!"
break
fi
sleep 2
done

- name: Log Selenium Grid Status
run: |
echo "Grid status:"
curl -s http://localhost:4444/status | jq .

- name: Print environment variables
run: env

- name: Show Docker networks
run: docker network ls && docker network inspect bridge

- name: Show Docker container status before tests
run: docker ps -a

- 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
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
with:
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

- name: Show selenium hub logs on failure
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}}"

12 changes: 11 additions & 1 deletion EAAppTest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,4 +24,11 @@ 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"]

# 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"]
CMD ["/bin/sh", "-c", "dotnet test EAAppTest.csproj --configuration Release --logger:trx;LogFileName=test-results.trx; tail -f /dev/null"]

21 changes: 17 additions & 4 deletions EAAppTest/DriverFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@ public class DriverFixture : IDisposable

public void Setup(BrowserType browserType)
{
driver = new RemoteWebDriver(new Uri("http://selenium-hub:4444/"), GetBrowserOptions(browserType));
int retries = 9;
Exception? lastException = null;

if (driver == null)
for (int i = 0; i < retries; i++)
{
// Do something here
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(8000); // Wait before retrying
}
}

throw new InvalidOperationException("Driver initialization failed after retries", lastException);
}

// This solution provided by co-pilot.
Expand All @@ -42,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:
Expand Down
2 changes: 1 addition & 1 deletion EAAppTest/UnitTest2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class UnitTest2 : IClassFixture<DriverFixture>

public UnitTest2(DriverFixture driverFixture)
{
driverFixture.Setup(BrowserType.Firefox);
driverFixture.Setup(BrowserType.Chrome);
this.driverFixture = driverFixture;
}

Expand Down
46 changes: 31 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -71,9 +86,10 @@ services:
context: .
dockerfile: EAAppTest/Dockerfile
restart: on-failure
depends_on:
- selenium-hub
- ea_webapp
depends_on:
ea_webapp:
condition : service_started

networks:
- ea_network

Expand Down