diff options
author | DR695H <dr695h@att.com> | 2019-04-18 10:56:38 -0400 |
---|---|---|
committer | Gary Wu <gary.i.wu@huawei.com> | 2019-04-23 10:34:04 -0700 |
commit | d050b58d3fde6a049104d8287f8d8cfbe3013d5d (patch) | |
tree | 7563bfffabfc4f713996b1f12e52b5f2317fc6e2 /loadtest | |
parent | 5709f89501b9ecf93fcb1667de017e1736c8919f (diff) |
move robotframeworkonap to subdirectory
i also moved the build to maven based, although that isnt needed
to work right now.
Change-Id: Ib18d70e3ea4858cc4b9d51fdc2046b59202640ab
Issue-ID: TEST-141
Signed-off-by: DR695H <dr695h@att.com>
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'loadtest')
-rw-r--r-- | loadtest/RunEte.py | 39 | ||||
-rw-r--r-- | loadtest/TestConfig.py | 59 | ||||
-rw-r--r-- | loadtest/TestController.py | 80 | ||||
-rw-r--r-- | loadtest/TestMain.py | 93 | ||||
-rw-r--r-- | loadtest/__init__.py | 0 |
5 files changed, 0 insertions, 271 deletions
diff --git a/loadtest/RunEte.py b/loadtest/RunEte.py deleted file mode 100644 index 5012e7d..0000000 --- a/loadtest/RunEte.py +++ /dev/null @@ -1,39 +0,0 @@ -''' -Created on Apr 7, 2017 - -@author: jf9860 -''' -from threading import Thread -import subprocess -import os -from datetime import datetime -import logging - -class RunEte(Thread): - ''' - classdocs - ''' - robot_test = "" - robot_command = "runEteTag.sh" - soaksubfolder = "" - test_number =0 - - def __init__(self, test_name, soaksubfolder, test_number): - ''' - Constructor - ''' - super(RunEte, self).__init__() - self.robot_test = test_name - self.soaksubfolder = soaksubfolder - self.test_number = test_number - - def run(self): - logging.info("{} ({}) started - {}".format(self.getName(), self.robot_test, str(datetime.now()))) - try: - ''' Add the '/' here so that the shell doesn't require a subfolder... ''' - env = dict(os.environ, SOAKSUBFOLDER=self.soaksubfolder + "/") - output = subprocess.check_output(["bash", self.robot_command, self.robot_test, self.test_number], shell=False, env=env) - logging.info("{} ({}) {}".format(self.getName(), self.robot_test, output)) - except Exception, e: - logging.error("{} ({}) Unexpected error {}".format(self.getName(), self.robot_test, repr(e))) - logging.info("{} ({}) ended - {}".format(self.getName(), self.robot_test, str(datetime.now()))) diff --git a/loadtest/TestConfig.py b/loadtest/TestConfig.py deleted file mode 100644 index b9b8112..0000000 --- a/loadtest/TestConfig.py +++ /dev/null @@ -1,59 +0,0 @@ -''' -Created on Apr 7, 2017 - -@author: jf9860 -''' -import json - -class TestConfig(object): - ''' - The profile defines a cycle of tests. Each entry is defined as - [<seconds to wait>, [<list of ete tags to run after the wait]], - ''' - profile = [ - [0, ["health"]], - ] - - duration=10 - cyclelength=60 - - def __init__(self, duration=None, cyclelength=None, json=None): - ''' - Constructor - ''' - if (json != None): - self.parseConfig(json) - if (duration != None): - self.duration = duration - if (cyclelength != None): - self.cyclelength = cyclelength - running_time = 0 - for p in self.profile: - secs = p[0] - running_time = running_time + secs - if (running_time < self.cyclelength): - last = self.cyclelength - running_time - self.profile.append([last, []]) - - def parseConfig(self, fileName): - with open(fileName) as data_file: - config = json.load(data_file) - self.profile = config["profile"] - self.cyclelength = config["cyclelength"] - self.duration = config["duration"] - - - def to_string(self): - pstring = 'Cycle length is {} seconds'.format(self.cyclelength) - pstring = '{}\nDuration is {} seconds'.format(pstring, self.duration) - running_time = 0 - for p in self.profile: - secs = p[0] - running_time = running_time + secs - for ete in p[1]: - pstring = "{0}\n{1:08d} : {2:08d} : {3}".format(pstring, secs, running_time, ete) - if (len(p[1]) == 0): - pstring = "{0}\n{1:08d} : {2:08d} : {3}".format(pstring, secs, running_time, "") - return pstring - - diff --git a/loadtest/TestController.py b/loadtest/TestController.py deleted file mode 100644 index 3ba0083..0000000 --- a/loadtest/TestController.py +++ /dev/null @@ -1,80 +0,0 @@ -''' -Created on Apr 7, 2017 - -@author: jf9860 -''' -import time -import os -from loadtest.RunEte import RunEte -from loadtest.TestConfig import TestConfig -import logging - -class TestController(object): - ''' - classdocs - ''' - - threads = {} - threadid = 0 - soaksubfolder = 'soak_' + str(os.getpid()) - test_number = 0 - - def __init__(self, options): - ''' - Constructor - ''' - self.config = TestConfig(duration=options.duration, cyclelength=options.cyclelength, json=options.profile) - logging.info(self.config.to_string()) - - def execute(self): - starttime = time.time() - endtime = starttime + self.config.duration - profileindex = 0 - currenttime = time.time() - logging.info("{}:{}:{}".format(starttime, endtime, currenttime)) - while currenttime < endtime: - if (profileindex >= len(self.config.profile)): - profileindex = 0 - profile = self.config.profile[profileindex] - sleeptime = profile[0] - currenttime = time.time() - if ((currenttime + sleeptime) < endtime): - time.sleep(sleeptime) - self.schedule(profile) - profileindex = profileindex + 1 - currenttime = time.time() - else: - currenttime = endtime - - for threadname in self.threads: - logging.info("TestController waiting on " + threadname) - t = self.threads[threadname] - t.join() - logging.info("Soak test completed") - - def schedule(self, profile): - self.remove_completed_threads() - tests = profile[1] - for test in tests: - self.schedule_one(test) - - def schedule_one(self, test): - self.test_number = self.test_number + 1 - self.threadid = self.threadid + 1 - threadname = "RunEte_" + str(self.threadid) - ''' test for max threads ''' - t = RunEte(test, self.soaksubfolder, str(self.test_number)) - t.setName(threadname) - t.start() - self.threads[threadname] = t - - - def remove_completed_threads(self): - toremove = [] - for threadname in self.threads: - t = self.threads[threadname] - if (t.isAlive() == False): - toremove.append(threadname) - for threadname in toremove: - logging.info("Removing " + threadname) - del(self.threads[threadname])
\ No newline at end of file diff --git a/loadtest/TestMain.py b/loadtest/TestMain.py deleted file mode 100644 index 81c635f..0000000 --- a/loadtest/TestMain.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/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.add_option("-c", "--cyclelength", dest="cyclelength", help="Length of a single cycle through the config.\nMust be longer than a single iteration", type=int) - parser.add_option("-p", "--profile", dest="profile", help="Filename of json profile file") - parser.set_defaults(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 diff --git a/loadtest/__init__.py b/loadtest/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/loadtest/__init__.py +++ /dev/null |