Skip to content

Commit

Permalink
add PS run workflow test
Browse files Browse the repository at this point in the history
  • Loading branch information
MehmedGIT committed Jan 24, 2024
1 parent a64b3b5 commit c69b334
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
11 changes: 7 additions & 4 deletions tests/network/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ services:
context: ../../
dockerfile: Dockerfile
args:
BASE_IMAGE: 'ubuntu:20.04'
BASE_IMAGE: 'ubuntu:22.04'
target: ocrd_core_test
hostname: processing-server-host
container_name: ocrd_network_processing_server
Expand All @@ -75,7 +75,8 @@ services:
volumes:
- "/tmp/ocrd_network_logs:/tmp/ocrd_network_logs"
- "/tmp/ocrd_network_sockets:/tmp/ocrd_network_sockets"
- "../assets:/tmp/assets"
- "../assets/kant_aufklaerung_1784:/tmp/assets/kant_aufklaerung_1784"
- "./dummy-workflow.txt:/tmp/assets/dummy-workflow.txt"
- "./ocrd_logging.conf:/etc/ocrd_logging.conf"
command: |
/bin/bash -c "echo -e \"
Expand Down Expand Up @@ -107,7 +108,8 @@ services:
volumes:
- "/tmp/ocrd_network_logs:/tmp/ocrd_network_logs"
- "/tmp/ocrd_network_sockets:/tmp/ocrd_network_sockets"
- "../assets:/tmp/assets"
- "../assets/kant_aufklaerung_1784:/tmp/assets/kant_aufklaerung_1784"
- "./dummy-workflow.txt:/tmp/assets/dummy-workflow.txt"
- "./ocrd_logging.conf:/etc/ocrd_logging.conf"
command: >
ocrd-dummy worker
Expand All @@ -125,7 +127,8 @@ services:
volumes:
- "/tmp/ocrd_network_logs:/tmp/ocrd_network_logs"
- "/tmp/ocrd_network_sockets:/tmp/ocrd_network_sockets"
- "../assets:/tmp/assets"
- "../assets/kant_aufklaerung_1784:/tmp/assets/kant_aufklaerung_1784"
- "./dummy-workflow.txt:/tmp/assets/dummy-workflow.txt"
- "./ocrd_logging.conf:/etc/ocrd_logging.conf"
environment:
DB_NAME: ocrd_network_test
Expand Down
31 changes: 26 additions & 5 deletions tests/network/test_processing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ def test_processing_server_deployed_processors():
response = get(test_url)
processors = response.json()
assert response.status_code == 200, \
f'Processing server is not reachable on: {test_url}, {response.status_code}'
f'Processing server: {test_url}, {response.status_code}'
assert processors == [], f'Mismatch in deployed processors'


def test_processing_server_processing_request():
# Note: the path_to_mets is volume mapped
# TODO: Still failing test with internal error 500
def _test_processing_server_processing_request():
# Note: the used path is volume mapped
test_processing_job_input = {
"path_to_mets": "/tmp/assets/kant_aufklaerung_1784/data/mets.xml",
"input_file_grps": ['OCR-D-IMG'],
Expand All @@ -37,6 +38,26 @@ def test_processing_server_processing_request():
}
test_processor = 'ocrd-dummy'
test_url = f'{PROCESSING_SERVER_URL}/processor/run/{test_processor}'
response = post(url=test_url, data=test_processing_job_input)
response = post(
url=test_url,
headers={"accept": "application/json"},
json=test_processing_job_input
)
assert response.status_code == 200, \
f'Processing server is not reachable on: {test_url}, {response.status_code}'
f'Processing server: {test_url}, {response.status_code}'


def test_processing_server_workflow_request():
# Note: the used paths are volume mapped
path_to_mets = "/tmp/assets/kant_aufklaerung_1784/data/mets.xml"
path_to_dummy_wf = "/tmp/assets/dummy-workflow.txt"

test_url = f"{PROCESSING_SERVER_URL}/workflow?mets_path={path_to_mets}&page_wise=False"
response = post(
url=test_url,
files={"workflow": open(path_to_dummy_wf, 'rb')}
)
assert response.status_code == 201, \
f'Processing server: {test_url}, {response.status_code}'

# TODO: Check workflow status here

0 comments on commit c69b334

Please sign in to comment.