Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 85c8aaf

Browse files
committed
Update build logic
1 parent 99027e1 commit 85c8aaf

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

build.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
HERE = os.path.abspath(os.path.dirname(__file__))
1111

1212
TEST_DIRECTORY_PATH = "tests"
13-
TEST_MARKER_NO_SLOW = "no_slow"
1413

1514

1615
def main(args: Dict[str, Union[bool, str]]) -> None:
@@ -39,7 +38,7 @@ def main(args: Dict[str, Union[bool, str]]) -> None:
3938
build_python.build_distribution(exit_on_error=True)
4039

4140
if args[build_utils.FLAG_CHECK]:
42-
build_python.code_checks(exit_on_error=True)
41+
build_python.code_checks(exit_on_error=True, safety=False)
4342

4443
if args.get(build_utils.FLAG_TEST):
4544
# Remove coverage files

tests/functional/test_integration.py

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import docker
1010
import requests
11-
from docker.client import DockerClient
11+
import storm.__main__ as storm
1212

13-
from lazycluster import Runtime
13+
from lazycluster import Runtime, RuntimeGroup, RuntimeManager, RuntimeTask
1414

1515
from .config import RUNTIME_DOCKER_IMAGE, RUNTIME_NAMES, WORKSPACE_PORT
1616

@@ -29,6 +29,13 @@ def setup_module(module: ModuleType) -> None:
2929
_setup_ssh_connection_to_runtime(runtime_name)
3030

3131

32+
def teardown_module(module: ModuleType) -> None:
33+
"""teardown any state that was previously setup with a setup_module
34+
method.
35+
"""
36+
_remove_runtimes()
37+
38+
3239
class TestRuntime:
3340
def test_setup(self) -> None:
3441
for runtime_name in RUNTIME_NAMES:
@@ -47,17 +54,40 @@ def test_setup(self) -> None:
4754

4855
Runtime(RUNTIME_NAMES[0])
4956

50-
# def test_echo(self):
51-
# rt = Runtime(RUNTIME_NAMES[len(RUNTIME_NAMES - 1)])
52-
# msg = "Hello Runtime"
53-
# assert rt.echo(msg) == msg
57+
def test_echo(self) -> None:
58+
runtime_name = RUNTIME_NAMES[len(RUNTIME_NAMES) - 1]
59+
rt = Runtime(runtime_name)
60+
msg = f"Hello Runtime {runtime_name}"
61+
assert rt.echo(msg).rstrip("\n") == msg
62+
63+
def test_working(self) -> None:
64+
runtime_name = RUNTIME_NAMES[0]
65+
exp_working_dir = "/etc"
66+
rt = Runtime(runtime_name, working_dir=exp_working_dir)
67+
act_working_dir = rt.echo("${PWD}").rstrip("\n")
68+
assert exp_working_dir == act_working_dir
69+
70+
task = RuntimeTask("get-working-dir").run_command("echo ${PWD}")
71+
rt.execute_task(task, execute_async=False)
72+
assert exp_working_dir == rt.execution_log(task.name)[0].rstrip("\n").rstrip(
73+
"\r"
74+
)
5475

5576

56-
def teardown_module(module: ModuleType) -> None:
57-
"""teardown any state that was previously setup with a setup_module
58-
method.
59-
"""
60-
_remove_runtimes()
77+
class TestRuntimeGroup:
78+
def test_creation(self) -> None:
79+
runtime_group = RuntimeGroup(hosts=RUNTIME_NAMES)
80+
for runtime_name in RUNTIME_NAMES:
81+
assert runtime_name in runtime_group._runtimes
82+
assert isinstance(runtime_group._runtimes[runtime_name], Runtime)
83+
84+
85+
class TestRuntimeManager:
86+
def test_create_group(self) -> None:
87+
runtime_group = RuntimeManager().create_group()
88+
for runtime_name in RUNTIME_NAMES:
89+
assert runtime_name in runtime_group._runtimes
90+
assert isinstance(runtime_group._runtimes[runtime_name], Runtime)
6191

6292

6393
# -------------------------------------------------------------------------
@@ -72,6 +102,9 @@ def _remove_runtimes() -> None:
72102
except docker.errors.NotFound:
73103
# TODO: handle create a docker container if not running as containerized test
74104
print(f"Conatiner {runtime_name} not found")
105+
# Delete ssh config as well, because the ssh setup fails
106+
# when testing against multiple python versions
107+
storm.delete(runtime_name)
75108

76109

77110
def _get_current_container_id() -> str:
@@ -84,7 +117,7 @@ def _get_current_container_id() -> str:
84117
).stdout.rstrip("\n")
85118

86119

87-
def _start_runtime_container(name: str, client: DockerClient) -> None:
120+
def _start_runtime_container(name: str, client: docker.DockerClient) -> None:
88121
try:
89122
container = client.containers.run(
90123
RUNTIME_DOCKER_IMAGE,

0 commit comments

Comments
 (0)