diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-08-28 09:55:05 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-08-28 09:55:05 +0000 |
commit | 731a5bcfacc17c9189837d2af2d5dc1f0a95ccff (patch) | |
tree | b51f0537dffb2009813b42d5afccc4af235c1355 /yardstick | |
parent | 952ccb549c08b620a35f20ae809e0cea88ae4d99 (diff) |
Kubernetes context adoption when run in CI
JIRA: YARDSTICK-801
We need kubernetes test case run in CI.
We have one scenario k8-nosdb-lb-noha for kubernetes.
But for now, we need to do some adoption in CI script.
Also I move check OS_AUTH_URL in heat.py.
Change-Id: Iff86caf77fd74e70469ad2dc43f2238097ce0001
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick')
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 20 | ||||
-rw-r--r-- | yardstick/benchmark/core/task.py | 15 |
2 files changed, 18 insertions, 17 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index e52c1076c..deed4af93 100644 --- a/yardstick/benchmark/contexts/heat.py +++ b/yardstick/benchmark/contexts/heat.py @@ -14,6 +14,7 @@ import collections import logging import os import uuid +import errno from collections import OrderedDict import ipaddress @@ -26,7 +27,8 @@ from yardstick.benchmark.contexts.model import Server from yardstick.benchmark.contexts.model import update_scheduler_hints from yardstick.common.openstack_utils import get_neutron_client from yardstick.orchestrator.heat import HeatTemplate, get_short_key_uuid -from yardstick.common.constants import YARDSTICK_ROOT_PATH +from yardstick.common import constants as consts +from yardstick.common.utils import source_env from yardstick.ssh import SSH LOG = logging.getLogger(__name__) @@ -71,7 +73,7 @@ class HeatContext(Context): self.key_uuid = uuid.uuid4() self.heat_timeout = None self.key_filename = ''.join( - [YARDSTICK_ROOT_PATH, 'yardstick/resources/files/yardstick_key-', + [consts.YARDSTICK_ROOT_PATH, 'yardstick/resources/files/yardstick_key-', get_short_key_uuid(self.key_uuid)]) super(HeatContext, self).__init__() @@ -88,6 +90,7 @@ class HeatContext(Context): return sorted_networks def init(self, attrs): + self.check_environment() """initializes itself from the supplied arguments""" self.name = attrs["name"] @@ -131,6 +134,19 @@ class HeatContext(Context): self.attrs = attrs SSH.gen_keys(self.key_filename) + def check_environment(self): + try: + os.environ['OS_AUTH_URL'] + except KeyError: + try: + source_env(consts.OPENRC) + except IOError as e: + if e.errno != errno.EEXIST: + LOG.error('OPENRC file not found') + raise + else: + LOG.error('OS_AUTH_URL not found') + @property def image(self): """returns application's default image name""" diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py index 2c67e736c..a49a2cb71 100644 --- a/yardstick/benchmark/core/task.py +++ b/yardstick/benchmark/core/task.py @@ -21,7 +21,6 @@ import ipaddress import time import logging import uuid -import errno import collections from six.moves import filter @@ -32,7 +31,6 @@ from yardstick.benchmark.runners import base as base_runner from yardstick.common.yaml_loader import yaml_load from yardstick.dispatcher.base import Base as DispatcherBase from yardstick.common.task_template import TaskTemplate -from yardstick.common.utils import source_env from yardstick.common import utils from yardstick.common import constants from yardstick.common.html_template import report_template @@ -70,8 +68,6 @@ class Task(object): # pragma: no cover self._set_log() - check_environment() - try: output_config = utils.parse_ini_file(config_file) except Exception: @@ -675,17 +671,6 @@ def parse_task_args(src_name, args): return kw -def check_environment(): - auth_url = os.environ.get('OS_AUTH_URL', None) - if not auth_url: - try: - source_env(constants.OPENRC) - except IOError as e: - if e.errno != errno.EEXIST: - raise - LOG.debug('OPENRC file not found') - - def change_server_name(scenario, suffix): try: host = scenario['host'] |