X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f675fb2c202516021b961b5aa2de4528ba9f0d1f..a8378b8deaa2bbf9d2c154d9d9bb072538c288cc:/sdk/python/tests/run_test_server.py diff --git a/sdk/python/tests/run_test_server.py b/sdk/python/tests/run_test_server.py index 5ef5e2a9f5..d10e60c22f 100644 --- a/sdk/python/tests/run_test_server.py +++ b/sdk/python/tests/run_test_server.py @@ -34,9 +34,19 @@ import arvados.config ARVADOS_DIR = os.path.realpath(os.path.join(MY_DIRNAME, '../../..')) SERVICES_SRC_DIR = os.path.join(ARVADOS_DIR, 'services') if 'GOPATH' in os.environ: + # Add all GOPATH bin dirs to PATH -- but insert them after the + # ruby gems bin dir, to ensure "bundle" runs the Ruby bundler + # command, not the golang.org/x/tools/cmd/bundle command. gopaths = os.environ['GOPATH'].split(':') - gobins = [os.path.join(path, 'bin') for path in gopaths] - os.environ['PATH'] = ':'.join(gobins) + ':' + os.environ['PATH'] + addbins = [os.path.join(path, 'bin') for path in gopaths] + newbins = [] + for path in os.environ['PATH'].split(':'): + newbins.append(path) + if os.path.exists(os.path.join(path, 'bundle')): + newbins += addbins + addbins = [] + newbins += addbins + os.environ['PATH'] = ':'.join(newbins) TEST_TMPDIR = os.path.join(ARVADOS_DIR, 'tmp') if not os.path.exists(TEST_TMPDIR): @@ -109,6 +119,7 @@ def kill_server_pid(pidfile, wait=10, passenger_root=False): try: exited, _ = os.waitpid(server_pid, os.WNOHANG) if exited > 0: + _remove_pidfile(pidfile) return except OSError: # already exited, or isn't our child process @@ -122,6 +133,7 @@ def kill_server_pid(pidfile, wait=10, passenger_root=False): if error.errno == errno.ESRCH: # Thrown by os.getpgid() or os.kill() if the process # does not exist, i.e., our work here is done. + _remove_pidfile(pidfile) return raise time.sleep(0.1) @@ -131,6 +143,13 @@ def kill_server_pid(pidfile, wait=10, passenger_root=False): format(server_pid, pidfile, wait), file=sys.stderr) +def _remove_pidfile(pidfile): + try: + os.unlink(pidfile) + except: + if os.path.lexists(pidfile): + raise + def find_available_port(): """Return an IPv4 port number that is not in use right now. @@ -220,8 +239,9 @@ def run(leave_running_atexit=False): # This will clear cached docs that belong to other processes (like # concurrent test suites) even if they're still running. They should # be able to tolerate that. - for fn in glob.glob(os.path.join(arvados.http_cache('discovery'), - '*,arvados,v1,rest,*')): + for fn in glob.glob(os.path.join( + str(arvados.http_cache('discovery')), + '*,arvados,v1,rest,*')): os.unlink(fn) pid_file = _pidfile('api') @@ -294,7 +314,10 @@ def run(leave_running_atexit=False): env = os.environ.copy() env['RAILS_ENV'] = 'test' env['ARVADOS_TEST_WSS_PORT'] = str(wss_port) - env.pop('ARVADOS_WEBSOCKETS', None) + if env.get('ARVADOS_TEST_EXPERIMENTAL_WS'): + env.pop('ARVADOS_WEBSOCKETS', None) + else: + env['ARVADOS_WEBSOCKETS'] = 'yes' env.pop('ARVADOS_TEST_API_HOST', None) env.pop('ARVADOS_API_HOST', None) env.pop('ARVADOS_API_HOST_INSECURE', None) @@ -379,6 +402,7 @@ Client: APIHost: {} Insecure: true Listen: :{} +LogLevel: {} Postgres: host: {} dbname: {} @@ -387,6 +411,7 @@ Postgres: sslmode: require """.format(os.environ['ARVADOS_API_HOST'], port, + ('info' if os.environ.get('ARVADOS_DEBUG', '') in ['','0'] else 'debug'), _dbconfig('host'), _dbconfig('database'), _dbconfig('username'), @@ -583,6 +608,7 @@ def stop_keep_web(): def run_nginx(): if 'ARVADOS_TEST_PROXY_SERVICES' in os.environ: return + stop_nginx() nginxconf = {} nginxconf['KEEPWEBPORT'] = _getport('keep-web') nginxconf['KEEPWEBDLSSLPORT'] = find_available_port()