Commit 1d4ab56a authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][test_docker_execution] Code cleanup

parent e96abdf7
......@@ -37,7 +37,8 @@
# Tests for experiment execution within Docker containers
import os
import subprocess
import subprocess # nosec
import nose.tools
from ..dock import Host
from ..execution import DockerExecutor
......@@ -115,10 +116,10 @@ class TestDockerExecution(BaseExecutionMixIn):
print(self.host.logs(builder_container))
self.host.rm(builder_container)
assert status == 0
nose.tools.eq_(status, 0)
# Update the tmp prefix with the latest content
subprocess.check_call(
subprocess.check_call( # nosec
[
"rsync",
"-arz",
......@@ -138,7 +139,7 @@ class TestDockerExecution(BaseExecutionMixIn):
network_name=network_name,
)
assert result is None
nose.tools.assert_is_none(result)
@slow
def test_custom_port_range(self):
......@@ -148,21 +149,25 @@ class TestDockerExecution(BaseExecutionMixIn):
port_range="50000:50100",
)
assert result is None
nose.tools.assert_is_none(result)
@slow
def test_single_1_prepare_error(self):
result = self.execute("user/user/single/1/prepare_error", [None])
assert result["status"] == 1
assert result["user_error"] == "'Could not prepare algorithm (returned False)'"
nose.tools.eq_(result["status"], 1)
nose.tools.eq_(
result["user_error"], "'Could not prepare algorithm (returned False)'"
)
@slow
def test_single_1_setup_error(self):
result = self.execute("user/user/single/1/setup_error", [None])
assert result["status"] == 1
assert result["user_error"] == "'Could not setup algorithm (returned False)'"
nose.tools.eq_(result["status"], 1)
nose.tools.eq_(
result["user_error"], "'Could not setup algorithm (returned False)'"
)
# NOT COMPATIBLE YET WITH THE NEW API
# @slow
......@@ -179,20 +184,19 @@ class TestDockerExecution(BaseExecutionMixIn):
[{"out_data": 42}],
datasets_uid=datasets_uid,
)
assert result is None
nose.tools.assert_is_none(result)
@slow
def test_cxx_double_sequential(self):
datasets_uid = os.getuid()
self.build_algorithm("prefix/algorithms/user/cxx_integers_echo_sequential")
assert (
nose.tools.assert_is_none(
self.execute(
"user/user/double/1/cxx_double_sequential",
[{"out_data": 42}],
datasets_uid=datasets_uid,
)
is None
)
@slow
......@@ -200,13 +204,12 @@ class TestDockerExecution(BaseExecutionMixIn):
datasets_uid = os.getuid()
self.build_algorithm("prefix/algorithms/user/cxx_integers_echo_autonomous")
assert (
nose.tools.assert_is_none(
self.execute(
"user/user/double/1/cxx_double_autonomous",
[{"out_data": 42}],
datasets_uid=datasets_uid,
)
is None
)
@slow
......@@ -226,5 +229,7 @@ class TestDockerExecution(BaseExecutionMixIn):
datasets_uid=datasets_uid,
)
assert result["status"] == 255
assert "[sys] C++ algorithm can't be analyzers" in result["stderr"]
nose.tools.eq_(result["status"], 255)
nose.tools.assert_true(
"[sys] C++ algorithm can't be analyzers" in result["stderr"]
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment