-
Notifications
You must be signed in to change notification settings - Fork 13
Add an E2E step to scan unsupported processors. #242
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,27 @@ | |
- Clone integrations repo and prepare packages | ||
- When E2E finishes, teardown the stack | ||
""" | ||
import glob | ||
import os | ||
import sys | ||
import time | ||
import util | ||
import ruamel.yaml | ||
|
||
YAML = ruamel.yaml.YAML() | ||
|
||
class Bootstrap: | ||
ELASTIC_PACKAGE_DISTRO_URL = "https://api.github.com/repos/elastic/elastic-package/releases/latest" | ||
LOGSTASH_CONTAINER_NAME = "elastic-package-stack-e2e-logstash-1" | ||
PLUGIN_NAME = "logstash-filter-elastic_integration" | ||
|
||
SUPPORTED_PROCESSORS: list = [ | ||
"append", "bytes", "community_id", "convert", "csv", "date", "date_index_name", "dissect", "dot_expander", | ||
"drop", "fail", "fingerprint", "foreach", "grok", "gsub", "html_strip", "join", "json", "kv", "lowercase", | ||
"network_direction", "pipeline", "registered_domain", "remove", "rename", "reroute", "script", "set", | ||
"sort", "split", "trim", "uppercase", "uri_parts", "urldecode", "user_agent", "redact", "geoip" | ||
] | ||
|
||
def __init__(self, stack_version: str, project_type: str) -> None: | ||
f""" | ||
A constructor of the {Bootstrap}. | ||
|
@@ -73,6 +83,34 @@ def __clone_integrations_repo(self) -> None: | |
"https://github.com/elastic/integrations.git"], | ||
"Error occurred while cloning an integrations repo. Check logs for details.") | ||
|
||
def __scan_for_unsupported_processors(self) -> None: | ||
curr_dir = os.getcwd() | ||
pipeline_definition_file_path = "integrations/packages/**/data_stream/**/elasticsearch/ingest_pipeline/*.yml" | ||
files = glob.glob(os.path.join(curr_dir, pipeline_definition_file_path)) | ||
unsupported_processors: dict[list] = {} # {processor_type: list<file>} | ||
|
||
for file in files: | ||
try: | ||
with open(file, "r") as f: | ||
yaml_content = YAML.load(f) | ||
processors = yaml_content.get("processors", []) | ||
|
||
for processor in processors: | ||
for processor_type, _ in processor.items(): | ||
if processor_type not in self.SUPPORTED_PROCESSORS: | ||
if processor_type not in unsupported_processors: | ||
unsupported_processors[processor_type]: list = [] | ||
if file not in unsupported_processors[processor_type]: | ||
unsupported_processors[processor_type].append(file) | ||
except Exception as e: | ||
# Intentionally failing CI for better visibility | ||
# For the long term, creating a whitelist of unsupported processors (assuming _really_ cannot support) | ||
# and skipping them by warning would be ideal approach. | ||
print(f"Failed to parse file: {file}. Error: {e}") | ||
|
||
if len(unsupported_processors) > 0: | ||
raise Exception(f"Unsupported processors found: {unsupported_processors}") | ||
|
||
def __get_profile_path(self) -> str: | ||
return os.path.join(util.get_home_path(), ".elastic-package/profiles/e2e") | ||
|
||
|
@@ -154,6 +192,7 @@ def run_elastic_stack(self) -> None: | |
self.__download_elastic_package() | ||
self.__make_elastic_package_global() | ||
self.__clone_integrations_repo() | ||
self.__scan_for_unsupported_processors() | ||
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. 🤔 so if the elastic/integrations begin using an unsupported processor, our build breaks. I think we might end up needing a "known incompatibilities" list so that we can mark something as known and get our build back to green once we file an issue to address it. 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. Yup this is the idea for the long term. As soon as we will have unsupported plugin (assuming the plugin really cannot support), we will have a white list to continue the E2E without failing. For now, for better visibility breaking CI (since it is important to know which integration will become problematic) seems better to me. 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. I will comment this plan in the raising failure part of the source. |
||
self.__setup_elastic_package_profile() | ||
self.__spin_stack() | ||
self.__install_plugin() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
requests==2.31.0 | ||
docker==7.0.0 | ||
docker==7.0.0 | ||
ruamel.yaml==0.18.10 |
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.
it would be nice to codify this in a shared yaml that is consumed by the EventProcessorBuilder.
Not a blocker, though. Could you file an issue to unify it?
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.
This is good idea! Otherwise we need to maintain both places. Yup let me see if I can do it with change. Otherwise I will create an issue and follow up 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.
Created an issue: #249
We can utilize https://github.com/c2nes/javalang to parse the Java class and compare with the processors found from the file. I will follow up and add separately.