mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Track ansible-test cloud and target overhead. (#34902)
This commit is contained in:
parent
17d9ba304e
commit
5fa1edc15d
2 changed files with 29 additions and 0 deletions
|
@ -3,6 +3,9 @@ from __future__ import absolute_import, print_function
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import atexit
|
import atexit
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
|
import time
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import random
|
import random
|
||||||
|
@ -128,9 +131,30 @@ def cloud_init(args, targets):
|
||||||
|
|
||||||
args.metadata.cloud_config = {}
|
args.metadata.cloud_config = {}
|
||||||
|
|
||||||
|
results = {}
|
||||||
|
|
||||||
for provider in get_cloud_providers(args, targets):
|
for provider in get_cloud_providers(args, targets):
|
||||||
args.metadata.cloud_config[provider.platform] = {}
|
args.metadata.cloud_config[provider.platform] = {}
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
provider.setup()
|
provider.setup()
|
||||||
|
end_time = time.time()
|
||||||
|
|
||||||
|
results[provider.platform] = dict(
|
||||||
|
platform=provider.platform,
|
||||||
|
setup_seconds=int(end_time - start_time),
|
||||||
|
targets=[t.name for t in targets],
|
||||||
|
)
|
||||||
|
|
||||||
|
if not args.explain and results:
|
||||||
|
results_path = 'test/results/data/%s-%s.json' % (args.command, re.sub(r'[^0-9]', '-', str(datetime.datetime.utcnow().replace(microsecond=0))))
|
||||||
|
|
||||||
|
data = dict(
|
||||||
|
clouds=results,
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(results_path, 'w') as results_fd:
|
||||||
|
results_fd.write(json.dumps(data, sort_keys=True, indent=4))
|
||||||
|
|
||||||
|
|
||||||
class CloudBase(ABC):
|
class CloudBase(ABC):
|
||||||
|
|
|
@ -777,7 +777,12 @@ def command_integration_filtered(args, targets, all_targets):
|
||||||
display.warning('Retrying test target "%s" with maximum verbosity.' % target.name)
|
display.warning('Retrying test target "%s" with maximum verbosity.' % target.name)
|
||||||
display.verbosity = args.verbosity = 6
|
display.verbosity = args.verbosity = 6
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
original_environment.validate(target.name, throw=True)
|
original_environment.validate(target.name, throw=True)
|
||||||
|
end_time = time.time()
|
||||||
|
|
||||||
|
results[target.name]['validation_seconds'] = int(end_time - start_time)
|
||||||
|
|
||||||
passed.append(target)
|
passed.append(target)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
failed.append(target)
|
failed.append(target)
|
||||||
|
|
Loading…
Reference in a new issue