From 4f860fb97842a6e6a0a420889f99a87104fba498 Mon Sep 17 00:00:00 2001 From: drebs Date: Sun, 19 Nov 2017 18:37:40 -0200 Subject: [test] use environment to pass the couch_url to server TAC test --- .gitlab-ci.yml | 2 ++ tests/server/test_tac.py | 26 ++++++++++++++++++-------- tox.ini | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2878d78c..d6a76012 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,6 +63,8 @@ tests: image: 0xacab.org:4567/leap/soledad:latest services: - couchdb + variables: + SOLEDAD_COUCH_URL: http://couchdb:5984 script: - tox -- --couch-url http://couchdb:5984 diff --git a/tests/server/test_tac.py b/tests/server/test_tac.py index e2e15f44..1ebe3308 100644 --- a/tests/server/test_tac.py +++ b/tests/server/test_tac.py @@ -61,15 +61,25 @@ class TacServerTestCase(unittest.TestCase): yield self._get(public_using_local_port_url) def _spawnServer(self): + + # Format the following command: + # /path/to/twistd --pidfile= -noy /path/to/server.tac + path = os.environ.get('VIRTUAL_ENV', '/usr') + twistd = os.path.join(path, 'bin', 'twistd') + args = [twistd, '--pidfile=', '-noy', TAC_FILE_PATH] + + # Use a special environment when running twistd. + couch_url = os.environ.get('SOLEDAD_COUCH_URL') + env = { + 'DEBUG_SERVER': 'yes', # run Users API on port 2424 without TLS + 'SOLEDAD_COUCH_URL': couch_url, # used by gitlab ci with docker + } + protocol = ProcessProtocol() - env = os.environ.get('VIRTUAL_ENV', '/usr') - executable = os.path.join(env, 'bin', 'twistd') - no_pid_argument = '--pidfile=' - args = [executable, no_pid_argument, '-noy', TAC_FILE_PATH] - env = {'DEBUG_SERVER': 'yes'} - t = reactor.spawnProcess(protocol, executable, args, env=env) - self.addCleanup(os.kill, t.pid, signal.SIGKILL) - self.addCleanup(t.loseConnection) + proc = reactor.spawnProcess(protocol, twistd, args, env=env) + self.addCleanup(os.kill, proc.pid, signal.SIGKILL) + self.addCleanup(proc.loseConnection) + d = self._wait_for_server() return d diff --git a/tox.ini b/tox.ini index ca7c11f2..00aba168 100644 --- a/tox.ini +++ b/tox.ini @@ -42,6 +42,7 @@ setenv = TERM=xterm XDG_CACHE_HOME=./.cache/ CHECK_SQLCIPHER={toxinidir}/scripts/testing/ensure-pysqlcipher-has-usleep.sh +passenv = SOLEDAD_COUCH_URL install_command = pip install {opts} {packages} [testenv:py34] -- cgit v1.2.3