57
57
import java .util .stream .Collectors ;
58
58
import java .util .stream .IntStream ;
59
59
60
+ import static org .elasticsearch .common .logging .DeprecationLogger .DEPRECATION ;
60
61
import static org .hamcrest .Matchers .endsWith ;
61
62
import static org .hamcrest .Matchers .equalTo ;
62
63
import static org .hamcrest .Matchers .hasItem ;
@@ -119,7 +120,7 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException,
119
120
final List <Integer > ids = IntStream .range (0 , 128 ).boxed ().collect (Collectors .toList ());
120
121
Randomness .shuffle (ids );
121
122
final ThreadContext threadContext = new ThreadContext (Settings .EMPTY );
122
- DeprecationLogger .setThreadContext (threadContext );
123
+ HeaderWarning .setThreadContext (threadContext );
123
124
try {
124
125
barrier .await ();
125
126
} catch (final BrokenBarrierException | InterruptedException e ) {
@@ -180,8 +181,8 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException,
180
181
for (int i = 0 ; i < 128 ; i ++) {
181
182
assertLogLine (
182
183
deprecationEvents .get (i ),
183
- Level . WARN ,
184
- "org.elasticsearch.common.logging.ThrottlingLogger \\ $2 \\ .run " ,
184
+ DEPRECATION ,
185
+ "org.elasticsearch.common.logging.DeprecationLogger \\ $DeprecationLoggerBuilder.withDeprecation " ,
185
186
"This is a maybe logged deprecation message" + i );
186
187
}
187
188
@@ -191,49 +192,6 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException,
191
192
192
193
}
193
194
194
- public void testDeprecationLoggerMaybeLog () throws IOException , UserException {
195
- setupLogging ("deprecation" );
196
-
197
- final DeprecationLogger deprecationLogger = DeprecationLogger .getLogger ("deprecation" );
198
-
199
- final int iterations = randomIntBetween (1 , 16 );
200
-
201
- for (int i = 0 ; i < iterations ; i ++) {
202
- deprecationLogger .deprecate ("key" , "This is a maybe logged deprecation message" );
203
- assertWarnings ("This is a maybe logged deprecation message" );
204
- }
205
- for (int k = 0 ; k < 128 ; k ++) {
206
- for (int i = 0 ; i < iterations ; i ++) {
207
- deprecationLogger .deprecate ("key" + k , "This is a maybe logged deprecation message" + k );
208
- assertWarnings ("This is a maybe logged deprecation message" + k );
209
- }
210
- }
211
- for (int i = 0 ; i < iterations ; i ++) {
212
- deprecationLogger .deprecate ("key" , "This is a maybe logged deprecation message" );
213
- assertWarnings ("This is a maybe logged deprecation message" );
214
- }
215
-
216
- final String deprecationPath =
217
- System .getProperty ("es.logs.base_path" ) +
218
- System .getProperty ("file.separator" ) +
219
- System .getProperty ("es.logs.cluster_name" ) +
220
- "_deprecation.log" ;
221
- final List <String > deprecationEvents = Files .readAllLines (PathUtils .get (deprecationPath ));
222
- assertThat (deprecationEvents .size (), equalTo (1 + 128 + 1 ));
223
- assertLogLine (
224
- deprecationEvents .get (0 ),
225
- Level .WARN ,
226
- "org.elasticsearch.common.logging.ThrottlingLogger\\ $2\\ .run" ,
227
- "This is a maybe logged deprecation message" );
228
- for (int k = 0 ; k < 128 ; k ++) {
229
- assertLogLine (
230
- deprecationEvents .get (1 + k ),
231
- Level .WARN ,
232
- "org.elasticsearch.common.logging.ThrottlingLogger\\ $2\\ .run" ,
233
- "This is a maybe logged deprecation message" + k );
234
- }
235
- }
236
-
237
195
public void testDeprecatedSettings () throws IOException , UserException {
238
196
setupLogging ("settings" );
239
197
@@ -256,8 +214,8 @@ public void testDeprecatedSettings() throws IOException, UserException {
256
214
assertThat (deprecationEvents .size (), equalTo (1 ));
257
215
assertLogLine (
258
216
deprecationEvents .get (0 ),
259
- Level . WARN ,
260
- "org.elasticsearch.common.logging.ThrottlingLogger \\ $2 \\ .run " ,
217
+ DEPRECATION ,
218
+ "org.elasticsearch.common.logging.DeprecationLogger \\ $DeprecationLoggerBuilder.withDeprecation " ,
261
219
"\\ [deprecated.foo\\ ] setting was deprecated in Elasticsearch and will be removed in a future release! " +
262
220
"See the breaking changes documentation for the next major version." );
263
221
}
0 commit comments