Skip to content

Commit

Permalink
fix: some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatore-campagna committed Nov 23, 2023
1 parent d256209 commit a2b7ab3
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);

Expand Down Expand Up @@ -176,33 +161,24 @@ public void testMultiBucketAggregationAsSubAggregation() throws IOException {
Consumer<InternalTimeSeries> 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(
Expand All @@ -224,24 +200,9 @@ public void testAggregationSize() throws IOException {

List<Consumer<InternalTimeSeries>> verifiers = new ArrayList<Consumer<InternalTimeSeries>>();

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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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 }

Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"
Expand Down Expand Up @@ -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}

---
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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}

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
Expand All @@ -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 }

0 comments on commit a2b7ab3

Please sign in to comment.