diff --git a/circusweb/tests/__init__.py b/circusweb/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/circusweb/tests/test_utils.py b/circusweb/tests/test_utils.py deleted file mode 100644 index 3838296..0000000 --- a/circusweb/tests/test_utils.py +++ /dev/null @@ -1,52 +0,0 @@ -from time import time - -from circusweb.util import AutoDiscovery - -from circus.tests.support import TestCircus -from circus.util import DEFAULT_ENDPOINT_MULTICAST, DEFAULT_ENDPOINT_DEALER - - -class TestAutoDiscovery(TestCircus): - def setUp(self): - TestCircus.setUp(self) - - def test_auto_discovery(self): - self._stop_runners() - - dummy_process = 'circus.tests.support.run_process' - self._run_circus(dummy_process) - - auto_discovery = AutoDiscovery(DEFAULT_ENDPOINT_MULTICAST, - self.io_loop) - - def oracle(): - self.assertIn(DEFAULT_ENDPOINT_DEALER, - auto_discovery.get_endpoints()) - self.retry_timeout(oracle, 10) - - def retry_timeout(self, oracle, timeout=5, step=0.1): - """ For a given oracle, a callable, try to execute it. - - If it doesn't raises an AssertionError, oracle is green, return and - continue execution. - Else, if we doesn't reach the timeout, sleep for step seconds and try - again. - If we reach the timeout, raise an AssertionError. - """ - - assert timeout > 0, "Timeout should be > 0" - begin_time = time() - - def test(): - global begin_time, oracle, timeout - - if time() - begin_time >= timeout: - raise AssertionError("Timeout before oracle went true.") - else: - try: - oracle() - return True - except AssertionError: - return False - - self.wait(test) diff --git a/circusweb/tests/test_web.ini b/circusweb/tests/test_web.ini deleted file mode 100644 index e5208be..0000000 --- a/circusweb/tests/test_web.ini +++ /dev/null @@ -1,10 +0,0 @@ -[circus] -check_delay = 5 -endpoint = tcp://127.0.0.1:5555 -pubsub_endpoint = tcp://127.0.0.1:5556 -stats_endpoint = tcp://127.0.0.1:5557 - -[watcher:sleeper] -cmd = sleep 120 -warmup_delay = 0 -numprocesses = 1 diff --git a/circusweb/tests/test_web.py b/circusweb/tests/test_web.py deleted file mode 100644 index 6a2726d..0000000 --- a/circusweb/tests/test_web.py +++ /dev/null @@ -1,106 +0,0 @@ -import time -import subprocess -import os -import sys -import re - -from webtest import TestApp - -from circusweb.circushttpd import app -from circus.tests.support import TestCircus -from circus.stream import QueueStream - - -cfg = os.path.join(os.path.dirname(__file__), 'test_web.ini') - - -class TestHttpd(TestCircus): - def setUp(self): - TestCircus.setUp(self) - self.app = TestApp(app) - self.stream = QueueStream() - # let's run a circus - cmd = [sys.executable, "-c", - "from circus import circusd; circusd.main()", cfg] - self.p = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - - def tearDown(self): - self.p.terminate() - counter = 0 - while self.p.poll() is None and counter < 10: - counter += 1 - time.sleep(0.1) - if self.p.returncode is None: - self.p.kill() - - TestCircus.tearDown(self) - - def test_index(self): - # let's open the web app - res = self.app.get('/') - - if res.status_code == 302: - res = res.follow() - - # we have a form to connect to the current app - res = res.form.submit() - - # that should be a 302, redirecting to the connected index - # let's follow it - res = res.follow() - self.assertTrue('tcp://127.0.0.1:5557' in res.body) - - def test_watcher_page(self): - # let's go to the watcher page now - watcher_page = self.app.get('/watchers/sleeper') - self.assertTrue('1' in - watcher_page.body) - - # let's add two watchers - self.app.get('/watchers/sleeper/process/incr') - self.app.get('/watchers/sleeper/process/incr') - self.app.get('/watchers/sleeper/process/decr') - self.app.get('/watchers/sleeper/process/incr') - - # let's go back to the watcher page now - # and check the number of watchers - watcher_page = self.app.get('/watchers/sleeper') - self.assertTrue('3' in - watcher_page.body) - - # kill all processes - pids = set(re.findall('Process #(\d+)<', watcher_page.body)) - for pid in pids: - self.app.get('/watchers/sleeper/process/kill/%s' % pid) - - # wait a sec - time.sleep(1.) - - # check all pids have changed - watcher_page = self.app.get('/watchers/sleeper') - new_pids = set(re.findall('Process #(\d+)<', watcher_page.body)) - self.assertTrue(new_pids.isdisjoint(pids)) - - def test_watcher_status(self): - # starting/stopping the watcher - watcher_page = self.app.get('/watchers/sleeper') - self.assertTrue('title="active"' in watcher_page.body) - - # stopping - self.app.get('/watchers/sleeper/switch_status') - watcher_page = self.app.get('/watchers/sleeper') - self.assertFalse('title="active"' in watcher_page.body) - self.assertTrue('class="stopped"' in watcher_page.body) - - # starting - self.app.get('/watchers/sleeper/switch_status') - watcher_page = self.app.get('/watchers/sleeper') - self.assertTrue('title="active"' in watcher_page.body) - self.assertFalse('class="stopped"' in watcher_page.body) - - def test_disconnect(self): - self.assertFalse('Connect' in self.app.get('/').body) - res = self.app.get('/disconnect') - res = res.follow() - self.assertTrue('Connect' in res.body)