@@ -70,8 +70,6 @@ private void reset() {
70
70
.put (HierarchyCircuitBreakerService .REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING ,
71
71
HierarchyCircuitBreakerService .DEFAULT_REQUEST_BREAKER_LIMIT )
72
72
.put (HierarchyCircuitBreakerService .REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING , 1.0 )
73
- .put (HierarchyCircuitBreakerService .REQUEST_CIRCUIT_BREAKER_TYPE_SETTING ,
74
- HierarchyCircuitBreakerService .DEFAULT_BREAKER_TYPE )
75
73
.build ();
76
74
client ().admin ().cluster ().prepareUpdateSettings ().setTransientSettings (resetSettings ).execute ().actionGet ();
77
75
}
@@ -90,9 +88,27 @@ private String randomRidiculouslySmallLimit() {
90
88
return randomFrom (Arrays .asList ("100b" , "100" ));
91
89
}
92
90
91
+ /** Returns true if any of the nodes used a noop breaker */
92
+ private boolean noopBreakerUsed () {
93
+ NodesStatsResponse stats = client ().admin ().cluster ().prepareNodesStats ().setBreaker (true ).get ();
94
+ for (NodeStats nodeStats : stats ) {
95
+ if (nodeStats .getBreaker ().getStats (CircuitBreaker .Name .REQUEST ).getLimit () == 0 ) {
96
+ return true ;
97
+ }
98
+ if (nodeStats .getBreaker ().getStats (CircuitBreaker .Name .FIELDDATA ).getLimit () == 0 ) {
99
+ return true ;
100
+ }
101
+ }
102
+ return false ;
103
+ }
104
+
93
105
@ Test
94
106
//@TestLogging("indices.breaker:TRACE,index.fielddata:TRACE,common.breaker:TRACE")
95
107
public void testMemoryBreaker () throws Exception {
108
+ if (noopBreakerUsed ()) {
109
+ logger .info ("--> noop breakers used, skipping test" );
110
+ return ;
111
+ }
96
112
assertAcked (prepareCreate ("cb-test" , 1 , settingsBuilder ().put (SETTING_NUMBER_OF_REPLICAS , between (0 , 1 ))));
97
113
final Client client = client ();
98
114
@@ -134,6 +150,10 @@ public void testMemoryBreaker() throws Exception {
134
150
135
151
@ Test
136
152
public void testRamAccountingTermsEnum () throws Exception {
153
+ if (noopBreakerUsed ()) {
154
+ logger .info ("--> noop breakers used, skipping test" );
155
+ return ;
156
+ }
137
157
final Client client = client ();
138
158
139
159
// Create an index where the mappings have a field data filter
@@ -184,6 +204,10 @@ public void testRamAccountingTermsEnum() throws Exception {
184
204
*/
185
205
@ Test
186
206
public void testParentChecking () throws Exception {
207
+ if (noopBreakerUsed ()) {
208
+ logger .info ("--> noop breakers used, skipping test" );
209
+ return ;
210
+ }
187
211
assertAcked (prepareCreate ("cb-test" , 1 , settingsBuilder ().put (SETTING_NUMBER_OF_REPLICAS , between (0 , 1 ))));
188
212
Client client = client ();
189
213
@@ -240,36 +264,10 @@ public void testParentChecking() throws Exception {
240
264
241
265
@ Test
242
266
public void testRequestBreaker () throws Exception {
243
- assertAcked (prepareCreate ("cb-test" , 1 , settingsBuilder ().put (SETTING_NUMBER_OF_REPLICAS , between (0 , 1 ))));
244
- Client client = client ();
245
-
246
- // Make request breaker limited to a small amount
247
- Settings resetSettings = settingsBuilder ()
248
- .put (HierarchyCircuitBreakerService .REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING , "10b" )
249
- .build ();
250
- client .admin ().cluster ().prepareUpdateSettings ().setTransientSettings (resetSettings ).execute ().actionGet ();
251
-
252
- // index some different terms so we have some field data for loading
253
- int docCount = scaledRandomIntBetween (300 , 1000 );
254
- List <IndexRequestBuilder > reqs = newArrayList ();
255
- for (long id = 0 ; id < docCount ; id ++) {
256
- reqs .add (client .prepareIndex ("cb-test" , "type" , Long .toString (id )).setSource ("test" , id ));
267
+ if (noopBreakerUsed ()) {
268
+ logger .info ("--> noop breakers used, skipping test" );
269
+ return ;
257
270
}
258
- indexRandom (true , reqs );
259
-
260
- // A cardinality aggregation uses BigArrays and thus the REQUEST breaker
261
- try {
262
- client .prepareSearch ("cb-test" ).setQuery (matchAllQuery ()).addAggregation (cardinality ("card" ).field ("test" )).get ();
263
- fail ("aggregation should have tripped the breaker" );
264
- } catch (Exception e ) {
265
- String errMsg = "CircuitBreakingException[[REQUEST] Data too large, data for [<reused_arrays>] would be larger than limit of [10/10b]]" ;
266
- assertThat ("Exception: " + ExceptionsHelper .unwrapCause (e ) + " should contain a CircuitBreakingException" ,
267
- ExceptionsHelper .unwrapCause (e ).getMessage ().contains (errMsg ), equalTo (true ));
268
- }
269
- }
270
-
271
- @ Test
272
- public void testNoopRequestBreaker () throws Exception {
273
271
assertAcked (prepareCreate ("cb-test" , 1 , settingsBuilder ().put (SETTING_NUMBER_OF_REPLICAS , between (0 , 1 ))));
274
272
Client client = client ();
275
273
@@ -296,14 +294,5 @@ public void testNoopRequestBreaker() throws Exception {
296
294
assertThat ("Exception: " + ExceptionsHelper .unwrapCause (e ) + " should contain a CircuitBreakingException" ,
297
295
ExceptionsHelper .unwrapCause (e ).getMessage ().contains (errMsg ), equalTo (true ));
298
296
}
299
-
300
- // Make request breaker into a noop breaker
301
- resetSettings = settingsBuilder ()
302
- .put (HierarchyCircuitBreakerService .REQUEST_CIRCUIT_BREAKER_TYPE_SETTING , "noop" )
303
- .build ();
304
- client .admin ().cluster ().prepareUpdateSettings ().setTransientSettings (resetSettings ).execute ().actionGet ();
305
-
306
- // A cardinality aggregation uses BigArrays and thus the REQUEST breaker
307
- client .prepareSearch ("cb-test" ).setQuery (matchAllQuery ()).addAggregation (cardinality ("card" ).field ("test" )).get ();
308
297
}
309
298
}
0 commit comments