summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-08-28 17:24:04 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-28 17:24:04 +0000
commit57b17a2223d8751f2c5eae660b706e2fc736a47c (patch)
tree2531c3a7ea354ab9b8ddace0a411b0925842b381
parent6b762e9edb2f7913348d99c1c240fe94b9f7cbf9 (diff)
parent731a5bcfacc17c9189837d2af2d5dc1f0a95ccff (diff)
Merge "Kubernetes context adoption when run in CI"
-rwxr-xr-xdocker/exec_tests.sh6
-rwxr-xr-xtests/ci/yardstick-verify68
-rw-r--r--yardstick/benchmark/contexts/heat.py20
-rw-r--r--yardstick/benchmark/core/task.py15
4 files changed, 59 insertions, 50 deletions
diff --git a/docker/exec_tests.sh b/docker/exec_tests.sh
index 46e5a05bd..93e017f49 100755
--- a/docker/exec_tests.sh
+++ b/docker/exec_tests.sh
@@ -96,8 +96,10 @@ fi
cd ${YARDSTICK_REPO_DIR}
git_checkout ${YARDSTICK_BRANCH}
-# setup the environment
-source ${YARDSTICK_REPO_DIR}/tests/ci/prepare_env.sh
+if [[ "${DEPLOY_SCENARIO:0:2}" == "os" ]];then
+ # setup the environment
+ source ${YARDSTICK_REPO_DIR}/tests/ci/prepare_env.sh
+fi
# execute tests
${YARDSTICK_REPO_DIR}/tests/ci/yardstick-verify $@
diff --git a/tests/ci/yardstick-verify b/tests/ci/yardstick-verify
index 16598df7b..ca8a0b27a 100755
--- a/tests/ci/yardstick-verify
+++ b/tests/ci/yardstick-verify
@@ -248,6 +248,38 @@ EOF
}
+check_openstack(){
+ # check if some necessary variables is set
+ if [ -z "$OS_AUTH_URL" ]; then
+ echo "OS_AUTH_URL is unset or empty"
+ exit 1
+ fi
+
+ echo "OS_AUTH_URL is $OS_AUTH_URL"
+ echo
+
+ # check OpenStack services
+ if [[ $OS_INSECURE ]] && [[ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]]; then
+ SECURE="--insecure"
+ else
+ SECURE=""
+ fi
+ echo "Checking OpenStack services:"
+ for cmd in "openstack ${SECURE} image list" "openstack ${SECURE} server list" "openstack ${SECURE} stack list"; do
+ echo " checking ${cmd} ..."
+ if ! $cmd >/dev/null; then
+ echo "error: command \"$cmd\" failed"
+ exit 1
+ fi
+ done
+
+ echo
+ echo "Checking for External network:"
+ for net in $(openstack network list --external -c Name -f value); do
+ echo " external network: $net"
+ done
+}
+
main()
{
GITROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
@@ -283,41 +315,15 @@ main()
done
echo
- # check if some necessary variables is set
- if [ -z "$OS_AUTH_URL" ]; then
- echo "OS_AUTH_URL is unset or empty"
- exit 1
- fi
+ trap "error_exit" EXIT SIGTERM
- echo "OS_AUTH_URL is $OS_AUTH_URL"
- echo
+ if [[ "${DEPLOY_SCENARIO:0:2}" == "os" ]];then
+ check_openstack
- # check OpenStack services
- if [[ $OS_INSECURE ]] && [[ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]]; then
- SECURE="--insecure"
- else
- SECURE=""
+ source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
+ source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh
fi
- echo "Checking OpenStack services:"
- for cmd in "openstack ${SECURE} image list" "openstack ${SECURE} server list" "openstack ${SECURE} stack list"; do
- echo " checking ${cmd} ..."
- if ! $cmd >/dev/null; then
- echo "error: command \"$cmd\" failed"
- exit 1
- fi
- done
-
- echo
- echo "Checking for External network:"
- for net in $(openstack network list --external -c Name -f value); do
- echo " external network: $net"
- done
-
- source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
-
- trap "error_exit" EXIT SIGTERM
- source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh
install_storperf
run_test
remove_storperf
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']