From e2135b8d68b439ba050e8cbdc3eefd81608aa4bb Mon Sep 17 00:00:00 2001 From: John Westcott IV <32551173+john-westcott-iv@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:24:06 -0400 Subject: [PATCH] Collection meta runtime updates (#11952) * Update runtime.yml * Extending test_completness to include meta/runtime.yml and adding remaining missing modules from runtime.yml Co-authored-by: quasd --- awx_collection/meta/runtime.yml | 15 +++++++- awx_collection/test/awx/test_completeness.py | 37 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/awx_collection/meta/runtime.yml b/awx_collection/meta/runtime.yml index 519c9b8301..e611902ccf 100644 --- a/awx_collection/meta/runtime.yml +++ b/awx_collection/meta/runtime.yml @@ -2,13 +2,23 @@ requires_ansible: '>=2.9.10' action_groups: controller: + - ad_hoc_command + - ad_hoc_command_cancel + - ad_hoc_command_wait + - application + - controller_meta - credential_input_source - credential - credential_type + - execution_environment + - export - group - host + - import + - instance_group - inventory - inventory_source + - inventory_source_update - job_cancel - job_launch - job_list @@ -16,18 +26,21 @@ action_groups: - job_wait - label - license - - notification + - notification_template - organization - project + - project_update - role - schedule - settings - team - token - user + - workflow_approval - workflow_job_template_node - workflow_job_template - workflow_launch + - workflow_node_wait plugin_routing: inventory: tower: diff --git a/awx_collection/test/awx/test_completeness.py b/awx_collection/test/awx/test_completeness.py index 98a6598dff..8f3deae7b1 100644 --- a/awx_collection/test/awx/test_completeness.py +++ b/awx_collection/test/awx/test_completeness.py @@ -7,6 +7,7 @@ from ansible.module_utils.six import string_types import yaml import os import re +import glob # Analysis variables # ----------------------------------------------------------------------------------------------------------- @@ -93,6 +94,40 @@ def cause_error(msg): return msg +def test_meta_runtime(): + base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) + meta_filename = 'meta/runtime.yml' + module_dir = 'plugins/modules' + + print("\nMeta check:") + + with open('{0}/{1}'.format(base_dir, meta_filename), 'r') as f: + meta_data_string = f.read() + + meta_data = yaml.load(meta_data_string, Loader=yaml.Loader) + + needs_grouping = [] + for file_name in glob.glob('{0}/{1}/*'.format(base_dir, module_dir)): + if not os.path.isfile(file_name) or os.path.islink(file_name): + continue + with open(file_name, 'r') as f: + if 'extends_documentation_fragment: awx.awx.auth' in f.read(): + needs_grouping.append(os.path.splitext(os.path.basename(file_name))[0]) + + needs_to_be_removed = list(set(meta_data['action_groups']['controller']) - set(needs_grouping)) + needs_to_be_added = list(set(needs_grouping) - set(meta_data['action_groups']['controller'])) + + needs_to_be_removed.sort() + needs_to_be_added.sort() + + group = 'action-groups.controller' + if needs_to_be_removed: + print(cause_error("The following items should be removed from the {0} {1}:\n {2}".format(meta_filename, group, '\n '.join(needs_to_be_removed)))) + + if needs_to_be_added: + print(cause_error("The following items should be added to the {0} {1}:\n {2}".format(meta_filename, group, '\n '.join(needs_to_be_added)))) + + def determine_state(module_id, endpoint, module, parameter, api_option, module_option): # This is a hierarchical list of things that are ok/failures based on conditions @@ -319,5 +354,7 @@ def test_completeness(collection_import, request, admin_user, job_template, exec ) ) + test_meta_runtime() + if return_value != 0: raise Exception("One or more failures caused issues")