blob: 5a334c53902f2b942527155fc6b18dc0b09ca11d [file] [log] [blame]
Marc Kodererba6206d2013-10-11 08:04:10 +02001# 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
16import shlex
17import subprocess
18
19import tempest.cli as cli
20from tempest.openstack.common import log as logging
Matthew Treinishea42f112014-06-10 09:03:43 -040021from tempest.tests import base
Marc Kodererba6206d2013-10-11 08:04:10 +020022
23LOG = logging.getLogger(__name__)
24
25
Matthew Treinishea42f112014-06-10 09:03:43 -040026class StressFrameworkTest(base.TestCase):
Marc Kodererba6206d2013-10-11 08:04:10 +020027 """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 Treinish55e29b42014-05-07 01:04:17 -040054 result = self._cmd("python", "-m tempest.cmd.run_stress -h")
Marc Kodererba6206d2013-10-11 08:04:10 +020055 self.assertEqual(0, result)