Commit graph

220 commits

Author SHA1 Message Date
Martijn van Groningen
696191d1c7
Fix testMapperDynamicIndexSetting() failures (#109574)
Currently these tests run against any old cluster older than 8.0.0, but
the fix that allowed `index.mapper.dynamic` to exist is only available
in 7.17.22.

Adjust these tests to only run if old cluster is after version 7.17.21
and before 8.0.0
2024-06-12 12:06:41 +10:00
Martijn van Groningen
09fc32090c
Re-define index.mapper.dynamic setting in 8.x (#109341)
Currently when upgrading a 7.x cluster to 8.x with
`index.mapper.dynamic` index setting defined the following happens:

- In case of a full cluster restart upgrade, then the index setting gets archived and after the upgrade the cluster is in a green health.
- In case of a rolling cluster restart upgrade, then shards of indices with the index setting fail to allocate as nodes start with 8.x version. The result is that the cluster has a red health and the index setting isn't archived. Closing and opening the index should archive the index setting and allocate the shards.

The change is about ensuring the same behavior happens when upgrading a
cluster from 7.x to 8.x with indices that have the
`index.mapper.dynamic` index setting defined.  By re-defining the
`index.mapper.dynamic `index setting with
`IndexSettingDeprecatedInV7AndRemovedInV8` property, the index is
allowed to exist in 7.x indices, but can't be defined in new indices
after the upgrade. This way we don't have to rely on index archiving and
upgrading via full cluster restart or rolling restart will yield the
same outcome.

Based on the test in #109301. Relates to #109160 and #96075
2024-06-11 18:17:48 +10:00
Simon Cooper
b6b20a5d6f
Update several references to IndexVersion.toString to use toReleaseVersion (#107828) 2024-04-25 10:37:02 +01:00
Moritz Mack
1f5e04b721
Migrate YAML REST tests to synthetic cluster feature check (#107068)
To simplify the migration away from version based skip checks in YAML specs, 
this PR adds a synthetic version feature `gte_vX.Y.Z` for any version at or before 8.14.0.

New test specs for 8.14 or later are expected to use respective new cluster features,
or a test-only feature supplied via ESRestTestCase#createAdditionalFeatureSpecifications
if sufficient.
2024-04-11 18:22:38 +02:00
Kostas Krikellas
755226df23
[TEST] Add full cluster restart test for downsampling (#107053)
This is a copy of the test added for rolling upgrade in #107036
2024-04-03 11:09:17 -04:00
Lorenzo Dematté
f437b7416a
Introduce oldClusterHasFeatures to full-cluster-restart (#104462)
Remove Version-based prerequisites in favour of feature-based prerequisites in ParameterizedFullClusterRestartTestCase and derived.

Follows #104279
2024-01-18 14:24:22 +01:00
Joe Gallo
af50962ec3
Fix CoreFullClusterRestartIT testRollover (#104373) 2024-01-16 10:54:17 -05:00
Mark Vieira
c6752e18f4
Fix failing test in release mode (#103883) 2024-01-03 15:27:32 -08:00
David Turner
60b833bb6d
Add utils for general XContent REST requests (#103711)
Tests that send REST requests with bodies must today build up a separate
`String` containing the body contents as JSON. This is kinda ugly, and
also means we do not cover the other supported body formats in these
tests. This commit introduces a utility to allow construction of REST
requests with `XContent` bodies directly, and generalizes things to
choose randomly between JSON and other supported body formats.
2024-01-02 13:39:21 +00:00
James Baiera
f4d791f8b4
Add failure store feature flag to bwc testing (#103341)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2023-12-12 15:01:11 -05:00
Lorenzo Dematté
93bd1abf2a
Addressing more Version usages in tests (#102803) 2023-12-12 16:44:24 +01:00
Lorenzo Dematté
bbe9f115cc
More version removal/mitigation (#102867) 2023-12-05 10:18:49 +01:00
Lorenzo Dematté
4e81494361
Introducing TestFeatureService to ESRestTestCase (#102243)
* Introducing TestFeatureService to ESRestTestCase

- Added RestTestLegacyFeatures to encompass legacy (historical) features that have been removed from production code but are still needed by REST tests
- Encapsulated Mark's getHistoricalFeatures method inside a FeatureProvider (ESRestTestCaseHistoricalFeatures)
- ESRestTestCaseHistoricalFeatures is not yet used, as we need to figure out how to deal with old cluster tests
2023-11-22 16:35:39 +01:00
Lorenzo Dematté
db53786601
Moved Version checks to IndexVersion to reflect production code (#102217)
Checks for soft delete support (and deprecation of non-soft delete), peer recovery retention leases and replication of closed indices are using IndexVersion in production code. Moving these checks from Version to IndexVersion in rest tests too.
2023-11-15 13:45:22 +01:00
Iraklis Psaroudakis
aa862640e5
Remove translog from bwc testRecovery (#101068)
When the test was trying to test recovering translog ops,
since we flush on close/shutdown, it failed because it never
recovered any translog ops.

The code for translog recovery is irrelevant due to that and
this PR proposes to remove it.

Alternatively, we could simulate killing nodes forcibly before
upgrading, but (a) that seems out of the ordinary for upgrades,
and (b) in trying that, it did not consistently pass the test
because sometimes the flush on close still happened.

Fixes #52031
2023-10-19 10:52:44 +03:00
William Brafford
04e478ae36
Hardcode version condition instead of calling minimumCompatibilityVersion() (#100102)
This is one of the few uses of Version#minimumCompatibilityVersion that isn't covered by other planned work. Since the minimum compatibility version for 7.14.0 is always going to be 6.8.0, we can just hardcode the value.
2023-10-02 09:59:07 -04:00
Simon Cooper
5f43cd8f46
Retry rolling upgrade junit tests (#99760)
Re-applies the changes from #99572 to move some bwc tests to a junit-based build infrastructure. Some tests that did not handle the move well have been kept in rolling-upgrade-legacy using the old gradle-based infrastructure
2023-09-22 15:52:59 +01:00
Simon Cooper
06f09d861d
Revert "Migrate rolling upgrade tests to new junit format" (#99750)
Reverts elastic/elasticsearch#99572 and #99733

The new tests are unstable, and don't work on CI. This re-opens
https://github.com/elastic/elasticsearch/issues/97200
2023-09-21 09:42:04 -04:00
Simon Cooper
1b8df61bd6
Limit test parallelism to 1 for junit bwc tests (#99733)
gradle runs test tasks in parallel, this results in multiple test clusters being created, which breaks CI.
2023-09-21 11:16:37 +01:00
Simon Cooper
cafa545786
Read index version from the old deployed cluster instead of inferring it in full restart tests (#99524)
The index version is needed to check the output against an upgraded cluster. Now the junit tests share a JVM between the old & upgraded clusters, we can store the old index version in the class to be read when needed
2023-09-18 08:46:19 +01:00
Mark Vieira
7be3d2c191
Increase flexibility of test cluster execution environments (#99437) 2023-09-13 11:18:40 -07:00
Simon Cooper
bebe2538b1
Bump to first non-release IndexVersion (#98478)
This bumps to an IndexVersion that is not associated with any specific release version. From this point, index metadata/data versioning will be handled in the same way as TransportVersion - a new constant for every change
2023-08-31 15:10:40 +01:00
Simon Cooper
a399fa877c
Update test version check to also include 8.10 patch releases (#99004) 2023-08-30 09:51:55 +01:00
Simon Cooper
b67a9e1ec3
Move text references to index created version to IndexVersion (#98727) 2023-08-23 10:51:56 +01:00
Simon Cooper
547947d465
Specify correct current IndexVersion after 8.10 release (#98574)
The current IndexVersion wasn't bumped by the release automation as it should have been
2023-08-17 09:28:34 +01:00
Tim Vernum
136a60c92a
Mute upgrades.FullClusterRestartIT.testClusterState (#98556)
Relates: #98555
2023-08-17 00:06:34 -04:00
Simon Cooper
cbec47f541
Modify upgrade test version check to include 8.10 (#98536)
IndexVersion hasn't yet been separated from Version. So it's ok to modify this check to allow 8.10 releases to run the test.
2023-08-16 15:04:08 +01:00
Simon Cooper
52a6820813
Migrate some full-cluster restart tests to use IndexVersion (#97368)
This infers the index version from the specified node version. Note that this will break when 8.10 is released, and BwC tests try to use 8.10 nodes. #97200 should be implemented before 8.10 is released to properly specify IndexVersion, without requiring inference.
2023-07-10 10:48:51 +01:00
Simon Cooper
5486667d73
Convert snapshot version to IndexVersion (#96857) 2023-06-28 16:04:19 +01:00
Simon Cooper
a873e26cf7
Convert IndexVersion.CURRENT to a method with a pluggable interface (#97132) 2023-06-27 14:47:32 +01:00
Simon Cooper
ec6b7900a9
Migrate some uses of Version.luceneVersion() to IndexVersion (#96300)
Redirect some uses of `Version.luceneVersion` to use
`IndexVersion.luceneVersion` instead
2023-06-08 11:13:15 -04:00
Simon Cooper
84a85901ac
Change Version.luceneVersion to a method (#96244) 2023-05-22 14:54:54 +01:00
Armin Braun
c41bda9e3a
Dry up remaining verbose index setting building in tests (#95652)
Lasts spots I could easily find via regex.
Follow-up to #95569
2023-04-28 11:18:07 +02:00
Simon Cooper
9fa7612d2d
Use separate transportversion for percolator query serialization (#94517)
This changes the serialization format for queries - when the index version is >=8.8.0, it serializes the actual transport version used into the stream. For BwC with old query formats, it uses the mapped TransportVersion for the index version.

This can be modified later if needed to re-interpret the vint used to store TransportVersion to something else, allowing the format to be further modified if necessary.
2023-04-05 13:13:14 +01:00
Simon Cooper
4c46ccacaa
Migrate the remaining uses of Version to TransportVersion (#93384)
Remove get/setVersion methods
2023-02-13 09:15:53 +00:00
Mark Vieira
43d9a6a0c8
Convert full cluster restart tests to new rest testing framework (#93477) 2023-02-02 13:13:54 -08:00
Nikolaj Volgushev
221c93531b
Revert "Convert full cluster restart tests to new rest testing framework (#93422)" (#93444)
Reverts #93422

Should address: #93442 and possibly #93440
2023-02-02 11:29:41 +01:00
Mark Vieira
820ba5af23
Convert full cluster restart tests to new rest testing framework (#93422) 2023-02-01 11:34:21 -08:00
Craig Taverner
bc7a31fd08
Revert "Convert full cluster restart tests to new rest testing framework (#93062)" (#93407)
This reverts commit 013b2e5d5e.
2023-02-01 12:57:50 +01:00
Mark Vieira
013b2e5d5e
Convert full cluster restart tests to new rest testing framework (#93062) 2023-01-31 12:26:45 -08:00
Artem Prigoda
2bc7398754
Use Strings.format instead of String.format(Locale.ROOT, ...) in tests (#92106)
Use local-independent `Strings.format` method instead of `String.format(Locale.ROOT, ...)`. 
Inline `ESTestCase.forbidden` calls with `Strings.format` for the consistency sake.
Add `Strings.format` alias in `common.Strings`
2023-01-03 19:28:27 +01: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
David Turner
75ae3f8e6f
Clean up request/response for get-cluster-settings (#86347)
Today there are request and response objects for the
get-cluster-settings action but the request is unused and the response
is only used in the REST layer. This commit removes the unused request
and renames the response to reflect that it's not a transport-layer
response. It also tidies a few things up in this area, removing the
unused `ActionResponse` superclass, making its fields final, and
replacing the overly-general `RestBuilderListener` with a regular
`RestToXContentListener` in the REST action.

Relates #82342 because to resolve that issue we will want to introduce
transport-layer request/response classes, and the classes involved in
this commit are in the way of that change.
2022-05-02 11:21:34 -04:00
Yannick Welsch
4c47daa8d6
Rewrite match_all inside must_not (#85999)
A must_not with a match_all clause inside a bool query is currently not rewritten to a match_none query. This means that running a boolean query with "must_not":[{"terms":{"_tier":["data_frozen","data_cold"]}] is currently not rewritten as match_none on a cold/frozen tier node.
2022-04-20 08:58:19 +02:00
Martijn van Groningen
660d9f75a9
Remove HLRC IndicesClient and related classes. (#85492)
Relates to #83423
2022-03-31 07:00:57 -04: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
Stuart Tettemer
5b1be93241
Test: IT testSystemIndexMetadataIsUpgraded requires 7.10 (#84830)
FullClusterRestartIT.testSystemIndexMetadataIsUpgraded assumes
the `.tasks` index is a system index, which became true in 7.10.

Fixes: #81409
2022-03-10 10:39:22 -06:00
Nik Everett
37ea6a8255
TSDB: Support GET and DELETE and doc versioning (#82633)
This adds support for GET and DELETE and the ids query and
Elasticsearch's standard document versioning to TSDB. So you can do
things like:
```
POST /tsdb_idx/_doc?filter_path=_id
{
  "@timestamp": "2021-12-29T19:25:05Z", "uid": "adsfadf", "v": 1.2
}
```

That'll return `{"_id" : "BsYQJjqS3TnsUlF3aDKnB34BAAA"}` which you can turn
around and fetch with
```
GET /tsdb_idx/_doc/BsYQJjqS3TnsUlF3aDKnB34BAAA
```
just like any other document in any other index. You can delete it too!
Or fetch it.

The ID comes from the dimensions and the `@timestamp`. So you can
overwrite the document:
```
POST /tsdb_idx/_bulk
{"index": {}}
{"@timestamp": "2021-12-29T19:25:05Z", "uid": "adsfadf", "v": 1.2}
```

Or you can write only if it doesn't already exist:
```
POST /tsdb_idx/_bulk
{"create": {}}
{"@timestamp": "2021-12-29T19:25:05Z", "uid": "adsfadf", "v": 1.2}
```

This works by generating an id from the dimensions and the `@timestamp`
when parsing the document. The id looks like:
* 4 bytes of hash from the routing calculated from routing_path fields
* 8 bytes of hash from the dimensions
* 8 bytes of timestamp
All that's base 64 encoded so that `Uid` can chew on it fairly
efficiently.

When it comes time to fetch or delete documents we base 64 decode the id
and grab the routing from the first four bytes. We use that hash to pick
the shard. Then we use the entire ID to perform the fetch or delete.

We don't implement update actions because we haven't written the
infrastructure to make sure the dimensions don't change. It's possible
to do, but feels like more than we need now.

There *ton* of compromises with this. The long term sad thing is that it
locks us into *indexing* the id of the sample. It'll index fairly
efficiently because the each time series will have the same first eight
bytes. It's also possible we'd share many of the first few bytes in the
timestamp as well. In our tsdb rally track this costs 8.75 bytes per
document. It's substantial, but not overwhelming.

In the short term there are lots of problems that I'd like to save for a
follow up change:
1. ~~We still generate the automatic `_id` for the document but we don't use
   it. We should stop generating it.~~ Included in this PR based on review comments.
2. We generated the time series `_id` on each shard and when replaying
   the translog. It'd be the good kind of paranoid to generate it once
   on the primary and then keep it forever.
3. We have to encode the `_id` as a string to pass it around
   Elasticsearch internally. And Elasticsearch assumes that when an id
   is loaded we always store as bytes encoded the `Uid` - which *does*
   have nice encoding for base 64 bytes. But this whole thing requires
   us to make the bytes, base 64 encode them, and then hand them back to
   `Uid` to base 64 decode them into bytes. It's a bit hacky. And, it's
   a small thing, but if the first byte of the routing hash encodes to
   254 or 255 we `Uid` spends an extra byte to encode it. One that'll
   always be a common prefix for tsdb indices, but still, it hurts my
   heart. It's just hard to fix.
4. We store the `_id` in Lucene stored fields for tsdb indices. Now
   that we're building it from the dimensions and the `@timestamp` we
   really don't *need* to store it. We could recalculate it when fetching
   documents. In the tsdb rall ytrick this'd save us 6 bytes per document
   at the cost of marginally slower fetches. Which is *fine*.
5. There are several error messages that try to use `_id` right now
   during parsing but the `_id` isn't available until after the parsing
   is complete. And, if parsing fails, it may not be possible to know
   the id at all. All of these error messages will have to change,
   at least in tsdb mode.
6. ~~If you specify an `_id` on the request right now we just overwrite
   it. We should send you an error.~~ Included in this PR after review comments.
7. We have to entirely disable the append-only optimization that allows
   Elasticsearch to skip looking up the ids in lucene. This *halves*
   indexing speed. It's substantial. We have to claw that optimization
   back *somehow*. Something like sliding bloom filters or relying on
   the increasing timestamps.
8. We parse the source from json when building the routing hash when
   parsing fields. We should just build it from to parsed field values.
   It looks like that'd improve indexing speed by about 20%.
9. Right now we write the `@timestamp` little endian. This is likely bad
   the prefix encoded inverted index. It'll prefer big endian. Might shrink it.
10. Improve error message on version conflict to include tsid and timestamp.
11. Improve error message when modifying dimensions or timestamp in update_by_query
12. Make it possible to modify dimension or timestamp in reindex.
13. Test TSDB's `_id` in `RecoverySourceHandlerTests.java` and `EngineTests.java`.

I've had to make some changes as part of this that don't feel super
expected. The biggest one is changing `Engine.Result` to include the
`id`. When the `id` comes from the dimensions it is calculated by the
document parsing infrastructure which is happens in
`IndexShard#pepareIndex`. Which returns an `Engine.IndexResult`. To make
everything clean I made it so `id` is available on all `Engine.Result`s
and I made all of the "outer results classes" read from
`Engine.Results#id`. I'm not excited by it. But it works and it's what
we're going with.

I've opted to create two subclasses of `IdFieldMapper`, one for standard
indices and one for tsdb indices. This feels like the right way to
introduce the distinction, especially if we don't want tsdb to cary
around it's old fielddata support. Honestly if we *need* to aggregate on
`_id` in tsdb mode we have doc values for the `tsdb` and the
`@timestamp` - we could build doc values for `_id` on the fly. But I'm
not expecting folks will need to do this. Also! I'd like to stop storing
tsdb'd `_id` field (see number 4 above) and the new subclass feels like
a good place to put that too.
2022-03-10 10:05:27 -05:00
Mark Vieira
64929dc5df
Introduce explicit API for configure test cluster feature flags (#83876) 2022-02-14 15:22:33 -08:00
Alan Woodward
2d77ef57cf
Rewrite match and match_phrase queries to term queries on keyword fields (#82612)
Term queries can in certain circumstances (eg when run against constant keyword
fields) rewrite themselves to match_no_docs queries, which is very useful for filtering
out shards from searches and field_caps requests. But match and match_phrase
queries can reduce down to simple term queries when there is no fuzziness defined
on them, and when they are run using a keyword analyzer.

This commit makes simple match and match_phrase rewrite themselves to term
queries when run against keyword fields.

Fixes #82515
2022-01-17 17:02:07 +00:00