Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7b7ca33
create docker using github action
jsjiang May 21, 2025
7c48990
test github action
jsjiang May 21, 2025
27f69c7
test github action
jsjiang May 21, 2025
55256bd
remove push as a github action trigger
jsjiang May 21, 2025
0c07f5c
trigger github action on changes to a file
jsjiang May 22, 2025
090e6af
test trigger github action
jsjiang May 22, 2025
47d3dcc
test trigger github action
jsjiang May 22, 2025
cd13f95
Merge branch 'main' into test-docker
jsjiang May 30, 2025
d08cb9a
Add ezid status tests to github action
jsjiang May 30, 2025
8262834
test github secret
jsjiang May 30, 2025
45cb1e3
testing github secret
jsjiang May 31, 2025
2e85eb0
define environment variables for Docker
jsjiang Jun 3, 2025
6118aac
document docker compose commands
jsjiang Jun 3, 2025
af06801
rename file
jsjiang Jun 3, 2025
3ef74e7
Merge branch 'main' into test-docker
jsjiang Jun 12, 2025
ba6186d
add test cases to docker version ui tests
jsjiang Jun 13, 2025
dc5b5cb
update .env to trigger github action
jsjiang Jun 13, 2025
0c1f5e6
rename test script
jsjiang Jun 13, 2025
dc6b072
add UI test cases and setup env variables
jsjiang Jun 13, 2025
ad00538
refactor output format
jsjiang Jun 16, 2025
eae9cb3
document docker version ezid test suite
jsjiang Jun 16, 2025
e9d6e1b
rename file
jsjiang Jun 16, 2025
2d1efe1
update documentation
jsjiang Jun 16, 2025
cd304f3
remove --abort-on-container-exit to keep both ui and function test co…
jsjiang Jun 17, 2025
7706142
stop and remove containers after tests are done
jsjiang Jun 17, 2025
4cc7dd9
combine two tests in one script for github action
jsjiang Jun 18, 2025
83c8b13
save docker-compose config for 2 run services
jsjiang Jun 18, 2025
601dee9
rename github action
jsjiang Jun 18, 2025
dcb341b
rename step
jsjiang Jun 18, 2025
3e9d37f
rename github workflow file
jsjiang Jun 18, 2025
da0f5ac
test debug option
jsjiang Jun 20, 2025
57acb0e
test debug option
jsjiang Jun 20, 2025
7a8d7a0
refactor debug option
jsjiang Jun 23, 2025
5182c0e
testing ezid v3.3.13
jsjiang Jun 23, 2025
53a01b8
testing ezid v3.3.13 on prd
jsjiang Jun 24, 2025
a848245
testing ezid v3.3.14rc0 on stg
jsjiang Jun 26, 2025
1ae5e21
test v3.3.14 on ezid-stg
jsjiang Jun 27, 2025
0a8f240
test v3.3.14 on ezid-prd
jsjiang Jun 30, 2025
e3c4424
testing OS patching on stg
jsjiang Jul 7, 2025
5388237
testing prd
jsjiang Jul 9, 2025
82e1241
test related item on stg
jsjiang Jul 11, 2025
c772c26
testing ezid test-related-item-v2 on stg
jsjiang Jul 15, 2025
67c2e16
testing ezid test-related-item-v3 on stg
jsjiang Jul 17, 2025
b1afbe5
testing v3.3.15 on ezid-stg
jsjiang Jul 28, 2025
b446d38
testing v3.3.15 on EZID-prd
jsjiang Jul 29, 2025
bbe22ac
verify ezid version
jsjiang Jul 29, 2025
e1b1e49
update doc on how to run ezid in docker
jsjiang Jul 29, 2025
9dcb9c1
skip testing batch download on ezid-dev
jsjiang Aug 5, 2025
76fc8f4
test ezid-dev with vpn on
jsjiang Aug 5, 2025
cc5f8ff
testing ezid-stg
jsjiang Aug 5, 2025
79538d9
test ezid-prd
jsjiang Aug 5, 2025
a75be73
remove unused files
jsjiang Aug 27, 2025
0d0ebba
testing v3.3.15-accessability on stg
jsjiang Aug 27, 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
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ENV=stg
EZID_VER=v3.3.15-accessability
NOTIFICATION_EMAIL="[email protected]"
TEST_NOTES="Test EZID with Docker version EZID tests suite"
24 changes: 24 additions & 0 deletions .github/workflows/ezid-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run EZID UI and functional tests in Docker

