Fix the system tests to work with keystone auth
smoke test worked before but others were broken after switch to using keystone Fixed measurement_test.py to check for measurements in reverse order they were sent since the API returns newest first Change-Id: I22d242b12e66160e67979f1db808ed94f360d487
This commit is contained in:
parent
2cc609367c
commit
f28905687d
@ -9,6 +9,7 @@ import pytz
|
||||
from datetime import datetime
|
||||
from monascaclient import client
|
||||
import monascaclient.exc as exc
|
||||
import utils
|
||||
|
||||
|
||||
def call_mon_api(method, fields):
|
||||
@ -32,10 +33,7 @@ def main():
|
||||
print('usage: %s metric_name count' % sys.argv[0], file=sys.stderr)
|
||||
return 1
|
||||
|
||||
api_version = '2_0'
|
||||
endpoint = 'http://192.168.10.4:8080/v2.0'
|
||||
kwargs = {'token': '82510970543135'}
|
||||
mon_client = client.Client(api_version, endpoint, **kwargs)
|
||||
mon_client = utils.create_mon_client()
|
||||
|
||||
metric_start_time = time.time()
|
||||
metric_name = sys.argv[1]
|
||||
@ -83,7 +81,7 @@ def main():
|
||||
print('Took %d seconds for metrics to fully arrive' % i)
|
||||
expected = num_metrics_to_send - 1
|
||||
result = 0
|
||||
for index in range(0, num_metrics_to_send):
|
||||
for index in range(num_metrics_to_send, 0):
|
||||
value = measurements[index]
|
||||
if value[2] != expected:
|
||||
print('Expected %d but found %d for %d' %
|
||||
|
@ -6,12 +6,19 @@ import json
|
||||
import subprocess
|
||||
import cli_wrapper
|
||||
from monascaclient import client
|
||||
from monagent.common.keystone import Keystone
|
||||
|
||||
"""
|
||||
Utility methods for testing
|
||||
"""
|
||||
|
||||
|
||||
OS_USERNAME = 'mini-mon'
|
||||
OS_PASSWORD = 'password'
|
||||
OS_TENANT_NAME = 'mini-mon'
|
||||
OS_AUTH_URL = 'http://192.168.10.5:35357/'
|
||||
|
||||
|
||||
def check_alarm_history(alarm_id, states):
|
||||
transitions = len(states) - 1
|
||||
print('Checking Alarm History')
|
||||
@ -78,10 +85,11 @@ def setup_cli():
|
||||
api_host = get_api_host()
|
||||
|
||||
# These need to be set because we are invoking the CLI as a process
|
||||
os.environ['OS_USERNAME'] = 'mini-mon'
|
||||
os.environ['OS_PASSWORD'] = 'password'
|
||||
os.environ['OS_TENANT_NAME'] = 'mini-mon'
|
||||
os.environ['OS_AUTH_URL'] = 'http://192.168.10.5:35357/v2.0/'
|
||||
os.environ['OS_USERNAME'] = OS_USERNAME
|
||||
os.environ['OS_PASSWORD'] = OS_PASSWORD
|
||||
os.environ['OS_TENANT_NAME'] = OS_TENANT_NAME
|
||||
# I don't know v2.0 is needed for CLI, but v3 if client accessed directly
|
||||
os.environ['OS_AUTH_URL'] = OS_AUTH_URL + 'v2.0/'
|
||||
os.environ['MONASCA_API_URL'] = 'http://' + api_host + ':8080/v2.0/'
|
||||
os.environ['http_proxy'] = ''
|
||||
os.environ['https_proxy'] = ''
|
||||
@ -92,12 +100,25 @@ def setup_cli():
|
||||
def create_mon_client():
|
||||
api_host = get_api_host()
|
||||
|
||||
# See above comment for v3 vs v2.0
|
||||
token = get_token(OS_USERNAME, OS_PASSWORD, OS_TENANT_NAME,
|
||||
OS_AUTH_URL + 'v3/')
|
||||
|
||||
api_version = '2_0'
|
||||
endpoint = 'http://' + api_host + ':8080/v2.0'
|
||||
kwargs = {'token': '82510970543135'}
|
||||
kwargs = {'token': token}
|
||||
return client.Client(api_version, endpoint, **kwargs)
|
||||
|
||||
|
||||
def get_token(os_username, os_password, os_tenant_name, os_auth_url):
|
||||
keystone = Keystone(os_auth_url,
|
||||
os_username,
|
||||
os_password,
|
||||
os_tenant_name)
|
||||
|
||||
return keystone.refresh_token()
|
||||
|
||||
|
||||
def ensure_has_notification_engine():
|
||||
if not os.path.isfile('/etc/monasca/notification.yaml'):
|
||||
print('Must be run on a VM with Notification Engine installed',
|
||||
|
Loading…
Reference in New Issue
Block a user