Commit graph

165 commits

Author SHA1 Message Date
Dmitry Cherniachenko
a50e58d99a
Use single-char variant of String.indexOf() where possible (#105205)
* Use single-char variant of String.indexOf() where possible

indexOf(char) is more efficient than searching for the same one-character String.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-02-12 14:14:32 -05:00
Dmitry Cherniachenko
e21a4874ab
Use String.replace() instead of replaceAll() for non-regexp replacements (#105127)
* Use String.replace() instead of replaceAll() for non-regexp replacements

When arguments do not make use of regexp features replace() is a more efficient option, especially the char-variant.
2024-02-12 13:11:15 -05:00
Mark Vieira
6c4e55e714
Fix file path when looking for docker exclusions file (#105304) 2024-02-08 12:27:09 -08:00
Yang Wang
552d2f563b
Expose OperationPurpose via CustomQueryParameter to s3 logs (#105044)
This PR adds the OperationPurpose as a custom query parameter for each
S3 request so that they are available in s3 access logs.

Resolves: ES-7750
2024-02-04 03:21:50 -05:00
Rene Groeschke
ab8ee60bba
Fix SamlAuthenticationIT flakyness (#103867) 2024-01-24 13:44:31 -05:00
Rene Groeschke
de502db05e
Fix cacheTestFixtures dependency conflicts (#103676)
fixes #103667
2023-12-22 05:17:55 -05:00
Rene Groeschke
62ddafb0e0
Port smb fixture from test fixture plugin to testcontainer (#103440)
this removes smb test fixture to use test container instead of relying
on our gradle test fixture plugin.
2023-12-20 04:01:52 -05:00
Rene Groeschke
7773364284
Replace Nginx fixture usage with UrlFixture (#103494)
- Simplify test setup in URLSearchableSnapshotsIT
- Delete nginx test fixture project
2023-12-20 09:06:23 +01:00
Rene Groeschke
673cb49a4e
Avoid docker fixture failures on unsupported environments (#103420)
Fixes #103417
2023-12-14 06:58:41 -05:00
Rene Groeschke
6e36ea841d
Port idp-fixture to testcontainers (#103320)
This ports idp-fixture to test container and updates downstream tests
accordingly.
2023-12-13 05:38:24 -05:00
Rene Groeschke
f5be180cb2
Configure test fixture dir correctly (#102839)
Make just the basic configuration of a project using test fixture plugin
not break configuration cache.  This is just for not breaking caching of
the gradle configuration. Running tests task relying on  test fixture
plugin and its wiring is still configuration cache in complete. This is
just for unblocking other configuration cache related work. 

In the long run we are going to remove this plugin
2023-12-12 14:10:14 -05:00
David Turner
447ddf49e1
Permit S3HttpHandler#parseRequestBody to fail (#103014)
This method may throw an exception if we send it bogus requests, e.g. a
truncated body, but that's not a reason to fail tests. This commit
removes the `AssertionError` wrapper so that the exception is handled
more gracefully.

Relates #102976
Closes #103012
2023-12-06 11:17:47 +00:00
Rene Groeschke
ab0bb4889a
Fix :plugins:repository-hdfs:forbiddenApisJavaRestTest (#102983)
Reworking forbiddenApis check to use gradle worker api exposed a bug in
how we resolve krb5kdc keytab information. This fixes the depenendency to krb5kdc keytab configuration and
its builtBy task.

This also changes the usage of krb5kdc keytab files to be passed directly to task classpath as
they are only required at runtime and directly having them as part of javaRestTestRuntimeOnly would mean precommit
requires krb5kdc compose up which we definitely not want
2023-12-06 08:33:27 +01:00
David Turner
0b9487b269
Rethrow errors in S3HttpFixture (#102976)
This fixture runs in a context that catches `Throwable` and quietly
turns all errors into a `500 Internal Server Error`, which may not lead
to a test failure. This commit rethrows any errors on another thread to
ensure they lead to test failures.
2023-12-05 14:15:03 +00:00
Rene Groeschke
26905047fb
Rework minio test fixture and its usages (#102707)
* Update minio fixture and usages to rely on new test cluster framework and testcontainer
* Cache test fixture resources during packer caching

Add logic that ensures we resolve docker images resolved from docker registry as part of our packer
cache setup.
2023-12-05 09:30:50 +01:00
Rene Groeschke
bc17acdada
Port repository-url to new TestFramework (#102588)
removes docker-compose dependency from url-fixture
2023-12-01 11:23:53 +01:00
Rene Groeschke
420ffc0f75
Port S3 qa projects to new test framework (#102555)
This removes the legacy test cluster based plugin usage with our new
testing framework for the searchable snapshots s3 QA project.

- This also cleans up s3-fixture to not rely on docker compose and the test fixture gradle plugin
2023-11-28 07:30:47 -05:00
Rene Groeschke
2a24bd29fb
Fix this-escape -Werror (#102574)
Using newer java versions expose a -Werror failure in building
MinioTestContainer
2023-11-24 05:18:25 -05:00
Rene Groeschke
5bc01896d8
Fix Nullpointer in test container tests and setup logging (#102561)
related to #102532
2023-11-24 02:47:12 -05:00
Rene Groeschke
62be62cec0
Check docker env by probing docker (#102558)
For now we probe ddocker functionality when using minio testcontainer.
We need to adjust our docker availability matrix.

Should mute tests and address #102532
2023-11-24 00:32:10 +01:00
Rene Groeschke
f2a9c150cb
Apply docker environment checks for TestContainers (#102553)
This is related to #102532. We need to have checks we did in the build
logic now in our test container setup.
2023-11-23 14:52:30 -05:00
Rene Groeschke
832e48e87f Do not run tests using minitestcontainer on windows 2023-11-23 18:05:51 +01:00
Rene Groeschke
05ead7ec59
Mute test using MinioTestContainer on windows (#102535)
see https://github.com/elastic/elasticsearch/issues/102532
2023-11-23 09:47:07 -05:00
Rene Groeschke
c871bea859
Fix thirdparty test configuration for repository-s3 (#102454) 2023-11-22 06:36:12 -05:00
Rene Groeschke
c11315d0d7
repository-s3 yamlRestTests to new cluster test framework (#102353)
- Replace docker-compose based s3-fixture usages to use plain java
- Support lazy evaluated system properties for local cluster definitions
- Make it work with configuration cache enabled
- Port Minio fixture usage to leverage test container testing library.
2023-11-22 10:08:58 +01:00
David Turner
50d4a28209
Remove more throw new AssertionError(e) calls (#101508)
Replaces them with calls to `fail(e)` or an `assertNoFailureListener` as
appropriate.
2023-10-30 06:19:37 -04:00
David Turner
4bbf760cda
Repo analysis of uncontended register behaviour (#101185)
Today repository analysis verifies that a register behaves correctly
under contention, retrying until successful, but it turns out that some
repository implementations cannot even perform uncontended register
writes correctly which may cause endless retries in the contended case.
This commit adds another repository analyser which verifies that
uncontended register writes work correctly on the first attempt.
2023-10-23 11:46:30 +01:00
Armin Braun
b7eafce32c
Make some practically static methods static (#97565)
Another round of automated fixes to this, marking things that can be
made static as static. Saves some JIT cycles but also turns some lambdas
from capturing to non-capturing and makes the "utilityness" of some
classes visible.
2023-10-06 23:37:07 +02:00
Brian Seeders
f69dce029e
[buildkite] Add third-party tests to periodic pipeline (#99376) 2023-09-29 15:15:05 -04:00
James Baiera
7d990d5a09
Allow custom geo ip database files to be downloaded (#97850)
This PR extends the assumptions we make about database file availability to all database file 
names instead of the default ones we host at Elastic. When creating a geo ip processor with 
a database name that is not recognized we unilaterally convert the processor to one that 
tags documents with a missing database message until the database file requested is 
downloaded or provided via the manual configuration route. This allows a pipeline to be 
created and for the download service to be started, potentially sourcing the needed files.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2023-08-16 00:31:51 -04:00
Armin Braun
63e64ae61b
Cleanup Stream usage in various spots (#97306)
Lots of spots where we did weird things around streams like redundant stream creation, redundant collecting
before adding all the collected elements to another collection or so, redundant streams for joining strings
and using less efficient `Collectors.toList` and in a few cases also incorrectly relying on the result being mutable.
2023-07-03 14:24:57 +02:00
Mark Vieira
9502d39c96
Refactor GCS test fixture to remove docker dependency (#94755) 2023-05-17 11:05:26 -07:00
Armin Braun
29ecff1802
Use openjdk base image for fixtures (#96189)
No need to build our own from a full ubuntu image
when the openjdk image fully suffices.
2023-05-17 11:01:46 +02:00
Armin Braun
43e526f4e8
Fix incorrect apt-get update usage in fixture DockerFile (#96156)
We had a couple of spots where we do the update in a separate step from
the install. This has led to apt returning error 100 from going out of sync
more than once for me locally.
-> Fix by always doing update + install in the same step so we don't run
into stale metadata during install.
2023-05-17 07:01:26 +02:00
Mark Vieira
679e73d355
Refactor azure test fixture to remove docker dependency (#94750) 2023-03-27 12:36:14 -07:00
David Turner
49d5cd7f26
S3 compare-and-exchange implementation (#94150)
Adds an implementation of `compareAndExchangeRegister` to
`S3BlobContainer`.
2023-02-28 06:44:15 -05:00
Mark Vieira
20dce68e65
Refactor geoip-fixture to remove Docker requirement (#93488) 2023-02-22 12:59:20 -08:00
Iraklis Psaroudakis
60870d6046
Move GCS TestUtils to fixture (#92370) 2022-12-14 17:22:12 +02:00
Rene Groeschke
43a0377735
Update forbiddenapis to 3.4 (#90624)
Fix breaking changes to source validation after change in default jdk rule set
2022-10-06 16:52:06 +02:00
Przemyslaw Gomulka
24fa003f5c
Replace supplier of ParameterizedMessage with java.util.Supplier<String> (#86971)
This is a result of structural search/replace in intellij. This only affects log methods with a signature
logger.info(Supplier<?>) where level could be info/debug etc and supplier argument is in a form of
()-> new ParameterizedMessage

This commit also introduced a Strings utility class to avoid passing Locale.ROOT to every
String.format(Locale.ROOT, pattern, args)
relates #86549
2022-05-23 08:51:07 +02:00
Joe Gallo
cfe1f11147
Handle .geoip_databases being an alias or a concrete index (#85792) 2022-05-03 15:47:32 -04:00
Ryan Ernst
ed749fcc5c
Move cli sysprops and envVars to execute parameter (#86279)
The sysprops and envVars members of Command provide cli implementations
with information about the jvm process that is running. This is
convenient for runtime, but difficult for tests to mock because they
must subclass the cli class.

This commit adds a ProcessInfo record, and plumbs it through the
main and execute methods. The new record includes system properties,
environment variables and the working directory. By having this be a
single new parameter, additional information can be added in the future
without again needing to modify the method signatures.

relates #85758
2022-04-29 13:47:30 -07: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
e209a100b8
Cleanup repository-hdfs project (#84486)
- use separate sourceSets for different type of tests
- remove usage of RestBuildPlugin
- Make fixture dependencies gradle idiomatic

Co-authored-by: Rory Hunter <pugnascotia@users.noreply.github.com>
2022-03-02 09:55:05 +01:00
Artem Prigoda
e47b7a63f4
[s3-repository] Support IAM roles for Kubernetes service accounts (#81255)
There have been many requests to support repository-s3 authentication via IAM roles in Kubernetes service accounts.

The AWS SDK is supposed to support them out of the box with the aws-java-sdk-sts library. Unfortunately, we can't use WebIdentityTokenCredentialsProvider from the SDK. It reads the token from AWS_WEB_IDENTITY_TOKEN_FILE environment variable which is usually mounted to /var/run/secrets/eks.amazonaws.com/serviceaccount/token and the S3 repository doesn't have the read permission to read it. We don't want to hard-code a file permission for the repository, because the location of AWS_WEB_IDENTITY_TOKEN_FILE can change at any time in the future and we would also generally prefer to restrict the ability of plugins to access things outside of their config directory.

To overcome this limitation, this change adds a custom WebIdentityCredentials provider that reads the service account from a symlink to AWS_WEB_IDENTITY_TOKEN_FILE created in the repository's config directory. We expect the end user to create the symlink to indicate that they want to use service accounts for authentification.

Service accounts are checked and exchanged for session tokens by the AWS STS. To test the authentification flow, this change adds a test fixture which mocks the assume-role-with-web-identity call to the service and returns a response with test credentials.

Fixes #52625
2022-01-19 14:03:11 +01: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
Artem Prigoda
763d6d510f
Use Java 15 text blocks for JSON and multiline strings (#80751)
The ES code base is quite JSON heavy. It uses a lot of multi-line JSON requests in tests which need to be escaped and concatenated which in turn makes them hard to read. Let's try to leverage Java 15 text blocks for representing them.
2021-12-15 18:01:28 +01:00
Mark Vieira
06d7e1682e
Bump source compatibility version to Java 17 (#80851) 2021-12-06 10:58:56 -08:00
Rene Groeschke
c2b62847aa
Fix stopping of old elasticsearch cluster (#81059)
due to not exposing the PID of the underlaying cluster the Fixture Stop task
was skipped, leaving running clusters behind after the build finished
2021-11-30 09:37:20 +01:00
Rene Groeschke
71eb10904b
Fix old elasticsearch fixture on certain work paths (#80283)
Should fix #79898 after the still fail on paths with &&. Manually tested
2021-11-03 12:03:04 -04:00