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