Commit graph

195 commits

Author SHA1 Message Date
Mark Vieira
9e9f19bc9c Further attempt at capturing reaper error logs 2022-08-02 14:47:53 -07:00
Mark Vieira
898b373169
Reinstate test cluster throttling behavior (#88664)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2022-07-21 12:24:24 +02:00
Rene Groeschke
160b14fbb1
Remove random runner from build tools (internal) tests (#88577)
This removes unrequited overhead for writing build tool and build tool internal tests and mechanically ports all junit3 tests to junit4.
2022-07-20 08:04:26 +02:00
Rene Groeschke
98b789c940
Update to to Gradle wrapper 7.5 (#85141)
This updates the gradle wrapper to a 7.5

Fixes #85123
2022-07-19 08:12:19 +02:00
Rene Groeschke
48d3063791
Remove duplicate definition of checkstyle version in use (#88339)
We only rely on the checkstyle version in the buildLibs.toml gradle version catalogue with this change.
Also added some hints for gradle best practices.

This is an aftermath of #88283
2022-07-15 19:31:50 +02:00
Rene Groeschke
a2ee4c5393
Polish reworked LoggedExec task (#88424)
Some polishing of reworked LoggedExec task
2022-07-12 12:48:56 +02:00
Rene Groeschke
dbf39741a0
Make LoggedExec gradle task configuration cache compatible (#87621)
This changes the LoggedExec task to be configuration cache compatible. We changed the implementation
to use `ExecOperations` instead of extending `Exec` task. As double checked with the Gradle team this task
is not planned to be made configuration cache compatible out of the box anytime soon.

This is part of the effort on https://github.com/elastic/elasticsearch/issues/57918
2022-07-11 08:46:54 +02:00
Rene Groeschke
ca4f3a3eeb
Run gradle integration tests with configuration cache enabled by default (#88148)
This changes AbstractGradleFuncTest to run with configuration cache enabled by default. That gives us better test coverage on how our build logic works with configuration cache enabled and makes it explicit which parts are not yet working.
We fixed some minor configuration cache related issues in our code.
2022-06-30 11:08:51 +02:00
Rene Groeschke
8ccae4da71
Setup elasticsearch dependency monitoring with Snyk for production code (#88036)
This adds the generation and upload logic of Gradle dependency graphs to snyk

We directly implemented a rest api based snyk plugin as:

the existing snyk gradle plugin delegates to the snyk command line tool the command line tool 
uses custom gradle logic by injecting a init file that is 

a) using deprecated build logic which we definitely want to avoid
b) uses gradle api we avoid like eager task creation.

Shipping this as a internal gradle plugin gives us the most flexibility as we only want to monitor 
production code for now we apply this plugin as part of the elasticsearch.build plugin, 
that usage has been for now the de-facto indicator if a project is considered a "production" project 
that ends up in our distribution or public maven repositories. This isnt yet ideal and we will revisit 
the distinction between production and non production code / projects in a separate effort.

As part of this effort we added the elasticsearch.build plugin to more projects that actually end up 
in the distribution. To unblock us on this we for now disabled a few check tasks that started failing by applying elasticsearch.build. 

Addresses  #87620
2022-06-29 13:29:14 +02:00
Rene Groeschke
d5ebe3d073
Port all remaining build-tool tests to spock (#88089)
- Make our build tool tests more readable
- One step closer to remove outdated test fixtures like GradleUnitTestCase and friends

Didn't port some basic setter getter tests like PluginExtensionTests as it does not add much value and we have integration test coverage for this stuff too
2022-06-29 09:27:33 +02:00
Rene Groeschke
12525adf83
Add easier configuration cache test support in build logic tests (#88047)
This is intended to help us getting closer to #57918 by implicitly
testing our build logic configuration-cache support. Plugin and Task
tests can be marked as configuration cache compatible now and we will
always run then with configuration cache enabled.

By default, gradle will fail the build if configuration cache problems
have been detected during build execution. That should be in general
better then adding explicit tests for testing configuration cache
compatibility per Test class
2022-06-27 08:11:17 -04:00
Ryan Ernst
e3c4cddbe2
Remove legacy bootstrap plugins (#87775)
Bootstrap plugins were an internal mechanism added to allow a
filesystemprovider for cloud with the quota-aware-fs plugin. Since that
was removed, bootstrap plugins no longer serve a purpose. They were
never officially documented because they were for internal use only.
This commit removes the bootstrap plugins infrastructure.
2022-06-23 20:38:06 -04:00
Rene Groeschke
cdf5bd7ed0
Rework testing conventions gradle plugin (#87213)
This PR reworks the testing conventions precommit plugin. This plugin now:
- is compatible with yaml, java rest tests and internalClusterTest (aka different sourceSets per test type)
- enforces test base class and simple naming conventions (as it did before)
- adds one check task per test sourceSet
- uses the worker api to improve task execution parallelism and encapsulation
- is gradle configuration cache compatible  

This also ports the TestingConventions integration testing to Spock and removes the build-tools-internal/test kit folder that is not required anymore. We also add some common logic for testing java related gradle plugins. 
We will apply further cleanup on other tests within our test suite in a dedicated follow up cleanup
2022-06-20 16:26:38 +02:00
David Turner
b9f8025979
Log 'output of node' separators to stdout (#87736)
Today when using Gradle-managed test clusters we separate the log output
from each node with a separator that looks like this:

    === Log output of node `node{:qa:mixed-cluster:v8.2.0-0}` ===

However, we write this to `stderr` and yet write the rest of the log
output to `stdout`. This commit moves the separators to the same log
level as the rest of this output so that they can all be redirected to
the same place.
2022-06-16 07:44:16 -04:00
Mark Vieira
b293ffb9ae
Report file checksum when encountering artifact transform failures (#87522) 2022-06-08 10:49:52 -07:00
Mark Vieira
ab1946f4c1
Skip ML tests on later glibc for incompatible BWC versions (#87476) 2022-06-07 14:11:18 -07:00
Rene Groeschke
5547df5a32
Do not keep gradle func test test projects 2022-05-24 18:03:00 +02:00
Rene Groeschke
07d0e17b23
Port Thirdparty audit task tests to spock (#86832)
One step closer to #86720
2022-05-24 14:53:39 +02:00
Rene Groeschke
591df50587
Port buildResources func tests to spock (#86756)
Unify our build tool testing

Part of #86720
2022-05-16 07:45:05 +02:00
Chris Hegarty
79a59f470b
Add a Gradle Plugin for compiling modular source projects. (#86602)
This PR upstreams a custom Gradle Plugin for compiling modular source
projects, that we've been using for a while now over on the modules
branch. The Plugin infers which dependencies should be on the module
path and which dependencies should be on the class path, when compilng
the main java sourceset. This supports the "bottom up" modularization of
Elasticsearch, where parent projects are modularized before child
projects. Allowing to modularize the core of the server independently of
the extension components, that can themselves be modularized later.

With this plugin various subprojects can be modularized (by adding a
module-info.java in the source root) with minimal fuss - no custom
gradle logic is required by the subproject, beyond a couple of
subproject specific compiler lint suppressions.

The inference in the plugin is driven by walking the project
dependencies, searching for the presence of a module-info.java,
afterwhich all subprojects will be put on the module path. Again, this
supports "bottom up" modularization.

Co-authored-by: ChrisHegarty <christopher.hegarty@elastic.co>
Co-authored-by: Mark Vieira <portugee@gmail.com>
Co-authored-by: Ryan Ernst <ryan@iernst.net>
Co-authored-by: Rene Groeschke <rene@breskeby.com>
2022-05-13 08:03:57 +01:00
Rene Groeschke
e195da0c12
More cleanup on reaper tests (#86762)
- Remove duplicate files.
- Move to build-tools
2022-05-12 15:31:45 -04:00
Rene Groeschke
333fe4d840
Fix javadoc plugin func tests on windows (#86674)
Handle special javadoc options path format
2022-05-12 11:45:29 +02:00
Rene Groeschke
da5750c460
Port build dependencies to gradle version catalogue (#86548)
We introduce the use of a Gradle version catalogue for handling build related dependencies.

This provides type safe accessors for dependencies and allow centralised version definitions.
Later we want to move all our dependency handling to version catalogues.
Since this is a Gradle feature we remove long term maintenance cost for custom version handling in
our build and make centralised version handling more straight forward and support better tooling
based on version catalogues

Fixes asm version alignment on the way using 9.3 everywhere in our build logic.
2022-05-10 12:15:36 +02:00
Rene Groeschke
8bbc7c2e0b
Port javadoc configuration logic into a binary plugin (#86471)
Also adding test coverage and fixing certain issues we stumbled into

when resolving project dependencies of compileClasspath we need to use allDependencies instead of dependencies as usually no dependencies are added directly to compileClasspath but via implementation, compileonly and api and friends
Fixed javadoc setup for projects using shadowed dependencies via shadow plugin
Fixed dealing with skipped javadoc tasks in referenced dependent projects.
In general this PR only fixes expected javadoc generation as it was intended before this PR.

This also contains some tweaks to our gradle integration test fixtures for setting up and debugging test projects
2022-05-10 09:58:43 +02:00
Rene Groeschke
0f43267a84
Update asm version in build tools for java19 support (#86288)
This also fixes issues with using asm in functional tests where
spock dependencies brought in an older version of asm not compatible
with java 18
2022-05-02 10:47:11 +02:00
Rene Groeschke
51dc7746a1
Align spock platform used in build-tool and build-tool-internal (#86276) 2022-04-28 18:24:21 -04:00
Ryan Ernst
0131d9fc00
Add optional module name to plugin properties (#86016)
In preparation for modularizing Elasticsearch server, each plugin needs
a way to declare itself as modular. When modularized, the main class of
a plugin must be found in a named module. This commit adds a module name
property to the plugin properties template and gradle support for
setting it, as well as automatically inferring the module name when a
module-info.java exists in the source a plugin.
2022-04-25 14:46:53 -07:00
Ryan Ernst
832dece32a
Remove old optional deps from plugin build (#86098)
The main elasticsearch jar used to have optional deps. This was because
of the high level rest client, where users did not want to pull in these
additional heavyweight deps that are not actually exposed by the Java apis.
These optional deps no longer exist since we no longer ship the HLRC.
When building plugins, these deps were "upgraded" to normal compile
classpath deps, since they were in fact available at runtime for
plugins. Since they are no longer optional, they are included
transitively by the dependency on the elasticsearch jar. This commit
removes the addition of these deps in the plugin build.
2022-04-22 06:06:02 -07:00
Rene Groeschke
718a241449
Apply precommit checks for non productive projects (#85533)
Ensure projects with only yaml, java or cluster tests also apply precommit checks.
We only apply testingconventions now for projects with existing src test folder
as the TestingConventionsTask is incompatible with projects with no test sourceSet.
This is a prerequisite to port more projects away from using StandaloneRestTestPlugin
and RestTestPlugin in favor of yaml, java or cluster tests with dedicated sourceSets.

Also we fix deprecation warnings for forbiddenPattern and filePermissions tasks about
implicit non declared dependencies on resources tasks
2022-04-20 08:54:56 +02:00
Ryan Ernst
e1882f8abf
Remove lazy evaluation from plugin properties building (#85871)
Plugins and modules use PluginBuildPlugin in gradle to build their
plugin properties file. Internally that uses an afterEvaluate since the
plugin properties extension will not have been filled in yet when the
plugin is first applied. This commit removes the afterEvaluate in favor
of configuring the plugin properties map for filling in the template
within the pluginProperties task configuration, which is applied when
the task is actually realized in the task graph.
2022-04-13 09:15:14 -07:00
Ryan Ernst
f0d0c373cd
Remove uses of Charset name parsing (#85795)
There are many places in Elasticsearch which must decode some stream of
bytes into characters. Most of the time this is expected to be UTF-8
encoded data, and we hardcode that charset name. However, methods in the
JDK that take a String charset name require catching
UnsupportedEncodingException. Yet most of these APIs also has a variant
of the same methods which take a known Charset instance, for which we
can use StandardCharsets.UTF_8. This commit converts most instances of
passing string charset names to use a Charset instance.
2022-04-12 12:05:32 -07:00
Lee Hinman
3a3ee6e342
Bump commons-compress to 1.21 (#85581)
This updates the dependency version for the Apache commons compress
project to 1.21
2022-04-04 01:04:35 -04:00
Rene Groeschke
3381fcd6d7
Update gradle wrapper to 7.4.2 (#85608) 2022-04-01 07:06:27 -04:00
Ryan Ernst
44e399b3a9
Do not reuse ES log file in testclusters (#85576)
In #85349 we restored capturing the stdout and stderr of Elasticsearch
processes started by testclusters. However, since testclusters launches
Elasticsearch in the forground for each process, the log output is
duplicated to stdout. This commit changes the redirects to use a 
unique file, separate from ES's log file.

closes #85553
2022-03-31 21:58:08 -07:00
Rene Groeschke
50c0798b3b
Cleaning up some buildscripts (#85394)
Just some housekeeping on build scripts
2022-03-31 10:48:48 +02:00
Nikola Grcevski
344649573d
Introduce an unauthenticated endpoint for readiness checks (#84375)
Add optional Elasticsearch readiness TCP listener.
2022-03-25 10:38:06 -04:00
Ryan Ernst
5d40345fed
Redirect testclusters ES process stdout/stderr to log file (#85349)
Although most of the time the stdout and stderr of the Java process is
not needed since ES has its own log file, there are some cases where it
is very important to have the output before ES has initialized its
logging system. This commit changes the stdout/stderr of the ES process
created by testclusters to use the same log file that ES will write to.
There should not be contention with ProcessBuilder and ES trying to
write at the same time because ES swaps out the stream handles to write
to its logging system, so after that point ProcessBuilder will never see
anymore output.

relates #68333
2022-03-24 20:32:57 -04:00
Rene Groeschke
35448a2f29
Use explodedBundle for test cluster module configurations (#84997)
This removes the overhead of zipping modules that are referenced in
test cluster configurations
We now Support declaring task providers as module input in testclusters
2022-03-24 08:30:19 +01:00
Nikolaj Volgushev
822e2c77f6
Update X509Certificate principal methods (#85163)
X509Certificate methods getSubjectDN and getIssuerDN are deprecated.
Use getSubjectX500Principal and getIssuerX500Principal instead

Closes #81008
2022-03-23 10:47:17 +01:00
Rene Groeschke
b3e44a7dd6
Fix StandaloneRestTestTask incompatibilities with future Gradle version (#85157)
Related to #85123
2022-03-21 12:38:30 -04:00
Rene Groeschke
00f2dc09ff
Avoid overhead of zip / unzip modules when packaging distribution (#84660)
This removes the overhead of zipping up modules that are immediately unzipped again when packaging
the elasticsearch distribution.
We also move some logic for packaging the elasticsearch distribution into a plugin and remove some outdated
overhead dealing with 'meta plugins' when copying modules into a distribution.

Another follow up and related optimization out of scope of this PR is, to also not zip unzip modules declared
for usage in our test cluster setups.

This partially addresses #76726.
2022-03-15 11:37:47 +01:00
Ryan Ernst
0ec229050e
Move yaml rest test case to separate test lib (#84835)
The ESClientYamlSuiteTestCase is used to run yaml tests throughout
Elasticsearch. It utilizes the low level rest client in sniffing for
nodes, but the sniffer is not needed anywhere else in the test
framework.

This commit creates a new project, `:test:rest-runner` which is meant to
house the rest test running infrastructure. This has two purposes. First
is to remove the sniffer from the test framework dependencies, because
it transitively depends on Jackson. Second is to setup the runner for
future refactorings where it could be made to not depend on the entire
test framework, though how that could work is left for the future.
2022-03-11 10:51:11 -05:00
Ryan Ernst
070fcaa0ad
Move x-content implementation to a separate classloader (#83705)
This change isolates the Jackson implementation of x-content parsers and generators to a separate classloader. The code is loaded dynamically upon accessing any x-content functionality.

The x-content implementation is embedded inside the x-content jar, as a hidden set of resource files. These are loaded through a special classloader created to initialize the XContentProvider through service loader. One caveat to this approach is that IDEs will no longer trigger building the x-content implementation when it changes. However, running any test from the command line, or running a full Build in IntelliJ will trigger the directory to be built.

Co-authored-by: ChrisHegarty <christopher.hegarty@elastic.co>
2022-03-07 15:44:59 -08:00
Rene Groeschke
c4686128f0
Replace getProject() references with injected services in task implementations where possible (#81681)
- Rework task implementations to avoid project usage at execution time
- In general usages of getProject() within a task should be avoided as it is not compatible
with gradle configuration cache. Related to #57918
2022-02-23 12:56:21 +01:00
Rene Groeschke
d465ee1be4
Replace deprecated api in artifact transforms (#84015)
`ArtifactAttributes.ARTIFACT_FORMAT` has been deprecated in favor of
public available `ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE`
2022-02-16 06:10:54 -05:00
Mark Vieira
64929dc5df
Introduce explicit API for configure test cluster feature flags (#83876) 2022-02-14 15:22:33 -08:00
Rene Groeschke
a54c2f7f05
Fix getBuildPluginFile for examples and thirdparty build (#82730)
- Resolve default roles.yaml via TextResourceHandler 
- This fixes plugin usage for external builds and fixes relying on internal file structures
- Remove unused roles.yml file
2022-01-19 17:20:12 +01:00
Artem Prigoda
fc5a820da9
Migrate to Java 16 Records (part 1) (#82338)
Try to represent immutable data with Java records introduced in [JEP 395](https://openjdk.java.net/jeps/395)
2022-01-18 17:53:06 +01:00
Tim Vernum
d61dda2c01
Remove system-index write-access from superuser role (#81400)
This commit changes the superuser role (as used by the "elastic"
builtin user) so that it no longer has any sort of write access to
restricted indices (system indices).
This improves the safety and security of the cluster, as it means
that there are no out-of-the-box users or roles that can write to,
delete or close the security index.

Superusers can still read from (and monitor) system indices.

Other roles (and users) can still access system indices as specified
in their descriptor. These can be custom such as the
"_es_test_root" role used in the integration test suite, or builtin
roles such as kibana_system.
2022-01-17 12:00:38 +11:00
Artem Prigoda
0699c9351f
Use Java 14 switch expressions (#82178)
JEP 361[https://openjdk.java.net/jeps/361] added support for switch expressions
which can be much more terse and less error-prone than switch statements.

Another useful feature of switch expressions is exhaustiveness: we can make
sure that an enum switch expression covers all the cases at compile time.
2022-01-10 09:53:35 +01:00