Skip to content

Commit

Permalink
Github workflow env vars
Browse files Browse the repository at this point in the history
Add env vars to github workflow file as database scripts and
integration tests use environment variables.
  • Loading branch information
genie9 committed Dec 13, 2021
1 parent e2e1070 commit d0c83ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ jobs:
docker-compose --env-file .env.example up -d --build
sleep 30
- name: Run Integration test
- name: Clear database
run: |
python tests/integration/clean_db.py
env:
MONGO_HOST: localhost:27017
MONGO_DATABASE: default
MONGO_AUTHDB: admin

- name: Run Integration test
run: |
python tests/integration/run_tests.py
env:
BASE_URL: http://localhost:5430
ISS_URL: http://localhost:8000

- name: Collect logs from docker
if: ${{ failure() }}
Expand All @@ -58,10 +68,20 @@ jobs:
docker-compose -f docker-compose-tls.yml --env-file .env.example up -d
sleep 30
- name: Run Integration test
- name: Clear database
run: |
python tests/integration/clean_db.py --tls
env:
MONGO_HOST: localhost:27017
MONGO_DATABASE: default
MONGO_AUTHDB: admin

- name: Run Integration test
run: |
python tests/integration/run_tests.py
env:
BASE_URL: http://localhost:5430
ISS_URL: http://localhost:8000

- name: Collect logs from docker
if: ${{ failure() }}
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import asyncio
import json
import logging
import os
import urllib
import xml.etree.ElementTree as ET
from pathlib import Path
Expand Down Expand Up @@ -47,8 +48,8 @@
("experiment", "ERX000119.json", "ERX000119.json"),
("analysis", "ERZ266973.json", "ERZ266973.json"),
]
base_url = "http://localhost:5430"
mock_auth_url = "http://localhost:8000"
base_url = os.getenv("BASE_URL", "http://localhost:5430")
mock_auth_url = os.getenv("ISS_URL", "http://localhost:8000")
objects_url = f"{base_url}/objects"
drafts_url = f"{base_url}/drafts"
templates_url = f"{base_url}/templates"
Expand Down Expand Up @@ -357,8 +358,8 @@ async def post_folder(sess, data):
"""
async with sess.post(f"{folders_url}", data=json.dumps(data)) as resp:
LOG.debug("Adding new folder")
assert resp.status == 201, "HTTP Status code error"
ans = await resp.json()
assert resp.status == 201, f"HTTP Status code error {resp.status} {ans}"
return ans["folderId"]


Expand Down Expand Up @@ -937,13 +938,13 @@ async def test_getting_folders_filtered_by_name(sess):
folders.append(await post_folder(sess, folder_data))

async with sess.get(f"{folders_url}?name=filter") as resp:
assert resp.status == 200
ans = await resp.json()
assert resp.status == 200, f"HTTP Status code error {resp.status} {ans}"
assert ans["page"]["totalFolders"] == 3

async with sess.get(f"{folders_url}?name=extra") as resp:
assert resp.status == 200
ans = await resp.json()
assert resp.status == 200, f"HTTP Status code error {resp.status} {ans}"
assert ans["page"]["totalFolders"] == 1

async with sess.get(f"{folders_url}?name=2021 special") as resp:
Expand Down

0 comments on commit d0c83ab

Please sign in to comment.