Merge ~chad.smith/cloud-init:tests/integration-simplified-failure-output into cloud-init:master

Proposed by Chad Smith
Status: Merged
Approved by: Chad Smith
Approved revision: e7917b981b7eb762b0df7a73e42fcc9d7f850ecf
Merge reported by: Chad Smith
Merged at revision: d0f6c4602f9cc412d372e10bd7411ff0214c1435
Proposed branch: ~chad.smith/cloud-init:tests/integration-simplified-failure-output
Merge into: cloud-init:master
Diff against target: 64 lines (+46/-1)
1 file modified
tests/cloud_tests/verify.py (+46/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Joshua Powers (community) Approve
Ryan Harper Approve
Review via email: mp+347833@code.launchpad.net

Commit message

tests: provide human-readable integration test summary when --verbose

Integration tests will now provide a brief summary for test failures
listed by platform and distribution. The failure summary will only consist
of failed test name and assert error message.

Drop the verbose dictionary of all integration test output because this
content is unreadable given the large number of integration test results
listed within this dictionary.

Description of the change

verbose test output before:

OK (skipped=2)
2018-06-12 18:39:47,003 - tests.cloud_tests - WARNING - test: platform='lxd', os='artful' failed 1 tests
2018-06-12 18:39:47,003 - tests.cloud_tests - DEBUG - verify results: {'lxd': {'artful': {'modules/apt_pipelining_disable': {'passed': True, 'failures': []}, 'modules/runcmd': {'passed': True, 'failures': []}, 'modules/salt_minion': {'passed': True, 'failures': []}, 'modules/user_groups': {'passed': True, 'failures': []}, 'modules/ssh_auth_key_fingerprints_enable': {'passed': True, 'failures': []}, 'modules/bootcmd': {'passed': True, 'failures': []}, 'modules/keys_to_console': {'passed': True, 'failures': []}, 'main/command_output_simple': {'passed': True, 'failures': []}, 'modules/set_password_expire': {'passed': True, 'failures': []}, 'modules/timezone': {'passed': True, 'failures': []}, 'modules/seed_random_data': {'passed': True, 'failures': []}, 'modules/apt_configure_sources_key': {'passed': True, 'failures': []}, 'modules/write_files': {'passed': True, 'failures': []}, 'modules/lxd_dir': {'passed': True, 'failures': []}, 'modules/ntp_servers': {'passed': True, 'failures': []}, 'modules/apt_configure_proxy': {'passed': True, 'failures': []}, 'modules/snappy': {'passed': True, 'failures': []}, 'modules/set_password': {'passed': True, 'failures': []}, 'modules/ssh_import_id': {'passed': True, 'failures': []}, 'modules/ntp_chrony': {'passed': False, 'failures': [{'traceback': 'Traceback (most recent call last):\n File "/var/lib/jenkins/slaves/torkoal/workspace/cloud-init-integration-lxd-a/cloud-init/tests/cloud_tests/testcases/base.py", line 132, in test_no_stages_errors\n .format(status[stage][\'errors\'], stage))\nAssertionError: 1 != 0 : errors [\'(\\\'ntp\\\', ProcessExecutionError("Unexpected error while running command.\\\\nCommand: [\\\'eatmydata\\\', \\\'apt-get\\\', \\\'--option=Dpkg::Options::=--force-confold\\\', \\\'--option=Dpkg::options::=--force-unsafe-io\\\', \\\'--assume-yes\\\', \\\'--quiet\\\', \\\'install\\\', \\\'chrony\\\']\\\\nExit code: 100\\\\nReason: -\\\\nStdout: -\\\\nStderr: -",))\'] were encountered in stage modules-config\n', 'module': 'tests.cloud_tests.testcases.modules.ntp_chrony', 'function': 'test_no_stages_errors', 'class': 'TestNtpChrony', 'error': 'AssertionError: 1 != 0 : errors [\'(\\\'ntp\\\', ProcessExecutionError("Unexpected error while running command.\\\\nCommand: [\\\'eatmydata\\\', \\\'apt-get\\\', \\\'--option=Dpkg::Options::=--force-confold\\\', \\\'--option=Dpkg::options::=--force-unsafe-io\\\', \\\'--assume-yes\\\', \\\'--quiet\\\', \\\'install\\\', \\\'chrony\\\']\\\\nExit code: 100\\\\nReason: -\\\\nStdout: -\\\\nStderr: -",))\'] were encountered in stage modules-config'}, {'traceback': 'Traceback (most recent call last):\n File "/var/lib/jenkins/slaves/torkoal/workspace/cloud-init-integration-lxd-a/cloud-init/tests/cloud_tests/testcases/base.py", line 149, in test_no_warnings_in_log\n [], warnings, msg="\'WARN\' found inside cloud-init.log")\nAssertionError: Lists differ: [] != ["2018-06-12 12:11:09,883 - util.py[WARNIN[128 chars]led"]\n\nSecond list contains 1 additional elements.\nFirst extra element 0:\n"2018-06-12 12:11:09,883 - util.py[WARNING]: Running module ntp (<module \'cloudinit.config.cc_ntp\' from \'/usr/lib/python3/dist-packages/cloudinit/config/cc_ntp.py\'>) failed"\n\n- []\n+ [\'2018-06-12 12:11:09,883 - util.py[WARNING]: Running module ntp (<module \'\n+ "\'cloudinit.config.cc_ntp\' from "\n+ "\'/usr/lib/python3/dist-packages/cloudinit/config/cc_ntp.py\'>) failed"] : \'WARN\' found inside cloud-init.log\n', 'module': 'tests.cloud_tests.testcases.modules.ntp_chrony', 'function': 'test_no_warnings_in_log', 'class': 'TestNtpChrony', 'error': '+ "\'/usr/lib/python3/dist-packages/cloudinit/config/cc_ntp.py\'>) failed"] : \'WARN\' found inside cloud-init.log'}]}, 'modules/ntp_pools': {'passed': True, 'failures': []}, 'modules/ssh_auth_key_fingerprints_disable': {'passed': True, 'failures': []}, 'modules/apt_configure_security': {'passed': True, 'failures': []}, 'modules/set_hostname': {'passed': True, 'failures': []}, 'modules/set_password_list': {'passed': True, 'failures': []}, 'modules/apt_configure_sources_ppa': {'passed': True, 'failures': []}, 'modules/set_hostname_fqdn': {'passed': True, 'failures': []}, 'modules/locale': {'passed': True, 'failures': []}, 'modules/ca_certs': {'passed': True, 'failures': []}, 'modules/apt_configure_primary': {'passed': True, 'failures': []}, 'modules/package_update_upgrade_install': {'passed': True, 'failures': []}, 'modules/debug_disable': {'passed': True, 'failures': []}, 'modules/final_message': {'passed': True, 'failures': []}, 'modules/apt_pipelining_os': {'passed': True, 'failures': []}, 'modules/lxd_bridge': {'passed': True, 'failures': []}, 'modules/ntp_timesyncd': {'passed': True, 'failures': []}, 'modules/snap': {'passed': True, 'failures': []}, 'modules/debug_enable': {'passed': True, 'failures': []}, 'modules/apt_configure_sources_list': {'passed': True, 'failures': []}, 'bugs/lp1628337': {'passed': True, 'failures': []}, 'modules/apt_configure_disable_suites': {'passed': True, 'failures': []}, 'modules/apt_configure_sources_keyserver': {'passed': True, 'failures': []}, 'modules/byobu': {'passed': True, 'failures': []}, 'modules/set_password_list_string': {'passed': True, 'failures': []}, 'modules/apt_configure_conf': {'passed': True, 'failures': []}, 'modules/ssh_keys_generate': {'passed': True, 'failures': []}, 'modules/ntp': {'passed': True, 'failures': []}}}}

verbose integration test output after this branch:
OK (skipped=2)
2018-06-12 18:47:07,118 - tests.cloud_tests - WARNING - test: platform='lxd', os='artful' failed 1 tests
2018-06-12 18:47:07,118 - tests.cloud_tests - DEBUG -
---- Verify summarized results:

Platform: lxd
  Distro: artful
    test modules passed:46 tests failed:2
    test failures:
    * tests.cloud_tests.testcases.modules.ntp_chrony.TestNtpChrony.test_no_stages_errors
          AssertionError: 1 != 0 : errors ['(\'ntp\', ProcessExecutionError("Unexpected error while running command.\\nCommand: [\'eatmydata\', \'apt-get\', \'--option=Dpkg::Options::=--force-confold\', \'--option=Dpkg::options::=--force-unsafe-io\', \'--assume-yes\', \'--quiet\', \'install\', \'chrony\']\\nExit code: 100\\nReason: -\\nStdout: -\\nStderr: -",))'] were encountered in stage modules-config
    * tests.cloud_tests.testcases.modules.ntp_chrony.TestNtpChrony.test_no_warnings_in_log
          + "'/usr/lib/python3/dist-packages/cloudinit/config/cc_ntp.py'>) failed"] : 'WARN' found inside cloud-init.log

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

