Skip to content

Commit 2773101

Browse files
mashhursdonoghuc
andauthored
Simplify running E2E test script on local. (#268)
* Simplify running E2E test script on local. Co-authored-by: Cas Donoghue <[email protected]> * Update .buildkite/scripts/e2e-pipeline/main.py Set `skip-setup` to false which makes sense when running for the first time. Co-authored-by: Cas Donoghue <[email protected]> --------- Co-authored-by: Cas Donoghue <[email protected]>
1 parent df68cfd commit 2773101

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

.buildkite/scripts/e2e-pipeline/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ Make sure you have python installed on you local
4141
pip install -r .buildkite/scripts/e2e-pipeline/requirements.txt
4242
```
4343

44-
### Run
44+
### Run on local
4545
Run the following command from the repo dir:
4646
```bash
47-
python3 .buildkite/scripts/e2e-pipeline/main.py
47+
python3 .buildkite/scripts/e2e-pipeline/main.py --skip-setup=true --integrations='apache','nginx'
4848
```
4949

50+
This will run entire ELK docker containers.
51+
Remove `--skip-setup` or use `--skip-setup=true` if you are running the script for the first time, where it needs to set up elastic-package and integrations.
52+
5053
## Troubleshooting
5154
- The project retries on some operations to overcome timeout issues, uses [`retry` tool](https://formulae.brew.sh/formula/retry). If you get `retry` undefined error, make sure to install it.
5255
```

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
YAML = ruamel.yaml.YAML()
1616

17+
1718
class Bootstrap:
1819
ELASTIC_PACKAGE_DISTRO_URL = "https://api.github.com/repos/elastic/elastic-package/releases/latest"
1920
LOGSTASH_CONTAINER_NAME = "elastic-package-stack-e2e-logstash-1"
@@ -87,7 +88,7 @@ def __scan_for_unsupported_processors(self) -> None:
8788
curr_dir = os.getcwd()
8889
pipeline_definition_file_path = "integrations/packages/**/data_stream/**/elasticsearch/ingest_pipeline/*.yml"
8990
files = glob.glob(os.path.join(curr_dir, pipeline_definition_file_path))
90-
unsupported_processors: dict[list] = {} # {processor_type: list<file>}
91+
unsupported_processors: dict[list] = {} # {processor_type: list<file>}
9192

9293
for file in files:
9394
try:
@@ -185,15 +186,16 @@ def __teardown_stack(self) -> None:
185186
util.run_or_raise_error(["elastic-package", "stack", "down"],
186187
"Error occurred while stopping stacks with elastic-package. Check logs for details.")
187188

188-
def run_elastic_stack(self) -> None:
189+
def run_elastic_stack(self, skip_setup=False) -> None:
189190
"""
190191
Downloads elastic-package, creates a profile and runs ELK, Fleet, ERP and elastic-agent
191192
"""
192-
self.__download_elastic_package()
193-
self.__make_elastic_package_global()
194-
self.__clone_integrations_repo()
195-
self.__scan_for_unsupported_processors()
196-
self.__setup_elastic_package_profile()
193+
if not skip_setup:
194+
self.__download_elastic_package()
195+
self.__make_elastic_package_global()
196+
self.__clone_integrations_repo()
197+
self.__scan_for_unsupported_processors()
198+
self.__setup_elastic_package_profile()
197199
self.__spin_stack()
198200
self.__install_plugin()
199201
self.__reload_container()

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Main entry point of the E2E test suites
33
"""
44

5+
import argparse
56
import os
67
from bootstrap import Bootstrap
78
from plugin_test import PluginTest
@@ -11,6 +12,10 @@
1112

1213

1314
class BootstrapContextManager:
15+
def __init__(self, skip_setup=False):
16+
# save args as attributes
17+
self.skip_setup = skip_setup
18+
1419
def __enter__(self):
1520
stack_version = os.environ.get("ELASTIC_STACK_VERSION")
1621
project_type = os.environ.get("E2E_PROJECT_TYPE", "on_prems")
@@ -19,7 +24,7 @@ def __enter__(self):
1924

2025
print(f"Starting E2E test of Logstash running Elastic Integrations against {stack_version} version.")
2126
self.bootstrap = Bootstrap(stack_version, project_type)
22-
self.bootstrap.run_elastic_stack()
27+
self.bootstrap.run_elastic_stack(self.skip_setup)
2328
return self.bootstrap
2429

2530
def __exit__(self, exc_type, exc_value, traceback):
@@ -30,13 +35,14 @@ def __exit__(self, exc_type, exc_value, traceback):
3035
self.bootstrap.stop_elastic_stack()
3136

3237

33-
def main():
38+
def main(skip_setup=False, integrations=[]):
3439
failed_packages = []
3540

36-
with BootstrapContextManager() as bootstrap:
41+
with BootstrapContextManager(skip_setup) as bootstrap:
3742
working_dir = os.getcwd()
3843
test_plugin = PluginTest()
39-
for package in INTEGRATION_PACKAGES_TO_TEST:
44+
packages = integrations or INTEGRATION_PACKAGES_TO_TEST
45+
for package in packages:
4046
try:
4147
os.chdir(f"{working_dir}/integrations/packages/{package}")
4248
test_plugin.on(package)
@@ -57,4 +63,13 @@ def main():
5763

5864

5965
if __name__ == "__main__":
60-
main()
66+
parser = argparse.ArgumentParser()
67+
parser.add_argument('--skip-setup, 'action='store_false')
68+
parser.add_argument('--integrations')
69+
args = parser.parse_args()
70+
71+
skip_setup = args.skip_setup
72+
integrations = args.integrations.split(',') if args.integrations else []
73+
74+
print(f"Running with --skip-setup:{skip_setup}, --integrations:{integrations}")
75+
main(skip_setup, integrations)

0 commit comments

Comments
 (0)