Skip to content

Commit

Permalink
Run jobs in tests with a particular preset ("cpu-small") (#2764)
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored Jun 30, 2022
1 parent 71d466f commit 46a4dcf
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 133 deletions.
25 changes: 23 additions & 2 deletions neuro-cli/tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self, nmrc_path: Optional[Path], tmp_path: Path) -> None:
self._tmpstorage = URL(f"storage:{self.tmpstoragename}")
self._closed = False
self._executed_jobs: List[str] = []
self.DEFAULT_PRESET = os.environ.get("E2E_PRESET", "cpu-small")

def close(self) -> None:
if not self._closed:
Expand Down Expand Up @@ -489,6 +490,25 @@ def run_cli(
print(f"neuro stderr: {err}")
return SysCap(out, err)

def run_cli_run_job(
self,
arguments: List[Any],
*,
verbosity: int = 0,
network_timeout: float = NETWORK_TIMEOUT,
input: Optional[str] = None,
timeout: float = 300,
) -> SysCap:
if self.DEFAULT_PRESET:
arguments = ["-s", self.DEFAULT_PRESET, *arguments]
return self.run_cli(
["job", "run", *arguments],
verbosity=verbosity,
network_timeout=network_timeout,
input=input,
timeout=timeout,
)

def find_job_id(self, arg: str) -> Optional[str]:
match = JOB_ID_PATTERN.search(arg)
return match.group(1) if match else None
Expand Down Expand Up @@ -909,8 +929,9 @@ def go(
if http_auth:
description += " with authentication"
args += ["-d", description]
capture = helper.run_cli(
["-q", "job", "run", "--detach", *args, NGINX_IMAGE_NAME, "--", command]
capture = helper.run_cli_run_job(
["--detach", *args, NGINX_IMAGE_NAME, "--", command],
verbosity=-1,
)
http_job_id = capture.out
status: JobDescription = helper.job_info(http_job_id, wait_start=True)
Expand Down
2 changes: 1 addition & 1 deletion neuro-cli/tests/e2e/test_e2e_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_images_complete_lifecycle(
assert image in local_images

# Execute image and check result
captured = helper.run_cli(["-q", "run", "--no-wait-start", str(image_url)])
captured = helper.run_cli_run_job(["--no-wait-start", str(image_url)], verbosity=-1)
assert not captured.err
job_id = captured.out
assert job_id.startswith("job-")
Expand Down
Loading

0 comments on commit 46a4dcf

Please sign in to comment.