Re-Add ODL federation test. 55/21755/1
authorThomas Duval <thomas.duval@orange.com>
Wed, 7 Sep 2016 08:56:59 +0000 (10:56 +0200)
committerThomas Duval <thomas.duval@orange.com>
Tue, 20 Sep 2016 08:38:37 +0000 (10:38 +0200)
Change-Id: I66995d2ff37eb36e7aac754d712742efbd0222be
(cherry picked from commit 64ee6a784251c6d977794125f176aed3c5e104ce)

tests/run_tests.py

index 4b70219..7c48e26 100755 (executable)
@@ -48,8 +48,8 @@ except ImportError:
     from urllib2 import HTTPBasicAuthHandler, build_opener, install_opener
 
 
-def __get_keystone_url():
-    with subprocess.Popen(["openstack", "endpoint", "show", "keystone", "-f", "yaml"], stdout=subprocess.PIPE) as proc:
+def __get_endpoint_url(name="keystone"):
+    with subprocess.Popen(["openstack", "endpoint", "show", name, "-f", "yaml"], stdout=subprocess.PIPE) as proc:
         y = yaml.load(proc.stdout.read())
         url = y['publicurl']
         url = url.replace("http://", "")
@@ -61,18 +61,25 @@ def __get_keystone_url():
 
 def test_federation():
     # Retrieve Moon token
-    khost, kport = __get_keystone_url()
+    nhost, nport = __get_endpoint_url()
     auth_data = {'username': 'admin', 'password': 'console'}
-    conn = client.HTTPConnection(khost, kport)
+    conn = client.HTTPConnection(nhost, nport)
     headers = {"Content-type": "application/json"}
     conn.request("POST", "/moon/auth/tokens", json.dumps(auth_data).encode('utf-8'), headers=headers)
     resp = conn.getresponse()
     if resp.status not in (200, 201, 202, 204):
-        return False, "Not able to retrieve Moon token on {}:{} (error code: {}).".format(khost, kport, resp.status)
+        return False, "Not able to retrieve Moon token on {}:{} (error code: {}).".format(nhost, nport, resp.status)
 
 
     # Retrieve ODL token
-    # TODO (asteroide): must found how to get ODL host and port
+    nhost, nport = __get_endpoint_url(name="neutron")
+    auth_data = {'username': 'admin', 'password': 'console'}
+    conn = client.HTTPConnection(nhost, nport)
+    headers = {"Content-type": "application/json"}
+    conn.request("POST", "/auth/v1/domains", json.dumps(auth_data).encode('utf-8'), headers=headers)
+    resp = conn.getresponse()
+    if resp.status not in (200, 201, 202, 204):
+        return False, "Not able to retrieve ODL token on {}:{} (error code: {}).".format(nhost, nport, resp.status)
     # auth_handler = HTTPBasicAuthHandler()
     # auth_handler.add_password(realm='Moon',
     #                           uri='http://{host}:{port}/auth/v1/domains'.format(host=HOST_ODL, port=PORT_ODL),