on:
workflow_dispatch:
push:
paths:
- '.env'


jobs:
ezid-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Run EZID Tests
env:
APITEST_PASSWORD: ${{ secrets.APITEST_PASSWORD }}
run: docker compose up --build --abort-on-container-exit

- name: Stop and remove containers
if: always()
run: docker compose down --volumes --remove-orphans
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.8"

services:
selenium:
image: seleniarm/standalone-chromium:latest
ports:
- "4444:4444"
shm_size: 2gb
networks:
- selenium-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4444/wd/hub/status"]
interval: 5s
timeout: 3s
retries: 10


test-runner:
build: ./scripts
env_file:
- .env
environment:
- APITEST_PASSWORD=${APITEST_PASSWORD}
- SELENIUM_REMOTE_URL=http://selenium:4444/wd/hub
command: ["./run_ezid_tests.sh", "${ENV}", "apitest", "${APITEST_PASSWORD}", "${NOTIFICATION_EMAIL}", "${EZID_VER}"]
depends_on:
selenium:
condition: service_healthy
networks:
- selenium-network

networks:
selenium-network:
driver: bridge

171 changes: 171 additions & 0 deletions how_to_run_ezid_in_docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# How to run EZID tests in Docker
Here are the major components of the Docker version EZID test suite:

**Test scripts**
Test scripts are located in the `ezid-ops-scripts.git/scripts` directory.
* ezid_ui_tests_docker.py - test EZID UI
* verify_ezid_status.py - Verify EZID status including testing API endpoints

**The Dockerfile**
The `Dockerfile` is located in the `ezid-ops-scripts.git/scripts` directory.
It provides instructions on how to build a Docker image.

**The docker-compose file**
The `docker-compose.yml` file is located in the root directory of the `EZID-OPS-SCRIPTS` repo.
It defines and manages multiple Docker containers (services) in one file.

**The .env file***
The `.env` file is located in the root directory of the `EZID-OPS-SCRIPTS` repo.
It stores environment variables, which can be used in both `docker-compose.yml` and `Dockerfile`.

**Services defined in the `docker-compose.yml` file**
* selenium - a standalone-chromium
* test-runner-ui - a sesrvice runs the `ezid_ui_tests_docker.py` script
* test-runner-ezid-status- a service runs the `verify_ezid_status.py` script

Note: the `docker-compose.yml` was updated later with a single container combining both the UI and EZID status tests.

## Docker compose commands

Remove existing container by name:
```
docker rm -f selenium
```

Stop and remove all containers in the docker-compose file
```
docker compose down
```

Build docker images using the docker-compose file
```
docker compose build
```

Build docker images using the docker-compose file and then start the containers
```
docker compose up --build
```
* The selenium container starts up and waits on port 4444.
* The test-runner-ui container installs selenium, runs `ezid_ui_tests_docker.py`
* The test-runner-ezid-status container runs `verify_ezid_status.py`

Pass an environment variable to the docker compose command
```
APITEST_PASSWORD=xxx docker compose up --build
```

Rerunning just the test-runner-ui , remove the container once the command finishes executing
```
docker compose run --rm test-runner-ui
```

Re-run everything (fresh)
```
docker compose up --force-recreate
```

## Test without using docker-compose file

Start docker standalone Chrome container
```
docker run -d -p 4444:4444 --name selenium seleniarm/standalone-chromium:latest
```

Run the test script
```
python ezid_ui_tests_docker.py -e stg -u apitest -p apitest_password -n [email protected]
```

## Precedence Order for environment variables in Docker Compose

