From 92843d04b2d569b616e1ea6ade9d3de21e6337b0 Mon Sep 17 00:00:00 2001 From: panguixin Date: Mon, 16 Dec 2024 20:49:55 +0800 Subject: [PATCH] fix Signed-off-by: panguixin --- .../test/search/260_sort_double.yml | 46 ++++++------ .../test/search/260_sort_long.yml | 42 +++++------ .../test/search/260_sort_unsigned_long.yml | 72 +++++++++---------- .../rest/yaml/section/MatchAssertion.java | 23 ------ 4 files changed, 80 insertions(+), 103 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_double.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_double.yml index 654d3f6c58a61..eccafaf96dd23 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_double.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_double.yml @@ -37,13 +37,13 @@ setup: - length: {hits.hits: 4 } - match: { hits.hits.0._index: double_sort } - match: { hits.hits.0._source.field: [ 900719925474099.2, 900719925474099.2 ] } - - match: { hits.hits.0.sort: [ 900719925474099.2 ] } + - match: { hits.hits.0.sort.0: 900719925474099.2 } - match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] } - - match: { hits.hits.1.sort: [ 900719925474099.1 ] } + - match: { hits.hits.1.sort.0: 900719925474099.1 } - match: { hits.hits.2._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] } - - match: { hits.hits.2.sort: [ 450359962737049.7 ] } + - match: { hits.hits.2.sort.0: 450359962737049.7 } - match: { hits.hits.3._source.field: [ 450359962737049.4, 3.5, 4.6 ] } - - match: { hits.hits.3.sort: [ 450359962737049.4 ] } + - match: { hits.hits.3.sort.0: 450359962737049.4 } - do: search: @@ -55,13 +55,13 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: double_sort } - match: { hits.hits.0._source.field: [ 450359962737049.4, 3.5, 4.6 ] } - - match: { hits.hits.0.sort: [ 450359962737049.4 ] } + - match: { hits.hits.0.sort.0: 450359962737049.4 } - match: { hits.hits.1._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] } - - match: { hits.hits.1.sort: [ 450359962737049.7 ] } + - match: { hits.hits.1.sort.0: 450359962737049.7 } - match: { hits.hits.2._source.field: [ 900719925474099.1, 1.1 ] } - - match: { hits.hits.2.sort: [ 900719925474099.1 ] } + - match: { hits.hits.2.sort.0: 900719925474099.1 } - match: { hits.hits.3._source.field: [ 900719925474099.2, 900719925474099.2 ] } - - match: { hits.hits.3.sort: [ 900719925474099.2 ] } + - match: { hits.hits.3.sort.0: 900719925474099.2 } - do: search: @@ -75,11 +75,11 @@ setup: - match: { hits.hits.0._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] } - match: { hits.hits.0.sort: [ -2.0 ] } - match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] } - - match: { hits.hits.1.sort: [ 1.1 ] } + - match: { hits.hits.1.sort.0: 1.1 } - match: { hits.hits.2._source.field: [ 450359962737049.4, 3.5, 4.6 ] } - - match: { hits.hits.2.sort: [ 3.5 ] } + - match: { hits.hits.2.sort.0: 3.5 } - match: { hits.hits.3._source.field: [ 900719925474099.2, 900719925474099.2 ] } - - match: { hits.hits.3.sort: [ 900719925474099.2 ] } + - match: { hits.hits.3.sort.0: 900719925474099.2 } - do: search: @@ -91,13 +91,13 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: double_sort } - match: { hits.hits.0._source.field: [ 900719925474099.2, 900719925474099.2 ] } - - match: { hits.hits.0.sort: [ 900719925474099.2 ] } + - match: { hits.hits.0.sort.0: 900719925474099.2 } - match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] } - - match: { hits.hits.1.sort: [ 450359962737050.1 ] } + - match: { hits.hits.1.sort.0: 450359962737050.1 } - match: { hits.hits.2._source.field: [ 450359962737049.4, 3.5, 4.6 ] } - - match: { hits.hits.2.sort: [ 4.6 ] } + - match: { hits.hits.2.sort.0: 4.6 } - match: { hits.hits.3._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] } - - match: { hits.hits.3.sort: [ 1.95 ] } + - match: { hits.hits.3.sort.0: 1.95 } - do: search: @@ -109,13 +109,13 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: double_sort } - match: { hits.hits.0._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] } - - match: { hits.hits.0.sort: [ 112589990684262.89 ] } + - match: { hits.hits.0.sort.0: 112589990684262.89 } - match: { hits.hits.1._source.field: [ 450359962737049.4, 3.5, 4.6 ] } - - match: { hits.hits.1.sort: [ 150119987579019.16 ] } + - match: { hits.hits.1.sort.0: 150119987579019.16 } - match: { hits.hits.2._source.field: [ 900719925474099.1, 1.1 ] } - - match: { hits.hits.2.sort: [ 450359962737050.1 ] } + - match: { hits.hits.2.sort.0: 450359962737050.1 } - match: { hits.hits.3._source.field: [ 900719925474099.2, 900719925474099.2 ] } - - match: { hits.hits.3.sort: [ 900719925474099.2 ] } + - match: { hits.hits.3.sort.0: 900719925474099.2 } - do: search: @@ -127,10 +127,10 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: double_sort } - match: { hits.hits.0._source.field: [ 900719925474099.2, 900719925474099.2 ] } - - match: { hits.hits.0.sort: [ 1801439850948198.5 ] } + - match: { hits.hits.0.sort.0: 1801439850948198.5 } - match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] } - - match: { hits.hits.1.sort: [ 900719925474100.2 ] } + - match: { hits.hits.1.sort.0: 900719925474100.2 } - match: { hits.hits.2._source.field: [ 450359962737049.4, 3.5, 4.6 ] } - - match: { hits.hits.2.sort: [ 450359962737057.5 ] } + - match: { hits.hits.2.sort.0: 450359962737057.5 } - match: { hits.hits.3._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] } - - match: { hits.hits.3.sort: [ 450359962737051.56 ] } + - match: { hits.hits.3.sort.0: 450359962737051.56 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_long.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_long.yml index b71e38bccd40c..f354dff6cbf02 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_long.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_long.yml @@ -37,13 +37,13 @@ setup: - length: {hits.hits: 4 } - match: { hits.hits.0._index: long_sort } - match: { hits.hits.0._source.field: [ 9223372036854775807, 1 ] } - - match: { hits.hits.0.sort: [ 9223372036854775807 ] } + - match: { hits.hits.0.sort.0: 9223372036854775807 } - match: { hits.hits.1._source.field: [ 922337203685477777, 2 ] } - - match: { hits.hits.1.sort: [ 922337203685477777 ] } + - match: { hits.hits.1.sort.0: 922337203685477777 } - match: { hits.hits.2._source.field: [ 2147483648, 5, -1, -2 ] } - - match: { hits.hits.2.sort: [ 2147483648 ] } + - match: { hits.hits.2.sort.0: 2147483648 } - match: { hits.hits.3._source.field: [ 2147483647, 3, 4 ] } - - match: { hits.hits.3.sort: [ 2147483647 ] } + - match: { hits.hits.3.sort.0: 2147483647 } - do: search: @@ -55,13 +55,13 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: long_sort } - match: { hits.hits.0._source.field: [ 2147483647, 3, 4 ] } - - match: { hits.hits.0.sort: [ 2147483647 ] } + - match: { hits.hits.0.sort.0: 2147483647 } - match: { hits.hits.1._source.field: [ 2147483648, 5, -1, -2 ] } - - match: { hits.hits.1.sort: [ 2147483648 ] } + - match: { hits.hits.1.sort.0: 2147483648 } - match: { hits.hits.2._source.field: [ 922337203685477777, 2 ] } - - match: { hits.hits.2.sort: [ 922337203685477777 ] } + - match: { hits.hits.2.sort.0: 922337203685477777 } - match: { hits.hits.3._source.field: [ 9223372036854775807, 1 ] } - - match: { hits.hits.3.sort: [ 9223372036854775807 ] } + - match: { hits.hits.3.sort.0: 9223372036854775807 } - do: @@ -74,11 +74,11 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: long_sort } - match: { hits.hits.0._source.field: [ 2147483647, 3, 4 ] } - - match: { hits.hits.0.sort: [ 3 ] } + - match: { hits.hits.0.sort.0: 3 } - match: { hits.hits.1._source.field: [ 922337203685477777, 2 ] } - - match: { hits.hits.1.sort: [ 2 ] } + - match: { hits.hits.1.sort.0: 2 } - match: { hits.hits.2._source.field: [ 9223372036854775807, 1 ] } - - match: { hits.hits.2.sort: [ 1 ] } + - match: { hits.hits.2.sort.0: 1 } - match: { hits.hits.3._source.field: [ 2147483648, 5, -1, -2 ] } - match: { hits.hits.3.sort: [ -2 ] } @@ -92,13 +92,13 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: long_sort } - match: { hits.hits.0._source.field: [ 2147483648, 5, -1, -2 ] } - - match: { hits.hits.0.sort: [ 2 ] } + - match: { hits.hits.0.sort.0: 2 } - match: { hits.hits.1._source.field: [ 2147483647, 3, 4 ] } - - match: { hits.hits.1.sort: [ 4 ] } + - match: { hits.hits.1.sort.0: 4 } - match: { hits.hits.2._source.field: [ 922337203685477777, 2 ] } - - match: { hits.hits.2.sort: [ 461168601842738880 ] } + - match: { hits.hits.2.sort.0: 461168601842738880 } - match: { hits.hits.3._source.field: [ 9223372036854775807, 1 ] } - - match: { hits.hits.3.sort: [ 4611686018427387904 ] } + - match: { hits.hits.3.sort.0: 4611686018427387904 } - do: search: @@ -110,11 +110,11 @@ setup: - length: { hits.hits: 4 } - match: { hits.hits.0._index: long_sort } - match: { hits.hits.0._source.field: [ 922337203685477777, 2 ] } - - match: { hits.hits.0.sort: [ 461168601842738880 ] } + - match: { hits.hits.0.sort.0: 461168601842738880 } - match: { hits.hits.1._source.field: [ 2147483647, 3, 4 ] } - - match: { hits.hits.1.sort: [ 715827885 ] } + - match: { hits.hits.1.sort.0: 715827885 } - match: { hits.hits.2._source.field: [ 2147483648, 5, -1, -2 ] } - - match: { hits.hits.2.sort: [ 536870913 ] } + - match: { hits.hits.2.sort.0: 536870913 } - match: { hits.hits.3._source.field: [ 9223372036854775807, 1 ] } - match: { hits.hits.3.sort: [ -4611686018427387904 ] } @@ -130,8 +130,8 @@ setup: - match: { hits.hits.0._source.field: [ 9223372036854775807, 1 ] } - match: { hits.hits.0.sort: [ -9223372036854775808 ] } - match: { hits.hits.1._source.field: [ 2147483648, 5, -1, -2 ] } - - match: { hits.hits.1.sort: [ 2147483650 ] } + - match: { hits.hits.1.sort.0: 2147483650 } - match: { hits.hits.2._source.field: [ 2147483647, 3, 4 ] } - - match: { hits.hits.2.sort: [ 2147483654 ] } + - match: { hits.hits.2.sort.0: 2147483654 } - match: { hits.hits.3._source.field: [ 922337203685477777, 2 ] } - - match: { hits.hits.3.sort: [ 922337203685477779 ] } + - match: { hits.hits.3.sort.0: 922337203685477779 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_unsigned_long.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_unsigned_long.yml index fb3b1f994fd8c..056b2f58b2229 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_unsigned_long.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_unsigned_long.yml @@ -44,17 +44,17 @@ setup: - length: {hits.hits: 6 } - match: { hits.hits.0._index: unsigned_long_sort } - match: { hits.hits.0._source.field: [ 13835058055282163722, 5, 6, 7 ] } - - match: { hits.hits.0.sort: [ 13835058055282163722 ] } + - match: { hits.hits.0.sort.0: 13835058055282163722 } - match: { hits.hits.1._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } - - match: { hits.hits.1.sort: [ 13835058055282163721 ] } + - match: { hits.hits.1.sort.0: 13835058055282163721 } - match: { hits.hits.2._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } - - match: { hits.hits.2.sort: [ 13835058055282163719 ] } + - match: { hits.hits.2.sort.0: 13835058055282163719 } - match: { hits.hits.3._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } - - match: { hits.hits.3.sort: [ 13835058055282163716 ] } + - match: { hits.hits.3.sort.0: 13835058055282163716 } - match: { hits.hits.4._source.field: [ 13835058055282163713, 13835058055282163714 ] } - - match: { hits.hits.4.sort: [ 13835058055282163714 ] } + - match: { hits.hits.4.sort.0: 13835058055282163714 } - match: { hits.hits.5._source.field: [ 13835058055282163712, 1 ] } - - match: { hits.hits.5.sort: [ 13835058055282163712 ] } + - match: { hits.hits.5.sort.0: 13835058055282163712 } - do: search: @@ -66,17 +66,17 @@ setup: - length: {hits.hits: 6 } - match: { hits.hits.0._index: unsigned_long_sort } - match: { hits.hits.0._source.field: [ 13835058055282163712, 1 ] } - - match: { hits.hits.0.sort: [ 13835058055282163712 ] } + - match: { hits.hits.0.sort.0: 13835058055282163712 } - match: { hits.hits.1._source.field: [ 13835058055282163713, 13835058055282163714 ] } - - match: { hits.hits.1.sort: [ 13835058055282163714 ] } + - match: { hits.hits.1.sort.0: 13835058055282163714 } - match: { hits.hits.2._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } - - match: { hits.hits.2.sort: [ 13835058055282163716 ] } + - match: { hits.hits.2.sort.0: 13835058055282163716 } - match: { hits.hits.3._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } - - match: { hits.hits.3.sort: [ 13835058055282163719 ] } + - match: { hits.hits.3.sort.0: 13835058055282163719 } - match: { hits.hits.4._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } - - match: { hits.hits.4.sort: [ 13835058055282163721 ] } + - match: { hits.hits.4.sort.0: 13835058055282163721 } - match: { hits.hits.5._source.field: [ 13835058055282163722, 5, 6, 7 ] } - - match: { hits.hits.5.sort: [ 13835058055282163722 ] } + - match: { hits.hits.5.sort.0: 13835058055282163722 } - do: search: @@ -88,17 +88,17 @@ setup: - length: { hits.hits: 6 } - match: { hits.hits.0._index: unsigned_long_sort } - match: { hits.hits.0._source.field: [ 13835058055282163722, 5, 6, 7 ] } - - match: { hits.hits.0.sort: [ 7 ] } + - match: { hits.hits.0.sort.0: 7 } - match: { hits.hits.1._source.field: [ 13835058055282163713, 13835058055282163714 ] } - - match: { hits.hits.1.sort: [ 4611686018427387906 ] } + - match: { hits.hits.1.sort.0: 4611686018427387906 } - match: { hits.hits.2._source.field: [ 13835058055282163712, 1 ] } - - match: { hits.hits.2.sort: [ 6917529027641081857 ] } + - match: { hits.hits.2.sort.0: 6917529027641081857 } - match: { hits.hits.3._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } - - match: { hits.hits.3.sort: [ 6917529027641081862 ] } + - match: { hits.hits.3.sort.0: 6917529027641081862 } - match: { hits.hits.4._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } - - match: { hits.hits.4.sort: [ 13835058055282163715 ] } + - match: { hits.hits.4.sort.0: 13835058055282163715 } - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } - - match: { hits.hits.5.sort: [ 13835058055282163718 ] } + - match: { hits.hits.5.sort.0: 13835058055282163718 } - do: search: @@ -110,17 +110,17 @@ setup: - length: { hits.hits: 6 } - match: { hits.hits.0._index: unsigned_long_sort } - match: { hits.hits.0._source.field: [ 13835058055282163722, 5, 6, 7 ] } - - match: { hits.hits.0.sort: [ 13835058055282163740 ] } + - match: { hits.hits.0.sort.0: 13835058055282163740 } - match: { hits.hits.1._source.field: [ 13835058055282163712, 1 ] } - - match: { hits.hits.1.sort: [ 13835058055282163713 ] } + - match: { hits.hits.1.sort.0: 13835058055282163713 } - match: { hits.hits.2._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } - - match: { hits.hits.2.sort: [ 9223372036854775832 ] } + - match: { hits.hits.2.sort.0: 9223372036854775832 } - match: { hits.hits.3._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } - - match: { hits.hits.3.sort: [ 9223372036854775817 ] } + - match: { hits.hits.3.sort.0: 9223372036854775817 } - match: { hits.hits.4._source.field: [ 13835058055282163713, 13835058055282163714 ] } - - match: { hits.hits.4.sort: [ 9223372036854775811 ] } + - match: { hits.hits.4.sort.0: 9223372036854775811 } - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } - - match: { hits.hits.5.sort: [ 4611686018427387922 ] } + - match: { hits.hits.5.sort.0: 4611686018427387922 } - do: search: @@ -132,17 +132,17 @@ setup: - length: { hits.hits: 6 } - match: { hits.hits.0._index: unsigned_long_sort } - match: { hits.hits.0._source.field: [ 13835058055282163712, 1 ] } - - match: { hits.hits.0.sort: [ 6917529027641081857 ] } + - match: { hits.hits.0.sort.0: 6917529027641081857 } - match: { hits.hits.1._source.field: [ 13835058055282163713, 13835058055282163714 ] } - - match: { hits.hits.1.sort: [ 4611686018427387906 ] } + - match: { hits.hits.1.sort.0: 4611686018427387906 } - match: { hits.hits.2._source.field: [ 13835058055282163722, 5, 6, 7 ] } - - match: { hits.hits.2.sort: [ 3458764513820540935 ] } + - match: { hits.hits.2.sort.0: 3458764513820540935 } - match: { hits.hits.3._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } - - match: { hits.hits.3.sort: [ 3074457345618258606 ] } + - match: { hits.hits.3.sort.0: 3074457345618258606 } - match: { hits.hits.4._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } - - match: { hits.hits.4.sort: [ 2305843009213693958 ] } + - match: { hits.hits.4.sort.0: 2305843009213693958 } - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } - - match: { hits.hits.5.sort: [ 1537228672809129307 ] } + - match: { hits.hits.5.sort.0: 1537228672809129307 } - do: search: @@ -154,14 +154,14 @@ setup: - length: { hits.hits: 6 } - match: { hits.hits.0._index: unsigned_long_sort } - match: { hits.hits.0._source.field: [ 13835058055282163712, 1 ] } - - match: { hits.hits.0.sort: [ 1 ] } + - match: { hits.hits.0.sort.0: 1 } - match: { hits.hits.1._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } - - match: { hits.hits.1.sort: [ 2 ] } + - match: { hits.hits.1.sort.0: 2 } - match: { hits.hits.2._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } - - match: { hits.hits.2.sort: [ 3 ] } + - match: { hits.hits.2.sort.0: 3 } - match: { hits.hits.3._source.field: [ 13835058055282163722, 5, 6, 7 ] } - - match: { hits.hits.3.sort: [ 5 ] } + - match: { hits.hits.3.sort.0: 5 } - match: { hits.hits.4._source.field: [ 13835058055282163713, 13835058055282163714 ] } - - match: { hits.hits.4.sort: [ 13835058055282163713 ] } + - match: { hits.hits.4.sort.0: 13835058055282163713 } - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } - - match: { hits.hits.5.sort: [ 13835058055282163717 ] } + - match: { hits.hits.5.sort.0: 13835058055282163717 } diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java index b46ea23f8cd77..77d8f3154729e 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java @@ -40,7 +40,6 @@ import org.opensearch.test.hamcrest.RegexMatcher; import java.io.IOException; -import java.util.ArrayList; import java.util.regex.Pattern; import static org.hamcrest.Matchers.equalTo; @@ -111,28 +110,6 @@ protected void doAssert(Object actualValue, Object expectedValue) { } if (expectedValue.equals(actualValue) == false) { - if (expectedValue instanceof ArrayList && actualValue instanceof ArrayList) { - ArrayList expectedList = (ArrayList) expectedValue; - ArrayList actualList = (ArrayList) actualValue; - if (expectedList.size() == actualList.size()) { - boolean pass = true; - for (int i = 0; i < expectedList.size(); i++) { - // BigInteger 1 is equal to Integer 1 - Object expected = expectedList.get(i); - Object actual = actualList.get(i); - if (expected instanceof Number == false - || actual instanceof Number == false - || ((Number) expected).longValue() != ((Number) actual).longValue()) { - pass = false; - break; - } - } - if (pass) { - return; - } - } - } - NotEqualMessageBuilder message = new NotEqualMessageBuilder(); message.compare(getField(), true, actualValue, expectedValue); throw new AssertionError(getField() + " didn't match expected value:\n" + message);