|
5 | 5 | - Clone integrations repo and prepare packages
|
6 | 6 | - When E2E finishes, teardown the stack
|
7 | 7 | """
|
| 8 | +import glob |
8 | 9 | import os
|
9 | 10 | import sys
|
10 | 11 | import time
|
11 | 12 | import util
|
| 13 | +import ruamel.yaml |
12 | 14 |
|
| 15 | +YAML = ruamel.yaml.YAML() |
13 | 16 |
|
14 | 17 | class Bootstrap:
|
15 | 18 | ELASTIC_PACKAGE_DISTRO_URL = "https://api.github.com/repos/elastic/elastic-package/releases/latest"
|
16 | 19 | LOGSTASH_CONTAINER_NAME = "elastic-package-stack-e2e-logstash-1"
|
17 | 20 | PLUGIN_NAME = "logstash-filter-elastic_integration"
|
18 | 21 |
|
| 22 | + SUPPORTED_PROCESSORS: list = [ |
| 23 | + "append", "bytes", "community_id", "convert", "csv", "date", "date_index_name", "dissect", "dot_expander", |
| 24 | + "drop", "fail", "fingerprint", "foreach", "grok", "gsub", "html_strip", "join", "json", "kv", "lowercase", |
| 25 | + "network_direction", "pipeline", "registered_domain", "remove", "rename", "reroute", "script", "set", |
| 26 | + "sort", "split", "trim", "uppercase", "uri_parts", "urldecode", "user_agent", "redact", "geoip" |
| 27 | + ] |
| 28 | + |
19 | 29 | def __init__(self, stack_version: str, project_type: str) -> None:
|
20 | 30 | f"""
|
21 | 31 | A constructor of the {Bootstrap}.
|
@@ -73,6 +83,34 @@ def __clone_integrations_repo(self) -> None:
|
73 | 83 | "https://github.com/elastic/integrations.git"],
|
74 | 84 | "Error occurred while cloning an integrations repo. Check logs for details.")
|
75 | 85 |
|
| 86 | + def __scan_for_unsupported_processors(self) -> None: |
| 87 | + curr_dir = os.getcwd() |
| 88 | + pipeline_definition_file_path = "integrations/packages/**/data_stream/**/elasticsearch/ingest_pipeline/*.yml" |
| 89 | + files = glob.glob(os.path.join(curr_dir, pipeline_definition_file_path)) |
| 90 | + unsupported_processors: dict[list] = {} # {processor_type: list<file>} |
| 91 | + |
| 92 | + for file in files: |
| 93 | + try: |
| 94 | + with open(file, "r") as f: |
| 95 | + yaml_content = YAML.load(f) |
| 96 | + processors = yaml_content.get("processors", []) |
| 97 | + |
| 98 | + for processor in processors: |
| 99 | + for processor_type, _ in processor.items(): |
| 100 | + if processor_type not in self.SUPPORTED_PROCESSORS: |
| 101 | + if processor_type not in unsupported_processors: |
| 102 | + unsupported_processors[processor_type]: list = [] |
| 103 | + if file not in unsupported_processors[processor_type]: |
| 104 | + unsupported_processors[processor_type].append(file) |
| 105 | + except Exception as e: |
| 106 | + # Intentionally failing CI for better visibility |
| 107 | + # For the long term, creating a whitelist of unsupported processors (assuming _really_ cannot support) |
| 108 | + # and skipping them by warning would be ideal approach. |
| 109 | + print(f"Failed to parse file: {file}. Error: {e}") |
| 110 | + |
| 111 | + if len(unsupported_processors) > 0: |
| 112 | + raise Exception(f"Unsupported processors found: {unsupported_processors}") |
| 113 | + |
76 | 114 | def __get_profile_path(self) -> str:
|
77 | 115 | return os.path.join(util.get_home_path(), ".elastic-package/profiles/e2e")
|
78 | 116 |
|
@@ -154,6 +192,7 @@ def run_elastic_stack(self) -> None:
|
154 | 192 | self.__download_elastic_package()
|
155 | 193 | self.__make_elastic_package_global()
|
156 | 194 | self.__clone_integrations_repo()
|
| 195 | + self.__scan_for_unsupported_processors() |
157 | 196 | self.__setup_elastic_package_profile()
|
158 | 197 | self.__spin_stack()
|
159 | 198 | self.__install_plugin()
|
|
0 commit comments