You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve xpack integration test UX (#18919) (#18934)
- Make ES and Filebeat extraction incremental. copyEs and copyFilebeat now declare inputs / outputs so Gradle skips re-extraction when the tar.gz is unchanged.
- Support running a single xpack spec via `-PrubyIntegrationSpecs` to align with core.
Example: `./gradlew :logstash-xpack:rubyIntegrationTests -PrubyIntegrationSpecs=qa/integration/monitoring/monitoring_is_disabled_spec.rb`
(cherry picked from commit fcfcea0)
# Conflicts:
# x-pack/AGENTS.md
Co-authored-by: Kaise <69120390+kaisecheng@users.noreply.github.com>
Guidance for coding agents working with X-Pack (Elastic-licensed) features. See also the root `AGENTS.md` for general project conventions.
4
+
5
+
## Overview
6
+
7
+
X-Pack provides commercial features that extend the Logstash core. Most features integrate via the **UniversalPlugin** extension pattern; License Checking is a standalone library used by the other features. X-Pack is a separate Ruby package under `x-pack/` with its own test suite. Build without X-Pack by setting `OSS=true`.
8
+
9
+
## Features
10
+
11
+
| Feature | Path | Purpose |
12
+
|---------|------|---------|
13
+
|**Monitoring**|`lib/monitoring/`| Collects JVM, system, and pipeline metrics; ships to Elasticsearch |
14
+
|**Config Management**|`lib/config_management/`| Fetches pipeline configs from Elasticsearch/Kibana |
15
+
|**GeoIP Database Management**|`lib/geoip_database_management/`| Auto-downloads and updates GeoIP databases from Elastic CDN |
16
+
|**License Checking**|`lib/license_checker/`| Validates Elasticsearch license for feature gating |
17
+
18
+
## Extension Pattern
19
+
20
+
Monitoring, Config Management, and GeoIP follow the same integration pattern. Each has an **extension class** inheriting from `LogStash::UniversalPlugin` that implements two methods:
21
+
22
+
1.**`additionals_settings(settings)`** — Registers `xpack.*` configuration settings with the core settings registry.
23
+
2.**`register_hooks(hooks)`** — Registers lifecycle callbacks with `LogStash::Runner` (e.g. `before_bootstrap_checks`, `after_bootstrap_checks`).
24
+
25
+
**Entry point:**`lib/x-pack/logstash_registry.rb` registers all three extensions plus built-in input/output plugins with `LogStash::PLUGIN_REGISTRY`.
26
+
27
+
**Extension files:**
28
+
-`lib/config_management/extension.rb`
29
+
-`lib/geoip_database_management/extension.rb`
30
+
-`lib/monitoring/monitoring.rb` (extension at bottom of file)
31
+
32
+
### Adding New Settings
33
+
34
+
Use `LogStash::Setting::*` classes in `additionals_settings`:
All X-Pack settings use the `xpack.` prefix. Elasticsearch connection options (hosts, SSL, auth, proxy) are shared across features via the `ElasticsearchOptions` helper mixin.
46
+
47
+
## License Checking
48
+
49
+
Features that require a commercial license use the `Licensed` mixin (`lib/license_checker/licensed.rb`):
50
+
51
+
1. Call `setup_license_checker(FEATURE_NAME)` during initialization.
52
+
2. Wrap feature logic in `with_license_check(raise_on_error) { ... }`.
The `LicenseManager` (`lib/license_checker/license_manager.rb`) polls Elasticsearch every 30 seconds and notifies observers on state changes. License types: `trial`, `basic`, `standard`, `gold`, `platinum`, `enterprise`. Config management requires trial or above (not basic).
-**Unit specs:**`x-pack/spec/` — Organized by feature (`spec/monitoring/`, `spec/config_management/`, `spec/geoip_database_management/`, `spec/license_checker/`).
74
+
-**Integration tests:**`x-pack/qa/integration/` — Subdirectories for `management/`, `monitoring/`, and `fips-validation/`.
75
+
-**Test helpers:**`x-pack/spec/support/helpers.rb` and `x-pack/spec/support/matchers.rb`.
76
+
-**Test runners:** JUnit-based RSpec invokers in `x-pack/src/test/java/org/logstash/xpack/test/` (`RSpecTests.java` for unit, `RSpecIntegrationTests.java` for integration).
77
+
78
+
### GeoIP Test Data
79
+
80
+
The `unzipGeolite` Gradle task downloads GeoLite2 test databases. Unit tests for GeoIP depend on this task running first (handled automatically by the `rubyTests` dependency chain).
81
+
82
+
## Key Architectural Patterns
83
+
84
+
-**Hook-based integration.** Config management intercepts bootstrap checks to swap the local config source with an Elasticsearch source. Monitoring adds an internal pipeline after the agent starts. Neither modifies core code directly.
85
+
-**Singleton managers.**`GeoipDatabaseManagement::Manager` and `LicenseChecker::LicenseManager` are singletons with thread-safe initialization via Mutex.
86
+
-**Observer pattern.** Database subscriptions and license managers notify observers on state changes, enabling features to react dynamically without polling.
87
+
-**Internal pipelines.** Monitoring generates its pipeline config from an ERB template (`lib/template.cfg.erb`) and injects it via `InternalPipelineSource`. These run alongside user pipelines but are hidden from the user-facing API.
0 commit comments