summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriilyak <iilyak@users.noreply.github.com>2019-08-16 03:32:18 -0700
committerGitHub <noreply@github.com>2019-08-16 03:32:18 -0700
commit18bda469e69e6e7e375b66490e4ed7df20ae53e5 (patch)
treea4930f84da138dcd2c06e443f13ec9e47e1590e8
parent5a6c94450c0f5ad7644c80a966547711347d582c (diff)
parentf2724d3fe19f58bca8c81b2ae610c6dd1c7e44c8 (diff)
downloadcouchdb-18bda469e69e6e7e375b66490e4ed7df20ae53e5.tar.gz
Merge pull request #2105 from cloudant/improve-admin-part-setup
Do not fail 'dev/run' on connection close
-rwxr-xr-xdev/run41
1 files changed, 29 insertions, 12 deletions
diff --git a/dev/run b/dev/run
index 60e7d5c35..10351eb86 100755
--- a/dev/run
+++ b/dev/run
@@ -690,27 +690,37 @@ def generate_cookie():
def cluster_setup_with_admin_party(ctx):
+ connect_nodes(ctx)
+ host, port = "127.0.0.1", cluster_port(ctx, 1)
+ create_system_databases(host, port)
+
+
+def connect_nodes(ctx):
host, port = "127.0.0.1", backend_port(ctx, 1)
for node in ctx["nodes"]:
- body = "{}"
- conn = httpclient.HTTPConnection(host, port)
- conn.request("PUT", "/_nodes/%s@127.0.0.1" % node, body)
- resp = conn.getresponse()
- if resp.status not in (200, 201, 202, 409):
- print(("Failed to join %s into cluster: %s" % (node, resp.read())))
- sys.exit(1)
- create_system_databases(host, cluster_port(ctx, 1))
+ path = "/_nodes/%s@127.0.0.1" % node
+ try_request(
+ host,
+ port,
+ "PUT",
+ path,
+ (200, 201, 202, 409),
+ body="{}",
+ error="Failed to join %s into cluster:\n" % node,
+ )
-def try_request(host, port, meth, path, success_codes, retries=10, retry_dt=1):
+def try_request(
+ host, port, meth, path, success_codes, body=None, retries=10, retry_dt=1, error=""
+):
while True:
conn = httpclient.HTTPConnection(host, port)
- conn.request(meth, path)
+ conn.request(meth, path, body=body)
resp = conn.getresponse()
if resp.status in success_codes:
return resp.status, resp.read()
elif retries <= 0:
- assert resp.status in success_codes, resp.read()
+ assert resp.status in success_codes, "%s%s" % (error, resp.read())
retries -= 1
time.sleep(retry_dt)
@@ -721,7 +731,14 @@ def create_system_databases(host, port):
conn.request("HEAD", "/" + dbname)
resp = conn.getresponse()
if resp.status == 404:
- try_request(host, port, "PUT", "/" + dbname, (201, 202, 412))
+ try_request(
+ host,
+ port,
+ "PUT",
+ "/" + dbname,
+ (201, 202, 412),
+ error="Failed to create '%s' database:\n" % dbname,
+ )
@log(