'File exists' validator and Utils class for validators

Change-Id: I43451ae5a79618cd7d8b60a98e9904052b242276
This commit is contained in:
astaroverov 2017-06-13 13:36:31 +03:00 committed by chenhb
parent 80bbdeb5d6
commit c4026b3ec4
9 changed files with 34 additions and 16 deletions

View File

@ -67,7 +67,7 @@
MuranoPackages.import_and_list_packages: MuranoPackages.import_and_list_packages:
- -
args: args:
package: "/home/jenkins/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/" package: "~/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/"
runner: runner:
type: "constant" type: "constant"
times: 10 times: 10
@ -81,7 +81,7 @@
max: 0 max: 0
- -
args: args:
package: "/home/jenkins/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter.zip" package: "~/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter.zip"
runner: runner:
type: "constant" type: "constant"
times: 1 times: 1
@ -97,7 +97,7 @@
MuranoPackages.import_and_delete_package: MuranoPackages.import_and_delete_package:
- -
args: args:
package: "/home/jenkins/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/" package: "~/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/"
runner: runner:
type: "constant" type: "constant"
times: 10 times: 10
@ -113,7 +113,7 @@
MuranoPackages.import_and_filter_applications: MuranoPackages.import_and_filter_applications:
- -
args: args:
package: "/home/jenkins/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/" package: "~/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/"
filter_query: {"category" : "Web"} filter_query: {"category" : "Web"}
runner: runner:
type: "constant" type: "constant"
@ -130,7 +130,7 @@
MuranoPackages.package_lifecycle: MuranoPackages.package_lifecycle:
- -
args: args:
package: "/home/jenkins/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/" package: "~/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/"
body: {"categories": ["Web"]} body: {"categories": ["Web"]}
operation: "add" operation: "add"
runner: runner:

View File

@ -737,7 +737,7 @@
context: context:
image_command_customizer: image_command_customizer:
command: command:
local_path: "/home/jenkins/.rally/extra/install_benchmark.sh" local_path: "~/.rally/extra/install_benchmark.sh"
remote_path: "./install_benchmark.sh" remote_path: "./install_benchmark.sh"
flavor: flavor:
name: "m1.tiny" name: "m1.tiny"

View File

@ -255,7 +255,7 @@
hooks: hooks:
- name: sys_call - name: sys_call
description: Run script description: Run script
args: sh /home/jenkins/.rally/extra/hook_example_script.sh args: sh ~/.rally/extra/hook_example_script.sh
trigger: trigger:
name: event name: event
args: args:

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
import requests import requests

View File

@ -51,7 +51,7 @@ class ListExecutions(utils.MistralScenario):
sort_keys=sort_keys, sort_dirs=sort_dirs) sort_keys=sort_keys, sort_dirs=sort_dirs)
@validation.file_exists("definition") @validation.add("file_exists", param_name="definition")
@types.convert(definition={"type": "file"}) @types.convert(definition={"type": "file"})
@types.convert(params={"type": "file"}) @types.convert(params={"type": "file"})
@types.convert(wf_input={"type": "file"}) @types.convert(wf_input={"type": "file"})

View File

@ -38,7 +38,7 @@ class ListWorkbooks(utils.MistralScenario):
self._list_workbooks() self._list_workbooks()
@validation.file_exists("definition") @validation.add("file_exists", param_name="definition")
@types.convert(definition={"type": "file"}) @types.convert(definition={"type": "file"})
@validation.add("required_platform", platform="openstack", users=True) @validation.add("required_platform", platform="openstack", users=True)
@validation.add("required_services", @validation.add("required_services",

View File

@ -25,7 +25,7 @@ from rally.task import validation
"""Scenarios for Murano packages.""" """Scenarios for Murano packages."""
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.add("file_exists", param_name="package", mode=os.F_OK)
@validation.add("required_services", services=[consts.Service.MURANO]) @validation.add("required_services", services=[consts.Service.MURANO])
@validation.add("required_platform", platform="openstack", users=True) @validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup": ["murano.packages"]}, @scenario.configure(context={"cleanup": ["murano.packages"]},
@ -55,7 +55,7 @@ class ImportAndListPackages(utils.MuranoScenario):
os.remove(package_path) os.remove(package_path)
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.add("file_exists", param_name="package", mode=os.F_OK)
@validation.add("required_services", services=[consts.Service.MURANO]) @validation.add("required_services", services=[consts.Service.MURANO])
@validation.add("required_platform", platform="openstack", users=True) @validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup": ["murano.packages"]}, @scenario.configure(context={"cleanup": ["murano.packages"]},
@ -82,7 +82,7 @@ class ImportAndDeletePackage(utils.MuranoScenario):
os.remove(package_path) os.remove(package_path)
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.add("file_exists", param_name="package", mode=os.F_OK)
@validation.add("required_services", services=[consts.Service.MURANO]) @validation.add("required_services", services=[consts.Service.MURANO])
@validation.add("required_platform", platform="openstack", users=True) @validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup": ["murano.packages"]}, @scenario.configure(context={"cleanup": ["murano.packages"]},
@ -118,7 +118,7 @@ class PackageLifecycle(utils.MuranoScenario):
os.remove(package_path) os.remove(package_path)
@validation.file_exists(param_name="package", mode=os.F_OK) @validation.add("file_exists", param_name="package", mode=os.F_OK)
@validation.add("required_services", services=[consts.Service.MURANO]) @validation.add("required_services", services=[consts.Service.MURANO])
@validation.add("required_platform", platform="openstack", users=True) @validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup": ["murano.packages"]}, @scenario.configure(context={"cleanup": ["murano.packages"]},

View File

@ -124,7 +124,8 @@ class VMScenario(nova_utils.NovaScenario):
"or list type") "or list type")
cmd.extend(remote_path) cmd.extend(remote_path)
if command.get("local_path"): if command.get("local_path"):
ssh.put_file(command["local_path"], remote_path[-1], ssh.put_file(os.path.expanduser(
command["local_path"]), remote_path[-1],
mode=self.USER_RWX_OTHERS_RX_ACCESS_MODE) mode=self.USER_RWX_OTHERS_RX_ACCESS_MODE)
if command.get("script_file"): if command.get("script_file"):

View File

@ -13,6 +13,8 @@
# under the License. # under the License.
import os import os
import shutil
import tempfile
import traceback import traceback
import mock import mock
@ -30,6 +32,22 @@ class RallyJobsTestCase(test.TestCase):
rally_jobs_path = os.path.join( rally_jobs_path = os.path.join(
os.path.dirname(rally.__file__), "..", "rally-jobs") os.path.dirname(rally.__file__), "..", "rally-jobs")
def setUp(self):
super(RallyJobsTestCase, self).setUp()
self.tmp_dir = tempfile.mkdtemp()
os.makedirs(os.path.join(self.tmp_dir, ".rally"))
shutil.copytree(os.path.join(self.rally_jobs_path, "extra"),
os.path.join(self.tmp_dir, ".rally", "extra"))
self.original_home = os.environ["HOME"]
os.environ["HOME"] = self.tmp_dir
def return_home():
os.environ["HOME"] = self.original_home
self.addCleanup(shutil.rmtree, self.tmp_dir)
self.addCleanup(return_home)
def test_schema_is_valid(self): def test_schema_is_valid(self):
discover.load_plugins(os.path.join(self.rally_jobs_path, "plugins")) discover.load_plugins(os.path.join(self.rally_jobs_path, "plugins"))