Files
rally/tests/benchmark/scenarios/tempest/test_utils.py
Andrey Kurilin 769aeb366c Add benchmark for tempest. Part 2
Several new scenarios added in tempest benchmark:

* scenario for launching all tests

* scenario for launching all tests from given set(special set_name
validator was added for this scenario)

* scenario for launching all tests from given list of test names
(Also, test coverage for validator `tempest_tests_exists` was increased
for situations like in this scenario)

* scenario for launching all tests which match given regex expression

bp benchmark-scenarios-based-on-tempest

Change-Id: I3e715cb360dec3d5d8683a9001c4f2221b49d1ac
2014-05-12 13:47:22 +03:00

58 lines
2.1 KiB
Python

# Copyright 2014: 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.
import mock
from rally.benchmark.scenarios.tempest import tempest
from rally.benchmark.scenarios.tempest import utils
from tests import test
TS = "rally.benchmark.scenarios.tempest"
class TempestLogWrappersTestCase(test.TestCase):
def setUp(self):
super(TempestLogWrappersTestCase, self).setUp()
verifier = mock.MagicMock()
verifier.parse_results.return_value = ({"fake": True},
{"have_results": True})
context = {"tmp_results_dir": "/tmp/dir", "verifier": verifier}
self.scenario = tempest.TempestScenario(context)
self.scenario._add_atomic_actions = mock.MagicMock()
@mock.patch(TS + ".utils.tempfile")
def test_launch_without_specified_log_file(self, mock_tmp):
mock_tmp.NamedTemporaryFile().name = "tmp_file"
target_func = mock.MagicMock()
func = utils.tempest_log_wrapper(target_func)
func(self.scenario)
target_func.assert_called_once_with(self.scenario,
log_file="/tmp/dir/tmp_file")
@mock.patch(TS + ".utils.tempfile")
def test_launch_with_specified_log_file(self, mock_tmp):
target_func = mock.MagicMock()
func = utils.tempest_log_wrapper(target_func)
func(self.scenario, log_file='log_file')
target_func.assert_called_once_with(self.scenario,
log_file="log_file")
self.assertEqual(0, mock_tmp.NamedTemporaryFile.call_count)