Skip to content

Commit

Permalink
Update tests for SSH task collection and job execution
Browse files Browse the repository at this point in the history
  • Loading branch information
tcompa committed Sep 20, 2024
1 parent d528c11 commit 15872b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
9 changes: 6 additions & 3 deletions tests/v2/03_api/test_api_task_collection_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from fractal_server.app.schemas.v2 import CollectionStatusV2
from fractal_server.ssh._fabric import FractalSSH
from fractal_server.ssh._fabric import FractalSSHCollection


PREFIX = "api/v2/task"
Expand All @@ -17,16 +17,19 @@ async def test_task_collection_ssh_from_pypi(
override_settings_factory,
tmp_path: Path,
tmp777_path: Path,
fractal_ssh: FractalSSH,
fractal_ssh_collection: FractalSSHCollection,
current_py_version: str,
):

assert fractal_ssh_collection.size == 1
fractal_ssh = list(fractal_ssh_collection._data.values())[0]

# Define and create remote working directory
WORKING_BASE_DIR = (tmp777_path / "working_dir").as_posix()
fractal_ssh.mkdir(folder=WORKING_BASE_DIR)

# Assign FractalSSH object to app state
app.state.fractal_ssh = fractal_ssh
app.state.fractal_ssh_collection = fractal_ssh_collection

# Override settins with Python/SSH configurations
current_py_version_underscore = current_py_version.replace(".", "_")
Expand Down
13 changes: 5 additions & 8 deletions tests/v2/08_full_workflow/test_full_workflow_slurm_ssh_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from common_functions import workflow_with_non_python_task

from fractal_server.ssh._fabric import FractalSSH
from fractal_server.ssh._fabric import get_ssh_connection
from fractal_server.ssh._fabric import FractalSSHCollection
from tests.fixtures_slurm import SLURM_USER


Expand Down Expand Up @@ -39,8 +38,7 @@ async def test_workflow_with_non_python_task_slurm_ssh(
FRACTAL_SLURM_CONFIG_FILE=testdata_path / "slurm_config.json",
)

connection = get_ssh_connection()
app.state.fractal_ssh = FractalSSH(connection=connection)
app.state.fractal_ssh_collection = FractalSSHCollection()

monkeypatch.setattr("sys.stdin", io.StringIO(""))

Expand All @@ -55,7 +53,7 @@ async def test_workflow_with_non_python_task_slurm_ssh(
tmp777_path=tmp777_path,
)

app.state.fractal_ssh.close()
app.state.fractal_ssh_collection.close_all()


async def test_workflow_with_non_python_task_slurm_ssh_fail(
Expand Down Expand Up @@ -91,8 +89,7 @@ async def test_workflow_with_non_python_task_slurm_ssh_fail(
FRACTAL_SLURM_CONFIG_FILE=testdata_path / "slurm_config.json",
)

connection = get_ssh_connection()
app.state.fractal_ssh = FractalSSH(connection=connection)
app.state.fractal_ssh_collection = FractalSSHCollection()

monkeypatch.setattr("sys.stdin", io.StringIO(""))

Expand All @@ -110,4 +107,4 @@ async def test_workflow_with_non_python_task_slurm_ssh_fail(
assert "Could not create" in job_logs
assert "via SSH" in job_logs

app.state.fractal_ssh.close()
app.state.fractal_ssh_collection.close_all()

0 comments on commit 15872b7

Please sign in to comment.