From 980c127182aa903daf036e11ffc0f30d51f9d204 Mon Sep 17 00:00:00 2001
From: Philip ABBET <philip.abbet@idiap.ch>
Date: Tue, 19 Sep 2017 11:57:07 +0200
Subject: [PATCH] [tests] Mark some tests as slow

---
 beat/core/test/test_docker.py    | 11 +++++++++++
 beat/core/test/test_execution.py | 23 +++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/beat/core/test/test_docker.py b/beat/core/test/test_docker.py
index 04d78ebe..a211d951 100644
--- a/beat/core/test/test_docker.py
+++ b/beat/core/test/test_docker.py
@@ -41,6 +41,7 @@ import requests
 
 from ..dock import Host
 from . import tmp_prefix
+from .utils import slow
 
 
 # in case you want to see the printouts dynamically, set to ``True``
@@ -73,6 +74,7 @@ class AsyncTest(unittest.TestCase):
     assert not self.host.containers # All containers are gone
 
 
+  @slow
   def test_echo(self):
 
     string = "hello, world"
@@ -86,6 +88,7 @@ class AsyncTest(unittest.TestCase):
     self.assertEqual(self.host.stderr(container), '')
 
 
+  @slow
   def test_non_existing(self):
 
     container = self.host.create_container('debian:8.4', ["sdfsdfdsf329909092"])
@@ -95,6 +98,7 @@ class AsyncTest(unittest.TestCase):
     assert not self.host.containers # All containers are gone
 
 
+  @slow
   def test_timeout(self):
 
     sleep_for = 100 # seconds
@@ -118,6 +122,7 @@ class AsyncTest(unittest.TestCase):
     self.assertEqual(self.host.stderr(container), '')
 
 
+  @slow
   def test_does_not_timeout(self):
 
     sleep_for = 0.5 # seconds
@@ -133,6 +138,7 @@ class AsyncTest(unittest.TestCase):
     self.assertEqual(self.host.stderr(container), '')
 
 
