Here we make a number of changes to port the existing specs to a form that validates the same desired behaviour without needing to reach into the implementation of the LS-core-provided extension.
we can trust that ifLogStash::Filters::GeoIP::DatabaseManager is available:
it will be a singleton that responds to subscribe_database_path and unsubscribe_database_path, and behaves as-specified in Logstash core, so we can write our spec in terms of those two methods only
it and its Extension will be loaded before an instance of this plugin can be instantiated, and therefore we should side-load the extension directly before running tests
when DISTRIBUTION=oss, x-pack isn't loaded and specs show behaviour without database manager
ci-logstash-1 | X-PACK is not available
ci-logstash-1 | Logstash >= 7.14
ci-logstash-1 | OSS-only
ci-logstash-1 | load_database_manager? should be false
ci-logstash-1 | select_database_path without path setting
ci-logstash-1 | should be default
ci-logstash-1 | when no database_path is given
ci-logstash-1 | when geoip database management is not available
ci-logstash-1 | enriches events
ci-logstash-1 | uses a plugin-vendored database
when 7.x or 8.x SNAPSHOT=false, the old extension is loaded
ci-logstash-1 | ADDING LOGSTASH X-PACK to load path: /usr/share/logstash/x-pack/lib
ci-logstash-1 | loading logstash extension for geoip: LogStash::Filters::Geoip::Extension
when 8.x SNAPSHOT=true the new extension is loaded
ci-logstash-1 | ADDING LOGSTASH X-PACK to load path: /usr/share/logstash/x-pack/lib
ci-logstash-1 | loading logstash extension for geoip: LogStash::GeoipDatabaseManagement::Extension
when default distro and dbm is available, we validate the behaviour:
ci-logstash-1 | Logstash >= 7.14
ci-logstash-1 | default distro
ci-logstash-1 | load_database_manager? should be true
ci-logstash-1 | when no database_path is given
ci-logstash-1 | when geoip database management is available
ci-logstash-1 | uses a managed database
ci-logstash-1 | enriches events
The existing specs reach into the internals of the Geoip Database Manager that may be provided by LS core, but those details are changing with Logstash 8.12's introduction of a Geoip Database Manager as a core feature.
Here we make a number of changes to port the existing specs to a form that validates the same desired behaviour without needing to reach into the implementation of the LS-core-provided extension.
LogStash::Filters::GeoIP::DatabaseManager
is available:subscribe_database_path
andunsubscribe_database_path
, and behaves as-specified in Logstash core, so we can write our spec in terms of those two methods onlyExtension
will be loaded before an instance of this plugin can be instantiated, and therefore we should side-load the extension directly before running testsNOTE: I've captured the output of the specs as-run on LS
7.x
,8.x SNAPSHOT=false
(old manager),8.x SNAPSHOT=true
(afterelastic/logstash#15348
), etc:https://gist.github.com/yaauie/fa042e9e22d08ad2a2c9f279f41f505e
Things to look for:
DISTRIBUTION=oss
, x-pack isn't loaded and specs show behaviour without database manager7.x
or8.x SNAPSHOT=false
, the old extension is loaded8.x SNAPSHOT=true
the new extension is loaded