aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdocker/exec_tests.sh19
-rw-r--r--tests/unit/common/test_utils.py16
-rw-r--r--yardstick/__init__.py16
-rw-r--r--yardstick/common/constants.py21
-rw-r--r--yardstick/common/utils.py14
5 files changed, 50 insertions, 36 deletions
diff --git a/docker/exec_tests.sh b/docker/exec_tests.sh
index 93e017f49..5d9a46c70 100755
--- a/docker/exec_tests.sh
+++ b/docker/exec_tests.sh
@@ -14,11 +14,6 @@ set -e
: ${YARDSTICK_REPO_DIR:='/home/opnfv/repos/yardstick'}
: ${YARDSTICK_BRANCH:='master'} # branch, tag, sha1 or refspec
-: ${RELENG_REPO:='https://gerrit.opnfv.org/gerrit/releng'}
-: ${RELENG_REPO_DIR:='/home/opnfv/repos/releng'}
-# TEMP HACK to freeze releng version to workaround fetch_os_creds.sh problem
-: ${RELENG_BRANCH:='master'} # branch, tag, sha1 or refspec
-
# git update using reference as a branch.
# git_update_branch ref
function git_update_branch {
@@ -74,19 +69,7 @@ git_checkout()
fi
}
-echo
-echo "INFO: Updating releng -> ${RELENG_BRANCH}"
-if [ ! -d ${RELENG_REPO_DIR} ]; then
- git clone ${RELENG_REPO} ${RELENG_REPO_DIR}
-fi
-cd ${RELENG_REPO_DIR}
-# reset remote so we know origin is valid
-git remote set-url origin ${RELENG_REPO}
-# fetch the exact ref
-git fetch --tags origin ${RELENG_BRANCH} || true
-# purge pyc files
-find . -name '*.pyc' -delete
-git_checkout ${RELENG_BRANCH}
+# releng is not needed, we bind-mount the credentials
echo
echo "INFO: Updating yardstick -> ${YARDSTICK_BRANCH}"
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py
index 923ec4aaa..42b75d1f0 100644
--- a/tests/unit/common/test_utils.py
+++ b/tests/unit/common/test_utils.py
@@ -17,6 +17,7 @@ import unittest
from copy import deepcopy
from itertools import product, chain
+import errno
import mock
from six.moves import configparser
@@ -780,6 +781,21 @@ class RemoveFileTestCase(unittest.TestCase):
class TestUtils(unittest.TestCase):
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs(self, *_):
+ self.assertIsNone(utils.makedirs('a/b/c/d'))
+
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs_exists(self, mock_os_makedirs):
+ mock_os_makedirs.side_effect = OSError(errno.EEXIST, 'exists')
+ self.assertIsNone(utils.makedirs('a/b/c/d'))
+
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs_busy(self, mock_os_makedirs):
+ mock_os_makedirs.side_effect = OSError(errno.EBUSY, 'busy')
+ with self.assertRaises(OSError):
+ utils.makedirs('a/b/c/d')
+
@mock.patch('yardstick.common.utils.jsonify')
def test_result_handler(self, mock_jsonify):
mock_jsonify.return_value = 432
diff --git a/yardstick/__init__.py b/yardstick/__init__.py
index b673e7c4a..f95b0a906 100644
--- a/yardstick/__init__.py
+++ b/yardstick/__init__.py
@@ -10,11 +10,22 @@
from __future__ import absolute_import
import logging
import os
+import errno
+# this module must only import other modules that do
+# not require loggers to be created, so this cannot
+# include yardstick.common.utils
from yardstick.common import constants
-from yardstick.common import utils as yardstick_utils
-yardstick_utils.makedirs(constants.LOG_DIR)
+try:
+ # do not use yardstick.common.utils.makedirs
+ # since yardstick.common.utils creates a logger
+ # and so it cannot be imported before this code
+ os.makedirs(constants.LOG_DIR)
+except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+
LOG_FILE = os.path.join(constants.LOG_DIR, 'yardstick.log')
LOG_FORMATTER = '%(asctime)s [%(levelname)s] %(name)s %(filename)s:%(lineno)d %(message)s'
@@ -34,6 +45,7 @@ def _init_logging():
_LOG_STREAM_HDLR.setLevel(logging.DEBUG)
else:
_LOG_STREAM_HDLR.setLevel(logging.INFO)
+
# don't append to log file, clobber
_LOG_FILE_HDLR.setFormatter(_LOG_FORMATTER)
_LOG_FILE_HDLR.setLevel(logging.DEBUG)
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
index b416f42b9..32ed746df 100644
--- a/yardstick/common/constants.py
+++ b/yardstick/common/constants.py
@@ -8,11 +8,16 @@
##############################################################################
from __future__ import absolute_import
import os
+import errno
+
from functools import reduce
import pkg_resources
-from yardstick.common.utils import parse_yaml
+# this module must only import other modules that do
+# not require loggers to be created, so this cannot
+# include yardstick.common.utils
+from yardstick.common.yaml_loader import yaml_load
dirname = os.path.dirname
abspath = os.path.abspath
@@ -29,7 +34,19 @@ def get_param(key, default=''):
# don't re-parse yaml for each lookup
if not CONF:
- CONF.update(parse_yaml(conf_file))
+ # do not use yardstick.common.utils.parse_yaml
+ # since yardstick.common.utils creates a logger
+ # and so it cannot be imported before this code
+ try:
+ with open(conf_file) as f:
+ value = yaml_load(f)
+ except IOError:
+ pass
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+ else:
+ CONF.update(value)
try:
return reduce(lambda a, b: a[b], key.split('.'), CONF)
except KeyError:
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 68c9ed63f..6ac99a5a9 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -37,7 +37,6 @@ from oslo_utils import importutils
from oslo_serialization import jsonutils
import yardstick
-from yardstick.common.yaml_loader import yaml_load
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
@@ -94,19 +93,6 @@ def import_modules_from_package(package):
logger.exception("unable to import %s", module_name)
-def parse_yaml(file_path):
- try:
- with open(file_path) as f:
- value = yaml_load(f)
- except IOError:
- return {}
- except OSError as e:
- if e.errno != errno.EEXIST:
- raise
- else:
- return value
-
-
def makedirs(d):
try:
os.makedirs(d)