When using Docker Compose, environment variables can be set in various ways. The precedence order for these variables is as follows:
| Priority | Source | Example |
| --------- | --------- | ------- |
|1 | Inline in docker compose call | MY_SECRET_TOKEN=inline docker compose up |
|2 | Shell or GitHub Actions env: block | `env: MY_SECRET_TOKEN: ${{ secrets.MY_SECRET_TOKEN }}` |
|3 | .env file | .env → MY_SECRET_TOKEN=dotenv_value |
|4 | Hardcoded in docker-compose.yml | MY_SECRET_TOKEN: fallback_value |

## Run EZID tests using GitHub action
A GitHub action `Run EZID UI and functional tests in Docker` is defined in the `.github/workflow/ezid-tests.yml` file. The action is triggered by content changes to the `.env` file. It runs the `docker compose up --build` command to build the images, start the containers and then run the test suites.

Sample `.github/workflow/ezid-tests.yml`:
```
nname: Run EZID UI and functional tests in Docker

on:
workflow_dispatch:
push:
paths:
- '.env'


jobs:
ezid-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Run EZID Tests
env:
APITEST_PASSWORD: ${{ secrets.APITEST_PASSWORD }}
run: docker compose up --build --abort-on-container-exit

- name: Stop and remove containers
if: always()
run: docker compose down --volumes --remove-orphans
```

We ran into problems with the `--abort-on-container-exit` option which stops all containers when one of them exits. Since we have two test containers, one for UI and one for functional tests, using the `--abort-on-container-exit` option will always result in an imcomplete test suite. However, without the `--abort-on-container-exit` option, the selenium container will be up and running until the job time out.

A wrapper Shell script `run_ezid_test.sh` was developed to resolve this issue. The script combines both the UI and funcitonal tests so we can use a single container for all types of tests.

## How to run `run_ezid_test.sh`
The `run_ezid_test.sh` script takes 5 or 6 positional parameters:

Usage: ./run_ezid_tests.sh <environment> <username> <password> <email> <version> <debug_flag>

The paramters are all required except the last one `debug_flag` which is optional.

1. To run the script with the debug option, for example:
```
./run_ezid_tests.sh stg apitest apitest_password [email protected] v3.3.15 debug
```
The debug option will instruct the script to start a standalone Selenium Chrome container for you.

2. To run the script without the debug option:

First, manually start a standalone Selenium Chrome container:
```
docker run -d -p 4444:4444 --name selenium seleniarm/standalone-chromium:latest
```
Then run the tests:
```
./run_ezid_tests.sh stg apitest apitest_password [email protected] v3.3.15
```
Last, remove the `selenium` container:
```
docker rm -f selenium
```

3. To run the script using docker compose command
The `docker-compose.yml` file is defined with the following command:
```
command: ["./run_ezid_tests.sh", "${ENV}", "apitest", "${APITEST_PASSWORD}", "${NOTIFICATION_EMAIL}", "${EZID_VER}"]
```

The following environment variables are defined in the `.env` file:
- ENV
- NOTIFICATION_EMAIL
- EZID_VER

Pass the API password in command line:
```
APITEST_PASSWORD=xxx docker compose up --build
```

4. To run the script through GitHub action

Update the `.env` file then push the changes to GitHub. This will trigger a GitHub action to run the tests.
10 changes: 10 additions & 0 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.11-slim

WORKDIR /tests

COPY . .

RUN pip install -r requirements.txt



2 changes: 1 addition & 1 deletion scripts/ezid_ui_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def main():
parser.add_argument('-e', '--env', type=str, required=True, choices=['test', 'dev', 'stg', 'prd'], help='Environment')
parser.add_argument('-u', '--user', type=str, required=True, help='user name')
parser.add_argument('-p', '--password', type=str, required=True, help='password')
parser.add_argument('-m', '--user_email', type=str, required=True, help='Email address for testing the Contact Us form.')
parser.add_argument('-n', '--user_email', type=str, required=True, help='Email address for testing the Contact Us form.')
parser.add_argument('-l', '--headless', action='store_true', required=False, help='Enable headless mode.')

args = parser.parse_args()
Expand Down
Loading