Skip to content

Commit 137948f

Browse files
fix(iast): Fix test name uniqueness (#7960)
1 parent ff8ee85 commit 137948f

File tree

11 files changed

+43
-40
lines changed

11 files changed

+43
-40
lines changed

dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecoratorTest.groovy

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
422422
def ig = new InstrumentationGateway()
423423
def ss = ig.getSubscriptionService(RequestContextSlot.APPSEC)
424424
def cbpAppSec = ig.getCallbackProvider(RequestContextSlot.APPSEC)
425-
def callbacks = new IGCallBacks(reqData)
425+
def data = reqData ? new Object() : null
426+
def callbacks = new IGCallBacks(data)
426427
if (reqStarted) {
427428
ss.registerCallback(EVENTS.requestStarted(), callbacks)
428429
}
@@ -434,7 +435,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
434435
}
435436
Map<String, String> headers = ["foo": "bar", "some": "thing", "another": "value"]
436437
def reqCtxt = Mock(RequestContext) {
437-
getData(RequestContextSlot.APPSEC) >> reqData
438+
getData(RequestContextSlot.APPSEC) >> data
438439
}
439440
def mSpan = Mock(AgentSpan) {
440441
getRequestContext() >> reqCtxt
@@ -461,13 +462,13 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
461462

462463
where:
463464
// spotless:off
464-
reqStarted | reqData | reqHeader | reqHeaderDone | reqStartedCount | reqHeaderCount | reqHeaderDoneCount
465-
false | null | false | false | 0 | 0 | 0
466-
false | new Object() | false | false | 0 | 0 | 0
467-
true | null | false | false | 1 | 0 | 0
468-
true | new Object() | false | false | 1 | 0 | 0
469-
true | new Object() | true | false | 1 | 3 | 0
470-
true | new Object() | true | true | 1 | 3 | 1
465+
reqStarted | reqData | reqHeader | reqHeaderDone | reqStartedCount | reqHeaderCount | reqHeaderDoneCount
466+
false | false | false | false | 0 | 0 | 0
467+
false | true | false | false | 0 | 0 | 0
468+
true | false | false | false | 1 | 0 | 0
469+
true | true | false | false | 1 | 0 | 0
470+
true | true | true | false | 1 | 3 | 0
471+
true | true | true | true | 1 | 3 | 1
471472
// spotless:on
472473
}
473474

dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/util/IteratorsTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class IteratorsTest extends Specification {
6060
['hello', 'World', '!'] | ['hello', 'World', '!']
6161
}
6262

