blob: 0ec2a5d59bf06bad0a9e53c98bce798def32608e [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
Matthew Treinish411130a2014-08-28 19:21:40 -040019from tempest_lib import exceptions
20
Doug Hellmann583ce2c2015-03-11 14:55:46 +000021from oslo_log import log as logging
Matthew Treinishea42f112014-06-10 09:03:43 -040022from tempest.tests import base
Marc Kodererba6206d2013-10-11 08:04:10 +020023
24LOG = logging.getLogger(__name__)
25
26
Matthew Treinishea42f112014-06-10 09:03:43 -040027class StressFrameworkTest(base.TestCase):
Ken'ichi Ohmichic864f592015-11-19 08:45:06 +000028 """Basic test for the stress test framework."""
Marc Kodererba6206d2013-10-11 08:04:10 +020029
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
Matthew Treinish09487242015-05-10 12:43:58 -040035 cmd = shlex.split(cmd)
Marc Kodererba6206d2013-10-11 08:04:10 +020036 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))
Michael Hudson-Doyle884e2f32014-10-10 12:29:56 +130046 raise exceptions.CommandFailed(proc.returncode,
47 cmd,
48 result)
Marc Kodererba6206d2013-10-11 08:04:10 +020049 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)