Skip to content

Commit

Permalink
Fix test name uniqueness (#7720)
Browse files Browse the repository at this point in the history
  • Loading branch information
PerfectSlayer authored Oct 3, 2024
1 parent 5a939c0 commit 85b316b
Show file tree
Hide file tree
Showing 22 changed files with 178 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFil

class ExcludeFilterTest extends DDSpecification {

def "test empty ExcludeFilter"() {
def "test empty ExcludeFilter #type.name()"() {
setup:
def one = new One()
def oneName = One.getName()
Expand All @@ -22,7 +22,7 @@ class ExcludeFilterTest extends DDSpecification {
type << ExcludeFilter.ExcludeType.values()
}

def "test ExcludeFilter"() {
def "test ExcludeFilter #type.name()"() {
setup:
def another = new Another()
def anotherName = Another.getName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DefaultInstrumenterForkedTest extends DDSpecification {
target.enabled
}

def "default enabled override"() {
def "default enabled override #enabled"() {
expect:
target.enabled == enabled

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class ComparisonExpressionTest {

@ParameterizedTest
@ParameterizedTest(name = "[{index}] {4}")
@MethodSource("expressions")
void evaluateOperator(
ValueExpression<?> left,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import static com.datadog.iast.IastTag.Enabled.SKIPPED

class IastTagTest extends DDSpecification {

void 'tags are sent on the segment'() {
void 'tags are sent on the segment (#tagName)'() {
given:
final segment = Mock(TraceSegment)
Expand All @@ -20,25 +20,25 @@ class IastTagTest extends DDSpecification {
1 * segment.setTagTop(tag.key(), tag.value())
where:
tag | _
ANALYZED | _
SKIPPED | _
tagName | tag
"analyzed" | ANALYZED
"skipped" | SKIPPED
}
void 'tags dont fail with null segment'() {
void 'tags dont fail with null segment (#tagName)'() {
when:
tag.setTagTop(null)
then:
noExceptionThrown()
where:
tag | _
ANALYZED | _
SKIPPED | _
tagName | tag
"analyzed" | ANALYZED
"skipped" | SKIPPED
}
void 'tags are sent on the span'() {
void 'tags are sent on the span (#tagName)'() {
given:
final span = Mock(AgentSpan)
Expand All @@ -49,22 +49,22 @@ class IastTagTest extends DDSpecification {
1 * span.setTag(tag.key(), tag.value())
where:
tag | _
ANALYZED | _
SKIPPED | _
tagName | tag
"analyzed" | ANALYZED
"skipped" | SKIPPED
}
void 'tags dont fail with null span'() {
void 'tags dont fail with null span (#tagName)'() {
when:
tag.setTag(null)
then:
noExceptionThrown()
where:
tag | _
ANALYZED | _
SKIPPED | _
tagName | tag
"analyzed" | ANALYZED
"skipped" | SKIPPED
}
void 'enabled tags are not set if IAST is opt-out'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class EvidenceRedactionTest extends DDSpecification {
vulnerabilitiesParser = moshi.adapter(Types.newParameterizedType(List, Vulnerability))
}

void 'test empty value parts'() {
void 'test empty value parts #iterationIndex'() {
given:
final writer = Stub(JsonWriter)
final ctx = new AdapterFactory.Context()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PropagationModuleTest extends IastModuleImplTestBase {
}
}

void '#method(#args) not taintable'() {
void '#method(#argTypes) not taintable'() {
when: 'there is no context by default'
module.&"$method".call(args.toArray())

Expand Down Expand Up @@ -102,6 +102,7 @@ class PropagationModuleTest extends IastModuleImplTestBase {
]
'findSource' | [null]
'isTainted' | [null]
argTypes = args*.class.name
}

void '#method without span'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ResourceLocatingTest extends DDSpecification {
lastLookup.set(null)
}

def "finds resources from parent classloader"() {
def "finds resources from parent classloader #locator.class.name"() {
expect:
locator.locate("java/lang/Object").isResolved() == usesProvidedClassloader
// lastLookup verifies that the given classloader is only used when expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import spock.lang.Requires
})
class AdvicesInvokeDynamicTest extends BaseCallSiteTest {

void 'test constant pool introspector with invoke dynamic'() {
void 'test constant pool introspector with invoke dynamic #pointcutName'() {
setup:
final type = new TypeDescription.ForLoadedType(StringPlusExample)
final advice = Stub(InvokeDynamicAdvice)
Expand All @@ -29,9 +29,10 @@ class AdvicesInvokeDynamicTest extends BaseCallSiteTest {
pointcutMock | emptyAdvices | adviceFound
stringConcatPointcut() | true | false
stringConcatFactoryPointcut() | false | true
pointcutName = pointcutMock.descriptor
}

void 'test constant pool introspector with invoke dynamic and constants'() {
void 'test constant pool introspector with invoke dynamic and constants #pointcutName'() {
setup:
final type = new TypeDescription.ForLoadedType(StringPlusConstantsExample)
final advice = Stub(InvokeDynamicAdvice)
Expand All @@ -50,5 +51,6 @@ class AdvicesInvokeDynamicTest extends BaseCallSiteTest {
pointcutMock | emptyAdvices | adviceFound
stringConcatPointcut() | true | false
stringConcatFactoryPointcut() | false | true
pointcutName = pointcutMock.descriptor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DataBundleMapWrapperSpecification extends DDSpecification {
def elem

expect:
iter.hasNext() == true
iter.hasNext()

when:
elem = iter.next()
Expand All @@ -46,7 +46,7 @@ class DataBundleMapWrapperSpecification extends DDSpecification {
then:
elem.key == KnownAddresses.REQUEST_CLIENT_IP.key
elem.value == [:]
iter.hasNext() == false
!iter.hasNext()

when:
iter.remove()
Expand All @@ -71,25 +71,24 @@ class DataBundleMapWrapperSpecification extends DDSpecification {
thrown(UnsupportedOperationException)
}

void 'methods other than entrySet and size are not supported'() {
void 'methods other than entrySet and size are not supported: #methodName'() {
when:
method(mapWrapper)

then:
thrown(UnsupportedOperationException)

where:
method << [
{ it.values() },
{ it.keySet() },
{ it.clear() },
{ it.putAll([:]) },
{ it.remove('a') },
{ it.put('b', 'a') },
{ it.get('a') },
{ it.containsValue('b') },
{ it.containsKey('a') },
{ it.isEmpty() },
]
methodName | method
"values" | { it.values() }
"keySet" | { it.keySet() }
"clean" | { it.clear() }
"putAll" | { it.putAll([:]) }
"remove" | { it.remove('a') }
"put" | { it.put('b', 'a') }
"get" | { it.get('a') }
"containsValue" | { it.containsValue('b') }
"containsKey" | { it.containsKey('a') }
"empty" | { it.isEmpty() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class JakartaRsAnnotations3InstrumentationTest extends AgentTestRunner {

def "no annotations has no effect"() {
setup:
def obj = new Jakarta() {
void call() {
}
}
runUnderTrace("test") {
obj.call()
}
Expand All @@ -157,13 +161,6 @@ class JakartaRsAnnotations3InstrumentationTest extends AgentTestRunner {
}
}
}

where:
obj | _
new Jakarta() {
void call() {
}
} | _
}

interface Jakarta {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CrossedContextTest extends AgentTestRunner {
pool.shutdownNow()
}

def "concurrent #action are traced with correct lineage in #executor"() {
def "concurrent #action are traced with correct lineage in #executor.class.name"() {
when:
def sut = executor
def fn = function
Expand Down Expand Up @@ -102,7 +102,7 @@ class CrossedContextTest extends AgentTestRunner {
new org.apache.tomcat.util.threads.ThreadPoolExecutor(1, 1, 5, TimeUnit.SECONDS, new TaskQueue()) | "execution" | executeRunnable
}

def "netty event loop internal executions in #executor are traced with correct lineage" () {
def "netty event loop internal executions in #executor.class.name are traced with correct lineage" () {
setup:
ExecutorService pool = executor
when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TaskUnwrappingForkedTest extends AgentTestRunner {
super.configurePreAgent()
}

def "check expected types instrumented and can be unwrapped"() {
def "check expected types instrumented and can be unwrapped (#iterationIndex)"() {
expect:
task instanceof TaskWrapper
type.isAssignableFrom(TaskWrapper.getUnwrappedType(task))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RecursiveThreadPoolPropagationTest extends AgentTestRunner {
@Shared
def mixedSubmissionAndExecution = { executor, depth -> executor.submit(new RecursiveThreadPoolMixedSubmissionAndExecution(executor, depth, 0)) }

def "propagate context in #executor with #parallelism threads #depth times"() {
def "propagate context in #executor.class.name with #parallelism threads #depth times"() {
when:
test(executor, depth)
then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ThreadLocalRandomCallSiteTest extends AgentTestRunner {
injectSysConfig('dd.iast.enabled', 'true')
}

void 'test #target.#method methods'() {
void 'test #target.class.name #method methods'() {
setup:
final module = Mock(WeakRandomnessModule)
InstrumentationBridge.registerIastModule(module)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class JaxRsAnnotations1InstrumentationTest extends AgentTestRunner {

def "no annotations has no effect"() {
setup:
def obj = new Jax() {
void call() {
}
}
runUnderTrace("test") {
obj.call()
}
Expand All @@ -157,13 +161,6 @@ class JaxRsAnnotations1InstrumentationTest extends AgentTestRunner {
}
}
}

where:
obj | _
new Jax() {
void call() {
}
} | _
}

interface Jax {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class JaxRsAnnotations2InstrumentationTest extends AgentTestRunner {

def "no annotations has no effect"() {
setup:
def obj = new Jax() {
void call() {
}
}
runUnderTrace("test") {
obj.call()
}
Expand All @@ -157,13 +161,6 @@ class JaxRsAnnotations2InstrumentationTest extends AgentTestRunner {
}
}
}

where:
obj | _
new Jax() {
void call() {
}
} | _
}

interface Jax {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class KotlinCoroutineInstrumentationTest extends AbstractKotlinCoroutineInstrume
return new KotlinCoroutineTests(dispatcher)
}

def "kotlin traced across channels"() {
def "kotlin traced across channels #dispatcherName"() {
setup:
KotlinCoroutineTests kotlinTest = new KotlinCoroutineTests(dispatcher)
int expectedNumberOfSpans = kotlinTest.tracedAcrossChannels()
Expand All @@ -23,6 +23,6 @@ class KotlinCoroutineInstrumentationTest extends AbstractKotlinCoroutineInstrume
findSpan(trace, "consume_2").context().getParentId() == trace[0].context().getSpanId()

where:
dispatcher << AbstractKotlinCoroutineInstrumentationTest.dispatchersToTest
[dispatcherName, dispatcher] << dispatchersToTest
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class KotlinCoroutineInstrumentationTest extends AbstractKotlinCoroutineInstrume
return new KotlinCoroutineTests(dispatcher)
}

def "kotlin traced across flows"() {
def "kotlin traced across flows #dispatcherName"() {
setup:
KotlinCoroutineTests kotlinTest = new KotlinCoroutineTests(dispatcher)
int expectedNumberOfSpans = kotlinTest.tracedAcrossFlows(false)
Expand All @@ -23,10 +23,10 @@ class KotlinCoroutineInstrumentationTest extends AbstractKotlinCoroutineInstrume
findSpan(trace, "consume_2").context().getParentId() == trace[0].context().getSpanId()

where:
dispatcher << AbstractKotlinCoroutineInstrumentationTest.dispatchersToTest
[dispatcherName, dispatcher] << dispatchersToTest
}

def "kotlin traced across flows with modified context"() {
def "kotlin traced across flows with modified context #dispatcherName"() {
setup:
KotlinCoroutineTests kotlinTest = new KotlinCoroutineTests(dispatcher)
int expectedNumberOfSpans = kotlinTest.tracedAcrossFlows(true)
Expand All @@ -40,6 +40,6 @@ class KotlinCoroutineInstrumentationTest extends AbstractKotlinCoroutineInstrume
findSpan(trace, "consume_2").context().getParentId() == trace[0].context().getSpanId()

where:
dispatcher << AbstractKotlinCoroutineInstrumentationTest.dispatchersToTest
[dispatcherName, dispatcher] << dispatchersToTest
}
}
Loading

0 comments on commit 85b316b

Please sign in to comment.