diff options
author | Luca Cavanna <javanna@users.noreply.github.com> | 2017-04-05 11:12:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 11:12:34 +0200 |
commit | 318d365b12648daf4231430ae0c5257f83d1da80 (patch) | |
tree | 45d5fc75523535060507aaa181f14235a29a6849 /core/src/test/java/org/elasticsearch/search/profile | |
parent | afd45c14327cd0f8d155e5ac9740f48e8e39b09c (diff) |
[TEST] make sure that fromXContent doesn't rely on keys ordering (#23901)
We shuffle the keys before we parse our responses for the high level client so that we make sure we never rely on keys ordering.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/search/profile')
5 files changed, 8 insertions, 5 deletions
diff --git a/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java b/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java index 70375c6d20..77b41b062d 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java @@ -65,7 +65,7 @@ public class ProfileResultTests extends ESTestCase { ProfileResult profileResult = createTestItem(2); XContentType xContentType = randomFrom(XContentType.values()); boolean humanReadable = randomBoolean(); - BytesReference originalBytes = toXContent(profileResult, xContentType, humanReadable); + BytesReference originalBytes = toShuffledXContent(profileResult, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); ProfileResult parsed; try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser::getTokenLocation); diff --git a/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java b/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java index 82ed118f55..ea851427c0 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.profile; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult; @@ -60,7 +61,7 @@ public class SearchProfileShardResultsTests extends ESTestCase { SearchProfileShardResults shardResult = createTestItem(); XContentType xContentType = randomFrom(XContentType.values()); boolean humanReadable = randomBoolean(); - BytesReference originalBytes = toXContent(shardResult, xContentType, humanReadable); + BytesReference originalBytes = toShuffledXContent(shardResult, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); SearchProfileShardResults parsed = null; try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { ensureExpectedToken(parser.nextToken(), XContentParser.Token.START_OBJECT, parser::getTokenLocation); diff --git a/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResultTests.java b/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResultTests.java index ca5f792e72..a21eeedb96 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResultTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResultTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.profile.aggregation; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParserUtils; import org.elasticsearch.common.xcontent.XContentType; @@ -52,7 +53,7 @@ public class AggregationProfileShardResultTests extends ESTestCase { AggregationProfileShardResult profileResult = createTestItem(2); XContentType xContentType = randomFrom(XContentType.values()); boolean humanReadable = randomBoolean(); - BytesReference originalBytes = toXContent(profileResult, xContentType, humanReadable); + BytesReference originalBytes = toShuffledXContent(profileResult, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); AggregationProfileShardResult parsed; try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { diff --git a/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java b/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java index 698e4a387a..8d87f19360 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java @@ -60,7 +60,7 @@ public class CollectorResultTests extends ESTestCase { CollectorResult collectorResult = createTestItem(1); XContentType xContentType = randomFrom(XContentType.values()); boolean humanReadable = randomBoolean(); - BytesReference originalBytes = toXContent(collectorResult, xContentType, humanReadable); + BytesReference originalBytes = toShuffledXContent(collectorResult, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); CollectorResult parsed; try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { diff --git a/core/src/test/java/org/elasticsearch/search/profile/query/QueryProfileShardResultTests.java b/core/src/test/java/org/elasticsearch/search/profile/query/QueryProfileShardResultTests.java index 1542ce2eca..6ffece354f 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/query/QueryProfileShardResultTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/query/QueryProfileShardResultTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.profile.query; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParserUtils; import org.elasticsearch.common.xcontent.XContentType; @@ -54,7 +55,7 @@ public class QueryProfileShardResultTests extends ESTestCase { QueryProfileShardResult profileResult = createTestItem(); XContentType xContentType = randomFrom(XContentType.values()); boolean humanReadable = randomBoolean(); - BytesReference originalBytes = toXContent(profileResult, xContentType, humanReadable); + BytesReference originalBytes = toShuffledXContent(profileResult, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); QueryProfileShardResult parsed; try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { |