Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests #132

Merged
merged 40 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d9374f0
add test cases for web and tiles
hiddewie Oct 30, 2024
45bde08
bbox
hiddewie Oct 30, 2024
e181189
add proxy tests
hiddewie Oct 30, 2024
cf8a8f8
move to correct directory
hiddewie Oct 30, 2024
b31c3c7
print logs
hiddewie Oct 31, 2024
57d1265
print logs
hiddewie Oct 31, 2024
03184a6
martin healthcheck
hiddewie Oct 31, 2024
3a6ec0f
list generated tiles
hiddewie Oct 31, 2024
f9e3d1b
cancel in progress tests
hiddewie Oct 31, 2024
3da6be7
hurl 5
hiddewie Oct 31, 2024
4423be1
no deps for tiles
hiddewie Oct 31, 2024
dcf91f5
reuse imported DB
hiddewie Oct 31, 2024
e7492d1
needs
hiddewie Oct 31, 2024
6640aaa
cache import image
hiddewie Oct 31, 2024
6449fa3
run
hiddewie Oct 31, 2024
c5f6910
run
hiddewie Oct 31, 2024
34fd83c
docker login
hiddewie Oct 31, 2024
53ff893
pull quotes
hiddewie Oct 31, 2024
a05997c
wait for DB
hiddewie Oct 31, 2024
df3ee42
dont build API
hiddewie Oct 31, 2024
824aeca
no deps
hiddewie Oct 31, 2024
12433d7
inspect
hiddewie Oct 31, 2024
800b639
inspect
hiddewie Oct 31, 2024
a757dfd
build and run tile tests
hiddewie Oct 31, 2024
1e53a54
just detach
hiddewie Oct 31, 2024
a57dee5
skip UI tests
hiddewie Oct 31, 2024
3b66a49
no bounds test
hiddewie Oct 31, 2024
eb337b3
tile tests
hiddewie Oct 31, 2024
98ef1c9
tile does not exist
hiddewie Oct 31, 2024
1bb9dd5
document Hurl tests
hiddewie Oct 31, 2024
a800b16
TODO
hiddewie Oct 31, 2024
6980141
Add cypress UI tests
hiddewie Oct 31, 2024
1c9f06d
working directory
hiddewie Oct 31, 2024
5bd4640
restore other tests
hiddewie Oct 31, 2024
24a65ac
build API only once
hiddewie Nov 2, 2024
46754fc
remove hurl installation
hiddewie Nov 2, 2024
521de6b
only run cypress tests once
hiddewie Nov 2, 2024
431b827
log into docker for API push
hiddewie Nov 2, 2024
a21b859
log in to pull DB and API
hiddewie Nov 2, 2024
841f545
ref_name
hiddewie Nov 2, 2024
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
301 changes: 283 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ name: Test
on:
push: ~

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != 'master' }}

jobs:
test:
name: Test
import:
name: Import data
runs-on: ubuntu-latest

steps:
Expand All @@ -15,12 +19,12 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install Hurl
env:
VERSION: '4.3.0'
run: |
curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/$VERSION/hurl_${VERSION}_amd64.deb
sudo apt update && sudo apt install ./hurl_${VERSION}_amd64.deb
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get Date
id: get-date
Expand All @@ -42,26 +46,287 @@ jobs:
run: |
curl --location --fail --output data/berlin.osm.pbf https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf

- name: Import data
- name: Start database
env:
OSM2PGSQL_DATAFILE: berlin.osm.pbf
run: |
docker compose run --build import import
docker compose build db
docker compose up --no-build --wait db

- name: Build import image
run: |
docker compose build import
if [[ "${{ github.ref_name }}" = "master" ]]; then
docker compose push import
fi

# - name: Start tile server
# run: |
# docker compose up --build --wait martin
- name: Import data
env:
OSM2PGSQL_DATAFILE: berlin.osm.pbf
run: |
docker compose run import import

- name: Prepare and start API
run: |
docker compose stop db
DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')"
docker commit "$DB_CONTAINER_ID" ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }}
docker push ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }}

build-api:
name: Build API
runs-on: ubuntu-latest

needs:
- import

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull database
run: |
docker pull ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }}
docker tag ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }} ghcr.io/hiddewie/openrailwaymap-import-db:latest

- name: Start database
run: |
docker compose up --no-build --wait db

- name: Prepare API
run: |
api/prepare-api.sh
docker compose up --wait api

# - name: Start web server
# run: |
# docker compose up --build martin-proxy
- name: Push API image
run: |
docker tag ghcr.io/hiddewie/openrailwaymap-api:latest ghcr.io/hiddewie/openrailwaymap-api:${{ github.sha }}
docker push ghcr.io/hiddewie/openrailwaymap-api:${{ github.sha }}

test-api:
name: Test API
runs-on: ubuntu-latest

