Skip to content

Commit e6a9f29

Browse files
authored
FootprintForkedTest was also measuring Spock mock (#9298)
Removing the 'features' mock makes the test more predicatable.
1 parent 7b908a5 commit e6a9f29

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

dd-trace-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dependencies {
9191
testImplementation project(':remote-config:remote-config-core')
9292
testImplementation group: 'org.msgpack', name: 'msgpack-core', version: '0.8.20'
9393
testImplementation group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.8.20'
94-
testImplementation group: 'org.openjdk.jol', name: 'jol-core', version: '0.16'
94+
testImplementation group: 'org.openjdk.jol', name: 'jol-core', version: '0.17'
9595
testImplementation group: 'commons-codec', name: 'commons-codec', version: '1.3'
9696
testImplementation group: 'com.amazonaws', name: 'aws-lambda-java-events', version:'3.11.0'
9797
testImplementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.14.0'

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class FootprintForkedTest extends DDSpecification {
2525
setup:
2626
CountDownLatch latch = new CountDownLatch(1)
2727
ValidatingSink sink = new ValidatingSink(latch)
28-
DDAgentFeaturesDiscovery features = Mock(DDAgentFeaturesDiscovery)
29-
features.supportsMetrics() >> true
28+
DDAgentFeaturesDiscovery features = Stub(DDAgentFeaturesDiscovery) {
29+
it.supportsMetrics() >> true
30+
}
3031
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(
3132
new WellKnownTags("runtimeid","hostname", "env", "service", "version","language"),
3233
[].toSet() as Set<String>,
@@ -35,8 +36,10 @@ class FootprintForkedTest extends DDSpecification {
3536
1000,
3637
1000,
3738
100,
38-
SECONDS)
39-
long baseline = footprint(aggregator)
39+
SECONDS
40+
)
41+
// Removing the 'features' as it's a mock, and mocks are heavyweight, e.g. around 22MiB
42+
def baseline = footprint(aggregator, features)
4043
aggregator.start()
4144

4245
when: "lots of traces are published"
@@ -70,7 +73,8 @@ class FootprintForkedTest extends DDSpecification {
7073
assert latch.await(30, SECONDS)
7174

7275
then:
73-
footprint(aggregator) - baseline <= 10 * 1024 * 1024
76+
def layout = footprint(aggregator, features)
77+
layout.totalSize() - baseline.totalSize() <= 10 * 1024 * 1024
7478

7579
cleanup:
7680
aggregator.close()
@@ -134,9 +138,14 @@ class FootprintForkedTest extends DDSpecification {
134138
}
135139

136140

137-
static long footprint(Object o) {
138-
GraphLayout layout = GraphLayout.parseInstance(o)
139-
System.err.println(layout.toFootprint())
140-
return layout.totalSize()
141+
static GraphLayout footprint(Object root, Object... excludedRootFieldInstance) {
142+
GraphLayout layout = GraphLayout.parseInstance(root)
143+
144+
excludedRootFieldInstance.each {
145+
layout = layout.subtract(GraphLayout.parseInstance(it))
146+
}
147+
148+
println layout.toFootprint()
149+
return layout
141150
}
142151
}

0 commit comments

Comments
 (0)