From a2b7ab3a8ca449c3d942b06b8ab5dedb3ac08d5b Mon Sep 17 00:00:00 2001 From: Salvatore Campagna Date: Thu, 23 Nov 2023 16:32:07 +0100 Subject: [PATCH] fix: some more tests --- .../timeseries/TimeSeriesAggregatorTests.java | 73 +++++-------------- .../rest-api-spec/test/delete/70_tsdb.yml | 12 +-- .../test/tsdb/140_routing_path.yml | 11 +-- .../test/tsdb/25_id_generation.yml | 36 ++++----- .../rest-api-spec/test/tsdb/50_alias.yml | 8 +- .../test/analytics/reset_tracking_rate.yml | 5 +- 6 files changed, 48 insertions(+), 97 deletions(-) diff --git a/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/timeseries/TimeSeriesAggregatorTests.java b/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/timeseries/TimeSeriesAggregatorTests.java index 4326806c90e5e..96c4eb0d475b1 100644 --- a/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/timeseries/TimeSeriesAggregatorTests.java +++ b/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/timeseries/TimeSeriesAggregatorTests.java @@ -66,34 +66,19 @@ public void testStandAloneTimeSeriesWithSum() throws IOException { }, ts -> { assertThat(ts.getBuckets(), hasSize(3)); + assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzIS_0VrZGalylFPi9dkK4dYyY9g0yybS6o").docCount, equalTo(4L)); assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAAAS_0VrZGalylFPi9dkK4dYyY9g0yybS6o").docCount, - equalTo(4L) - ); - assertThat( - ((Sum) ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAAAS_0VrZGalylFPi9dkK4dYyY9g0yybS6o") - .getAggregations() - .get("sum")).value(), + ((Sum) ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzIS_0VrZGalylFPi9dkK4dYyY9g0yybS6o").getAggregations().get("sum")).value(), equalTo(22.0) ); + assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg").docCount, equalTo(2L)); assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg").docCount, - equalTo(2L) - ); - assertThat( - ((Sum) ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg") - .getAggregations() - .get("sum")).value(), + ((Sum) ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg").getAggregations().get("sum")).value(), equalTo(6.0) ); + assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4").docCount, equalTo(2L)); assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4").docCount, - equalTo(2L) - ); - assertThat( - ((Sum) ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4") - .getAggregations() - .get("sum")).value(), + ((Sum) ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4").getAggregations().get("sum")).value(), equalTo(8.0) ); @@ -176,33 +161,24 @@ public void testMultiBucketAggregationAsSubAggregation() throws IOException { Consumer verifier = ts -> { assertThat(ts.getBuckets(), hasSize(3)); - assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAAAS_0VrZGalylFPi9dkK4dYyY9g0yybS6o").docCount, - equalTo(4L) - ); - InternalDateHistogram byTimeStampBucket = ts.getBucketByKey( - "C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAAAS_0VrZGalylFPi9dkK4dYyY9g0yybS6o" - ).getAggregations().get("by_timestamp"); + assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzIS_0VrZGalylFPi9dkK4dYyY9g0yybS6o").docCount, equalTo(4L)); + InternalDateHistogram byTimeStampBucket = ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzIS_0VrZGalylFPi9dkK4dYyY9g0yybS6o") + .getAggregations() + .get("by_timestamp"); assertThat( byTimeStampBucket.getBuckets(), contains(new InternalDateHistogram.Bucket(startTime, 4, false, null, InternalAggregations.EMPTY)) ); - assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg").docCount, - equalTo(2L) - ); - byTimeStampBucket = ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg") + assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg").docCount, equalTo(2L)); + byTimeStampBucket = ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg") .getAggregations() .get("by_timestamp"); assertThat( byTimeStampBucket.getBuckets(), contains(new InternalDateHistogram.Bucket(startTime, 2, false, null, InternalAggregations.EMPTY)) ); - assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4").docCount, - equalTo(2L) - ); - byTimeStampBucket = ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4") + assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4").docCount, equalTo(2L)); + byTimeStampBucket = ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4") .getAggregations() .get("by_timestamp"); assertThat( @@ -224,24 +200,9 @@ public void testAggregationSize() throws IOException { List> verifiers = new ArrayList>(); - verifiers.add( - ts -> assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAAAS_0VrZGalylFPi9dkK4dYyY9g0yybS6o").docCount, - equalTo(4L) - ) - ); - verifiers.add( - ts -> assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg").docCount, - equalTo(2L) - ) - ); - verifiers.add( - ts -> assertThat( - ts.getBucketByKey("C0uMhZuLQSpAQ5ipTZFLMgAAAAAAAAAAAAAAAAAAAABjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4").docCount, - equalTo(2L) - ) - ); + verifiers.add(ts -> assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzIS_0VrZGalylFPi9dkK4dYyY9g0yybS6o").docCount, equalTo(4L))); + verifiers.add(ts -> assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyfgM9Vvd-IRpsCvXNT5j_dX4tz0qg").docCount, equalTo(2L))); + verifiers.add(ts -> assertThat(ts.getBucketByKey("KAtLjIWbi0EqQEOYqU2RSzJjzNyftxCMQuGv-XOPz9J6bZM-ZhUGnV4").docCount, equalTo(2L))); for (int i = 1; i <= 3; i++) { int size = i; diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/delete/70_tsdb.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/delete/70_tsdb.yml index 6f761f2d4a5e1..82e064304ce4c 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/delete/70_tsdb.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/delete/70_tsdb.yml @@ -1,14 +1,8 @@ ---- -setup: - - skip: - version: "8.7.00 - 8.9.99" - reason: "Synthetic source shows up in the mapping in 8.10 and on, may trigger assert failures in mixed cluster tests" - --- "basic tsdb delete": - skip: - version: " - 8.8.0" - reason: fixed in 8.8.1 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: indices.create: @@ -49,7 +43,7 @@ setup: location: swamp temperature: 32.4 humidity: 88.9 - - match: { _id: crxuhDzuYSDy965GAAABiHD35_g } + - match: { _id: crxuhC8WO3aVdhvtAAABiHD35_g } - match: { result: created } - match: { _version: 1 } diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/140_routing_path.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/140_routing_path.yml index 9b7052fd80810..e1393c4213fe8 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/140_routing_path.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/140_routing_path.yml @@ -1,10 +1,3 @@ ---- -setup: - - skip: - version: " - 8.9.99" - reason: "counter field support added in 8.10" - features: close_to - --- missing routing path field: - skip: @@ -133,8 +126,8 @@ missing dimension on routing path field: multi-value routing path field: - skip: features: close_to - version: " - 8.1.99" - reason: tsdb indexing changed in 8.2.0 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: indices.create: diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/25_id_generation.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/25_id_generation.yml index e666b3145a89e..4e5edc6400e97 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/25_id_generation.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/25_id_generation.yml @@ -136,8 +136,8 @@ generates a consistent id: --- index a new document on top of an old one: - skip: - version: " - 8.1.99" - reason: indexing on top of another document support added in 8.2 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: search: @@ -170,7 +170,7 @@ index a new document on top of an old one: network: tx: 111434595272 rx: 430605511 - - match: {_id: cn4exSPK93Q9eJj8AAABeRnR_mY} + - match: {_id: cn4excfoxSs_KdA5AAABeRnR_mY} - do: search: @@ -215,7 +215,7 @@ index a new document on top of an old one over bulk: body: - '{"index": {}}' - '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 111434595272, "rx": 430605511}}}}' - - match: {items.0.index._id: cn4exSPK93Q9eJj8AAABeRnR_mY} + - match: {items.0.index._id: cn4excfoxSs_KdA5AAABeRnR_mY} - do: search: @@ -268,7 +268,7 @@ create operation on top of old document fails over bulk: body: - '{"create": {}}' - '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 111434595272, "rx": 430605511}}}}' - - match: { items.0.create.error.reason: "[cn4exSPK93Q9eJj8AAABeRnR_mY][{_tsid=KMQn1H8GA7xNFfZA53p2lAAAAAAAAAAAAAAAAAAAAAA5ihHD--qoyLTiOy0pmP6_RAIE-e0-dKQ}@2021-04-28T18:51:03.142Z]: version conflict, document already exists (current version [1])" } + - match: { items.0.create.error.reason: "[cn4excfoxSs_KdA5AAABeRnR_mY][KCjEJ9R_BgO8TRX2QOd6dpQ5ihHD--qoyLTiOy0pmP6_RAIE-e0-dKQAAAAAAAAA@2021-04-28T18:51:03.142Z]: version conflict, document already exists (current version [1])" } --- ids query: @@ -295,15 +295,15 @@ ids query: --- get: - skip: - version: " - 8.1.99" - reason: ids generation changed in 8.2 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: get: index: test - id: cZZNs-xII2fZweptAAABeRnSA5M + id: cZZNs7B9sSWsyrL5AAABeRnSA5M - match: {_index: test} - - match: {_id: cZZNs-xII2fZweptAAABeRnSA5M} + - match: {_id: cZZNs7B9sSWsyrL5AAABeRnSA5M} - match: _source: "@timestamp": "2021-04-28T18:51:04.467Z" @@ -345,13 +345,13 @@ get with routing: --- delete: - skip: - version: " - 8.1.99" - reason: ids generation changed in 8.2 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: delete: index: test - id: cn4exSPK93Q9eJj8AAABeRnRFAY + id: cn4excfoxSs_KdA5AAABeRnR_mY - match: {result: deleted} --- @@ -414,8 +414,8 @@ delete over _bulk: --- routing_path matches deep object: - skip: - version: " - 8.1.99" - reason: id generation changed in 8.2 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: indices.create: @@ -454,13 +454,13 @@ routing_path matches deep object: - '{"index": {}}' - '{"@timestamp": "2021-04-28T18:50:04.467Z", "dim": {"foo": {"bar": {"baz": {"uid": "uid1"}}}}}' - match: {items.0.index.result: created} - - match: {items.0.index._id: OcEOGeykhIEIYuXSAAABeRnRGTM} + - match: {items.0.index._id: OcEOGchJrjH1fFX8AAABeRnRGTM} --- routing_path matches object: - skip: - version: " - 8.1.99" - reason: id generation changed in 8.2 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: indices.create: @@ -495,4 +495,4 @@ routing_path matches object: - '{"index": {}}' - '{"@timestamp": "2021-04-28T18:50:04.467Z", "dim": {"foo": {"uid": "uid1"}}}' - match: {items.0.index.result: created} - - match: {items.0.index._id: 8bgiqXPBT_mM6CX6AAABeRnRGTM} + - match: {items.0.index._id: 8bgiqW9JKwAyp1bZAAABeRnRGTM} diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/50_alias.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/50_alias.yml index 00005d3e1881a..a36bd16647b93 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/50_alias.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/50_alias.yml @@ -64,8 +64,8 @@ setup: --- search an alias: - skip: - version: " - 8.1.99" - reason: tsdb indexing changed in 8.2.0 + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: indices.put_alias: @@ -85,9 +85,9 @@ search an alias: _key: asc - match: {hits.total.value: 8} - - match: {aggregations.tsids.buckets.0.key: {_tsid: "KMQn1H8GA7xNFfZA53p2lAAAAAAAAAAAAAAAAAAAAAA5ihHD--qoyLTiOy0pmP6_RAIE-e0-dKQ"}} + - match: {aggregations.tsids.buckets.0.key: "AgtrOHMucG9kLnVpZHMkOTQ3ZTRjZWQtMTc4Ni00ZTUzLTllMGMtNWM0NDdlOTU5NTA3CW1ldHJpY3NldHMDcG9k"} - match: {aggregations.tsids.buckets.0.doc_count: 4} - - match: {aggregations.tsids.buckets.1.key: {_tsid: "KMQn1H8GA7xNFfZA53p2lAAAAAAAAAAAAAAAAAAAAAB12oDh--qoyNZRQPy43y34Qdy2dpsyG0o"}} + - match: {aggregations.tsids.buckets.1.key: "AgtrOHMucG9kLnVpZHMkOTQ3ZTRjZWQtMTc4Ni00ZTUzLTllMGMtNWM0NDdlOTU5NTA3CW1ldHJpY3NldHMDcG9k"} - match: {aggregations.tsids.buckets.1.doc_count: 4} --- diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/reset_tracking_rate.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/reset_tracking_rate.yml index 62115b3b87081..e6e9a8a0aa295 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/reset_tracking_rate.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/reset_tracking_rate.yml @@ -103,6 +103,9 @@ setup: - '{ "key": "bar", "val": 20, "@timestamp": "2021-01-01T02:40:00Z" }' --- "test resets do not lead to negative rate": + - skip: + version: " - 8.11.99" + reason: _tsid hasing introduced in 8.12 - do: search: index: tsdb-* @@ -126,7 +129,7 @@ setup: - match: { hits.total.value: 9 } - length: { aggregations.ts.buckets: 1 } - - match: { aggregations.ts.buckets.0.key: { "key": "bar" } } + - match: { aggregations.ts.buckets.0.key: "JEMc3XgEDWzF216sBF5nxwW5AZB2-M4K_VYiHrKDjUNX3zHVkw" } - match: { aggregations.ts.buckets.0.doc_count: 9 } - gte: { aggregations.ts.buckets.0.rate.value: 0.0 }