blob: 106049d184e260d40b69670461272046bb7d8f81 [file] [log] [blame]
David Kranzb9d97502013-05-01 15:55:04 -04001#!/usr/bin/env python
2
3# vim: tabstop=4 shiftwidth=4 softtabstop=4
4
5# Copyright 2013 Quanta Research Cambridge, Inc.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18
19import argparse
20import json
Marc Koderer888ddc42013-07-23 16:13:07 +020021import sys
David Kranzb9d97502013-05-01 15:55:04 -040022
David Kranzb9d97502013-05-01 15:55:04 -040023
24def main(ns):
Marc Kodererfa399e72013-07-16 08:56:01 +020025 #NOTE(kodererm): moved import to make "-h" possible without OpenStack
26 from tempest.stress import driver
Marc Koderer888ddc42013-07-23 16:13:07 +020027 result = 0
David Kranzb9d97502013-05-01 15:55:04 -040028 tests = json.load(open(ns.tests, 'r'))
Matthew Treinish8e663fc2013-07-16 10:55:22 -040029 if ns.serial:
30 for test in tests:
Marc Koderer888ddc42013-07-23 16:13:07 +020031 step_result = driver.stress_openstack([test],
32 ns.duration,
33 ns.number)
34 #NOTE(kodererm): we just save the last result code
35 if (step_result != 0):
36 result = step_result
Matthew Treinish8e663fc2013-07-16 10:55:22 -040037 else:
Marc Koderer69d3bea2013-07-18 08:32:11 +020038 driver.stress_openstack(tests, ns.duration, ns.number)
Marc Koderer888ddc42013-07-23 16:13:07 +020039 return result
David Kranzb9d97502013-05-01 15:55:04 -040040
41
42parser = argparse.ArgumentParser(description='Run stress tests. ')
43parser.add_argument('-d', '--duration', default=300, type=int,
Matthew Treinish8e663fc2013-07-16 10:55:22 -040044 help="Duration of test in secs.")
45parser.add_argument('-s', '--serial', action='store_true',
46 help="Trigger running tests serially.")
Marc Koderer69d3bea2013-07-18 08:32:11 +020047parser.add_argument('-n', '--number', type=int,
48 help="How often an action is executed for each process.")
David Kranzb9d97502013-05-01 15:55:04 -040049parser.add_argument('tests', help="Name of the file with test description.")
Marc Koderer888ddc42013-07-23 16:13:07 +020050
51if __name__ == "__main__":
52 sys.exit(main(parser.parse_args()))