From 53e7d377dd0a6c25e2400b2ccadf5cf767b7736a Mon Sep 17 00:00:00 2001 From: Evgeny Sikachev Date: Tue, 19 Apr 2016 10:51:34 +0200 Subject: [PATCH] Fix relative path for default templates After installing package we have a problem with running tests from default templates. closes-bug: 1569826 Co-Authored-By: Luigi Toscano Change-Id: I879c63b65b6f89a77acd672eea9d1c16d42f1a1b --- ...ed-resource-discovery-36ffa157cf9b06b9.yaml | 6 ++++++ sahara_tests/scenario/runner.py | 10 ++++++++-- sahara_tests/version.py | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-installed-resource-discovery-36ffa157cf9b06b9.yaml create mode 100644 sahara_tests/version.py diff --git a/releasenotes/notes/fix-installed-resource-discovery-36ffa157cf9b06b9.yaml b/releasenotes/notes/fix-installed-resource-discovery-36ffa157cf9b06b9.yaml new file mode 100644 index 00000000..29aa2b2a --- /dev/null +++ b/releasenotes/notes/fix-installed-resource-discovery-36ffa157cf9b06b9.yaml @@ -0,0 +1,6 @@ +--- +prelude: > + Fix default resource discovery from the installed package. +fixes: + - The default set of resources (test templates for each plugin, etc) + can now be properly discovered when the package is installed. diff --git a/sahara_tests/scenario/runner.py b/sahara_tests/scenario/runner.py index e49e6fb5..b3776e10 100755 --- a/sahara_tests/scenario/runner.py +++ b/sahara_tests/scenario/runner.py @@ -25,18 +25,24 @@ import tempfile from mako import template as mako_template from oslo_utils import fileutils +import pkg_resources as pkg import six import yaml from sahara_tests.scenario import validation +from sahara_tests import version -TEST_TEMPLATE_DIR = 'sahara_tests/scenario/defaults/' +SCENARIO_RESOURCES_DIR = pkg.resource_filename(version.version_info.package, + 'scenario') + +TEST_TEMPLATE_DIR = os.path.join(SCENARIO_RESOURCES_DIR, 'defaults/') DEFAULT_TEMPLATE_VARS = [os.path.join(TEST_TEMPLATE_DIR, 'credentials.yaml.mako'), os.path.join(TEST_TEMPLATE_DIR, 'edp.yaml.mako')] -TEST_TEMPLATE_PATH = 'sahara_tests/scenario/testcase.py.mako' +TEST_TEMPLATE_PATH = os.path.join(SCENARIO_RESOURCES_DIR, + 'testcase.py.mako') def set_defaults(config): diff --git a/sahara_tests/version.py b/sahara_tests/version.py new file mode 100644 index 00000000..b9d277f0 --- /dev/null +++ b/sahara_tests/version.py @@ -0,0 +1,18 @@ +# Copyright (c) 2016 Mirantis Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pbr import version + +version_info = version.VersionInfo('sahara_tests')