Skip to content

Commit 7135011

Browse files
committed
[test] remove Streamable serde assertions (#29307)
Removes a set of assertions in the test framework that verified that Streamable objects could be serialized and deserialized across different versions. When this was discussed the consensus was that this approach has not caught many bugs in a long time and that serialization testing of objects was best left to their respective unit and integration tests. This commit also removes a transport interceptor that was used in ESIntegTestCase tests to make these assertions about objects coming in or off the wire.
1 parent d9859cb commit 7135011

File tree

7 files changed

+11
-331
lines changed

7 files changed

+11
-331
lines changed

server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java

-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import org.elasticsearch.test.ESTestCase;
8282
import org.elasticsearch.test.TestSearchContext;
8383
import org.elasticsearch.test.VersionUtils;
84-
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
8584
import org.elasticsearch.transport.ActionNotFoundTransportException;
8685
import org.elasticsearch.transport.ActionTransportException;
8786
import org.elasticsearch.transport.ConnectTransportException;
@@ -116,7 +115,6 @@
116115
import static java.util.Collections.emptyMap;
117116
import static java.util.Collections.emptySet;
118117
import static java.util.Collections.singleton;
119-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertVersionSerializable;
120118
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
121119
import static org.hamcrest.Matchers.instanceOf;
122120

@@ -233,7 +231,6 @@ private <T extends Exception> T serialize(T exception) throws IOException {
233231
}
234232

235233
private <T extends Exception> T serialize(T exception, Version version) throws IOException {
236-
ElasticsearchAssertions.assertVersionSerializable(version, exception);
237234
BytesStreamOutput out = new BytesStreamOutput();
238235
out.setVersion(version);
239236
out.writeException(exception);
@@ -578,9 +575,6 @@ public void testWriteThrowable() throws IOException {
578575
}
579576
assertArrayEquals(deserialized.getStackTrace(), ex.getStackTrace());
580577
assertTrue(deserialized.getStackTrace().length > 1);
581-
assertVersionSerializable(VersionUtils.randomVersion(random()), cause);
582-
assertVersionSerializable(VersionUtils.randomVersion(random()), ex);
583-
assertVersionSerializable(VersionUtils.randomVersion(random()), deserialized);
584578
}
585579
}
586580

server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFirstHit;
9595
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
9696
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
97-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHit;
9897
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
9998
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
10099
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSecondHit;
@@ -191,7 +190,7 @@ public void testConstantScoreQuery() throws Exception {
191190
SearchResponse searchResponse = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("field1", "quick"))).get();
192191
assertHitCount(searchResponse, 2L);
193192
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
194-
assertSearchHit(searchHit, hasScore(1.0f));
193+
assertThat(searchHit, hasScore(1.0f));
195194
}
196195

197196
searchResponse = client().prepareSearch("test").setQuery(
@@ -210,7 +209,7 @@ public void testConstantScoreQuery() throws Exception {
210209
assertHitCount(searchResponse, 2L);
211210
assertFirstHit(searchResponse, hasScore(searchResponse.getHits().getAt(1).getScore()));
212211
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
213-
assertSearchHit(searchHit, hasScore(1.0f));
212+
assertThat(searchHit, hasScore(1.0f));
214213
}
215214

216215
int num = scaledRandomIntBetween(100, 200);
@@ -228,7 +227,7 @@ public void testConstantScoreQuery() throws Exception {
228227
long totalHits = searchResponse.getHits().getTotalHits();
229228
SearchHits hits = searchResponse.getHits();
230229
for (SearchHit searchHit : hits) {
231-
assertSearchHit(searchHit, hasScore(1.0f));
230+
assertThat(searchHit, hasScore(1.0f));
232231
}
233232
searchResponse = client().prepareSearch("test_1").setQuery(
234233
boolQuery().must(matchAllQuery()).must(
@@ -238,7 +237,7 @@ public void testConstantScoreQuery() throws Exception {
238237
if (totalHits > 1) {
239238
float expected = hits.getAt(0).getScore();
240239
for (SearchHit searchHit : hits) {
241-
assertSearchHit(searchHit, hasScore(expected));
240+
assertThat(searchHit, hasScore(expected));
242241
}
243242
}
244243
}

server/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
7070
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
7171
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
72-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHit;
7372
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasId;
7473
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasScore;
7574
import static org.hamcrest.Matchers.contains;
@@ -245,8 +244,8 @@ public void testSuggestDocument() throws Exception {
245244
int id = numDocs;
246245
for (CompletionSuggestion.Entry.Option option : options) {
247246
assertThat(option.getText().toString(), equalTo("suggestion" + id));
248-
assertSearchHit(option.getHit(), hasId("" + id));
249-
assertSearchHit(option.getHit(), hasScore((id)));
247+
assertThat(option.getHit(), hasId("" + id));
248+
assertThat(option.getHit(), hasScore((id)));
250249
assertNotNull(option.getHit().getSourceAsMap());
251250
id--;
252251
}
@@ -280,8 +279,8 @@ public void testSuggestDocumentNoSource() throws Exception {
280279
int id = numDocs;
281280
for (CompletionSuggestion.Entry.Option option : options) {
282281
assertThat(option.getText().toString(), equalTo("suggestion" + id));
283-
assertSearchHit(option.getHit(), hasId("" + id));
284-
assertSearchHit(option.getHit(), hasScore((id)));
282+
assertThat(option.getHit(), hasId("" + id));
283+
assertThat(option.getHit(), hasScore((id)));
285284
assertNull(option.getHit().getSourceAsMap());
286285
id--;
287286
}
@@ -317,8 +316,8 @@ public void testSuggestDocumentSourceFiltering() throws Exception {
317316
int id = numDocs;
318317
for (CompletionSuggestion.Entry.Option option : options) {
319318
assertThat(option.getText().toString(), equalTo("suggestion" + id));
320-
assertSearchHit(option.getHit(), hasId("" + id));
321-
assertSearchHit(option.getHit(), hasScore((id)));
319+
assertThat(option.getHit(), hasId("" + id));
320+
assertThat(option.getHit(), hasScore((id)));
322321
assertNotNull(option.getHit().getSourceAsMap());
323322
Set<String> sourceFields = option.getHit().getSourceAsMap().keySet();
324323
assertThat(sourceFields, contains("a"));

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
144144
import org.elasticsearch.test.store.MockFSIndexStore;
145145
import org.elasticsearch.test.transport.MockTransportService;
146-
import org.elasticsearch.transport.AssertingTransportInterceptor;
147146
import org.hamcrest.Matchers;
148147
import org.junit.After;
149148
import org.junit.AfterClass;
@@ -1921,9 +1920,6 @@ protected Collection<Class<? extends Plugin>> getMockPlugins() {
19211920
if (randomBoolean()) {
19221921
mocks.add(MockSearchService.TestPlugin.class);
19231922
}
1924-
if (randomBoolean()) {
1925-
mocks.add(AssertingTransportInterceptor.TestPlugin.class);
1926-
}
19271923
if (randomBoolean()) {
19281924
mocks.add(MockFieldFilterPlugin.class);
19291925
}

0 commit comments

Comments
 (0)