diff --git a/callback_plugins/custom_junit.py b/callback_plugins/custom_junit.py index f1b84c37..eee3afc5 100644 --- a/callback_plugins/custom_junit.py +++ b/callback_plugins/custom_junit.py @@ -6,6 +6,44 @@ import re from ansible.utils._junit_xml import TestCase, TestError, TestFailure, TestSuite, TestSuites +DOCUMENTATION = ''' + callback: custom_junit + type: notification + short_description: TODO + description: + custom_junit generates an XML files 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. + 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 + output_dir: + description: the direcory which the output files are saved to + ini: + - section: custom_junit + key: output_dir + env: + - name: JUNIT_OUTPUT_DIR + default: "~/ci-framework-data/tests/feature-verification-tests/" + type: path +''' class CallbackModule(JunitCallbackModule): """ @@ -14,12 +52,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("~/ci-framework-data/tests/feature-verification-tests/") - self._test_case_prefix = os.getenv('JUNIT_TEST_CASE_PREFIX', 'TEST') + self._output_dir = self.get_option("output_dir") + 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 +145,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