From cde3f7882cc21af95a844f9c7b19795af84741d4 Mon Sep 17 00:00:00 2001 From: kubi Date: Fri, 5 Feb 2016 08:48:00 +0000 Subject: add precondition check as we discussed yersterday, for daily jenkins task, i have a new idea, i add a precondition check and a key parameter in test case, if environment info(eg. "DEPLOY_SCENARIO") meet the preconditon which was defined in test case , this test case will run, if not meet, this test case will skip. and default is allow all test case to run, so this patch will not influence existing test case. any comments are welcomed Change-Id: I4300ac58994d51c0ddb4dd6d58b7191f796ddcee Signed-off-by: kubi (cherry picked from commit ff5cb9501b155e07fe75f03062217270b9745131) --- tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml | 3 +++ tests/unit/cmd/commands/test_task.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml index e360b4bd0..cf3afc866 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml @@ -24,6 +24,9 @@ scenarios: max_rtt: 30 action: monitor +precondition: + installer_type: compass + deploy_scenarios: os-nosdn context: type: Node diff --git a/tests/unit/cmd/commands/test_task.py b/tests/unit/cmd/commands/test_task.py index e785e99a9..5b404c48d 100644 --- a/tests/unit/cmd/commands/test_task.py +++ b/tests/unit/cmd/commands/test_task.py @@ -56,3 +56,17 @@ class TaskCommandsTestCase(unittest.TestCase): mock_base_runner.Runner.get.return_value = runner t._run([scenario], False, "yardstick.out") self.assertTrue(runner.run.called) + + @mock.patch('yardstick.cmd.commands.task.os') + def test_check_precondition(self, mock_os): + cfg = \ + {'precondition': + {'installer_type': 'compass', + 'deploy_scenarios': 'os-nosdn' + } + } + + t = task.TaskParser('/opt') + mock_os.environ.get.side_effect = ['compass', 'os-nosdn'] + result = t._check_precondition(cfg) + self.assertTrue(result) -- cgit 1.2.3-korg