summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2017-08-25 18:14:47 -0400
committerGitHub <noreply@github.com>2017-08-25 18:14:47 -0400
commitf71d8615637560c26d54e314451ada1b1781b02e (patch)
tree9232138b03865395db6129158cb49978fab4b4dd
parent357119f3b7e67293359285eb7b2cd1c920ec5376 (diff)
downloadansible-f71d8615637560c26d54e314451ada1b1781b02e.tar.gz
Collect data from integration test runs. (#28650)
-rw-r--r--.gitignore1
-rw-r--r--test/results/data/.keep0
-rw-r--r--test/runner/lib/executor.py32
3 files changed, 33 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index cffbbbec24..8b36dee09f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@ packaging/release/ansible_release
/test/results/bot/*.json
/test/results/junit/*.xml
/test/results/logs/*.log
+/test/results/data/*.json
/test/integration/inventory.remote
/test/integration/inventory.networking
/test/integration/inventory.winrm
diff --git a/test/results/data/.keep b/test/results/data/.keep
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/results/data/.keep
diff --git a/test/runner/lib/executor.py b/test/runner/lib/executor.py
index 422da2f21f..d378e0a1c8 100644
--- a/test/runner/lib/executor.py
+++ b/test/runner/lib/executor.py
@@ -5,6 +5,7 @@ from __future__ import absolute_import, print_function
import json
import os
import collections
+import datetime
import re
import tempfile
import time
@@ -554,6 +555,8 @@ def command_integration_filtered(args, targets, all_targets):
start_at_task = args.start_at_task
+ results = {}
+
for target in targets_iter:
if args.start_at and not found:
found = target.name == args.start_at
@@ -580,6 +583,9 @@ def command_integration_filtered(args, targets, all_targets):
try:
run_setup_targets(args, test_dir, target.setup_once, all_targets_dict, setup_targets_executed, False)
+
+ start_time = time.time()
+
run_setup_targets(args, test_dir, target.setup_always, all_targets_dict, setup_targets_executed, True)
if not args.explain:
@@ -592,6 +598,22 @@ def command_integration_filtered(args, targets, all_targets):
else:
command_integration_role(args, target, start_at_task)
start_at_task = None
+
+ end_time = time.time()
+
+ results[target.name] = dict(
+ name=target.name,
+ type=target.type,
+ aliases=target.aliases,
+ modules=target.modules,
+ run_time_seconds=int(end_time - start_time),
+ setup_once=target.setup_once,
+ setup_always=target.setup_always,
+ coverage=args.coverage,
+ coverage_label=args.coverage_label,
+ python_version=args.python_version,
+ )
+
break
except SubprocessError:
if cloud_environment:
@@ -626,6 +648,16 @@ def command_integration_filtered(args, targets, all_targets):
finally:
display.verbosity = args.verbosity = verbosity
+ if not args.explain:
+ results_path = 'test/results/data/%s-%s.json' % (args.command, re.sub(r'[^0-9]', '-', str(datetime.datetime.utcnow().replace(microsecond=0))))
+
+ data = dict(
+ targets=results,
+ )
+
+ with open(results_path, 'w') as results_fd:
+ results_fd.write(json.dumps(data, sort_keys=True, indent=4))
+
if failed:
raise ApplicationError('The %d integration test(s) listed below (out of %d) failed. See error output above for details:\n%s' % (
len(failed), len(passed) + len(failed), '\n'.join(target.name for target in failed)))