63-
void 'joined iterator'() {
63+
void 'joined iterator #iterationIndex'() {
6464
when:
6565
final iterator = Iterators.join(iterators as Iterator<?>[])
6666

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/csi/BaseCallSiteTest.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,10 @@ class BaseCallSiteTest extends DDSpecification {
184184
String type
185185
String method
186186
String descriptor
187+
188+
@Override
189+
String toString() {
190+
return descriptor
191+
}
187192
}
188193
}

dd-trace-core/src/test/groovy/datadog/trace/common/metrics/SerializingMetricWriterTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import static java.util.concurrent.TimeUnit.SECONDS
1414

1515
class SerializingMetricWriterTest extends DDSpecification {
1616

17-
def "should produce correct message" () {
17+
def "should produce correct message #iterationIndex" () {
1818
setup:
1919
long startTime = MILLISECONDS.toNanos(System.currentTimeMillis())
2020
long duration = SECONDS.toNanos(10)

dd-trace-core/src/test/groovy/datadog/trace/common/sampling/RuleBasedSamplingTest.groovy

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ class RuleBasedSamplingTest extends DDCoreSpecification {
328328
"*" | "anything..." | true
329329
"*" | null | false
330330
"*" | new StringBuilder("foo") | true
331-
"*" | new Object() {} | true
332-
"**" | new Object() {} | true
333-
"?" | new Object() {} | false
331+
"*" | object() | true
332+
"**" | object() | true
333+
"?" | object() | false
334334
"*" | "foo" | true
335335
"**" | "foo" | true
336336
"**" | true | true
@@ -485,4 +485,13 @@ class RuleBasedSamplingTest extends DDCoreSpecification {
485485
static bigDecimal(str) {
486486
return new BigDecimal(str)
487487
}
488+
489+
static object() {
490+
return new Object() {
491+
@Override
492+
String toString() {
493+
return 'object'
494+
}
495+
}
496+
}
488497
}

dd-trace-core/src/test/groovy/datadog/trace/common/writer/SerializationTest.groovy

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@ import com.fasterxml.jackson.databind.ObjectMapper
55
import datadog.trace.test.util.DDSpecification
66
import org.msgpack.core.MessagePack
77
import org.msgpack.jackson.dataformat.MessagePackFactory
8-
import spock.lang.Shared
98

109
import static java.util.Collections.singletonMap
1110

1211
class SerializationTest extends DDSpecification {
13-
@Shared
14-
def jsonMapper = new ObjectMapper()
15-
@Shared
16-
def mpMapper = new ObjectMapper(new MessagePackFactory())
17-
18-
1912
def "test json mapper serialization"() {
2013
setup:
14+
def mapper = new ObjectMapper()
2115
def map = ["key1": "val1"]
2216
def serializedMap = mapper.writeValueAsBytes(map)
2317
def serializedList = "[${new String(serializedMap)}]".getBytes()
@@ -28,13 +22,13 @@ class SerializationTest extends DDSpecification {
2822
then:
2923
result == [map]
3024
new String(serializedList) == '[{"key1":"val1"}]'
31-
32-
where:
33-
mapper = jsonMapper
3425
}
3526

3627
def "test msgpack mapper serialization"() {
3728
setup:
29+
def mapper = new ObjectMapper(new MessagePackFactory())
30+
// GStrings get odd results in the serializer.
31+
def input = (1..1).collect { singletonMap("key$it".toString(), "val$it".toString()) }
3832
def serializedMaps = input.collect {
3933
mapper.writeValueAsBytes(it)
4034
}
@@ -51,11 +45,5 @@ class SerializationTest extends DDSpecification {
5145

5246
then:
5347
result == input
54-
55-
where:
56-
mapper = mpMapper
57-
58-
// GStrings get odd results in the serializer.
59-
input = (1..1).collect { singletonMap("key$it".toString(), "val$it".toString()) }
6048
}
6149
}

dd-trace-core/src/test/groovy/datadog/trace/core/histogram/HistogramsTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class HistogramsTest extends DDSpecification {
3636
@Shared
3737
Double[] quantiles = [0.5D, 0.75D, 0.9D, 0.95D, 0.99D]
3838

39-
def "test quantiles have 1% relative error"() {
39+
def "test quantiles have 1% relative error #iterationIndex"() {
4040
setup:
4141
def histogram
4242

internal-api/src/test/groovy/datadog/trace/api/FunctionsTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.util.function.Function
1111

1212
class FunctionsTest extends DDSpecification {
1313

14-
def "test common string functions"() {
14+
def "test common string functions #iterationIndex"() {
1515
when:
1616
CharSequence output = fn.apply(input)
1717
then:
@@ -46,14 +46,14 @@ class FunctionsTest extends DDSpecification {
4646
"value" | "value.test"
4747
}
4848

49-
def "test join strings"() {
49+
def "test join strings #iterationIndex"() {
5050
when:
5151
CharSequence output = fn.apply(left, right)
5252
then:
5353
String.valueOf(output) == expected
5454
where:
5555
fn | left | right | expected
56-
Functions.PrefixJoin.of("~", Function.identity()) | "x" | "y" | "x~y"
56+
Functions.PrefixJoin.of("~", Function.identity()) | "x" | "y" | "x~y"
5757
Functions.PrefixJoin.of("~") | "x" | "y" | "x~y"
5858
Functions.SuffixJoin.of("~", Function.identity()) | "x" | "y" | "x~y"
5959
Functions.SuffixJoin.of("~") | "x" | "y" | "x~y"

internal-api/src/test/groovy/datadog/trace/api/cache/QualifiedClassNameCacheTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import java.util.function.Function
77

88
class QualifiedClassNameCacheTest extends DDSpecification {
99

10-
def "test cached string operations"() {
10+
def "test cached string operations #iterationIndex"() {
1111
when:
1212
QualifiedClassNameCache cache = new QualifiedClassNameCache(new Function<Class<?>, String>() {
1313
@Override

internal-api/src/test/groovy/datadog/trace/api/iast/telemetry/IastMetricTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import static datadog.trace.api.iast.telemetry.IastMetric.TRACE_METRIC_PREFIX
99

1010
class IastMetricTest extends Specification {
1111

12-
void 'test iast metrics attributes'() {
12+
void 'test iast metrics attributes #metric.name()'() {
1313
given:
1414
final verbosity = Config.get().getIastTelemetryVerbosity()
1515

@@ -29,7 +29,7 @@ class IastMetricTest extends Specification {
2929
metric << (IastMetric.values() as List<IastMetric>)
3030
}
3131

32-
void 'test unwrapping of tags'() {
32+
void 'test unwrapping of tags #iterationIndex'() {
3333
when:
3434
final result = metricTag.unwrap(tag)
3535

@@ -46,7 +46,7 @@ class IastMetricTest extends Specification {
4646
IastMetric.Tag.SOURCE_TYPE | SourceTypes.REQUEST_PARAMETER_VALUE | null
4747
}
4848

49-
void 'test metric tags'() {
49+
void 'test metric tags #metric.name()'() {
5050
when:
5151
final telemetryTags = []
5252
final spanTags = []

0 commit comments

Comments
 (0)