@@ -37,19 +37,75 @@ class TriggerServiceTests : OpenSearchTestCase() {
37
37
val trigger = randomBucketLevelTrigger(bucketSelector = bucketSelectorExtAggregationBuilder)
38
38
val monitor = randomBucketLevelMonitor(triggers = listOf (trigger))
39
39
40
- val inputResultsStr = " {\" _shards\" :" +
41
- " {\" total\" :1,\" failed\" :0,\" successful\" :1,\" skipped\" :0},\" hits\" :{\" hits\" :" +
42
- " [{\" _index\" :\" sample-http-responses\" ,\" _type\" :\" http\" ,\" _source\" :" +
43
- " {\" status_code\" :100,\" http_4xx\" :0,\" http_3xx\" :0,\" http_5xx\" :0,\" http_2xx\" :0," +
44
- " \" timestamp\" :100000,\" http_1xx\" :1},\" _id\" :1,\" _score\" :1}],\" total\" :{\" value\" :4,\" relation\" :\" eq\" }," +
45
- " \" max_score\" :1},\" took\" :37,\" timed_out\" :false,\" aggregations\" :{\" status_code\" :" +
46
- " {\" doc_count_error_upper_bound\" :0,\" sum_other_doc_count\" :0,\" buckets\" :[{\" doc_count\" :2,\" key\" :100}," +
47
- " {\" doc_count\" :1,\" key\" :102},{\" doc_count\" :1,\" key\" :201}]},\" ${trigger.id} \" :{\" parent_bucket_path\" :" +
48
- " \" status_code\" ,\" bucket_indices\" :[0,1,2]}}}"
49
-
50
- val parser = XContentType .JSON .xContent().createParser(
51
- NamedXContentRegistry .EMPTY , DeprecationHandler .THROW_UNSUPPORTED_OPERATION , inputResultsStr
52
- )
40
+ val inputResultsStr = " {\n " +
41
+ " \" _shards\" : {\n " +
42
+ " \" total\" : 1,\n " +
43
+ " \" failed\" : 0,\n " +
44
+ " \" successful\" : 1,\n " +
45
+ " \" skipped\" : 0\n " +
46
+ " },\n " +
47
+ " \" hits\" : {\n " +
48
+ " \" hits\" : [\n " +
49
+ " {\n " +
50
+ " \" _index\" : \" sample-http-responses\" ,\n " +
51
+ " \" _type\" : \" http\" ,\n " +
52
+ " \" _source\" : {\n " +
53
+ " \" status_code\" : 100,\n " +
54
+ " \" http_4xx\" : 0,\n " +
55
+ " \" http_3xx\" : 0,\n " +
56
+ " \" http_5xx\" : 0,\n " +
57
+ " \" http_2xx\" : 0,\n " +
58
+ " \" timestamp\" : 100000,\n " +
59
+ " \" http_1xx\" : 1\n " +
60
+ " },\n " +
61
+ " \" _id\" : 1,\n " +
62
+ " \" _score\" : 1\n " +
63
+ " }\n " +
64
+ " ],\n " +
65
+ " \" total\" : {\n " +
66
+ " \" value\" : 4,\n " +
67
+ " \" relation\" : \" eq\"\n " +
68
+ " },\n " +
69
+ " \" max_score\" : 1\n " +
70
+ " },\n " +
71
+ " \" took\" : 37,\n " +
72
+ " \" timed_out\" : false,\n " +
73
+ " \" aggregations\" : {\n " +
74
+ " \" status_code\" : {\n " +
75
+ " \" doc_count_error_upper_bound\" : 0,\n " +
76
+ " \" sum_other_doc_count\" : 0,\n " +
77
+ " \" buckets\" : [\n " +
78
+ " {\n " +
79
+ " \" doc_count\" : 2,\n " +
80
+ " \" key\" : 100\n " +
81
+ " },\n " +
82
+ " {\n " +
83
+ " \" doc_count\" : 1,\n " +
84
+ " \" key\" : 102\n " +
85
+ " },\n " +
86
+ " {\n " +
87
+ " \" doc_count\" : 1,\n " +
88
+ " \" key\" : 201\n " +
89
+ " }\n " +
90
+ " ]\n " +
91
+ " },\n " +
92
+ " \" ${trigger.id} \" : {\n " +
93
+ " \" parent_bucket_path\" : \" status_code\" ,\n " +
94
+ " \" bucket_indices\" : [\n " +
95
+ " 0,\n " +
96
+ " 1,\n " +
97
+ " 2\n " +
98
+ " ]\n " +
99
+ " }\n " +
100
+ " }\n " +
101
+ " }"
102
+
103
+ val parser = XContentType .JSON .xContent()
104
+ .createParser(
105
+ NamedXContentRegistry .EMPTY ,
106
+ DeprecationHandler .THROW_UNSUPPORTED_OPERATION ,
107
+ inputResultsStr
108
+ )
53
109
54
110
val inputResults = parser.map()
55
111
@@ -70,23 +126,127 @@ class TriggerServiceTests : OpenSearchTestCase() {
70
126
val trigger = randomBucketLevelTrigger(bucketSelector = bucketSelectorExtAggregationBuilder)
71
127
val monitor = randomBucketLevelMonitor(triggers = listOf (trigger))
72
128
73
- val inputResultsStr = " {\" _shards\" :{\" total\" :1, \" failed\" :0, \" successful\" :1, \" skipped\" :0}, \" hits\" :{\" hits\" :" +
74
- " [{\" _index\" :\" sample-http-responses\" , \" _type\" :\" http\" , \" _source\" :{\" status_code\" :100, \" http_4xx\" :0," +
75
- " \" http_3xx\" :0, \" http_5xx\" :0, \" http_2xx\" :0, \" timestamp\" :100000, \" http_1xx\" :1}, \" _id\" :1, \" _score\" :1.0}, " +
76
- " {\" _index\" :\" sample-http-responses\" , \" _type\" :\" http\" , \" _source\" :{\" status_code\" :102, \" http_4xx\" :0, " +
77
- " \" http_3xx\" :0, \" http_5xx\" :0, \" http_2xx\" :0, \" timestamp\" :160000, \" http_1xx\" :1}, \" _id\" :2, \" _score\" :1.0}, " +
78
- " {\" _index\" :\" sample-http-responses\" , \" _type\" :\" http\" , \" _source\" :{\" status_code\" :100, \" http_4xx\" :0, " +
79
- " \" http_3xx\" :0, \" http_5xx\" :0, \" http_2xx\" :0, \" timestamp\" :220000, \" http_1xx\" :1}, \" _id\" :4, \" _score\" :1.0}, " +
80
- " {\" _index\" :\" sample-http-responses\" , \" _type\" :\" http\" , \" _source\" :{\" status_code\" :201, \" http_4xx\" :0, " +
81
- " \" http_3xx\" :0, \" http_5xx\" :0, \" http_2xx\" :1, \" timestamp\" :280000, \" http_1xx\" :0}, \" _id\" :5, \" _score\" :1.0}]," +
82
- " \" total\" :{\" value\" :4, \" relation\" :\" eq\" }, \" max_score\" :1.0}, \" took\" :15, \" timed_out\" :false, \" aggregations\" :" +
83
- " {\" ${trigger.id} \" :{\" parent_bucket_path\" :\" status_code\" , \" bucket_indices\" :[0, 1, 2]}, \" status_code\" :{\" buckets\" :" +
84
- " [{\" doc_count\" :2, \" key\" :{\" status_code\" :100}}, {\" doc_count\" :1, \" key\" :{\" status_code\" :102}}, {\" doc_count\" :1," +
85
- " \" key\" :{\" status_code\" :201}}], \" after_key\" :{\" status_code\" :201}}}}"
86
-
87
- val parser = XContentType .JSON .xContent().createParser(
88
- NamedXContentRegistry .EMPTY , DeprecationHandler .THROW_UNSUPPORTED_OPERATION , inputResultsStr
89
- )
129
+ val inputResultsStr = " {\n " +
130
+ " \" _shards\" : {\n " +
131
+ " \" total\" : 1,\n " +
132
+ " \" failed\" : 0,\n " +
133
+ " \" successful\" : 1,\n " +
134
+ " \" skipped\" : 0\n " +
135
+ " },\n " +
136
+ " \" hits\" : {\n " +
137
+ " \" hits\" : [\n " +
138
+ " {\n " +
139
+ " \" _index\" : \" sample-http-responses\" ,\n " +
140
+ " \" _type\" : \" http\" ,\n " +
141
+ " \" _source\" : {\n " +
142
+ " \" status_code\" : 100,\n " +
143
+ " \" http_4xx\" : 0,\n " +
144
+ " \" http_3xx\" : 0,\n " +
145
+ " \" http_5xx\" : 0,\n " +
146
+ " \" http_2xx\" : 0,\n " +
147
+ " \" timestamp\" : 100000,\n " +
148
+ " \" http_1xx\" : 1\n " +
149
+ " },\n " +
150
+ " \" _id\" : 1,\n " +
151
+ " \" _score\" : 1\n " +
152
+ " },\n " +
153
+ " {\n " +
154
+ " \" _index\" : \" sample-http-responses\" ,\n " +
155
+ " \" _type\" : \" http\" ,\n " +
156
+ " \" _source\" : {\n " +
157
+ " \" status_code\" : 102,\n " +
158
+ " \" http_4xx\" : 0,\n " +
159
+ " \" http_3xx\" : 0,\n " +
160
+ " \" http_5xx\" : 0,\n " +
161
+ " \" http_2xx\" : 0,\n " +
162
+ " \" timestamp\" : 160000,\n " +
163
+ " \" http_1xx\" : 1\n " +
164
+ " },\n " +
165
+ " \" _id\" : 2,\n " +
166
+ " \" _score\" : 1\n " +
167
+ " },\n " +
168
+ " {\n " +
169
+ " \" _index\" : \" sample-http-responses\" ,\n " +
170
+ " \" _type\" : \" http\" ,\n " +
171
+ " \" _source\" : {\n " +
172
+ " \" status_code\" : 100,\n " +
173
+ " \" http_4xx\" : 0,\n " +
174
+ " \" http_3xx\" : 0,\n " +
175
+ " \" http_5xx\" : 0,\n " +
176
+ " \" http_2xx\" : 0,\n " +
177
+ " \" timestamp\" : 220000,\n " +
178
+ " \" http_1xx\" : 1\n " +
179
+ " },\n " +
180
+ " \" _id\" : 4,\n " +
181
+ " \" _score\" : 1\n " +
182
+ " },\n " +
183
+ " {\n " +
184
+ " \" _index\" : \" sample-http-responses\" ,\n " +
185
+ " \" _type\" : \" http\" ,\n " +
186
+ " \" _source\" : {\n " +
187
+ " \" status_code\" : 201,\n " +
188
+ " \" http_4xx\" : 0,\n " +
189
+ " \" http_3xx\" : 0,\n " +
190
+ " \" http_5xx\" : 0,\n " +
191
+ " \" http_2xx\" : 1,\n " +
192
+ " \" timestamp\" : 280000,\n " +
193
+ " \" http_1xx\" : 0\n " +
194
+ " },\n " +
195
+ " \" _id\" : 5,\n " +
196
+ " \" _score\" : 1\n " +
197
+ " }\n " +
198
+ " ],\n " +
199
+ " \" total\" : {\n " +
200
+ " \" value\" : 4,\n " +
201
+ " \" relation\" : \" eq\"\n " +
202
+ " },\n " +
203
+ " \" max_score\" : 1\n " +
204
+ " },\n " +
205
+ " \" took\" : 15,\n " +
206
+ " \" timed_out\" : false,\n " +
207
+ " \" aggregations\" : {\n " +
208
+ " \" ${trigger.id} \" : {\n " +
209
+ " \" parent_bucket_path\" : \" status_code\" ,\n " +
210
+ " \" bucket_indices\" : [\n " +
211
+ " 0,\n " +
212
+ " 1,\n " +
213
+ " 2\n " +
214
+ " ]\n " +
215
+ " },\n " +
216
+ " \" status_code\" : {\n " +
217
+ " \" buckets\" : [\n " +
218
+ " {\n " +
219
+ " \" doc_count\" : 2,\n " +
220
+ " \" key\" : {\n " +
221
+ " \" status_code\" : 100\n " +
222
+ " }\n " +
223
+ " },\n " +
224
+ " {\n " +
225
+ " \" doc_count\" : 1,\n " +
226
+ " \" key\" : {\n " +
227
+ " \" status_code\" : 102\n " +
228
+ " }\n " +
229
+ " },\n " +
230
+ " {\n " +
231
+ " \" doc_count\" : 1,\n " +
232
+ " \" key\" : {\n " +
233
+ " \" status_code\" : 201\n " +
234
+ " }\n " +
235
+ " }\n " +
236
+ " ],\n " +
237
+ " \" after_key\" : {\n " +
238
+ " \" status_code\" : 201\n " +
239
+ " }\n " +
240
+ " }\n " +
241
+ " }\n " +
242
+ " }"
243
+
244
+ val parser = XContentType .JSON .xContent()
245
+ .createParser(
246
+ NamedXContentRegistry .EMPTY ,
247
+ DeprecationHandler .THROW_UNSUPPORTED_OPERATION ,
248
+ inputResultsStr
249
+ )
90
250
91
251
val inputResults = parser.map()
92
252
0 commit comments