Skip to content

Commit 4b0654a

Browse files
authored
Add an E2E step to scan unsupported processors. (#242)
* Add a step to scan unsupported processors. * Tracking multiple data stream file and map to processor type dictionary.
1 parent 63aa130 commit 4b0654a

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

.buildkite/scripts/e2e-pipeline/bootstrap.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,27 @@
55
- Clone integrations repo and prepare packages
66
- When E2E finishes, teardown the stack
77
"""
8+
import glob
89
import os
910
import sys
1011
import time
1112
import util
13+
import ruamel.yaml
1214

15+
YAML = ruamel.yaml.YAML()
1316

1417
class Bootstrap:
1518
ELASTIC_PACKAGE_DISTRO_URL = "https://api.github.com/repos/elastic/elastic-package/releases/latest"
1619
LOGSTASH_CONTAINER_NAME = "elastic-package-stack-e2e-logstash-1"
1720
PLUGIN_NAME = "logstash-filter-elastic_integration"
1821

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+
1929
def __init__(self, stack_version: str, project_type: str) -> None:
2030
f"""
2131
A constructor of the {Bootstrap}.
@@ -73,6 +83,34 @@ def __clone_integrations_repo(self) -> None:
7383
"https://github.com/elastic/integrations.git"],
7484
"Error occurred while cloning an integrations repo. Check logs for details.")
7585

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+
76114
def __get_profile_path(self) -> str:
77115
return os.path.join(util.get_home_path(), ".elastic-package/profiles/e2e")
78116

@@ -154,6 +192,7 @@ def run_elastic_stack(self) -> None:
154192
self.__download_elastic_package()
155193
self.__make_elastic_package_global()
156194
self.__clone_integrations_repo()
195+
self.__scan_for_unsupported_processors()
157196
self.__setup_elastic_package_profile()
158197
self.__spin_stack()
159198
self.__install_plugin()
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
requests==2.31.0
2-
docker==7.0.0
2+
docker==7.0.0
3+
ruamel.yaml==0.18.10

0 commit comments

Comments
 (0)