blob: 4d7de9d5806ae3048176accc81bf574565f31a06 [file] [log] [blame]
Marc Kodererba6206d2013-10-11 08:04:10 +02001# 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
18import shlex
19import subprocess
20
21import tempest.cli as cli
22from tempest.openstack.common import log as logging
23import tempest.test
24
25LOG = logging.getLogger(__name__)
26
27
28class 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)