4
from datetime import datetime
9
from assess_recovery import deploy_stack
10
from deploy_stack import (
13
from generate_perfscale_results import (
14
_convert_seconds_to_readable,
21
add_basic_testing_arguments,
32
log = logging.getLogger("perfscale_longrunning")
39
really_long = MINUTE * 120
42
def perfscale_longrun_perf(client, args):
43
test_length = args.run_length * (60 * MINUTE)
44
longrun_start = datetime.utcnow()
46
for _ in until_timeout(test_length):
47
applications = ['dummy-sink']
48
new_client = action_create(client)
49
new_models = action_busy(new_client, applications)
50
action_cleanup(new_client, new_models)
52
action_rest(Rest.short/2)
55
longrun_end = datetime.utcnow()
56
timing_data = TimingData(longrun_start, longrun_end)
58
'Longrun for {} Hours.'.format(test_length/60/60),
59
{'Total action runs': run_count},
64
def action_create(client, series='trusty'):
65
start = datetime.utcnow()
66
new_model = client.add_model(client.env.clone('newmodel'))
67
deploy_stack(new_model, series)
68
end = datetime.utcnow()
69
log.info('Create action took: {}'.format(
70
_convert_seconds_to_readable(int((end - start).total_seconds()))))
74
def action_busy(client, applications):
75
start = datetime.utcnow()
77
for app in applications:
78
client.juju('add-unit', (app, '-n', '1'))
79
client.wait_for_started(timeout=1200)
80
client.wait_for_workloads(timeout=1200)
82
global total_new_models
84
for i in range(0, 20):
86
new_model_name = 'model{}'.format(total_new_models)
87
new_model = client.add_model(client.env.clone(new_model_name))
88
new_model.wait_for_started()
89
log.info('Added model number {}'.format(total_new_models))
90
new_models.append(new_model)
92
for _ in until_timeout(MINUTE*2):
93
log.info('Checking status ping.')
95
log.info('Sleeping . . .')
97
end = datetime.utcnow()
99
log.info('Create action took: {}'.format(
100
_convert_seconds_to_readable(int((end - start).total_seconds()))))
105
def action_cleanup(client, new_models):
106
client.destroy_model()
107
for model in new_models:
108
model.destroy_model()
111
def action_rest(rest_length=Rest.short):
112
log.info('Resting for {} seconds'.format(rest_length))
113
time.sleep(rest_length)
116
def parse_args(argv):
117
"""Parse all arguments."""
118
parser = argparse.ArgumentParser(
119
description="Perfscale longrunning test.")
120
add_basic_testing_arguments(parser)
123
help='Length of time (in hours) to run the test',
126
return parser.parse_args(argv)
130
args = parse_args(argv)
131
configure_logging(args.verbose)
132
bs_manager = BootstrapManager.from_args(args)
133
run_perfscale_test(perfscale_longrun_perf, bs_manager, args)
137
if __name__ == '__main__':