summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/identity_auth.py34
-rw-r--r--tests/inspector.py10
-rw-r--r--tests/lib/installers/apex4
-rw-r--r--tests/monitor.py15
4 files changed, 47 insertions, 16 deletions
diff --git a/tests/identity_auth.py b/tests/identity_auth.py
new file mode 100644
index 00000000..4726ca37
--- /dev/null
+++ b/tests/identity_auth.py
@@ -0,0 +1,34 @@
+##############################################################################
+# Copyright (c) 2017 NEC Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import os
+
+from keystoneauth1.identity import v2
+from keystoneauth1.identity import v3
+
+
+def get_identity_auth():
+ auth_url = os.environ['OS_AUTH_URL']
+ username = os.environ['OS_USERNAME']
+ password = os.environ['OS_PASSWORD']
+ user_domain_name = os.environ.get('OS_USER_DOMAIN_NAME')
+ project_name = os.environ.get('OS_PROJECT_NAME') or os.environ.get('OS_TENANT_NAME')
+ project_domain_name = os.environ.get('OS_PROJECT_DOMAIN_NAME')
+ if auth_url.endswith('v3'):
+ return v3.Password(auth_url=auth_url,
+ username=username,
+ password=password,
+ user_domain_name=user_domain_name,
+ project_name=project_name,
+ project_domain_name=project_domain_name)
+ else:
+ return v2.Password(auth_url=auth_url,
+ username=username,
+ password=password,
+ tenant_name=project_name)
diff --git a/tests/inspector.py b/tests/inspector.py
index 27c969e5..ba00f40e 100644
--- a/tests/inspector.py
+++ b/tests/inspector.py
@@ -17,10 +17,11 @@ import os
import threading
import time
-from keystoneauth1.identity import v3
from keystoneauth1 import session
import novaclient.client as novaclient
+import identity_auth
+
LOG = doctor_log.Logger('doctor_inspector').getLogger()
@@ -49,12 +50,7 @@ class DoctorInspectorSample(object):
def __init__(self):
self.servers = collections.defaultdict(list)
self.novaclients = list()
- auth = v3.Password(auth_url=os.environ['OS_AUTH_URL'],
- username=os.environ['OS_USERNAME'],
- password=os.environ['OS_PASSWORD'],
- user_domain_name=os.environ['OS_USER_DOMAIN_NAME'],
- project_name=os.environ['OS_PROJECT_NAME'],
- project_domain_name=os.environ['OS_PROJECT_DOMAIN_NAME'])
+ auth=identity_auth.get_identity_auth()
sess=session.Session(auth=auth)
# Pool of novaclients for redundant usage
for i in range(self.NUMBER_OF_CLIENTS):
diff --git a/tests/lib/installers/apex b/tests/lib/installers/apex
index e353d251..d9c41f80 100644
--- a/tests/lib/installers/apex
+++ b/tests/lib/installers/apex
@@ -28,6 +28,10 @@ function setup_installer {
get_installer_ip
installer_get_ssh_keys
get_controller_ips
+
+ # NOTE: while executing command as doctor user,
+ # 'OS_PROJECT_ID' env parameter make openstack clients confused.
+ unset OS_PROJECT_ID
}
function get_compute_ip_from_hostname {
diff --git a/tests/monitor.py b/tests/monitor.py
index 8d29dceb..8e8aa7a5 100644
--- a/tests/monitor.py
+++ b/tests/monitor.py
@@ -18,8 +18,8 @@ import sys
import time
from congressclient.v1 import client
-from keystoneclient import session as ksc_session
-from keystoneclient.auth.identity import v2
+
+import identity_auth
# NOTE: icmp message with all zero data (checksum = 0xf7ff)
# see https://tools.ietf.org/html/rfc792
@@ -29,6 +29,7 @@ SUPPORTED_INSPECTOR_TYPES = ['sample', 'congress']
LOG = doctor_log.Logger('doctor_monitor').getLogger()
+
class DoctorMonitorSample(object):
interval = 0.1 # second
@@ -46,13 +47,9 @@ class DoctorMonitorSample(object):
if self.inspector_type == 'sample':
self.inspector_url = 'http://127.0.0.1:12345/events'
elif self.inspector_type == 'congress':
- auth = v2.Password(auth_url=os.environ['OS_AUTH_URL'],
- username=os.environ['OS_USERNAME'],
- password=os.environ['OS_PASSWORD'],
- tenant_name=os.environ['OS_TENANT_NAME'])
- self.session = ksc_session.Session(auth=auth)
-
- congress = client.Client(session=self.session, service_type='policy')
+ auth=identity_auth.get_identity_auth()
+ sess=session.Session(auth=auth)
+ congress = client.Client(session=sess, service_type='policy')
ds = congress.list_datasources()['results']
doctor_ds = next((item for item in ds if item['driver'] == 'doctor'),
None)