Nice!

Is there a reason for the indentation of the results?

Or can the "- Platform: lxd" be left justified?

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:ab9e431e4b40129f33e7747a1900551609dad899
https://jenkins.ubuntu.com/server/job/cloud-init-ci/75/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/75/rebuild

review: Needs Fixing (continuous-integration)
fa3014c... by Chad Smith

reduce indent on all summarized results

Revision history for this message
Ryan Harper (raharper) wrote :

Better. Approve with making ci happy.

review: Approve
Revision history for this message
Joshua Powers (powersj) :
review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:fa3014cd0cf3c1efb24f548ec51e9080fad42ddd
https://jenkins.ubuntu.com/server/job/cloud-init-ci/76/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/76/rebuild

review: Needs Fixing (continuous-integration)
e7917b9... by Chad Smith

pycodestyle fix unused variable

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:e7917b981b7eb762b0df7a73e42fcc9d7f850ecf
https://jenkins.ubuntu.com/server/job/cloud-init-ci/77/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/77/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=d0f6c460

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/cloud_tests/verify.py b/tests/cloud_tests/verify.py
2index 5a68a48..bfb2744 100644
3--- a/tests/cloud_tests/verify.py
4+++ b/tests/cloud_tests/verify.py
5@@ -56,6 +56,51 @@ def verify_data(data_dir, platform, os_name, tests):
6 return res
7
8
9+def format_test_failures(test_result):
10+ """Return a human-readable printable format of test failures."""
11+ if not test_result['failures']:
12+ return ''
13+ failure_hdr = ' test failures:'
14+ failure_fmt = ' * {module}.{class}.{function}\n {error}'
15+ output = []
16+ for failure in test_result['failures']:
17+ if not output:
18+ output = [failure_hdr]
19+ output.append(failure_fmt.format(**failure))
20+ return '\n'.join(output)
21+
22+
23+def format_results(res):
24+ """Return human-readable results as a string"""
25+ platform_hdr = 'Platform: {platform}'
26+ distro_hdr = ' Distro: {distro}'
27+ distro_summary_fmt = (
28+ ' test modules passed:{passed} tests failed:{failed}')
29+ output = ['']
30+ counts = {}
31+ for platform, platform_data in res.items():
32+ output.append(platform_hdr.format(platform=platform))
33+ counts[platform] = {}
34+ for distro, distro_data in platform_data.items():
35+ distro_failure_output = []
36+ output.append(distro_hdr.format(distro=distro))
37+ counts[platform][distro] = {'passed': 0, 'failed': 0}
38+ for _, test_result in distro_data.items():
39+ if test_result['passed']:
40+ counts[platform][distro]['passed'] += 1
41+ else:
42+ counts[platform][distro]['failed'] += len(
43+ test_result['failures'])
44+ failure_output = format_test_failures(test_result)
45+ if failure_output:
46+ distro_failure_output.append(failure_output)
47+ output.append(
48+ distro_summary_fmt.format(**counts[platform][distro]))
49+ if distro_failure_output:
50+ output.extend(distro_failure_output)
51+ return '\n'.join(output)
52+
53+
54 def verify(args):
55 """Verify test data.
56
57@@ -90,7 +135,7 @@ def verify(args):
58 failed += len(fail_list)
59
60 # dump results
61- LOG.debug('verify results: %s', res)
62+ LOG.debug('\n---- Verify summarized results:\n%s', format_results(res))
63 if args.result:
64 util.merge_results({'verify': res}, args.result)
65

Subscribers

People subscribed via source and target branches