-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a custom_junit callback plugin #132
base: master
Are you sure you want to change the base?
Conversation
Build failed (check pipeline). Post https://review.rdoproject.org/zuul/buildset/e8c007fe0bc8493baff88e377f733728 ✔️ openstack-k8s-operators-content-provider SUCCESS in 40m 47s |
recheck |
Build failed (check pipeline). Post https://review.rdoproject.org/zuul/buildset/c8c7ff17afe04310af8bb8e233af99a1 ✔️ openstack-k8s-operators-content-provider SUCCESS in 1h 21m 47s |
- name: Add failure to test result | ||
delegate_to: localhost | ||
lineinfile: | ||
path: "{{ logs_dir }}/test_run_result.xml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buildset logs are showing that this file doesn't exist: https://logserver.rdoproject.org/32/132/8c02c82c6426d08d090b9ae8a036610ab59f5c6f/github-check/functional-tests-on-osp18/3ccb604/controller/ci-framework-data/logs/post_deploy_run_functional_test.log
The logs at https://logserver.rdoproject.org/32/132/8c02c82c6426d08d090b9ae8a036610ab59f5c6f/github-check/functional-tests-on-osp18/3ccb604/controller/ci-framework-data/logs/functional-tests/
have an autoscaling_results file.
You need to update the file names to match.
Build failed (check pipeline). Post https://review.rdoproject.org/zuul/buildset/46d9b206bd794ec2b8a5752e4e7080f4 ✔️ openstack-k8s-operators-content-provider SUCCESS in 1h 30m 52s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/49968e7a68554e05a78f3a2266edf975 ✔️ openstack-k8s-operators-content-provider SUCCESS in 1h 35m 47s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/3c4a444c4e1d40a0b1dcbd3cd550bb96 ✔️ openstack-k8s-operators-content-provider SUCCESS in 1h 51m 13s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/80c5859d0993422db465a39200fc2aeb ✔️ feature-verification-tests-noop SUCCESS in 5s |
line: | | ||
'<testcase classname="openstack-observability" name="configure-hest-template-automatically-scaling_instances" time="1"/>' | ||
'<failure> configure Heat template failed <failure/>'</testcase>' | ||
insertbefore: "</testsuite>" | ||
|
||
- name: increment number of failures | ||
set_fact: | ||
number_of_failures: "{{ number_of_failures | int + 1 }}" | ||
|
||
- name: increment number of tests | ||
set_fact: | ||
number_of_tests: "{{ number_of_tests | int + 1 }}" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be done in v2_playbook_on_stats?
callback_plugins/custom_logger.py
Outdated
@@ -1,92 +1,274 @@ | |||
# (c) 2016 Matt Clay <[email protected]> | |||
# (c) 2017 Ansible Project | |||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy/pasting the existing junitXML plugin is not the way to go.
Either try to contribute upstream to it, or inherit from the existing class here to make changes.
There MIGHT be an issue with using a GPL-licensed library to provide the base class, since this project is not GPL licensed, nor do we plan to adopt GPL v3 as the license.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet another alternative would be to record the results and then render the XML at the end using a jinja2 template, so that there's no back-tracking through the document. However, this would use more memory.
- name: Add pass to test results | ||
delegate_to: localhost | ||
lineinfile: | ||
path: "{{ logs_dir }}/test_run_result.xml" | ||
line: '<testcase classname="openstack-observability" name="configure-hest-template-automatically-scaling-instances" time="1"/>' | ||
insertbefore: "</testsuite>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only test result file I can see.
I need to look for the one generated by the junit plugin
callback_plugins/custom_logger.py
Outdated
host = result._host.get_name() | ||
task_name = result._task.get_name() | ||
self.log_task_result(host, 'passed', task_name) | ||
self._output_dir = os.getcwd() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a sensible default. I don't know where this ends up, maybe on the executer, but it's not in a location that gets uploaded
callback_plugins/custom_logger.py
Outdated
self._fail_on_ignore = os.getenv('JUNIT_FAIL_ON_IGNORE', 'False').lower() | ||
self._include_setup_tasks_in_report = os.getenv('JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT', 'False').lower() | ||
self._hide_task_arguments = os.getenv('JUNIT_HIDE_TASK_ARGUMENTS', 'True').lower() | ||
self._test_case_prefix = os.getenv('JUNIT_TEST_CASE_PREFIX', 'RHOSO') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this needs further work. Using prefix only doesn't work if the same task has multiple test IDs in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this locally, using the test playbook for the custom logger
I left ci/ansible.cfg as-is, and used the following command to test cd ci && ansible-playbook -v github/test_logger.yml
The output was this:
cat *.xml
<?xml version="1.0" ?>
<testsuites disabled="0" errors="0" failures="0" tests="1" time="0.012203693389892578125">
<testsuite disabled="0" errors="0" failures="0" name="test_logger" skipped="0" tests="1" time="0.012203693389892578125">
<testcase classname="/home/emma/repos/github/infrawatch/feature-verification-tests/ci/github/test_logger.yml:6" name="[localhost] Run tests to make sure the custom_logger plugin is running as expected: RHOSO-01 show some message" time="0.012203693389892578">
<system-out>{
"changed": false,
"msg": "You can start the task name with the test ID."
}</system-out>
</testcase>
</testsuite>
</testsuites>
It looks like unexpected values are being used in unexpected places, and the TestCase class probably needs to be updated.
There's also only one testcase recorded because there's only one task with the ID at the start of the name.
callback_plugins/custom_logger.py
Outdated
self._task_class = os.getenv('JUNIT_TASK_CLASS', 'False').lower() | ||
self._task_relative_path = os.getenv('JUNIT_TASK_RELATIVE_PATH', '') | ||
self._fail_on_change = os.getenv('JUNIT_FAIL_ON_CHANGE', 'False').lower() | ||
self._fail_on_ignore = os.getenv('JUNIT_FAIL_ON_IGNORE', 'False').lower() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be true, because we use "ignore_errors: true" in our playbooks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can extend the existing xml plugin, and redefine only what we need.
It should be possible to create a new class, with the existing XML plugin as a base and then redefines the methods we need to update.
Merge Failed. This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset. |
callback_plugins/custom_junit.py
Outdated
@@ -0,0 +1,49 @@ | |||
from ansible.plugins.callback import CallbackModule as OriginalCallbackModule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ansible.plugins.callback.junit.CallbackModule as the superclass
callback_plugins/custom_junit.py
Outdated
from ansible.module_utils._text import to_bytes, to_text | ||
from ansible.utils._junit_xml import TestCase, TestError, TestFailure, TestSuite, TestSuites | ||
|
||
class CustomCallbackModule(OriginalCallbackModule): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CallbackModule is a required classname for ansible to run the module.
Merge Failed. This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset. |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/0c7dd74db81a43028204e648edaadcb0 ✔️ feature-verification-tests-noop SUCCESS in 4s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/15f121dab19441cda6f4bcc84d365aa5 ✔️ feature-verification-tests-noop SUCCESS in 5s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/abdfd613a7144e99a17b7380cb3eb14b ✔️ feature-verification-tests-noop SUCCESS in 4s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/47ac0c5c769f457f8f3111222c249bef ✔️ feature-verification-tests-noop SUCCESS in 4s |
recheck |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/97af9659e8c7442f933f22d5df65f300 ✔️ feature-verification-tests-noop SUCCESS in 4s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/d9453489e33749a5ab3a54abc929a062 ✔️ feature-verification-tests-noop SUCCESS in 4s |
The original test ID that custom_logger uses is still in the name, Custom logger will record test results as long as the expected test ids are in the name somewhere.
Use copy with remote src instead of shell/cp, so that the files can be copied from compute nodes into the controller logs dir Add a new play to make sure the output dir is created on the controller before copying the files.
Rename the files using the hostname of the src
ea2e1f1
to
3f163bf
Compare
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/9f2fafd5337146e0b77da991fd146755 ✔️ feature-verification-tests-noop SUCCESS in 5s |
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/78ad75d4b36c420a960550cdda1e0c09 ✔️ feature-verification-tests-noop SUCCESS in 4s |
This custom_junit plugin extends the existing junit plugin and produces an XML report with classes and names that polarian expects.