-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Is3418/validation with
ooil test my/osparc/service
(#3479)
- Loading branch information
Showing
18 changed files
with
246 additions
and
52 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
1.0.2 | ||
1.0.3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
IFS=$'\n\t' | ||
|
||
|
||
IMAGE_NAME="${DOCKER_REGISTRY:-itisfoundation}/service-integration:${DOCKER_IMAGE_TAG:-master-github-latest}" | ||
WORKDIR="$(pwd)" | ||
|
||
run() { | ||
docker run \ | ||
-it \ | ||
--rm \ | ||
--volume="/etc/group:/etc/group:ro" \ | ||
--volume="/etc/passwd:/etc/passwd:ro" \ | ||
--user="$(id --user "$USER")":"$(id --group "$USER")" \ | ||
--volume "$WORKDIR":/src \ | ||
--workdir=/src \ | ||
"$IMAGE_NAME" \ | ||
"$@" | ||
} | ||
|
||
|
||
run "$@" |
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
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
21 changes: 21 additions & 0 deletions
21
packages/service-integration/src/service_integration/commands/test.py
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,21 @@ | ||
from pathlib import Path | ||
|
||
import rich | ||
import typer | ||
|
||
from ..service import pytest_runner | ||
|
||
|
||
def main( | ||
service_dir: Path = typer.Argument( | ||
..., help="Root directory of the service under test" | ||
), | ||
): | ||
"""Runs tests against service directory""" | ||
|
||
if not service_dir.exists(): | ||
raise typer.BadParameter("Invalid path to service directory") | ||
|
||
rich.print(f"Testing '{service_dir.resolve()}' ...") | ||
error_code = pytest_runner.main(service_dir=service_dir, extra_args=[]) | ||
raise typer.Exit(code=error_code) |
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,22 @@ | ||
import warnings | ||
|
||
warnings.warn( | ||
f"{__name__} is deprecated for cookiecutter-osparc-service>0.4.Use directoy test CLI instead." | ||
"See https://github.com/ITISFoundation/cookiecutter-osparc-service/releases/tag/v0.4.0", | ||
DeprecationWarning, | ||
) | ||
|
||
|
||
def pytest_addoption(parser): | ||
group = parser.getgroup("service-integration") | ||
group.addoption( | ||
"--service-dir", | ||
action="store", | ||
help="Base directory for target service", | ||
) | ||
|
||
group.addoption( | ||
"--metadata", | ||
action="store", | ||
help="metadata yaml configuration 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
Empty file.
48 changes: 48 additions & 0 deletions
48
packages/service-integration/src/service_integration/service/pytest_runner.py
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,48 @@ | ||
import logging | ||
import sys | ||
import tempfile | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import pytest | ||
|
||
CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent | ||
TESTS_DIR = CURRENT_DIR / "tests" | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def main( | ||
service_dir: Path, *, debug: bool = False, extra_args: Optional[list[str]] = None | ||
) -> int: | ||
|
||
pytest_args = [ | ||
# global cache options | ||
"--cache-clear", | ||
f"--override-ini=cache_dir={tempfile.gettempdir()}/.pytest_cache__service_integration", | ||
# tests | ||
f"{TESTS_DIR}", | ||
# custom options | ||
f"--service-under-test-dir={service_dir}", | ||
] | ||
|
||
if debug: | ||
pytest_args += ["-vv", "--log-level=DEBUG", "--pdb"] | ||
|
||
if extra_args: | ||
pytest_args += extra_args | ||
|
||
logger.debug("Running 'pytest %s'", " ".join(pytest_args)) | ||
exit_code = pytest.main(pytest_args) | ||
logger.debug("exit with code=%d", exit_code) | ||
return exit_code | ||
|
||
|
||
if __name__ == "__main__": | ||
# Entrypoint for stand-alone 'service_integration/service' package | ||
sys.exit( | ||
main( | ||
service_dir=Path(sys.argv[1]), | ||
extra_args=sys.argv[2:], | ||
) | ||
) |
Oops, something went wrong.