Commit graph

88 commits

Author SHA1 Message Date
Dimitrios Liappis
72900ae7c6
Fix IT tests after version bumps (#15827) (#15839)
This commit fixes IT failures that frequently occur after
version bumps due to missing unified release snapshot builds for
the new version.

This commit uses project specific DRA snapshot URLs for ES and Filebeat
in all cases apart from release builds.

(cherry picked from commit d74fea4b55)
2024-01-23 16:41:19 +02:00
Andrea Selva
694ef69c45
Updates installDefaultGems task to replace Xerces (#15357)
Replaces the Xerces version shipped with Nokogiri
2023-09-28 16:49:41 +02:00
Edmo Vamerlatti Costa
55b39e17f9
Add release flag on the Gradle CompileJava task (#15178)
This commit adds the --release (JEP 247) option to Gradle's CompileJava task, with the same targetCompatibility major version value.
2023-07-17 14:36:49 +02:00
kaisecheng
1a5ef6ad13
pin snakeyaml to 1.33 (#14960)
Co-authored-by: Mashhur Sattorov <mashhur.sattorov@elastic.co>
2023-03-14 13:06:08 +00:00
github-actions[bot]
44b1913a15
pin bundler 2.3.18 to avoid bug in .19 (#14394) (#14404)
When using Bundler 2.3.19, doing a "bin/logstash-plugin uninstall <plugin>"
will crash, failing to find gems in the :build group.

Until we know more about why, pin bundler to 2.3.19

(cherry picked from commit 8aa62dc441)

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2022-08-02 16:54:41 +02:00
github-actions[bot]
b5e72822ef
Switch adoptopenjdk url to adoptium (#14098) (#14222)
* Switch adoptopenjdk url to adoptium

Newer versions of the JDK are only available from api.adoptium.net, and not dual hosted on api.adoptopenjdk.net
This commit allows the use of adoptium versions of the JDK.

Relates: #14072
(cherry picked from commit 9e2c87a1ab)

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2022-06-07 11:10:35 -04:00
Karol Bucek
4f6419fd1c
Build: avoid doing a redundant bundle install (#13820) (#13824)
(cherry picked from commit c3d2f5750f)
2022-03-01 17:41:20 +01:00
kaisecheng
5197b340aa
Unpin bundler, fix gem installer tests (#13762) (#13776)
Fix gem installer tests to enable unpinning the version of bundler

This commit removes changes the gem installer to use real gems, rather than
use `allow_instance_of` during testing, which appears to be problematic with the
latest version of bundler
# Conflicts:
#	build.gradle

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2022-02-15 15:52:09 +00:00
Andrea Selva
959248ac4d
[backport 7.x] Gradle 7 updates, issue #13177 (#13212)
This commit is a backport of three PRs #13182 #13183 #13184
Mainly it switched the Gradle to version 7 and applies fixes to make it run.
2021-09-08 15:16:52 +02:00
Rob Bavey
2ac869a9c4
Backport PR #13015 to 7.x: Bundler: freeze lockfile on run, and "norm… (#13140)
* Backport PR #13015 to 7.x: Bundler: freeze lockfile on run, and "normalize" platform on plugin changes

Backport PR #13015 to 7.x branch. Original Message:

This PR enables the upgrade of bundler to the latest version.

Prior to this PR, the ability to do so was blocked by bundler.setup in versions of bundler > `2.23` making runtime changes to `Gemfile.lock` (unless the lock file was `frozen`) based on the specific platform the application was being run on, overriding any platforms (including generic `java` platform) set during build time. This was in conflict with changes made in #12782, which prevented the logstash user writing to files in `/usr/share/logstash`.

This PR will freeze the lockfile when logstash is run, and unfreeze it when manipulating plugins (install, update, remove, install from offline pack) to allow new plugins to be added. While unfrozen, changes are also made to ensure that the platform list remains as the generic `java` platform, and not changed to the specific platform for the runtime JVM.

This PR also introduces a new runtime flag, `--enable-local-plugin-development`. This flag is intended for use by Logstash developers only, and enables a mode of operation where a Gemfile can be manipulated, eg

```
gem "logstash-integration-kafka", :path => '/users/developer/code/plugins/logstash-integration-kafka'
```

to facilitate quick and simple plugin testing.

This PR also sets the `silence_root_warning` flag to avoid bundler printing out alarming looking warning messages when `sudo` is used. This warning message was concerning for users - it would be printed out during normal operation of `bin/logstash-plugin install/update/remove` when run under `sudo`, which is the expected mode of operation when logstash is installed to run as a service via rpm/deb packages.

This PR also updates the vagrant based integration tests to ensure that Logstash still runs after plugin update/install/remove operations, fixes up some regular expressions that would cause test failures, and removes some dead code from tests.

* Updated Bundler to latest version
* Ensured that `Gemfile.lock` are appropriately frozen
* Added new developer-only flag to facilitate local plugin development to allow unfrozen lockfile in a development environment

(cherry picked from commit 4707cb)

* Remove code pinning bundler to ~> 1.17
2021-08-17 20:31:26 -04:00
Andrea Selva
24314350ab
[bacport 7.x] Update Snakeyaml version to 1.29 (#13129) (#13134)
Snakeyaml is used only in the build chain, and it's not packaged with Logstash

(cherry picked from commit a7f6c01a3a)
2021-08-16 14:29:07 +02:00
Andrea Selva
f33522f521
[backport 7.x]Move retrieval of Stack version from Gradle's configuration to execution (#13042) (#13066)
The Gradle's configuration of task should be as fast as possible and don't break the build.
This commit moves retrieval of Elastic Stack version from the remote registry to the execution phase of the tasks.
Also the tasks that depends on this has received the same change (downloadEs and check EsSHA), moving from configuration to execution phase.

Close #13030

(cherry picked from commit cef339ce57)
2021-07-13 08:53:19 +02:00
Andrea Selva
2ce40ced1b
Emergency revert to make bump 7.15.0 (#13037)
Revert "Change Gradle's :logstash-integration-tests:integrationTests task to depends on copyES (#12847) (#12868)"

This reverts commit 5287e7740e.
2021-06-30 19:24:36 +01:00
Andrea Selva
c081985782
Add unit test to grant that production aliases correspond to a published RubyGem (#12993) (#13009)
Loads the production plugin_aliases.yml definition file and check that every alias has
a properly published gem on RubyGems.

Adds clean up of plugin_aliases.yml files
Fixed task dependency for copyPluginAlias

(cherry picked from commit a5f3153a8f)
2021-06-28 16:54:08 +02:00
Andrea Selva
f063d86c31
Added test to cover the installation of aliased plugins (#12967) (#12998)
Added test to cover the installation of aliased plugins when exists a gem with same name but that's not a Logstash plugin.
In this case the alias is resolved to the original, skipping the gem retrieved from RubyGems.

(cherry picked from commit cafbf03158)
2021-06-17 17:01:14 +02:00
Andrea Selva
854fad6339
Avoid hard-coded plugin alias definitions (#12841) (#12960)
Remove hard coded alias definitions in favor of yaml descriptor file.

Introduce a single point of aliases definition (logstash-core/src/main/resources/org/logstash/plugins/AliasRegistry.yml),  checksum and copy it around to be used by Logstash and by Logstash's plugin management tool.

The descriptor yml file contains a checksum to verify it's not changed accidentally in a deployment of Logstash, if the verification phase fail Logstash avoid to start and plugin management tool avoid to operate.
The signing and copying around is managed by a specific Gradle task invoked during the build.

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>

Fixes #12831

(cherry picked from commit 446dc7d906)
2021-06-16 17:34:46 +02:00
Andrea Selva
5287e7740e
Change Gradle's :logstash-integration-tests:integrationTests task to depends on copyES (#12847) (#12868)
The integrationTests start instances of Elasticsearch so they need it to be present and unpacked in build/ folder before start.

(cherry picked from commit 149ee41a8b)
2021-05-03 12:43:09 +02:00
andsel
c96ae0d4bd Fix the run of copyEs and downloadEs gradle task. (#12586)
Avoid the deletion of downaloaded ES artifact during copyEs task and download a new version only if the SHA512 of the local copy differs from the what is retrived from remote repository.
This avoid unusefull download of the same ES artifact when run integrationTests task multiple times.
2021-02-03 09:45:48 -08:00
andsel
05ec149b39 Enable javadoc lint only for files that contains javadoc comments, avoid warning for missing javadoc comments on everything else
(cherry picked from commit d176e608bd)
2020-12-21 08:18:07 -08:00
andsel
06418b8631 Fix error due to missing variable when listitng tasks and no architecture is externally specified with -Pos_arch=
(cherry picked from commit 7144a3f7cf)
2020-12-10 07:09:11 -08:00
Karol Bucek
a693fa3bf4
Build: properly isolate integration (test) env setup (#12364)
to avoid gems being resolved from the usual LS GEM_HOME

this is problematic for gems such as jruby-openssl which are loaded
during boot (by RGs/Bundler) and thus activated in Bundler from a
different GEM_HOME. if such gem is updated it won't end up being
install-ed in the --path location as it's found on the GEM_HOME!

+ Fix: gem conflict 1.3.6 required by core
this is due now isolating GEM_HOME on `bundle install --path`

+ Refactor: we do not need LS_GEM_HOME/PATH

+ avoid pinning jruby-openssl to 0.10.4

resolves GH-12299 (reverting GH-12301)
2020-10-20 09:00:01 +02:00
Rob Bavey
a6a31ec428
[7x backport] Remove redundant shouldRunAfter (#12316)
Clean backport of #12314

The `shouldRunAfter` specified in the main script body was causing the runIntegrationTests
task to be evaluated even when it should not have been, causing unnecessary failures
when artifacts required only for integration tests are unavailable.
This can be removed, because the `shouldRunAfter` relationship for the `runIntegrationTests`
task is already defined in the task body.
2020-10-07 11:38:50 -04:00
andsel
9668b9ec5c Bundle JDK (AdoptOpenJDK 11) in Logstash artifacts (ARM64)
Changed Linux creation artifacts (tar.gz/deb/rpm) to include the ARM JDK.
Extracted common parts of artifact.rake into functions to be shared between ARM and Intel bundling tasks
2020-09-30 05:59:29 -07:00
Rob Bavey
813e059a9d Bundle JDK (AdoptOpenJDK 11) in Logstash artifacts (x86_64)
Create new artifacts with bundled JDK for the supported platforms on x86_64. Download JDK packages from AdoptOpenJDK site, the selected version is loaded from `versions.yml`.
Changed also the launch scripts to give precedence to JAVA_HOME, then fallback on bundled JDK if present, as last resource go to the system Java.

New artifacts produced with bundled JDK are:
- tar.gz with JDK for Linux and Darwin
- zip file for Windows
- dep and rpm
- Docker image

All artifacts without JDK are now postfixed with '-no-jdk' while the ones with JDK included has the architecture extension.

Covered with tests the touched parts

Co-authored-by: Rob Bavey <robbavey@users.noreply.github.com>
2020-09-30 05:44:42 -07:00
Joao Duarte
51b5217826 don't call runIntegrationTests from check gradle task
This is a temporary fix.
Currently the check task depends on the integrationt tests task,
which means all dependant tasks will be resolved even if they're just
registered instead of created.
This resolution is a problem because the downloadES task will fail
if, for the version we're building, Elasticsearch doesn't yet have a
build we can download.

So for now we'll remove this to unblock builds, but finding a way
to compartimentalize failures is needed going forward
2020-07-15 10:13:37 +00:00
Rob Bavey
b2c652bf9d Ensure more gradle tasks using task avoidance API
Release Manager builds were failing as `downloadEs` task was being
needlessly run during `rake artifact:all` task. When run with
`RELEASE=1`. this was causing build failures due to the non-availability
of Elasticsearch release artifacts. This commit aims to avoid running
the `downloadES` task when it is not needed, continuing the work done
in #11914

This commit also removes code that was repeated in different parts of
the build script.
2020-07-13 20:39:00 +00:00
Rob Bavey
efbdd8d27c Fix gradle typo
Inadvertent extra character causes aarch64 builds to fail.
2020-07-13 13:31:53 +00:00
Rob Bavey
af54d95df8 Tests: Add support for alternative architectures
Enable filebeat and elasticsearch downloads to pull different
architectures, Filebeat and Elasticsearch use different suffixes
to denote their aarch64 architectures, with beats using arm64 and
elasticsearch aarch64
2020-06-16 15:11:59 +00:00
Rob Bavey
1a0d5c961f Use branch appropriate version of Elasticsearch
Carrying on from the work done in #11958, update the gradle build to download
the same version of Elasticsearch as is specified in the logstash version.yml file.
This commit updates the standard integration tests to use the same version of
Elasticsearch that is already downloaded for x-pack integration tests, and also
fixes integration tests to allow for the different responses around hits generated
by different versions of Elasticsearch.
2020-06-16 13:32:16 +00:00
Rob Bavey
addcb8a0a7
Retrieve branch version of Filebeat via gradle (#12011)
Clean backport of #11958

This commit changes the download to pull the version of beats based on the version pulled from the branch rather than from an environment variable, or 6.5.4.
This commit also moves the download logic of Filebeat fromfilebeat_setup.sh to build.gradle in order to use the artifacts API in the same way as the downloadEs task, and does some refactoring to DRY up the artifact download tasks.
This commit also fixes the beats integration test to replace the use of a removed setting.
This commit also sets retries to 3 for the download tasks, using 'retries' functionality from gradle download task plugin
2020-06-12 09:27:18 -04:00
Rob Bavey
b2da4449a5
Use task avoidance API in gradle scripts (#11914) (#11943)
* Use task avoidance API in gradle scripts

This commit uses the task avoidance api (tasks.register vs task.create/
task DSL), as recommended since Gradle 5.1

This should reduce the execution of unnecessary tasks in build jobs, and
hopefully improve build resiliency and execution time.
2020-05-29 11:52:01 -04:00
Rob Bavey
0eb2f54de2
Update gradle version to 6.3 (#11742) (#11761)
* Backport of #11742. Not a clean backport as 7.x had not previously been upgraded to 5.6.4 as master had been.

* Update gradle version to 6.3

Gradle versions prior to 6.3 cannot run under JDK14.
This commit upgrades the version of Gradle to 6.3, and removes all deprecation warnings that can currently be removed.

Changes include:
* Increase gradle memory to 2g
* Increase gradle memory in the license check job to 2g
* Replace use of `testCompile`
* Replace `runtime` with `runtimeOnly`
* Remove`compile` depedencies from gradle files
* Replace deprecated archive methods
* Fix dependencies report build
* Make jruby dependencies 'api', fix archiveVersion
* Set `duplicatesStrategy` for all tasks of type Copy
* Use `configureEach` for global 'withType' calls
** Use the recommended Tasks API calls
(https://blog.gradle.org/preview-avoiding-task-configuration-time)
* Run `./gradlew wrapper` earlier to improve caching
* Use copy with chown for resources that need to be run during `./gradlew wrapper`
2020-04-08 09:00:34 -04:00
Joao Duarte
b19db959af ensure mavencentral is always used before plugins.gradle.org
Fixes #11682
2020-03-12 12:04:54 +00:00
João Duarte
1fc169b7f6 Add apache and elastic license headers to source code files (#11673)
* add license header to ruby and java files
* add license header to erb and rake files
* add license headers to gradle files
2020-03-11 11:54:32 +00:00
Karol Bucek
ba51feea21 Build: fix bundle bin path in bundler task
follow-up on d65f78728b

Fixes #11381
2019-12-03 10:37:51 +00:00
Joao Duarte
6842aba9eb stop installing rake and json on every bootstrap
Fixes #11102
2019-12-02 14:59:43 +00:00
Ry Biesemeyer
96dfeb5016 add tasks for generating config parsers
Fixes #11195
2019-10-15 16:54:48 +00:00
Joao Duarte
534c267622 Cleanup gradle tasks and dependency installation
- have `bootstrap` task do as little as possible: install gems in Gemfile.template that don't belong to groups
- have test tasks depend on the `installTestGems` task instead of `bootstrap`
- logstash es output is now a dependency because of license checking
- fix out of memory problem in SharedHelpers.trap

Also use release lockfile during installDefaultGems

The release lockfile is only copied to Gemfile.lock if
it doesn't exist. During the `installDefaultGems` task other
plugin installation tasks already occurred, generating a lock file.

This commit removes it before running the plugin installation.

Fixes #10942
2019-07-12 08:11:28 +00:00
Joao Duarte
de6ef0c04a moved to openjdk 11 in docker testing
- also fix javadoc warning when building on jdk11

Fixes #10563
2019-04-15 20:13:37 +00:00
Joao Duarte
86cae08547 updated bundler to 1.17.3
Fixes #10685
2019-04-12 21:07:54 +00:00
Colin Surprenant
f39e4a9446
download exact version artifact for release build otherwise download snapshot (#10664) 2019-04-11 22:24:51 +01:00
Dan Hermann
30dd8243d2 Move Gradle wrappers around Ruby operations to a separate file to facilitate sharing of common operations with Java plugins
Fixes #10642
2019-04-04 19:56:59 +00:00
Joao Duarte
2543539910 cleanup many rakelib tasks that aren't used anymore
* simplify the plugins-metadata.json file
* sort and update the plugin list in the rakelib/plugins-metadata.json
* remove dependency on twitter input for testing
* sorted Gemfile.template (grouped by group)
* remove default plugins from Gemfile.template

Fixes #10509
2019-03-15 16:26:58 +00:00
Colin Surprenant
8ec1d2276b
correctly handle unexecuted downloadEs task (#10557)
[7.x clean backport of #10555]
2019-03-13 18:08:19 -04:00
Colin Surprenant
f6933dbe9a
move download setup code inside the downloadEs task (#10549)
7.x clean backport of #10547
2019-03-13 18:04:24 -04:00
Joao Duarte
42c63b75df factor in OS and architecture when downloading ES
- use artifacts api to fetch latest build
- use latest build info to find download url
- download package

Fixes #10422
2019-02-11 14:28:19 +00:00
Joao Duarte
2910faa57f fix building of deb and rpm
fpm requires json 1.x but the artifact rake tasks
will activate the default gem json 2

This PR ensures json 1 is activated early and is present right after
jruby is bootstrapped.

Also downgrades fpm to 1.3 as 1.11.0 wasn't building correctly

Downgrades .ruby-version to a version we have available in CI

Fixes #10396
2019-02-06 09:39:55 +00:00
Ry Biesemeyer
583ec6b625
Java 11 support (#10279)
* bump jruby to 9.2

* don't rely on logstash-base docker image

* work around webmock ruby 2.5 support

* ensure data folder exists in docker

* change fixnum and bignum to integer

* FileUtils.rmdir to rm_rf

this is because from 2.3 to 2.5 FileUtils.rmdir will throw an exception
if the directory isn't empty. On 2.3 the operation will just not delete
the directory silently.

* bump jruby to 9.2.5.0 and fix test

* make rake default task since prepare pack needs it

* Resolve compiler warnings (#10247)

There are 3 types of compiler warnings that are either resolved or suppressed:

1. Rawtypes: In JRuby 9.2, `RubyArray` is a generic, so references throughout
   our codebase to the now "raw" type trigger warnings. In most cases we cannot
   actually resolve the issue, since the JRuby-provided methods for creating
   `RubyArray`s still return the raw type, so these have been suppressed.

2. Deprecations:
   - `RubyString#intern19()` -> `RubyString#intern()`
   - `RubyString#downcase19(ThreadContext)` -> `RubyString#downcase(ThreadContext)`
   - `NativeException`: remove import & reference directly; suppress usage
     warnings
   - `RaiseException()`: migrate to equivalent non-deprecated methods wherever
     possible; in some cases where we are using this in conjunction with the
     also-deprecated `NativeException` to preserve java stacktraces, there
     seems to be no non-deprecated path forward, so these cases have been
     suppressed.

3. Redundant Casts
   - Resolved

* JRuby 9.2 bundler shenanigans (#10266)

* Revert "Revert "remove forced dependency on old bundler (#9395)""

This reverts commit bef984143d.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict

* build: update gradle to version that has Java 11 support

* java11: resolve or suppress deprecation warnings

* Remove superfluous flag opting into ParNew GC implementation

When opting into CMS garbage collector with `XX:+UseConcMarkSweepGC`, the
young generation collector ParNew has been the default since Java 8, making
the `XX:+UseParNew` flag redundant; the flag was removed in Java 9, and
should no longer be specified to work with modern Javas.

https://bugs.openjdk.java.net/browse/JDK-8006478
https://openjdk.java.net/jeps/214

* spec: set thread name to example description for easier debugging

* spec: prevent errors in testing specs by checking against skip list before using

* no-op: remove use of `HashMap#computeIfAbsent` on single-threaded code

> This method will, on a best-effort basis, throw a `ConcurrentModificationException`
> if it is detected that the mapping function modifies this map during computation.
>
> -- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html#computeIfAbsent(K,java.util.function.Function)

* qa: by default, run integration against Elastic Stack 6.5.x

To support development on Logstash on top of Java 11, default to testing
against an Elastic Stack that is capable of running on Java 11.

* qa: ignore deprecation warnings when comparing offline pack output

* qa: add Java 9+ support to ChildProcess dev dependency

this can safely be removed when the childprocess gem supports Java9+
https://github.com/enkessler/childprocess/pull/141

* qa: allow connections to localhost in webmock

* bump jrjackson version

* fix filebeat integration tests

* spec: ensure license compliance spec runs first

The license compliance spec that validates the licenses of bundled
plugins appears to not be compatible with the hooks that we inject
into bundler for plugin management, and will fail in obscure ways
when run after those hooks have been added. Since those hooks are
not necessary for validating licenses, the easiest solution was to
ensure that those specs run first, before the VM has been poluted.

Since the gradle/junit/rspec bridge that is currently in place
runs all specs in the same JVM, we also need to make sure that the
rspec "world" is reset before a run, to ensure that it doesn't
retain spec definitions from previous runs.

Also updates the rake invocation, although I'm not sure it is used
any more.
2019-02-04 16:36:11 -08:00
Dan Hermann
e6d59de458
Update java dependencies (#10340) 2019-01-18 08:16:13 -06:00
Dan Hermann
76a1d0a664
Eliminate compiler and javadoc warnings (#10241) 2019-01-02 07:16:19 -06:00