projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
14965: Use netstat instead of lsof to check for listening process.
[arvados.git]
/
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 7b1f6059aeef07b8ff2a2d03a6d4980f9d5a835f..c845e78f0fbedfb6d473625c6d8af55365a14cd0 100644
(file)
--- a/
sdk/python/tests/run_test_server.py
+++ b/
sdk/python/tests/run_test_server.py
@@
-181,22
+181,18
@@
def _wait_until_port_listens(port, timeout=10, warn=True):
in seconds), print a warning on stderr before returning.
"""
try:
in seconds), print a warning on stderr before returning.
"""
try:
- subprocess.check_output(['which', '
lsof
'])
+ subprocess.check_output(['which', '
netstat
'])
except subprocess.CalledProcessError:
except subprocess.CalledProcessError:
- print("WARNING: No `
lsof
` -- cannot wait for port to listen. "+
+ print("WARNING: No `
netstat
` -- cannot wait for port to listen. "+
"Sleeping 0.5 and hoping for the best.",
file=sys.stderr)
time.sleep(0.5)
return
deadline = time.time() + timeout
while time.time() < deadline:
"Sleeping 0.5 and hoping for the best.",
file=sys.stderr)
time.sleep(0.5)
return
deadline = time.time() + timeout
while time.time() < deadline:
- try:
- subprocess.check_output(
- ['lsof', '-t', '-i', 'tcp:'+str(port)])
- except subprocess.CalledProcessError:
- time.sleep(0.1)
- continue
- return True
+ if re.search(r'\ntcp.*:'+str(port)+' .* LISTEN *\n', subprocess.check_output(['netstat', '-an'])):
+ return True
+ time.sleep(0.1)
if warn:
print(
"WARNING: Nothing is listening on port {} (waited {} seconds).".
if warn:
print(
"WARNING: Nothing is listening on port {} (waited {} seconds).".
@@
-413,29
+409,32
@@
def run_controller():
f.write("""
Clusters:
zzzzz:
f.write("""
Clusters:
zzzzz:
- HTTPRequestTimeout: 30s
+ ManagementToken: e687950a23c3a9bceec28c6223a06c79
+ API:
+ RequestTimeout: 30s
PostgreSQL:
ConnectionPool: 32
Connection:
PostgreSQL:
ConnectionPool: 32
Connection:
- host: {}
- dbname: {}
- user: {}
- password: {}
- NodeProfiles:
- "*":
- "arvados-controller":
- Listen: ":{}"
- "arvados-api-server":
- Listen: ":{}"
- TLS: true
- Insecure: true
+ host: {dbhost}
+ dbname: {dbname}
+ user: {dbuser}
+ password: {dbpass}
+ TLS:
+ Insecure: true
+ Services:
+ Controller:
+ InternalURLs:
+ "http://localhost:{controllerport}": {{}}
+ RailsAPI:
+ InternalURLs:
+ "https://localhost:{railsport}": {{}}
""".format(
""".format(
- _dbconfig('host'),
- _dbconfig('database'),
- _dbconfig('username'),
- _dbconfig('password'),
- port,
- rails_api_port,
+
dbhost=
_dbconfig('host'),
+
dbname=
_dbconfig('database'),
+
dbuser=
_dbconfig('username'),
+
dbpass=
_dbconfig('password'),
+
controllerport=
port,
+ rails
port=rails
_api_port,
))
logf = open(_logfilename('controller'), 'a')
controller = subprocess.Popen(
))
logf = open(_logfilename('controller'), 'a')
controller = subprocess.Popen(
@@
-582,6
+581,7
@@
def stop_keep(num_servers=2):
def run_keep_proxy():
if 'ARVADOS_TEST_PROXY_SERVICES' in os.environ:
def run_keep_proxy():
if 'ARVADOS_TEST_PROXY_SERVICES' in os.environ:
+ os.environ["ARVADOS_KEEP_SERVICES"] = "http://localhost:{}".format(_getport('keepproxy'))
return
stop_keep_proxy()
return
stop_keep_proxy()
@@
-631,6
+631,7
@@
def run_arv_git_httpd():
agh = subprocess.Popen(
['arv-git-httpd',
'-repo-root='+gitdir+'/test',
agh = subprocess.Popen(
['arv-git-httpd',
'-repo-root='+gitdir+'/test',
+ '-management-token=e687950a23c3a9bceec28c6223a06c79',
'-address=:'+str(gitport)],
env=env, stdin=open('/dev/null'), stdout=logf, stderr=logf)
with open(_pidfile('arv-git-httpd'), 'w') as f:
'-address=:'+str(gitport)],
env=env, stdin=open('/dev/null'), stdout=logf, stderr=logf)
with open(_pidfile('arv-git-httpd'), 'w') as f:
@@
-656,6
+657,7
@@
def run_keep_web():
['keep-web',
'-allow-anonymous',
'-attachment-only-host=download',
['keep-web',
'-allow-anonymous',
'-attachment-only-host=download',
+ '-management-token=e687950a23c3a9bceec28c6223a06c79',
'-listen=:'+str(keepwebport)],
env=env, stdin=open('/dev/null'), stdout=logf, stderr=logf)
with open(_pidfile('keep-web'), 'w') as f:
'-listen=:'+str(keepwebport)],
env=env, stdin=open('/dev/null'), stdout=logf, stderr=logf)
with open(_pidfile('keep-web'), 'w') as f:
@@
-738,7
+740,7
@@
def _getport(program):
def _dbconfig(key):
global _cached_db_config
if not _cached_db_config:
def _dbconfig(key):
global _cached_db_config
if not _cached_db_config:
- _cached_db_config = yaml.load(open(os.path.join(
+ _cached_db_config = yaml.
safe_
load(open(os.path.join(
SERVICES_SRC_DIR, 'api', 'config', 'database.yml')))
return _cached_db_config['test'][key]
SERVICES_SRC_DIR, 'api', 'config', 'database.yml')))
return _cached_db_config['test'][key]
@@
-750,7
+752,7
@@
def _apiconfig(key):
fullpath = os.path.join(SERVICES_SRC_DIR, 'api', 'config', f)
if not required and not os.path.exists(fullpath):
return {}
fullpath = os.path.join(SERVICES_SRC_DIR, 'api', 'config', f)
if not required and not os.path.exists(fullpath):
return {}
- return yaml.load(fullpath)
+ return yaml.
safe_
load(fullpath)
cdefault = _load('application.default.yml')
csite = _load('application.yml', required=False)
_cached_config = {}
cdefault = _load('application.default.yml')
csite = _load('application.yml', required=False)
_cached_config = {}
@@
-769,7
+771,7
@@
def fixture(fix):
yaml_file = yaml_file[0:trim_index]
except ValueError:
pass
yaml_file = yaml_file[0:trim_index]
except ValueError:
pass
- return yaml.load(yaml_file)
+ return yaml.
safe_
load(yaml_file)
def auth_token(token_name):
return fixture("api_client_authorizations")[token_name]["api_token"]
def auth_token(token_name):
return fixture("api_client_authorizations")[token_name]["api_token"]