77import static org .junit .jupiter .api .Assertions .assertNotNull ;
88import static org .junit .jupiter .api .Assertions .assertNull ;
99import static org .junit .jupiter .api .Assertions .assertTrue ;
10+ import static org .junit .jupiter .api .Assumptions .assumeFalse ;
1011import static org .mockito .ArgumentMatchers .any ;
1112import static org .mockito .ArgumentMatchers .eq ;
1213import static org .mockito .Mockito .doAnswer ;
4546import java .util .Map ;
4647import java .util .concurrent .CopyOnWriteArrayList ;
4748import java .util .concurrent .TimeUnit ;
48- import java .util .stream .Stream ;
4949import okhttp3 .HttpUrl ;
5050import okhttp3 .OkHttpClient ;
51- import org .junit .jupiter .api .Assumptions ;
5251import org .junit .jupiter .api .BeforeAll ;
5352import org .junit .jupiter .api .Test ;
5453import org .junit .jupiter .api .Timeout ;
55- import org .junit .jupiter .params .ParameterizedTest ;
56- import org .junit .jupiter .params .provider .MethodSource ;
5754import org .tabletest .junit .TableTest ;
5855
5956@ Timeout (value = 10 , unit = TimeUnit .SECONDS )
6057public class CoreTracerTest extends DDCoreJavaSpecification {
6158
6259 @ BeforeAll
6360 static void checkJvm () {
64- Assumptions . assumeFalse (
61+ assumeFalse (
6562 JavaVirtualMachine .isOracleJDK8 (),
6663 "Oracle JDK 1.8 did not merge the fix in JDK-8058322, leading to the JVM failing to"
6764 + " correctly extract method parameters without args, when the code is compiled on a"
@@ -118,8 +115,11 @@ void verifyUdsWindows() {
118115 }
119116 }
120117
121- @ ParameterizedTest
122- @ MethodSource ("verifyMappingConfigsOnTracerArguments" )
118+ @ TableTest ({
119+ "scenario | mapString | map " ,
120+ "duplicate keys | a:one, a:two, a:three | [a: three] " ,
121+ "empty value | a:b,c:d,e: | [a: b, c: d]"
122+ })
123123 void verifyMappingConfigsOnTracer (String scenario , String mapString , Map <String , String > map ) {
124124 injectSysConfig (TracerConfig .SERVICE_MAPPING , mapString );
125125 injectSysConfig (TracerConfig .SPAN_TAGS , mapString );
@@ -134,14 +134,11 @@ void verifyMappingConfigsOnTracer(String scenario, String mapString, Map<String,
134134 }
135135 }
136136
137- static Stream <Object []> verifyMappingConfigsOnTracerArguments () {
138- return Stream .of (
139- new Object [] {"duplicate keys" , "a:one, a:two, a:three" , buildStringMap ("a" , "three" )},
140- new Object [] {"empty value" , "a:b,c:d,e:" , buildStringMap ("a" , "b" , "c" , "d" )});
141- }
142-
143- @ ParameterizedTest
144- @ MethodSource ("verifyBaggageMappingConfigsOnTracerArguments" )
137+ @ TableTest ({
138+ "scenario | mapString | map " ,
139+ "duplicate keys | a:one, a:two, a:three | [a: three] " ,
140+ "empty value | a:b,c:d,e: | [a: b, c: d]"
141+ })
145142 void verifyBaggageMappingConfigsOnTracer (
146143 String scenario , String mapString , Map <String , String > map ) {
147144 injectSysConfig (TracerConfig .BAGGAGE_MAPPING , mapString );
@@ -153,12 +150,6 @@ void verifyBaggageMappingConfigsOnTracer(
153150 }
154151 }
155152
156- static Stream <Object []> verifyBaggageMappingConfigsOnTracerArguments () {
157- return Stream .of (
158- new Object [] {"duplicate keys" , "a:one, a:two, a:three" , buildStringMap ("a" , "three" )},
159- new Object [] {"empty value" , "a:b,c:d,e:" , buildStringMap ("a" , "b" , "c" , "d" )});
160- }
161-
162153 @ Test
163154 @ WithConfig (key = "agent.host" , value = "somethingelse" )
164155 void verifyOverridingHost () {
@@ -353,8 +344,15 @@ void verifyConfigurationPolling() throws Exception {
353344 }
354345 }
355346
356- @ ParameterizedTest
357- @ MethodSource ("verifyConfigurationPollingWithCustomTagsArguments" )
347+ @ TableTest ({
348+ "scenario | json | expectedValue " ,
349+ "a:b c:d e:f | '{\" lib_config\" :{\" tracing_tags\" : [\" a:b\" , \" c:d\" , \" e:f\" ]}}' | [a: b, c: d, e: f]" ,
350+ "empty and c:d | '{\" lib_config\" :{\" tracing_tags\" : [\" \" , \" c:d\" , \" \" ]}}' | [c: d] " ,
351+ ":b c: e:f | '{\" lib_config\" :{\" tracing_tags\" : [\" :b\" , \" c:\" , \" e:f\" ]}}' | [e: f] " ,
352+ ": c: e:f | '{\" lib_config\" :{\" tracing_tags\" : [\" :\" , \" c:\" , \" e:f\" ]}}' | [e: f] " ,
353+ ": c: empty | '{\" lib_config\" :{\" tracing_tags\" : [\" :\" , \" c:\" , \" \" ]}}' | [:] " ,
354+ "empty array | '{\" lib_config\" :{\" tracing_tags\" : []}}' | [:] "
355+ })
358356 void verifyConfigurationPollingWithCustomTags (
359357 String scenario , String json , Map <String , String > expectedValue ) throws Exception {
360358 ParsedConfigKey key = ParsedConfigKey .parse ("datadog/2/APM_TRACING/config_overrides/config" );
@@ -395,40 +393,22 @@ void verifyConfigurationPollingWithCustomTags(
395393 }
396394 }
397395
398- static Stream <Object []> verifyConfigurationPollingWithCustomTagsArguments () {
399- return Stream .of (
400- new Object [] {
401- "a:b c:d e:f" ,
402- "{\" lib_config\" :{\" tracing_tags\" : [\" a:b\" , \" c:d\" , \" e:f\" ]}}" ,
403- buildStringMap ("a" , "b" , "c" , "d" , "e" , "f" )
404- },
405- new Object [] {
406- "empty and c:d" ,
407- "{\" lib_config\" :{\" tracing_tags\" : [\" \" , \" c:d\" , \" \" ]}}" ,
408- buildStringMap ("c" , "d" )
409- },
410- new Object [] {
411- ":b c: e:f" ,
412- "{\" lib_config\" :{\" tracing_tags\" : [\" :b\" , \" c:\" , \" e:f\" ]}}" ,
413- buildStringMap ("e" , "f" )
414- },
415- new Object [] {
416- ": c: e:f" ,
417- "{\" lib_config\" :{\" tracing_tags\" : [\" :\" , \" c:\" , \" e:f\" ]}}" ,
418- buildStringMap ("e" , "f" )
419- },
420- new Object [] {
421- ": c: empty" ,
422- "{\" lib_config\" :{\" tracing_tags\" : [\" :\" , \" c:\" , \" \" ]}}" ,
423- Collections .emptyMap ()
424- },
425- new Object [] {
426- "empty array" , "{\" lib_config\" :{\" tracing_tags\" : []}}" , Collections .emptyMap ()
427- });
428- }
429-
430- @ ParameterizedTest
431- @ MethodSource ("verifyConfigurationPollingWithTracingEnabledArguments" )
396+ @ TableTest ({
397+ "scenario | json | expectedValue " ,
398+ "tracing disabled | '{\" lib_config\" :{\" tracing_enabled\" : false}}' | false " ,
399+ "tracing enabled | '{\" lib_config\" :{\" tracing_enabled\" : true}}' | true " ,
400+ "action with tracing disabled | '{\" action\" : \" enable\" , \" lib_config\" : " ,
401+ "{\" tracing_sampling_rate\" : null, " ,
402+ " \" log_injection_enabled\" : null, " ,
403+ "\" tracing_header_tags\" : null, " ,
404+ " \" runtime_metrics_enabled\" : null, " ,
405+ "\" tracing_debug\" : null, " ,
406+ " \" tracing_service_mapping\" : null, " ,
407+ "\" tracing_sampling_rules\" : null, " ,
408+ " \" span_sampling_rules\" : null, " ,
409+ "\" data_streams_enabled\" : null, " ,
410+ " \" tracing_enabled\" : false}}' | false "
411+ })
432412 void verifyConfigurationPollingWithTracingEnabled (
433413 String scenario , String json , boolean expectedValue ) throws Exception {
434414 ParsedConfigKey key = ParsedConfigKey .parse ("datadog/2/APM_TRACING/config_overrides/config" );
@@ -462,22 +442,6 @@ void verifyConfigurationPollingWithTracingEnabled(
462442 }
463443 }
464444
465- static Stream <Object []> verifyConfigurationPollingWithTracingEnabledArguments () {
466- return Stream .of (
467- new Object [] {"tracing disabled" , "{\" lib_config\" :{\" tracing_enabled\" : false}}" , false },
468- new Object [] {"tracing enabled" , "{\" lib_config\" :{\" tracing_enabled\" : true}}" , true },
469- new Object [] {
470- "action with tracing disabled" ,
471- "{\" action\" : \" enable\" , \" lib_config\" : {\" tracing_sampling_rate\" : null,"
472- + " \" log_injection_enabled\" : null, \" tracing_header_tags\" : null,"
473- + " \" runtime_metrics_enabled\" : null, \" tracing_debug\" : null,"
474- + " \" tracing_service_mapping\" : null, \" tracing_sampling_rules\" : null,"
475- + " \" span_sampling_rules\" : null, \" data_streams_enabled\" : null,"
476- + " \" tracing_enabled\" : false}}" ,
477- false
478- });
479- }
480-
481445 @ TableTest ({
482446 "scenario | preferred | expected" ,
483447 "no pref | | test " ,
0 commit comments