Commit graph

5193 commits

Author SHA1 Message Date
Mark Vieira
a87fb8d386
Upgrade mockito (#121849) (#121932) 2025-02-06 12:23:57 -08:00
Mark Tozzi
cf36d97a32
Aggregations cancellation after collection (#120944) (#121936)
This PR addresses issues around aggregations cancellation, mentioned in https://github.com/elastic/elasticsearch/issues/108701 and other places. In brief, during aggregations collection time, we respect cancellation via the mechanisms in the searcher to poison cancelled queries. But once the aggregation finishes collection, there is no further need to interact with the searcher, so we cannot rely on that for cancellation checking. In particular, deeply nested aggregations can spend a long time constructing the results tree.

Checking for cancellation is a trade off, as the check itself is somewhat expensive (it involves a volatile read), so we want to balance checking often enough that cancelled queries aren't taking up resources for a long time, but not so frequently that it slows down most aggregation queries. Our first attempt to this is to check once when we go to build sub-aggregations, as the worst cases for this that we've seen involve needing to build deep sub-aggregation trees. Checking at sub-aggregation construction time also provides a conveniently centralized method call to add the check to.

---------



 Conflicts:
	server/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java
	test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2025-02-07 06:51:21 +11:00
Mark Vieira
0b865d477e
Don't attempt to install modules into test cluster more than once (#121833) (#121863)
(cherry picked from commit 56cac1bfe9)
2025-02-06 11:56:51 +11:00
Christoph Büscher
a57a79269b
[8.16] Fix rare failures in YAML xContent roundtrip tests (#121515) (#121684)
Under very unfortunate conditions tests that check xContent objects
roundtrip parsing  (like i.e. SearchHitsTests#testFromXContent)
can fail when we happen to randomly pick YAML xContent type and create
random (realistic)Unicode character sequences that may contain the
character U+0085 (133) from the Latin1 code page. That specific character
doesn't get parsed back to its original form for YAML xContent, which can 
lead to rare but hard to diagnose test failures.

This change adds logic to AbstractXContentTestCase#test() which lies at
the core of most of our  xContent roundtrip tests that disallows test
instances containing that particular character  when using YAML xContent
type.

Closes #97716
2025-02-05 16:12:17 +01:00
Mark Vieira
de8664c5e5
Use links when possible when installing test cluster modules (#121067) (#121081)
When we install modules into test clusters we do a full copy instead of
links. This both eats up more IO and disk space unnecessarily.
2025-01-29 07:43:55 +11:00
Panagiotis Bailis
c5a57fc690
[8.16] backporting fix for negative scores in text_similarity_ranker retriever (#121056) 2025-01-28 18:30:16 +02:00
Jan Kuipers
eef2fb3ddb
[8.16] Test ML model server (#120270) (#120589)
* Test ML model server (#120270)

* Fix model downloading for very small models.

* Test MlModelServer

* Tiny ELSER

* unmute TextEmbeddingCrudIT and DefaultEndPointsIT

* update ELSER

* Improve MlModelServer

* tiny E5

* more logging

* improved E5 model

* tiny reranker

* scan for ports

* [CI] Auto commit changes from spotless

* Serve default models when optimized model is requested

* @ClassRule

* polish code

* Respect dynamic setting ML model repo

* fix metadata for optimized models

* improve logging

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>

* backport HttpHeaderParser

* Fix stripping platform

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2025-01-22 23:00:56 +11:00
Mark Vieira
a47c4d20af
Allow overriding of module metadata files in integration tests (#120427) (#120430) 2025-01-18 15:28:38 +11:00
Mark Vieira
289a8239c4
Allow overriding of plugin metadata files in integration tests (#120245) (#120298) 2025-01-17 04:16:57 +11:00
Felix Barnsteiner
7324f31e01
Add missing traces ilm policy for OTel traces data streams (#119449) (#119825) 2025-01-09 18:55:23 +11:00
Mark Vieira
0009de3575
Upgrade Bouncy Castle FIPS dependencies (#112989) (#119614)
This PR updates `bc-fips` and `bctls-fips` dependencies to the latest
minor versions.

(cherry picked from commit 6ea3e01958)

Co-authored-by: Slobodan Adamović <slobodanadamovic@users.noreply.github.com>
2025-01-07 08:03:17 +11:00
Rene Groeschke
3c025d78a6
[Build] Update krb5kdc test fixture base image and krb5 library (#119403) (#119490)
(cherry picked from commit 957064b279)

# Conflicts:
#	muted-tests.yml
2025-01-03 16:18:08 +01:00
Rene Groeschke
4d17b2193a
Update Gradle wrapper to 8.12 (#118683) (#119357)
This updates the gradle wrapper to 8.12

We addressed deprecation warnings due to the update that includes:

- Fix change in TestOutputEvent api
- Fix deprecation in groovy syntax
- Use latest ospackage plugin containing our fix
- Remove project usages at execution time
- Fix deprecated project references in repository-old-versions

(cherry picked from commit ba61f8c7f7)

# Conflicts:
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/distribution/DockerCloudElasticsearchDistributionType.java
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/distribution/DockerUbiElasticsearchDistributionType.java
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/Fixture.java
#	plugins/repository-hdfs/hadoop-client-api/build.gradle
#	server/src/main/java/org/elasticsearch/inference/ChunkingOptions.java
#	x-pack/plugin/kql/build.gradle
#	x-pack/plugin/migrate/build.gradle
#	x-pack/plugin/security/qa/security-basic/build.gradle
2024-12-31 08:37:28 +01:00
Jim Ferenczi
d563999ea8
Improve handling of nested fields in index reader wrappers (#118757) (#118981)
This update enhances the handling of parent filters to ensure proper exclusion of child documents.
2024-12-19 03:50:39 +11:00
Panagiotis Bailis
e52a6f2010
[8.16] Fix for propagating filters from compound to inner retrievers (#117914) (#118047)
* Fix for propagating filters from compound to inner retrievers

* fix for lucene 9

* Update CompoundRetrieverBuilder.java

* Update CompoundRetrieverBuilder.java

* Update CompoundRetrieverBuilder.java

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-12-06 21:50:41 +11:00
Mark Vieira
82ebd0aeb5
Update BWC version logic to support multiple bugfix versions (#117943) (#118116) (#118119) 2024-12-05 16:15:12 -08:00
Rene Groeschke
581b9ab7c0
[8.16] [Gradle] Remove static use of BuildParams (#115122) (#117434)
* [Gradle] Remove static use of BuildParams (#115122)

Static fields dont do well in Gradle with configuration cache enabled.

- Use buildParams extension in build scripts
- Keep BuildParams.ci for now for easy serverless migration
-  Tweak testing doc

(cherry picked from commit 13c8aaeffa)

# Conflicts:
#	TESTING.asciidoc
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java
#	build.gradle
#	modules/ingest-geoip/qa/full-cluster-restart/build.gradle
#	qa/mixed-cluster/build.gradle
#	x-pack/plugin/ent-search/qa/full-cluster-restart/build.gradle
#	x-pack/plugin/eql/qa/rest/build.gradle
#	x-pack/plugin/fleet/qa/rest/build.gradle
#	x-pack/plugin/kql/build.gradle
#	x-pack/plugin/mapper-unsigned-long/build.gradle
#	x-pack/plugin/ml/qa/multi-cluster-tests-with-security/build.gradle
#	x-pack/plugin/security/qa/multi-cluster/build.gradle
#	x-pack/plugin/sql/qa/jdbc/build.gradle
#	x-pack/plugin/transform/qa/multi-cluster-tests-with-security/build.gradle

* Fix merge

* [Build] Fix fips testing after buildparams rework (#116934)

* More Cleanup

* [Build] Fix checkstyle exclusions on windows (#115185)

* More merge fixes

* Delete x-pack/plugin/kql/build.gradle
2024-11-27 12:34:32 +01:00
Nhat Nguyen
3ef91e0ef1
Fix CCS exchange when multi cluster aliases point to same cluster (#117297) (#117387)
[esql] > Unexpected error from Elasticsearch: illegal_state_exception - sink exchanger for id [ruxoDDxXTGW55oIPHoCT-g:964613010] already exists.

This issue occurs when two or more clusterAliases point to the same 
physical remote cluster. The exchange service assumes the destination is
unique, which is not true in this topology. This PR addresses the
problem by appending a suffix using a monotonic increasing number,
ensuring that different exchanges are created in such cases.

Another issue arising from this behavior is that data on a remote 
cluster is processed multiple times, leading to incorrect results. I can
work on the fix for this once we agree that this is an issue.
2024-11-23 08:10:37 +11:00
David Turner
771bea1e37
Add end-to-end test for reloading S3 credentials (#116994)
We don't seem to have a test that completely verifies that a S3
repository can reload credentials from an updated keystore. This commit
adds such a test.

Backport of #116762 to 8.16.
2024-11-19 09:30:22 +11:00
Luca Cavanna
267abe781d
Fix handling of time exceeded exception in fetch phase (#116676)
The fetch phase is subject to timeouts like any other search phase. Timeouts
may happen when low level cancellation is enabled (true by default), hence the
directory reader is wrapped into ExitableDirectoryReader and a timeout is
provided to the search request.

The exception that is used is TimeExceededException, but it is an internal
exception that should never be returned to the user. When that is thrown, we
need to catch it and throw error or mark the response as timed out depending
on whether partial results are allowed or not.
2024-11-18 15:08:08 +01:00
Rene Groeschke
68337ff66e
[Gradle] Update shadow plugin (#116826) (#116877)
- The shadow plugin has changed ownership and plugin id.
- Make some formatting of poms more reproducible

(cherry picked from commit def490ef85)
2024-11-16 15:06:35 +01:00
David Turner
2532b8c29c
Handle status code 0 in S3 CMU response (#116212) (#116231)
A `CompleteMultipartUpload` action may fail after sending the `200 OK`
response line. In this case the response body describes the error, and
the SDK translates this situation to an exception with status code 0 but
with the `ErrorCode` string set appropriately. This commit enhances the
exception handling in `S3BlobContainer` to handle this possibility.

Closes #102294

Co-authored-by: Pat Patterson <metadaddy@gmail.com>
2024-11-05 21:29:53 +11:00
Simon Cooper
a51efe8da5
Include test features in feature name generation (#116078) (#116089) 2024-11-02 01:47:59 +11:00
Lorenzo Dematté
3bf0197950
Fix testApmIntegration histogram assertions (#115907) 2024-10-30 21:13:28 +11:00
Andrei Dan
e8877d686f
[8.16] Allow for queries on _tier to skip shards during coordinator rewrite (#114990) (#115513)
* Allow for queries on _tier to skip shards during coordinator rewrite (#114990)

The `_tier` metadata field was not used on the  coordinator when
rewriting queries in order to exclude shards that don't match. This lead
to queries in the following form to continue to report failures even
though the only unavailable shards were in the  tier that was excluded
from search (frozen tier in this example):

```
POST testing/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "term": {
            "_tier": "data_frozen"
          }
        }
      ]
    }
  }
}
```

This PR addresses this by having the queries that can execute on `_tier`
(term, match, query string, simple query string, prefix, wildcard)
execute a coordinator rewrite to  exclude the indices that don't match
the `_tier` query  **before** attempting to reach to the shards (shards,
that might not be available and raise errors). 

Fixes #114910

* Don't use getFirst

* Test compile
2024-10-24 23:43:28 +11:00
Ryan Ernst
61b0063c94
Remove LongGCDisruption scheme (#115046) (#115442)
Long GC disruption relies on Thread.resume, which is removed in JDK 23.
Tests that use it predate more modern disruption tests. This commit
removes gc disruption and the master disruption tests. Note that tests
relying on this scheme have already not been running since JDK 20 first
deprecated Thread.resume.
2024-10-24 05:51:05 +11:00
Mark Vieira
02e3c8dc6c
Always flush response body in AbstractBlobContainerRetriesTestCase#sendIncompleteContent with JDK23 (#115197) (#115441)
Resolves https://github.com/elastic/elasticsearch/issues/115172

Co-authored-by: Pooya Salehi <pxsalehi@users.noreply.github.com>
2024-10-24 05:23:04 +11:00
Panagiotis Bailis
06fd883b25
[8.16] Adding deprecation warnings for rank and sub_searches (#114854) (#114949)
* Adding deprecation warnings for rank and sub_searches (#114854)

* remove updatev10 reference
2024-10-17 08:04:16 +11:00
Salvatore Campagna
8e84e06c98
Inject the host.name field mapping only if required for logsdb index mode (#114573) (#114936)
Here we check for the existence of a `host.name` field in index sort settings
when the index mode is `logsdb` and decide to inject the field in the mapping
depending on whether it exists or not. By default `host.name` is required for
sorting in LogsDB. This reduces the chances for errors at mapping or template
composition time as a result of injecting the `host.name` field only if strictly
required. A user who wants to override index sort settings without including
a `host.name` field would be able to do so without finding an additional
`host.name` field in the mappings (injected automatically). If users override the
sort settings and a `host.name` field is not included we don't need
to inject such field since sorting does not require it anymore.

As a result of this change we have the following:
* the user does not provide any index sorting configuration: we are responsible for injecting the default sort fields and their mapping (for `logsdb`)
* the user explicitly provides non-empty index sorting configuration: the user is also responsible for providing correct mappings and we do not modify index sorting or mappings

Note also that all sort settings `index.sort.*` are `final` which means doing this
check once, when mappings are merged at template composition time, is enough.

(cherry picked from commit 9bf6e3b0ba)
2024-10-16 20:48:49 +02:00
Ryan Ernst
3935758426
Filter out JNA Cleaner thread from test leak detection (#114668)
JNA has a static thread which handles cleaning up native memory
references. This commit adds the thread name to those filtered out of
thread leak detection since it lives for the lifetime of the JDK (yet
might be started in the middle of a test).

closes #114555
2024-10-16 16:40:38 +02:00
David Turner
bdac01785a
Inline MockTransportService#getLocalDiscoNode() (#114883) (#114887)
This method just delegates to `getLocalNode()`, we may as well call the
more widely-used method with the shorter name directly.
2024-10-16 21:47:07 +11:00
Joe Gallo
c3e7eed0eb
Download IPinfo ip location databases (#114847) (#114872)
Backport of #114847
2024-10-16 13:34:15 +11:00
Martijn van Groningen
9348d9fcb8
Add feature flag for subobjects auto (#114616) (#114678) 2024-10-13 05:08:41 +11:00
Patrick Doyle
15343e4ec0
Backport ChunkedXContentBuilder to 8.16.0 (#114659)
* Create a fluent builder to help implement ChunkedToXContent (#112389)

Rather than manually adding startObject/endObject, and having to line everything up manually, this handles the start/end for you.
A few implementations are converted already. In the long run, I would like this to replace ChunkedXContentHelper.

* Convert a few more implementations to ChunkedXContentBuilder (#113125)

Remove the complex methods from ChunkedXContentHelper

* Further conversions to ChunkedXContentBuilder (#114237)

---------

Co-authored-by: Simon Cooper <simon.cooper@elastic.co>
2024-10-12 07:54:35 +11:00
Nik Everett
15308027b4
ESQL: Retry test on 403 (#114450) (#114650)
Retry the async test when you get a 403 - that could be because security
has not yet booted. We should have permission to fetch everything.
2024-10-12 07:04:07 +11:00
Dan Rubinstein
760f70ffcc
Removing ChunkingSettingsFeatureFlag (#114634)
* Removing ChunkingSettingsFeatureFlag

* Removing chunking settings feature flag from tests and ModelRegistryIT
2024-10-11 14:36:02 -04:00
Craig Taverner
c7da1633b1
Enable pushing Sort/Filter by ReferenceAttribute down to Lucene, and thereby optimize Sort by ST_DISTANCE (#112938) (#114604)
The ST_DISTANCE function added in #108764 was optimized for lucene pushdown in a series of followup PRs, but this did not include sorting by distance. Now this is resolved, for two key scenarios, both known to be valued by users:

* Sorting by distance:
    `FROM index | EVAL distance=ST_DISTANCE(field, literal) | SORT distance`
* Sorting and filtering by distance:
    `FROM index | EVAL distance=ST_DISTANCE(field, literal) | WHERE distance < literal | SORT distance`

The key changes required to make this work:
* Add to the EsQueryExec the appropriate sort->_geo_distance sort type
* Enhance PushTopNToSource to understand how to pushdown the sort even when there is an EVAL in between the FROM and the SORT (between the TopNExec and the EsQueryExec in the physical plan).
* Enhance PushFiltersToSource to understand how to pushdown the filter even when there is an EVAL in between the FROM and the WHERE (between the Filter and the EsQueryExec in the physical plan).

A useful bonus feature of this additional EVAL intelligence is that other, non-spatial cases are now also pushed down. In particular EVALs that are simple aliases are considered and pushed down, for both filtering and sorting.

Local benchmark results, very approximate, but show massive improvements for distanceSort and distanceFilterSort, which relate to the two cases listed above.

Benchmark	Query DSL	ESQL before this PR	ESQL after this PR	Comments
distanceFilter	10	5	5	Optimized in #109972
distanceEvalFilter	10	10000	1500	Still slow due to unnecessary EVAL
distanceSort	150	12000	160	
distanceFilterSort	20	10000	24	

NOTE: This enables pushing down sorting by any ReferenceAttribute that either refers to a sortable FieldAttribute, or to an StDistance function that itself refers to a suitable FieldAttribute of geo_point type.

---------

Co-authored-by: Alexander Spies <alexander.spies@elastic.co>
2024-10-12 00:25:00 +11:00
David Kyle
edd6326092
[ML] Remove scale to zero feature flag (#114323) (#114388)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-10-11 20:26:37 +11:00
David Turner
a0c5af3f07
Ensure clean thread context in MasterService (#114512) (#114569)
`ThreadContext#stashContext` doesn't guarantee to give a clean thread
context, but it's important we don't allow the callers' thread contexts
to leak into the cluster state update. This commit captures the desired
thread context at startup rather than using `stashContext` when forking
the processor.
2024-10-11 19:13:46 +11:00
Nik Everett
c7473ad8cc
ESQL: Delay construction of warnings (#114368) (#114459)
Delay construction of `Warnings` until they are needed to save memory
when evaluating many many many expressions. Most expressions won't use
warnings at all and there isn't any need to make registering warnings
super duper fast. So let's make the construction lazy to save a little
memory. It's like 200 bytes per expression which isn't much, but it's
possible to have thousands of expressions in a single query. Abusive,
but possible.

This also consolidates all `Warnings` usages to a single `Warnings`
class. We had two. We don't need two.
2024-10-10 10:13:44 +11:00
Nik Everett
09a50e504d
ESQL: Weaken test assertion (#114336) (#114351)
Weaken the assertion when testing breakers: it's ok to break while
building a block in addition to topn.
2024-10-10 08:13:40 +11:00
Kostas Krikellas
f6047ff704
[8.x] Skip storing ignored source for single-element leaf arrays (#113937) (#114384)
* Skip storing ignored source for single-element leaf arrays (#113937)

* Minimize storing array source

* restrict to fields

* revert changes for `addIgnoredFieldFromContext`

* fix test

* spotless

* count nulls

(cherry picked from commit f79705d9b6)

* fix list api

* fix tests

* Update MapperTestCase.java

* Update MapperTestCase.java

* Update MapperTestCase.java
2024-10-09 14:56:40 +03:00
Oleksandr Kolomiiets
1530927e05
Don't generate invalid combination of subobjects parameter in logsdb tests (#114265) (#114341)
(cherry picked from commit 965265a1a4)

# Conflicts:
#	muted-tests.yml
2024-10-08 11:17:31 -07:00
Kostas Krikellas
f1901b0e15
Avoid using dynamic:strict with subobjects:false at root (#114247) (#114254)
(cherry picked from commit 9cfe679173)

# Conflicts:
#	test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/datasource/DefaultMappingParametersHandler.java
2024-10-08 17:22:37 +03:00
Nik Everett
69a23d41e4
ESQL: Reenable part of heap attack test (#114252) (#114255)
This reenables a test and adds more debugging to another one. We'll use
this to collect more information the next time it fails.
2024-10-08 09:17:53 +11:00
Mike Pellegrini
5b8f9c12d2
[ML] Default inference endpoint for ELSER (#114164)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-10-08 06:58:10 +11:00
Oleksandr Kolomiiets
eeec634cff
Correctly inject subobjects parameter in logsdb tests (#113643) (#114178) 2024-10-07 09:52:42 -07:00
Ignacio Vera
8716bf9c49
Add getAndSet to Objectarray (#114200) (#114226)
This commit adds a getAndSet implementation to the ObjectArray API and changes the set method to return void.
2024-10-08 02:46:02 +11:00
Luca Cavanna
7e154ee50d
Replace some test usages of search(Query, Collector) (#113818) (#114212)
The leftover usages of the deprecated  search(Query, TotalHitCountCollector)
have been replaced with search(Query, TotalHitCountCollectorManager)
2024-10-07 22:03:11 +11:00
Tim Brooks
c4698c625b Introduce watermarks for indexing pressure backoff (#113912)
Currently we have a relatively basic decider about when to throttling
indexing. This commit adds two levels of watermarks with configurable
bulk size deciders. Additionally, adds additional settings to control
primary, coordinating, and replica rejection limits.
2024-10-04 15:46:17 -05:00