Merge branch '15467-update-install-docs' refs #15467
[arvados.git] / sdk / python / tests / run_test_server.py
index b073eff40d1bb7e0d446cea4feeb3ee0bfbeceb8..0f8f1c5f818e2768168e4c71094a67c34fb4478e 100644 (file)
@@ -26,6 +26,11 @@ import time
 import unittest
 import yaml
 
+try:
+    from urllib.parse import urlparse
+except ImportError:
+    from urlparse import urlparse
+
 MY_DIRNAME = os.path.dirname(os.path.realpath(__file__))
 if __name__ == '__main__' and os.path.exists(
       os.path.join(MY_DIRNAME, '..', 'arvados', '__init__.py')):
@@ -395,10 +400,12 @@ def get_config():
         return yaml.safe_load(f)
 
 def internal_port_from_config(service):
-    return int(list(get_config()["Clusters"]["zzzzz"]["Services"][service]["InternalURLs"].keys())[0].split(":")[2])
+    return int(urlparse(
+        list(get_config()["Clusters"]["zzzzz"]["Services"][service]["InternalURLs"].keys())[0]).
+               netloc.split(":")[1])
 
 def external_port_from_config(service):
-    return int(get_config()["Clusters"]["zzzzz"]["Services"][service]["ExternalURL"].split(":")[2])
+    return int(urlparse(get_config()["Clusters"]["zzzzz"]["Services"][service]["ExternalURL"]).netloc.split(":")[1])
 
 def run_controller():
     if 'ARVADOS_TEST_PROXY_SERVICES' in os.environ:
@@ -670,54 +677,56 @@ def setup_config():
     keep_web_dl_port = find_available_port()
     keep_web_dl_external_port = find_available_port()
 
-    if "CONFIGSRC" in os.environ:
-        dbconf = os.path.join(os.environ["CONFIGSRC"], "config.yml")
-    else:
-        dbconf = "/etc/arvados/config.yml"
+    dbconf = os.path.join(os.environ["CONFIGSRC"], "config.yml")
 
     print("Getting config from %s" % dbconf, file=sys.stderr)
 
-    pgconnection = list(yaml.safe_load(open(dbconf))["Clusters"].values())[0]["PostgreSQL"]["Connection"]
-
-    if "test" not in pgconnection["dbname"]:
-        pgconnection["dbname"] = "arvados_test"
+    pgconnection = yaml.safe_load(open(dbconf))["Clusters"]["zzzzz"]["PostgreSQL"]["Connection"]
 
+    localhost = "127.0.0.1"
     services = {
         "RailsAPI": {
-            "InternalURLs": { }
+            "InternalURLs": {
+                "https://%s:%s"%(localhost, rails_api_port): {}
+            }
         },
         "Controller": {
-            "ExternalURL": "https://localhost:%s" % controller_external_port,
-            "InternalURLs": { }
+            "ExternalURL": "https://%s:%s" % (localhost, controller_external_port),
+            "InternalURLs": {
+                "http://%s:%s"%(localhost, controller_port): {}
+            }
         },
         "Websocket": {
-            "ExternalURL": "https://localhost:%s" % websocket_external_port,
-            "InternalURLs": { }
+            "ExternalURL": "wss://%s:%s/websocket" % (localhost, websocket_external_port),
+            "InternalURLs": {
+                "http://%s:%s"%(localhost, websocket_port): {}
+            }
         },
         "GitHTTP": {
-            "ExternalURL": "https://localhost:%s" % git_httpd_external_port,
-            "InternalURLs": { }
+            "ExternalURL": "https://%s:%s" % (localhost, git_httpd_external_port),
+            "InternalURLs": {
+                "http://%s:%s"%(localhost, git_httpd_port): {}
+            }
         },
         "Keepproxy": {
-            "ExternalURL": "https://localhost:%s" % keepproxy_external_port,
-            "InternalURLs": { }
+            "ExternalURL": "https://%s:%s" % (localhost, keepproxy_external_port),
+            "InternalURLs": {
+                "http://%s:%s"%(localhost, keepproxy_port): {}
+            }
         },
         "WebDAV": {
-            "ExternalURL": "https://localhost:%s" % keep_web_external_port,
-            "InternalURLs": { }
+            "ExternalURL": "https://%s:%s" % (localhost, keep_web_external_port),
+            "InternalURLs": {
+                "http://%s:%s"%(localhost, keep_web_port): {}
+            }
         },
         "WebDAVDownload": {
-            "ExternalURL": "https://localhost:%s" % keep_web_dl_external_port,
-            "InternalURLs": { }
+            "ExternalURL": "https://%s:%s" % (localhost, keep_web_dl_external_port),
+            "InternalURLs": {
+                "http://%s:%s"%(localhost, keep_web_dl_port): {}
+            }
         }
     }
-    services["RailsAPI"]["InternalURLs"]["https://localhost:%s"%rails_api_port] = {}
-    services["Controller"]["InternalURLs"]["http://localhost:%s"%controller_port] = {}
-    services["Websocket"]["InternalURLs"]["http://localhost:%s"%websocket_port] = {}
-    services["GitHTTP"]["InternalURLs"]["http://localhost:%s"%git_httpd_port] = {}
-    services["Keepproxy"]["InternalURLs"]["http://localhost:%s"%keepproxy_port] = {}
-    services["WebDAV"]["InternalURLs"]["http://localhost:%s"%keep_web_port] = {}
-    services["WebDAVDownload"]["InternalURLs"]["http://localhost:%s"%keep_web_dl_port] = {}
 
     config = {
         "Clusters": {
@@ -746,7 +755,6 @@ def setup_config():
         yaml.safe_dump(config, f)
 
     ex = "export ARVADOS_CONFIG="+conf
-    print(ex, file=sys.stderr)
     print(ex)