Marc Koderer | ba6206d | 2013-10-11 08:04:10 +0200 | [diff] [blame] | 1 | # Copyright 2013 Deutsche Telekom AG |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | import shlex |
| 17 | import subprocess |
| 18 | |
| 19 | import tempest.cli as cli |
| 20 | from tempest.openstack.common import log as logging |
Matthew Treinish | ea42f11 | 2014-06-10 09:03:43 -0400 | [diff] [blame] | 21 | from tempest.tests import base |
Marc Koderer | ba6206d | 2013-10-11 08:04:10 +0200 | [diff] [blame] | 22 | |
| 23 | LOG = logging.getLogger(__name__) |
| 24 | |
| 25 | |
Matthew Treinish | ea42f11 | 2014-06-10 09:03:43 -0400 | [diff] [blame] | 26 | class StressFrameworkTest(base.TestCase): |
Marc Koderer | ba6206d | 2013-10-11 08:04:10 +0200 | [diff] [blame] | 27 | """Basic test for the stress test framework. |
| 28 | """ |
| 29 | |
| 30 | def _cmd(self, cmd, param): |
| 31 | """Executes specified command.""" |
| 32 | cmd = ' '.join([cmd, param]) |
| 33 | LOG.info("running: '%s'" % cmd) |
| 34 | cmd_str = cmd |
| 35 | cmd = shlex.split(cmd) |
| 36 | result = '' |
| 37 | result_err = '' |
| 38 | try: |
| 39 | stdout = subprocess.PIPE |
| 40 | stderr = subprocess.PIPE |
| 41 | proc = subprocess.Popen( |
| 42 | cmd, stdout=stdout, stderr=stderr) |
| 43 | result, result_err = proc.communicate() |
| 44 | if proc.returncode != 0: |
| 45 | LOG.debug('error of %s:\n%s' % (cmd_str, result_err)) |
| 46 | raise cli.CommandFailed(proc.returncode, |
| 47 | cmd, |
| 48 | result) |
| 49 | finally: |
| 50 | LOG.debug('output of %s:\n%s' % (cmd_str, result)) |
| 51 | return proc.returncode |
| 52 | |
| 53 | def test_help_function(self): |
Matthew Treinish | 55e29b4 | 2014-05-07 01:04:17 -0400 | [diff] [blame] | 54 | result = self._cmd("python", "-m tempest.cmd.run_stress -h") |
Marc Koderer | ba6206d | 2013-10-11 08:04:10 +0200 | [diff] [blame] | 55 | self.assertEqual(0, result) |