From bc45d715d7c3c32399da6640afcd18bdbd2dfe23 Mon Sep 17 00:00:00 2001 From: Rabi Panda Date: Mon, 29 Mar 2021 08:54:47 -0700 Subject: [PATCH] Make `:server:check` pass successfully (#471) * Fix package names in classes of the dummy plugin jars. The `PluginsServiceTests` uses couple of dummy plugin jars from the resources directory. The jars have classes with imports with package name `org.elasticsearch.*`. This commit recreates the jars after renaming those package names. * Fix the failing server tests as a result of renaming metadata prefix. As we changed the metadata prefix in `OpenSearchException` from `es.` to `opensearch.` (commit 13f6d23), the order of the keys in the `HashMap` changed. However, the tests are expecting a value which relies on a certain order . Ideally, these tests should not assume the order. This commit doesn't rewrite the test but only changes the order so the tests pass. * Properly rename the data examples to fix test failure. As part of the commit 0bdd129, we renamed the data examples in used in the test cases. This caused the test failures in `SimpleNestedIT` as it was sorting the results and the rename changed the order of the search result. In `SearchQueryIT`, we missed to rename the term used in the query. This commit fixes both the issues. Signed-off-by: Rabi Panda --- .../search/nested/SimpleNestedIT.java | 54 +++++++++--------- .../search/query/SearchQueryIT.java | 2 +- .../opensearch/OpenSearchExceptionTests.java | 2 +- .../SearchPhaseExecutionExceptionTests.java | 4 +- .../rest/action/RestActionsTests.java | 6 +- .../org/opensearch/plugins/dummy-plugin.jar | Bin 689 -> 767 bytes .../plugins/non-extensible-plugin.jar | Bin 711 -> 793 bytes 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java index 1798bb80b6b..8d23bf78731 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -200,7 +200,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1.nested2", - termQuery("nested1.nested2.field2", "2"), ScoreMode.Avg)).get(); + termQuery("nested1.nested2.field2", "2"), ScoreMode.Avg)).get(); assertNoFailures(searchResponse); assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L)); @@ -552,16 +552,16 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { + " {\n" + " \"name\": \"read\",\n" + " \"user\": [\n" - + " {\"username\": \"matt\", \"id\": 1},\n" - + " {\"username\": \"fred\", \"id\": 2},\n" - + " {\"username\": \"adrien\", \"id\": 3}\n" + + " {\"username\": \"grault\", \"id\": 1},\n" + + " {\"username\": \"quxx\", \"id\": 2},\n" + + " {\"username\": \"bar\", \"id\": 3}\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"write\",\n" + " \"user\": [\n" - + " {\"username\": \"fred\", \"id\": 2},\n" - + " {\"username\": \"adrien\", \"id\": 3}\n" + + " {\"username\": \"quxx\", \"id\": 2},\n" + + " {\"username\": \"bar\", \"id\": 3}\n" + " ]\n" + " }\n" + " ]\n" @@ -572,20 +572,20 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { + " {\n" + " \"name\": \"read\",\n" + " \"user\": [\n" - + " {\"username\": \"jim\", \"id\": 4},\n" - + " {\"username\": \"fred\", \"id\": 2}\n" + + " {\"username\": \"baz\", \"id\": 4},\n" + + " {\"username\": \"quxx\", \"id\": 2}\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"write\",\n" + " \"user\": [\n" - + " {\"username\": \"fred\", \"id\": 2}\n" + + " {\"username\": \"quxx\", \"id\": 2}\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"execute\",\n" + " \"user\": [\n" - + " {\"username\": \"fred\", \"id\": 2}\n" + + " {\"username\": \"quxx\", \"id\": 2}\n" + " ]\n" + " }\n" + " ]\n" @@ -601,14 +601,14 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { + " {\n" + " \"name\": \"read\",\n" + " \"user\": [\n" - + " {\"username\": \"matt\", \"id\": 1},\n" - + " {\"username\": \"quxx\", \"id\": 5}\n" + + " {\"username\": \"grault\", \"id\": 1},\n" + + " {\"username\": \"foo\", \"id\": 5}\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"execute\",\n" + " \"user\": [\n" - + " {\"username\": \"quxx\", \"id\": 5}\n" + + " {\"username\": \"foo\", \"id\": 5}\n" + " ]\n" + " }\n" + " ]\n" @@ -619,19 +619,19 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { + " {\n" + " \"name\": \"read\",\n" + " \"user\": [\n" - + " {\"username\": \"matt\", \"id\": 1}\n" + + " {\"username\": \"grault\", \"id\": 1}\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"write\",\n" + " \"user\": [\n" - + " {\"username\": \"matt\", \"id\": 1}\n" + + " {\"username\": \"grault\", \"id\": 1}\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"execute\",\n" + " \"user\": [\n" - + " {\"username\": \"matt\", \"id\": 1}\n" + + " {\"username\": \"grault\", \"id\": 1}\n" + " ]\n" + " }\n" + " ]\n" @@ -640,7 +640,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { + "}", XContentType.JSON).get(); refresh(); - // access id = 1, read, max value, asc, should use matt and fred + // access id = 1, read, max value, asc, should use grault and quxx SearchResponse searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) .addSort( @@ -658,12 +658,12 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { assertHitCount(searchResponse, 2); assertThat(searchResponse.getHits().getHits().length, equalTo(2)); assertThat(searchResponse.getHits().getHits()[0].getId(), equalTo("2")); - assertThat(searchResponse.getHits().getHits()[0].getSortValues()[0].toString(), equalTo("matt")); + assertThat(searchResponse.getHits().getHits()[0].getSortValues()[0].toString(), equalTo("grault")); assertThat(searchResponse.getHits().getHits()[1].getId(), equalTo("1")); - assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("fred")); + assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("quxx")); - // access id = 1, read, min value, asc, should now use adrien and quxx + // access id = 1, read, min value, asc, should now use bar and foo searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) .addSort( @@ -681,11 +681,11 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { assertHitCount(searchResponse, 2); assertThat(searchResponse.getHits().getHits().length, equalTo(2)); assertThat(searchResponse.getHits().getHits()[0].getId(), equalTo("1")); - assertThat(searchResponse.getHits().getHits()[0].getSortValues()[0].toString(), equalTo("adrien")); + assertThat(searchResponse.getHits().getHits()[0].getSortValues()[0].toString(), equalTo("bar")); assertThat(searchResponse.getHits().getHits()[1].getId(), equalTo("2")); - assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("quxx")); + assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("foo")); - // execute, by matt or quxx, by user id, sort missing first + // execute, by grault or foo, by user id, sort missing first searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) .addSort( @@ -694,7 +694,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { .setNestedSort(new NestedSortBuilder("acl.operation") .setFilter(QueryBuilders.termQuery("acl.operation.name", "execute")) .setNestedSort(new NestedSortBuilder("acl.operation.user") - .setFilter(QueryBuilders.termsQuery("acl.operation.user.username", "matt", "quxx"))))) + .setFilter(QueryBuilders.termsQuery("acl.operation.user.username", "grault", "foo"))))) .missing("_first") .sortMode(SortMode.MIN) .order(SortOrder.DESC) @@ -707,7 +707,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { assertThat(searchResponse.getHits().getHits()[1].getId(), equalTo("2")); assertThat(searchResponse.getHits().getHits()[1].getSortValues()[0].toString(), equalTo("1")); - // execute, by matt or luca, by username, sort missing last (default) + // execute, by grault or foo, by username, sort missing last (default) searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) .addSort( @@ -716,7 +716,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { .setNestedSort(new NestedSortBuilder("acl.operation") .setFilter(QueryBuilders.termQuery("acl.operation.name", "execute")) .setNestedSort(new NestedSortBuilder("acl.operation.user") - .setFilter(QueryBuilders.termsQuery("acl.operation.user.username", "matt", "quxx"))))) + .setFilter(QueryBuilders.termsQuery("acl.operation.user.username", "grault", "foo"))))) .sortMode(SortMode.MIN) .order(SortOrder.DESC) ) @@ -725,7 +725,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { assertHitCount(searchResponse, 2); assertThat(searchResponse.getHits().getHits().length, equalTo(2)); assertThat(searchResponse.getHits().getHits()[0].getId(), equalTo("2")); - assertThat(searchResponse.getHits().getHits()[0].getSortValues()[0].toString(), equalTo("quxx")); + assertThat(searchResponse.getHits().getHits()[0].getSortValues()[0].toString(), equalTo("foo")); assertThat(searchResponse.getHits().getHits()[1].getId(), equalTo("1")); // missing last } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java index 271612fcbcd..756fe59ddc3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -924,7 +924,7 @@ public class SearchQueryIT extends OpenSearchIntegTestCase { client().prepareIndex("test", "type1", "2").setSource("str", "fred", "date", "2012-02-05", "num", 20).get(); refresh(); - SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("str:kimcy~1")).get(); + SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("str:foobaz~1")).get(); assertNoFailures(searchResponse); assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); diff --git a/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java index 722484dc7ec..022a2a2c63a 100644 --- a/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java +++ b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java @@ -230,7 +230,7 @@ public class OpenSearchExceptionTests extends OpenSearchTestCase { "\"phase\":\"search\",\"grouped\":true,\"failed_shards\":[{\"shard\":1,\"index\":\"foo\",\"node\":\"node_1\"," + "\"reason\":{\"type\":\"parsing_exception\",\"reason\":\"foobar\",\"line\":1,\"col\":2}},{\"shard\":1," + "\"index\":\"foo1\",\"node\":\"node_1\",\"reason\":{\"type\":\"query_shard_exception\",\"reason\":\"foobar\"," + - "\"index_uuid\":\"_na_\",\"index\":\"foo1\"}}]}"; + "\"index\":\"foo1\",\"index_uuid\":\"_na_\"}}]}"; assertEquals(expected, Strings.toString(builder)); } { diff --git a/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java b/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java index 9831843774e..f799e8953d9 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java @@ -82,9 +82,9 @@ public class SearchPhaseExecutionExceptionTests extends OpenSearchTestCase { + " \"reason\": {" + " \"type\": \"index_shard_closed_exception\"," + " \"reason\": \"CurrentState[CLOSED] Closed\"," - + " \"index_uuid\": \"_na_\"," + + " \"index\": \"foo\"," + " \"shard\": \"1\"," - + " \"index\": \"foo\"" + + " \"index_uuid\": \"_na_\"" + " }" + " }" + " ]" diff --git a/server/src/test/java/org/opensearch/rest/action/RestActionsTests.java b/server/src/test/java/org/opensearch/rest/action/RestActionsTests.java index 9203c20cc2e..01bfefe632d 100644 --- a/server/src/test/java/org/opensearch/rest/action/RestActionsTests.java +++ b/server/src/test/java/org/opensearch/rest/action/RestActionsTests.java @@ -141,8 +141,8 @@ public class RestActionsTests extends OpenSearchTestCase { " \"reason\" : {\n" + " \"type\" : \"parsing_exception\",\n" + " \"reason\" : \"error\",\n" + - " \"index_uuid\" : \"_na_\",\n" + " \"index\" : \"index\",\n" + + " \"index_uuid\" : \"_na_\",\n" + " \"line\" : 0,\n" + " \"col\" : 0,\n" + " \"caused_by\" : {\n" + @@ -158,8 +158,8 @@ public class RestActionsTests extends OpenSearchTestCase { " \"reason\" : {\n" + " \"type\" : \"parsing_exception\",\n" + " \"reason\" : \"error\",\n" + - " \"index_uuid\" : \"_na_\",\n" + " \"index\" : \"index\",\n" + + " \"index_uuid\" : \"_na_\",\n" + " \"line\" : 0,\n" + " \"col\" : 0,\n" + " \"caused_by\" : {\n" + @@ -175,8 +175,8 @@ public class RestActionsTests extends OpenSearchTestCase { " \"reason\" : {\n" + " \"type\" : \"parsing_exception\",\n" + " \"reason\" : \"error\",\n" + - " \"index_uuid\" : \"_na_\",\n" + " \"index\" : \"index\",\n" + + " \"index_uuid\" : \"_na_\",\n" + " \"line\" : 0,\n" + " \"col\" : 0,\n" + " \"caused_by\" : {\n" + diff --git a/server/src/test/resources/org/opensearch/plugins/dummy-plugin.jar b/server/src/test/resources/org/opensearch/plugins/dummy-plugin.jar index 4f7d81df4fa30f28b2353c24265b4ebb1b278636..f90f71cea28911a6f974749c4a20e31e23b544da 100644 GIT binary patch literal 767 zcmWIWW@Zs#;Nak3xDr<##DD}i8CV#6T|*poJ^kGD|D9rBU}gyLX6FE@V1g>hQZvJ1*%R?8Kg5?jtK3OlH0I->`i{Fn92s z+nQ!wp#qK@;~y{5_6#%Ye2^T;DQ4HeUs||HqrzlhleY{GGwe_vgsP zM&IYp`vWhqd#rv^*URqpSNle57n4lT@dNf70+d--Hfmfy+tsEx+aDBf6+J7@Ujq7B zmJt+ij7%a7sL>9KQ&6;{0(d-v5&^na34l!CV!$152ov@Inb257 nxEB94?WU|;|Mj(O0u delta 435 zcmey*x{;MHz?+#xgn@&DgCQq=iuXi5OBOKg?dHH4@j~*5^sE^g89&5T)t)cWvUn~o z`b1oH8pGA>PemV#7#RY***WIblm)vmFfh0RF~Y3=IG|Z?)$9FjvzZ(PYF9s>YpJib zQpb0><{h=UioHpyjs`d0&po~Kq1~Z(^Crxns+I7N|ATvHaW+>Wo7`u+v;@EBhXoI4 z|5BV)!E=H4Lh^_EAq(GFI~SYWGpN{Hq%B$H9eSc)tAFV~kwUjqmpA#iY!i&S`X~O& z8^4*iHeZUcTmR`#`qa>s^;*k#9`0IGq9neG?_2(!lhbc>bI3(4xvy`;<2|=%CTDVJ z(vk}&`|7Pvf5>JzpK*b`)G%w8^9$j}eavg8+i!@MlH%Z~Rp+~)*0YY$Mxo@j?DQ@@ zkf)zaKcICP=wTT~kf#}$L>Lf32oz>u0uewkS&&Ja7ZjfGP@3$?q^k~74hkh?qr@P( Zpyc7n7nl_Jm>HNE4gy7P0j*+S002hlmtz0` diff --git a/server/src/test/resources/org/opensearch/plugins/non-extensible-plugin.jar b/server/src/test/resources/org/opensearch/plugins/non-extensible-plugin.jar index 54d330349eda2a696fff9ba97c31af5ad2501716..3ef903e030d8c8bd2c37d9a7002224b0d0045fc4 100644 GIT binary patch delta 514 zcmX@kI+Kkrz?+#xgn@&DgFz>uI%p!FB@3ALc8lSf@j~*2q-KW2vM1tGeuyu5R=Kkx z`%}@!B1VP)Z*~qABgSZ31_lNjAO;!2#lXP9z)&4u9Rw7B16ClbB(=CiA7Kwj$;6BL z_5BdP#{x>!sWJ|a{~7biXU>28z?;ytnuFKGnZANOX5`1zjIKMNIN>%3GHx;OpOI@ax+*E>(T zPUKph^*@^DPT16z*-!Sj`nS9|8e%rxJCvX2yg`5dBj<#c3FlWe|M-}=M*PjOd(3Ow zZC`ZT^SZ2=*uI>c8mC5qP6~fexLw)HdB)C4$%9ijGzEwWD;ROgfmch@^3~H zUQk%W19GwrlWr6j1MYwX>VkqjKpGmX2!lZZi)^VJOf{IkKY0R^CLap}3&S5EpPdOL F2moO_q`UwC delta 442 zcmbQqcAS+jz?+#xgn@&DgJE~yWbcW5mMmb}+s%P9;)Uc9=~**0GJc4wsy$z#W$|2G z^oh9YG={6$pNc*fF){>rvvbU=DGPRCU|?_sVuV@KKxVzwulKk0W_A>)ogDM-i%stm zuCQAxTW{acG+T64kjd-U*_|rN&)2|J{9K=QrgJZG+dKd#8TZ#*E#B00%cY>DvF4h%=V{x6F*CemB