diff --git a/tests/functional/extra/fake_dir1/fake_plugin1.py b/tests/functional/extra/fake_dir1/fake_plugin1.py new file mode 100644 index 00000000..67bb098a --- /dev/null +++ b/tests/functional/extra/fake_dir1/fake_plugin1.py @@ -0,0 +1,25 @@ +# Copyright 2015: Mirantis Inc. +# All Rights Reserved. +# +# 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 rally.benchmark.scenarios import base + + +class FakeScenarioPlugin1(base.Scenario): + """Sample fake plugin.""" + + @base.scenario() + def list(self): + """Fake scenario.""" + pass \ No newline at end of file diff --git a/tests/functional/extra/fake_dir2/fake_plugin2.py b/tests/functional/extra/fake_dir2/fake_plugin2.py new file mode 100644 index 00000000..06140c7d --- /dev/null +++ b/tests/functional/extra/fake_dir2/fake_plugin2.py @@ -0,0 +1,25 @@ +# Copyright 2015: Mirantis Inc. +# All Rights Reserved. +# +# 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 rally.benchmark.scenarios import base + + +class FakeScenarioPlugin2(base.Scenario): + """Sample fake plugin.""" + + @base.scenario() + def list(self): + """Fake scenario.""" + pass diff --git a/tests/functional/extra/test_fake_scenario.json b/tests/functional/extra/test_fake_scenario.json new file mode 100644 index 00000000..e831ae7e --- /dev/null +++ b/tests/functional/extra/test_fake_scenario.json @@ -0,0 +1,18 @@ +{ + "FakeScenarioPlugin1.list": [ + { + "runner": { + "type": "constant", + "times": 5 + } + } + ], + "FakeScenarioPlugin2.list": [ + { + "runner": { + "type": "constant", + "times": 5 + } + } + ] +} \ No newline at end of file diff --git a/tests/functional/test_cli_task.py b/tests/functional/test_cli_task.py index 4f74fe88..194910ef 100644 --- a/tests/functional/test_cli_task.py +++ b/tests/functional/test_cli_task.py @@ -301,6 +301,42 @@ class TaskTestCase(unittest.TestCase): r"(?P[0-9a-f\-]{36}): started", output) self.assertIsNotNone(result) + def test_validate_with_plugin_paths(self): + rally = utils.Rally() + with mock.patch.dict("os.environ", utils.TEST_ENV): + plugin_paths = ("tests/functional/extra/fake_dir1/," + "tests/functional/extra/fake_dir2/") + task_file = "tests/functional/extra/test_fake_scenario.json" + output = rally(("--plugin-paths %(plugin_paths)s " + "task validate --task %(task_file)s") % + {"task_file": task_file, + "plugin_paths": plugin_paths}) + + self.assertIn("Task config is valid", output) + + plugin_paths = ("tests/functional/extra/fake_dir1/" + "fake_plugin1.py," + "tests/functional/extra/fake_dir2/" + "fake_plugin2.py") + task_file = "tests/functional/extra/test_fake_scenario.json" + output = rally(("--plugin-paths %(plugin_paths)s " + "task validate --task %(task_file)s") % + {"task_file": task_file, + "plugin_paths": plugin_paths}) + + self.assertIn("Task config is valid", output) + + plugin_paths = ("tests/functional/extra/fake_dir1/," + "tests/functional/extra/fake_dir2/" + "fake_plugin2.py") + task_file = "tests/functional/extra/test_fake_scenario.json" + output = rally(("--plugin-paths %(plugin_paths)s " + "task validate --task %(task_file)s") % + {"task_file": task_file, + "plugin_paths": plugin_paths}) + + self.assertIn("Task config is valid", output) + def _test_start_abort_on_sla_failure_success(self, cfg, times): rally = utils.Rally() with mock.patch.dict("os.environ", utils.TEST_ENV):