-
Notifications
You must be signed in to change notification settings - Fork 9
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
[custom_junit] Add config options via ini file and env var #160
Open
elfiesmelfie
wants to merge
1
commit into
master
Choose a base branch
from
efoley_custom_junit_update_configuration_options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,32 @@ | |
import re | ||
from ansible.utils._junit_xml import TestCase, TestError, TestFailure, TestSuite, TestSuites | ||
|
||
DOCUMENTATION = ''' | ||
callback: custom_junit | ||
type: notification | ||
short_description: TODO | ||
description: | ||
TODO | ||
options: | ||
test_case_prefix: | ||
description: todo | ||
ini: | ||
- section: custom_junit | ||
key: test_case_prefix | ||
env: | ||
- name: JUNIT_TEST_CASE_PREFIX | ||
default: "TEST" | ||
type: string | ||
classname: | ||
description: The classname for the tests. | ||
ini: | ||
- section: custom_junit | ||
key: classname | ||
env: | ||
- name: CUSTOM_JUNIT_CLASSNAME | ||
default: "openstack-observability" | ||
type: string | ||
''' | ||
|
||
class CallbackModule(JunitCallbackModule): | ||
""" | ||
|
@@ -14,12 +40,15 @@ class CallbackModule(JunitCallbackModule): | |
CALLBACK_NAME = 'custom_junit' | ||
|
||
def __init__(self): | ||
self._defs = None | ||
super(CallbackModule, self).__init__() | ||
self.set_options() | ||
|
||
# Custom environment variable handling | ||
# Update this to parse these values from the config file, as well as the env. | ||
self._output_dir = os.path.expanduser("~/.ansible.log") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also be configurable, so we could point it at the expect logs dir in zuul jobs. |
||
self._test_case_prefix = os.getenv('JUNIT_TEST_CASE_PREFIX', 'TEST') | ||
self._test_case_prefix = self.get_option("test_case_prefix") | ||
self._classname = self.get_option("classname") | ||
|
||
self._fail_on_ignore = 'true' # this is needed because we use "ignore_errors" on the playbooks so that all the tests are run | ||
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() | ||
|
@@ -104,5 +133,5 @@ def _build_test_case(self, task_data, host_data): | |
# system_err elements that show STDOUT and STDERR | ||
tc.system_out = None | ||
tc.system_err = None | ||
tc.classname = "openstack-observability" | ||
tc.classname = self._classname | ||
return tc |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
custom_junit generates an XML file that polarion can read.
Only the tasks marked with $test_case_prefix are reported.
The first line of the task name (excluding the prefix) is converted to snake_case, and this becomes the testcase name in the results file.