From 3d3b57199a08bab4d2d39bfc7e9e92321f809678 Mon Sep 17 00:00:00 2001 From: Roman Vasilets Date: Thu, 14 May 2015 17:05:20 +0300 Subject: [PATCH] Add functional test for task samples It would be nice if there is a functional test to confirm all the task samples are good for out-of-box testing. So here we go. Also Fix nova/boot-lock-unlock-and-delete scenario flavor, nova/boot-and-associate-floating-ip flavor, nova/boot-and-rebuild. Change flavor value from apsent on gate to regexp. Change-Id: I033135828b960da4cc3fd35b96ee69f700815a35 Co-Authored-By: Roman Vasilets Co-Authored-By: Fei Long Wang --- .../nova/boot-and-associate-floating-ip.json | 2 +- .../nova/boot-and-associate-floating-ip.yaml | 2 +- .../scenarios/nova/boot-and-rebuild.json | 4 +- .../scenarios/nova/boot-and-rebuild.yaml | 4 +- .../nova/boot-lock-unlock-and-delete.json | 2 +- .../nova/boot-lock-unlock-and-delete.yaml | 2 +- tests/functional/test_task_samples.py | 55 +++++++++++++++++++ 7 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 tests/functional/test_task_samples.py diff --git a/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.json b/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.json index c8d23160d4..5b8ff0927a 100644 --- a/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.json +++ b/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.json @@ -11,7 +11,7 @@ "name": "m1.tiny" }, "image": { - "name": "cirros-0.3.2-x86_64-uec" + "name": "^cirros.*uec$" } }, "context": { diff --git a/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.yaml b/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.yaml index 50e039b8d0..9974fb90a0 100644 --- a/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.yaml +++ b/samples/tasks/scenarios/nova/boot-and-associate-floating-ip.yaml @@ -5,7 +5,7 @@ flavor: name: "m1.tiny" image: - name: "cirros-0.3.2-x86_64-uec" + name: "^cirros.*uec$" runner: type: "constant" times: 1 diff --git a/samples/tasks/scenarios/nova/boot-and-rebuild.json b/samples/tasks/scenarios/nova/boot-and-rebuild.json index 6e28dba959..9293bc3d3f 100644 --- a/samples/tasks/scenarios/nova/boot-and-rebuild.json +++ b/samples/tasks/scenarios/nova/boot-and-rebuild.json @@ -6,10 +6,10 @@ "name": "m1.tiny" }, "from_image": { - "name": "cirros-0.3.2-x86_64-uec" + "name": "^cirros.*uec$" }, "to_image": { - "name": "cirros-0.3.2-x86_64-uec" + "name": "^cirros.*uec$" } }, "runner": { diff --git a/samples/tasks/scenarios/nova/boot-and-rebuild.yaml b/samples/tasks/scenarios/nova/boot-and-rebuild.yaml index f519dd0597..1f644bff24 100644 --- a/samples/tasks/scenarios/nova/boot-and-rebuild.yaml +++ b/samples/tasks/scenarios/nova/boot-and-rebuild.yaml @@ -4,9 +4,9 @@ NovaServers.boot_and_rebuild_server: flavor: name: "m1.tiny" from_image: - name: "cirros-0.3.2-x86_64-uec" + name: "^cirros.*uec$" to_image: - name: "cirros-0.3.2-x86_64-uec" + name: "^cirros.*uec$" runner: type: constant times: 5 diff --git a/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.json b/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.json index ffa3acd1b9..69e23e12ba 100644 --- a/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.json +++ b/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.json @@ -6,7 +6,7 @@ "name": "m1.tiny" }, "image": { - "name": "cirros-0.3.2-x86_64-uec" + "name": "^cirros.*uec$" } }, "runner": { diff --git a/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.yaml b/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.yaml index e7e01a854e..b1f9e788d2 100644 --- a/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.yaml +++ b/samples/tasks/scenarios/nova/boot-lock-unlock-and-delete.yaml @@ -5,7 +5,7 @@ flavor: name: "m1.tiny" image: - name: "cirros-0.3.2-x86_64-uec" + name: "^cirros.*uec$" runner: type: "constant" times: 10 diff --git a/tests/functional/test_task_samples.py b/tests/functional/test_task_samples.py new file mode 100644 index 0000000000..164ad353c2 --- /dev/null +++ b/tests/functional/test_task_samples.py @@ -0,0 +1,55 @@ +# Copyright 2014: Mirantis Inc. +# Copyright 2014: Catalyst IT Ltd. +# 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. + +import os +import re +import traceback +import unittest + +from tests.functional import utils + + +class TestTaskSamples(unittest.TestCase): + + def test_task_samples_is_valid(self): + rally = utils.Rally() + samples_path = os.path.join( + os.path.dirname(__file__), os.pardir, os.pardir, + "samples", "tasks") + matcher = re.compile("\.json$") + + for dirname, dirnames, filenames in os.walk(samples_path): + # NOTE(rvasilets): Skip by suggest of boris-42 because in + # future we don't what to maintain this dir + if dirname.find("tempest-do-not-run-against-production") != -1: + continue + for filename in filenames: + full_path = os.path.join(dirname, filename) + + # NOTE(hughsaunders): Skip non config files + # (bug https://bugs.launchpad.net/rally/+bug/1314369) + if not matcher.search(filename): + continue + try: + rally("task validate --task %s" % full_path) + except utils.RallyCmdError as e: + if re.search( + "[Ss]ervice is not available", e.output) is None: + raise e + except Exception: + print(traceback.format_exc()) + self.assertTrue(False, + "Wrong task config %s" % full_path)