Commit 608391f8 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

scalability: add serial-test configuration parameter.

parent a671c94e
...@@ -143,6 +143,11 @@ class ScalabilityLauncher(object): ...@@ -143,6 +143,11 @@ class ScalabilityLauncher(object):
metavar='SITE_AVAILABILITY_URL', metavar='SITE_AVAILABILITY_URL',
help='Url to check instance availability') help='Url to check instance availability')
parser.add_argument('--serial-test',
metavar='SERIAL_TEST',
action='store_true',
help='Without this option, all test methods are invoked in parallel')
@staticmethod @staticmethod
def _checkParsedArguments(namespace): def _checkParsedArguments(namespace):
return namespace return namespace
...@@ -235,6 +240,7 @@ class ScalabilityLauncher(object): ...@@ -235,6 +240,7 @@ class ScalabilityLauncher(object):
instance_url = self.__argumentNamespace.instance_url instance_url = self.__argumentNamespace.instance_url
metric_url = self.__argumentNamespace.metric_url metric_url = self.__argumentNamespace.metric_url
site_availability_url = self.__argumentNamespace.site_availability_url site_availability_url = self.__argumentNamespace.site_availability_url
serial_test = self.__argumentNamespace.serial_test
# To take metrics # To take metrics
metric_thread_stop_event = threading.Event() metric_thread_stop_event = threading.Event()
...@@ -260,11 +266,12 @@ class ScalabilityLauncher(object): ...@@ -260,11 +266,12 @@ class ScalabilityLauncher(object):
now = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M") now = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M")
log_dir = "test-%s_%s" % (current_test.title, now) log_dir = "test-%s_%s" % (current_test.title, now)
command_list = []
user_index = 0 user_index = 0
max_test_duration = 0.0 max_test_duration = 0.0
exec_env = os.environ.copy()
exec_env.update({'raise_error_if_fail': False})
# Prepare commands # Prepare commands
for test_suite in test_suite_list: for index, test_suite in enumerate(test_suite_list, start=1):
getTestDuration = getattr(suite, 'getTestDuration', None) getTestDuration = getattr(suite, 'getTestDuration', None)
if getTestDuration is not None: if getTestDuration is not None:
if len(getargspec(getTestDuration).args) == 3: if len(getargspec(getTestDuration).args) == 3:
...@@ -286,7 +293,7 @@ class ScalabilityLauncher(object): ...@@ -286,7 +293,7 @@ class ScalabilityLauncher(object):
if max_test_duration < test_duration: if max_test_duration < test_duration:
max_test_duration = test_duration max_test_duration = test_duration
log_file_name_prefix = "%s_%s_suite_%s" %(LOG_FILE_PREFIX, current_test.title, test_suite) log_file_name_prefix = "%s_%s_suite_%s" %(LOG_FILE_PREFIX, current_test.title, test_suite)
command_list.append([tester_path, command = [tester_path,
instance_url, instance_url,
str(user_quantity_dict[test_suite]), str(user_quantity_dict[test_suite]),
test_suite, test_suite,
...@@ -299,18 +306,21 @@ class ScalabilityLauncher(object): ...@@ -299,18 +306,21 @@ class ScalabilityLauncher(object):
'--user-index', str(user_index), '--user-index', str(user_index),
"--repeat", "%d"%test_repeat, "--repeat", "%d"%test_repeat,
"--duration", "%d"%test_duration, "--duration", "%d"%test_duration,
]) ]
user_index += user_quantity_dict[test_suite] user_index += user_quantity_dict[test_suite]
# Launch commands # Launch command
exec_env = os.environ.copy()
exec_env.update({'raise_error_if_fail': False})
for index, command in enumerate(command_list, start=1):
test_thread = TestThread(process_manager, command, self.log, env=exec_env) test_thread = TestThread(process_manager, command, self.log, env=exec_env)
test_thread.start() test_thread.start()
# Sleep if serial_test:
self.log("Going to sleep for %s seconds." % str(max_test_duration)) self.log("Going to sleep for %s seconds." % str(test_duration))
time.sleep(max_test_duration) test_thread.join(test_duration)
process_manager.killPreviousRun() if test_thread.is_alive():
process_manager.killPreviousRun()
if not serial_test:
# Sleep
self.log("Going to sleep for %s seconds." % str(max_test_duration))
time.sleep(max_test_duration)
process_manager.killPreviousRun()
self.moveLogs(log_dir, current_test) self.moveLogs(log_dir, current_test)
self.log("Test Case %s has finished" %(current_test.title)) self.log("Test Case %s has finished" %(current_test.title))
......
...@@ -397,6 +397,7 @@ Require valid-user ...@@ -397,6 +397,7 @@ Require valid-user
self.frontend_address = configuration.get("frontend-address") self.frontend_address = configuration.get("frontend-address")
self.instance_software_release = configuration.get('instance-software-release') self.instance_software_release = configuration.get('instance-software-release')
self.use_existing_setup = self.instance_name is not None and self.frontend_address is not None self.use_existing_setup = self.instance_name is not None and self.frontend_address is not None
self.serial_test = configuration.get('serial-test', False)
node_test_suite.edit(configuration_list=configuration_list) node_test_suite.edit(configuration_list=configuration_list)
self.launcher_nodes_computer_guid = test_configuration['launcher_nodes_computer_guid'] self.launcher_nodes_computer_guid = test_configuration['launcher_nodes_computer_guid']
...@@ -653,6 +654,8 @@ Require valid-user ...@@ -653,6 +654,8 @@ Require valid-user
"--metric-url", metric_url, "--metric-url", metric_url,
"--site-availability-url", site_availability_url, "--site-availability-url", site_availability_url,
] ]
if self.serial_test:
command.append('--serial-test')
logger.info("Running test case...") logger.info("Running test case...")
test_thread = TestThread(self.testnode.process_manager, command, logger.info, env=self.exec_env) test_thread = TestThread(self.testnode.process_manager, command, logger.info, env=self.exec_env)
test_thread.start() test_thread.start()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment