summaryrefslogtreecommitdiffstats
path: root/loadtest/TestMain.py
diff options
context:
space:
mode:
authorDaniel Rose <dr695h@att.com>2017-05-30 20:19:02 +0000
committerGerrit Code Review <gerrit@onap.org>2017-05-30 20:19:02 +0000
commit301ac2d31a1e583d2ce594af335a00c7fd83759a (patch)
treea023ed4d0fceff64cc9a9db58de1fbdf33ad1036 /loadtest/TestMain.py
parent96e3d06bc97c9f357e5a74e3bee2cb6f509fadee (diff)
parentb88fc2d930537a47b12115a899322fb9cebbc0c1 (diff)
Merge "TEST-2 load/soak test utility"
Diffstat (limited to 'loadtest/TestMain.py')
-rw-r--r--loadtest/TestMain.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/loadtest/TestMain.py b/loadtest/TestMain.py
new file mode 100644
index 0000000..a9b57db
--- /dev/null
+++ b/loadtest/TestMain.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+# encoding: utf-8
+'''
+loadtest.TestMain -- shortdesc
+
+loadtest.TestMain is a description
+
+It defines classes_and_methods
+
+@author: user_name
+
+@copyright: 2017 organization_name. All rights reserved.
+
+@license: license
+
+@contact: user_email
+@deffield updated: Updated
+'''
+
+import sys
+import os
+
+from optparse import OptionParser, Values
+
+from loadtest.TestController import TestController
+
+__all__ = []
+__version__ = 0.1
+__date__ = '2017-04-07'
+__updated__ = '2017-04-07'
+
+DEBUG = 1
+TESTRUN = 0
+PROFILE = 0
+import time
+import logging
+
+def main(argv=None):
+ '''Command line options.'''
+ program_name = os.path.basename(sys.argv[0])
+ program_version = "v0.1"
+ program_build_date = "%s" % __updated__
+
+ program_version_string = '%%prog %s (%s)' % (program_version, program_build_date)
+ #program_usage = '''usage: spam two eggs''' # optional - will be autogenerated by optparse
+ program_longdesc = '''''' # optional - give further explanation about what the program does
+ program_license = "Copyright 2017 user_name (organization_name) \
+ Licensed under the Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0"
+
+ if argv is None:
+ argv = sys.argv[1:]
+ try:
+ # setup option parser
+ parser = OptionParser(version=program_version_string, epilog=program_longdesc, description=program_license)
+ parser.add_option("-d", "--duration", dest="duration", help="duration of soak test in seconds [default: %default]", type=int)
+ parser.add_option("-l", "--logfile", dest="logfile", help="Full path soak log file name")
+ parser.set_defaults(duration="60", logfile="")
+ (opts, args) = parser.parse_args(argv)
+
+ if (opts.logfile != ""):
+ logging.basicConfig(filename=opts.logfile, level=logging.DEBUG)
+ else:
+ logging.basicConfig(level=logging.DEBUG)
+ controller = TestController(opts)
+ controller.execute()
+
+ except Exception, e:
+ indent = len(program_name) * " "
+ sys.stderr.write(program_name + ": " + repr(e) + "\n")
+ sys.stderr.write(indent + " for help use --help")
+ return 2
+
+
+if __name__ == "__main__":
+ if DEBUG:
+ print "debug"
+ if TESTRUN:
+ import doctest
+ doctest.testmod()
+ if PROFILE:
+ import cProfile
+ import pstats
+ profile_filename = 'loadtest.TestMain_profile.txt'
+ cProfile.run('main()', profile_filename)
+ statsfile = open("profile_stats.txt", "wb")
+ p = pstats.Stats(profile_filename, stream=statsfile)
+ stats = p.strip_dirs().sort_stats('cumulative')
+ stats.print_stats()
+ statsfile.close()
+ sys.exit(0)
+ sys.exit(main()) \ No newline at end of file