needs:
- build-api

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install Hurl
env:
VERSION: '5.0.1'
run: |
curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/$VERSION/hurl_${VERSION}_amd64.deb
sudo apt update && sudo apt install ./hurl_${VERSION}_amd64.deb

- name: Pull API
run: |
docker pull ghcr.io/hiddewie/openrailwaymap-api:${{ github.sha }}
docker tag ghcr.io/hiddewie/openrailwaymap-api:${{ github.sha }} ghcr.io/hiddewie/openrailwaymap-api:latest

- name: Start API
run: |
docker compose up --wait --no-build api

- name: Run API tests
working-directory: api
run: |
hurl --test --verbose --variable base_url=http://localhost:5000/api tests/api.hurl
hurl --test --verbose --variable base_url=http://localhost:5000/api test/api.hurl

test-proxy:
name: Test proxy
runs-on: ubuntu-latest

needs:
- import

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install Hurl
env:
VERSION: '5.0.1'
run: |
curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/$VERSION/hurl_${VERSION}_amd64.deb
sudo apt update && sudo apt install ./hurl_${VERSION}_amd64.deb

- name: Pull database
run: |
docker pull ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }}
docker tag ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }} ghcr.io/hiddewie/openrailwaymap-import-db:latest

- name: Start database
run: |
docker compose up --no-build --wait db

- name: Start tile server
run: |
docker compose build martin
docker compose up --no-build --detach martin

- name: Start web server
run: |
docker compose build martin-proxy
docker compose up --no-build --wait martin-proxy

- name: Run proxy tests
working-directory: proxy
run: |
hurl --test --verbose --variable base_url=http://localhost:8000 test/proxy.hurl

test-tiles:
name: Test tiles
runs-on: ubuntu-latest

needs:
- import

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install Hurl
env:
VERSION: '5.0.1'
run: |
curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/$VERSION/hurl_${VERSION}_amd64.deb
sudo apt update && sudo apt install ./hurl_${VERSION}_amd64.deb

- name: Pull database
run: |
docker pull ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }}
docker tag ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }} ghcr.io/hiddewie/openrailwaymap-import-db:latest

- name: Start database
run: |
docker compose up --no-build --wait db

- name: Generate tiles
env:
BBOX: '12.9611,52.2934,13.8126,52.7147'
run: |
for tile in low-med high standard speed signals electrification; do
env "TILES=$tile" docker compose up --no-build martin-cp
done

- name: List generated tiles
run: |
ls -la tiles/*.mbtiles

- name: Start martin with tiles
run: |
docker compose build martin-static
docker compose up --no-build --wait martin-static

- name: Run static tile tests
working-directory: tiles
run: |
hurl --test --verbose --variable base_url=http://localhost:3000 test/tiles.hurl

test-ui:
name: Test UI
runs-on: ubuntu-latest

needs:
- test-proxy
- test-api
- build-api
- test-tiles

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull database
run: |
docker pull ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }}
docker tag ghcr.io/hiddewie/openrailwaymap-import-db:${{ github.sha }} ghcr.io/hiddewie/openrailwaymap-import-db:latest

- name: Pull API
run: |
docker pull ghcr.io/hiddewie/openrailwaymap-api:${{ github.sha }}
docker tag ghcr.io/hiddewie/openrailwaymap-api:${{ github.sha }} ghcr.io/hiddewie/openrailwaymap-api:latest

- name: Start database
run: |
docker compose up --no-build --wait db

- name: Start tile server
run: |
docker compose build martin
docker compose up --no-build --detach martin

- name: Start web server
run: |
docker compose build martin-proxy
docker compose up --no-build --wait martin-proxy

- name: Start API
run: |
docker compose up --wait --no-build api

- name: Run UI tests
uses: cypress-io/github-action@v6
with:
working-directory: proxy/test/ui
browser: chrome

- name: Store
uses: actions/upload-artifact@v4
if: always()
with:
name: screenshots
path: proxy/test/ui/cypress/screenshots
if-no-files-found: warn
22 changes: 22 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,25 @@ flyctl deploy --config proxy.fly.toml --local-only
```

The OpenRailwayMap is now available on https://openrailwaymap.fly.dev.

## Tests

Tests use [*hurl*](https://hurl.dev/docs/installation.html).

Run tests against the API:

```shell
hurl --test --verbose --variable base_url=http://localhost:5000/api api/test/api.hurl
```

Run tests against the proxy:

```shell
hurl --test --verbose --variable base_url=http://localhost:8000 proxy/test/proxy.hurl
```

Run tests against the tiles:

```shell
hurl --test --verbose --variable base_url=http://localhost:3000 tiles/test/tiles.hurl
```
File renamed without changes.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ services:
martin-static:
build:
dockerfile: martin-static.Dockerfile
ports:
- '3000:3000'

martin-proxy:
build:
Expand Down
Loading