+  @slow
   def test_memory_limit(self):
 
     cmd = ['python', '-c', '; '.join([
@@ -159,6 +165,7 @@ class AsyncTest(unittest.TestCase):
     self.assertEqual(self.host.stderr(container), '')
 
 
+  @slow
   def test_memory_limit2(self):
 
     cmd = ['python', '-c', '; '.join([
@@ -218,11 +225,13 @@ class AsyncTest(unittest.TestCase):
     self.assertEqual(self.host.wait(container), 137)
 
 
+  @slow
   def test_cpulimit_at_20percent(self):
     # runs 1 process that should consume at most 20% of the host CPU
     self._run_cpulimit(1, 20, 3)
 
 
+  @slow
   def test_cpulimit_at_100percent(self):
     # runs 4 processes that should consume 50% of the host CPU
     self._run_cpulimit(4, 100, 3)
@@ -235,6 +244,7 @@ class HostTest(unittest.TestCase):
     Host.images_cache = {}
 
 
+  @slow
   def test_images_cache(self):
     self.assertEqual(len(Host.images_cache), 0)
 
@@ -264,6 +274,7 @@ class HostTest(unittest.TestCase):
     self.assertTrue(stop - start < 1.0)
 
 
+  @slow
   def test_images_cache_file(self):
     self.assertEqual(len(Host.images_cache), 0)
 
diff --git a/beat/core/test/test_execution.py b/beat/core/test/test_execution.py
index d050e478..213c5564 100644
--- a/beat/core/test/test_execution.py
+++ b/beat/core/test/test_execution.py
@@ -54,6 +54,7 @@ from ..dock import Host
 
 from . import prefix, tmp_prefix
 from .utils import cleanup
+from .utils import slow
 
 
 class TestExecution(unittest.TestCase):
@@ -156,23 +157,29 @@ class TestExecution(unittest.TestCase):
       assert result.isclose(expected), "%r is not close enough to %r" % (result.as_dict(), expected.as_dict())
 
 
+  @slow
   def test_integers_addition_1(self):
     assert self.execute('user/user/integers_addition/1/integers_addition',
             [{'sum': 12272, 'nb': 10}]) is None
 
+  @slow
   def test_integers_addition_2(self):
     assert self.execute('user/user/integers_addition/2/integers_addition',
             [{'sum': 18392, 'nb': 10}]) is None
 
+  @slow
   def test_single_1_single(self):
     assert self.execute('user/user/single/1/single', [{'out_data': 42}]) is None
 
+  @slow
   def test_single_1_add(self):
     assert self.execute('user/user/single/1/single_add', [{'out_data': 43}]) is None
 
+  @slow
   def test_single_1_add2(self):
     assert self.execute('user/user/single/1/single_add2', [{'out_data': 44}]) is None
 
+  @slow
   def test_single_1_error(self):
     result = self.execute('user/user/single/1/single_error', [None])
     assert result
@@ -181,6 +188,7 @@ class TestExecution(unittest.TestCase):
     assert 'NameError' in result['user_error']
     self.assertEqual(result['system_error'], '')
 
+  @slow
   def test_single_1_crash(self):
     result = self.execute('user/user/single/1/single_crash', [None])
     assert result
@@ -189,6 +197,7 @@ class TestExecution(unittest.TestCase):
     assert 'NameError' in result['user_error']
     self.assertEqual(result['system_error'], '')
 
+  @slow
   def test_single_1_db_crash_done(self):
     result = self.execute('user/user/single/1/single_db_crash_done', [None])
     assert result
@@ -197,6 +206,7 @@ class TestExecution(unittest.TestCase):
     assert 'a = b' in result['user_error']
     self.assertEqual(result['system_error'], '')
 
+  @slow
   def test_single_1_db_crash_next(self):
     result = self.execute('user/user/single/1/single_db_crash_next', [None])
     assert result
@@ -205,15 +215,19 @@ class TestExecution(unittest.TestCase):
     assert 'a = b' in result['user_error']
     self.assertEqual(result['system_error'], '')
 
+  @slow
   def test_single_1_large(self):
     assert self.execute('user/user/single/1/single_large', [{'out_data': 2.0}]) is None
 
+  @slow
   def test_double_1(self):
     assert self.execute('user/user/double/1/double', [{'out_data': 42}]) is None
 
+  @slow
   def test_triangle_1(self):
     assert self.execute('user/user/triangle/1/triangle', [{'out_data': 42}]) is None
 
+  @slow
   def test_too_many_nexts(self):
     result = self.execute('user/user/triangle/1/too_many_nexts', [None])
     assert result
@@ -221,27 +235,35 @@ class TestExecution(unittest.TestCase):
     assert result['user_error']
     assert 'no more data' in result['user_error']
 
+  @slow
   def test_double_triangle_1(self):
     assert self.execute('user/user/double_triangle/1/double_triangle', [{'out_data': 42}]) is None
 
+  @slow
   def test_inputs_mix_1(self):
     assert self.execute('user/user/inputs_mix/1/test', [{'sum': 12272, 'nb': 10}]) is None
 
+  @slow
   def test_inputs_mix_2(self):
     assert self.execute('user/user/inputs_mix/2/test', [{'sum': 13529, 'nb': 10}]) is None
 
+  @slow
   def test_inputs_mix_3(self):
     assert self.execute('user/user/inputs_mix/3/test', [{'sum': 19523, 'nb': 10}]) is None
 
+  @slow
   def test_inputs_mix_3b(self):
     assert self.execute('user/user/inputs_mix/3/test2', [{'sum': 19533, 'nb': 10}]) is None
 
+  @slow
   def test_inputs_mix_4(self):
     assert self.execute('user/user/inputs_mix/4/test', [{'sum': 25150, 'nb': 10}]) is None
 
+  @slow
   def test_inputs_mix_4b(self):
     assert self.execute('user/user/inputs_mix/4/test2', [{'sum': 25170, 'nb': 10}]) is None
 
+  @slow
   def test_integers_labelled_1(self):
     assert self.execute('user/user/integers_labelled/1/test', [
         {
@@ -296,6 +318,7 @@ class TestDockerExecution(TestExecution):
                           proxy_mode=self.proxy_mode)
 
 
+  @slow
   def test_cxx_double_1(self):
     assert self.execute('user/user/double/1/cxx_double', [{'out_data': 42}]) is None
 
-- 
GitLab