-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration test for a Simple Service example (#516)
* Move assertions used in blender and yacat tests to a separate module * Add cmdline param specifying instance running time to simple_service.py * Add integration test that runs the simple service example with goth * Fix imports from tests.goth.assertions module * Rename tests/goth to tests/goth_tests to avoid conflicts with goth pkg
- Loading branch information
Showing
17 changed files
with
221 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Temporal assertions used in `goth` integration tests. | ||
The assertions express properties of lines of output printed by requestor | ||
scripts (e.g. `blender.py`) to their stdout or stderr. For example, one such | ||
property would be that if the requestor script prints a line containing | ||
the string "Agreement confirmed by provider P", for any name P, then | ||
eventually it will also print a line containing "Accepted invoice from P". | ||
""" | ||
import logging | ||
import re | ||
from typing import Set | ||
|
||
from goth.assertions import EventStream | ||
|
||
|
||
logger = logging.getLogger("goth.test.assertions") | ||
|
||
|
||
async def assert_no_errors(output_lines: EventStream[str]): | ||
"""Assert that no output line contains the substring `ERROR`.""" | ||
async for line in output_lines: | ||
if "ERROR" in line: | ||
raise AssertionError("Command reported ERROR") | ||
|
||
|
||
async def assert_all_invoices_accepted(output_lines: EventStream[str]): | ||
"""Assert that an invoice is accepted for every provider that confirmed an agreement.""" | ||
unpaid_agreement_providers = set() | ||
|
||
async for line in output_lines: | ||
m = re.search("Agreement confirmed by provider '([^']*)'", line) | ||
if m: | ||
prov_name = m.group(1) | ||
logger.debug("assert_all_invoices_accepted: adding provider '%s'", prov_name) | ||
unpaid_agreement_providers.add(prov_name) | ||
m = re.search("Accepted invoice from '([^']*)'", line) | ||
if m: | ||
prov_name = m.group(1) | ||
logger.debug("assert_all_invoices_accepted: adding invoice for '%s'", prov_name) | ||
unpaid_agreement_providers.remove(prov_name) | ||
|
||
if unpaid_agreement_providers: | ||
raise AssertionError(f"Unpaid agreements for: {','.join(unpaid_agreement_providers)}") | ||
|
||
|
||
async def assert_tasks_processed(tasks: Set[str], status: str, output_lines: EventStream[str]): | ||
"""Assert that for every task in `tasks` a line with `Task {status}` will appear.""" | ||
remaining_tasks = tasks.copy() | ||
|
||
async for line in output_lines: | ||
m = re.search(rf".*Task {status} .* task data: (.+)$", line) | ||
if m: | ||
task_data = m.group(1) | ||
logger.debug("assert_tasks_processed: Task %s: %s", status, task_data) | ||
remaining_tasks.discard(task_data) | ||
if not remaining_tasks: | ||
return | ||
|
||
raise AssertionError(f"Tasks not {status}: {remaining_tasks}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.