-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathInstrumenterIndexTest.groovy
More file actions
86 lines (64 loc) · 2.74 KB
/
InstrumenterIndexTest.groovy
File metadata and controls
86 lines (64 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package datadog.trace.agent.tooling
import datadog.trace.config.inversion.ConfigHelper
import datadog.trace.test.util.DDSpecification
import spock.lang.Shared
class InstrumenterIndexTest extends DDSpecification {
def setupSpec() {
ConfigHelper.get().setConfigInversionStrict(ConfigHelper.StrictnessPolicy.TEST)
}
@Shared
def unknownInstrumentation = new InstrumenterModule('unknown') {}
@Shared
def unknownTransformation = new Instrumenter() {}
def "index keeps track of instrumentation and transformation ids"() {
when:
InstrumenterIndex index = InstrumenterIndex.buildIndex()
then:
index.instrumentationCount() == 4
index.transformationCount() == 8
index.instrumentationId(unknownInstrumentation) == -1
index.transformationId(unknownTransformation) == -1
def moduleIterator = index.modules().iterator()
moduleIterator.hasNext()
// module with order=-100 is applied first
def firstModule = moduleIterator.next()
firstModule.class.simpleName == 'TestIndexFirstModule'
firstModule.order() == -100
index.instrumentationId(firstModule) == 0
moduleIterator.hasNext()
// multi-module declares several transformations
def multiModule = moduleIterator.next()
multiModule.class.simpleName == 'TestIndexMultiModule'
index.instrumentationId(multiModule) == 1
def multiItr = multiModule.typeInstrumentations().iterator()
index.transformationId(unknownTransformation) == -1
index.transformationId(multiItr.next()) == 1
index.transformationId(multiItr.next()) == 2
index.transformationId(unknownTransformation) == -1
index.transformationId(multiItr.next()) == 3
index.transformationId(unknownTransformation) == -1
index.transformationId(multiItr.next()) == 4
index.transformationId(multiItr.next()) == 5
index.transformationId(unknownTransformation) == -1
!multiItr.hasNext()
index.instrumentationId(unknownInstrumentation) == -1
index.transformationId(unknownTransformation) == -1
moduleIterator.hasNext()
// self-module just declares itself as a transformation
def selfModule = moduleIterator.next()
selfModule.class.simpleName == 'TestIndexSelfModule'
index.instrumentationId(selfModule) == 2
def selfItr = selfModule.typeInstrumentations().iterator()
index.transformationId(selfItr.next()) == 6
!selfItr.hasNext()
moduleIterator.hasNext()
// module with order=100 is applied last
def lastModule = moduleIterator.next()
lastModule.class.simpleName == 'TestIndexLastModule'
lastModule.order() == 100
index.instrumentationId(lastModule) == 3
!moduleIterator.hasNext()
index.instrumentationId(unknownInstrumentation) == -1
index.transformationId(unknownTransformation) == -1
}
}