Skip to content

Commit b7aa90d

Browse files
committed
fix: FootprintForkedTest was also measuring Spock mock
Removing the 'features' mock makes the test more predicatable.
1 parent e39c5f5 commit b7aa90d

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
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: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ 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
30-
features.spanKindsToComputedStats() >> []
31-
features.peerTags() >> []
28+
DDAgentFeaturesDiscovery features = Stub(DDAgentFeaturesDiscovery) {
29+
it.supportsMetrics() >> true
30+
it.spanKindsToComputedStats() >> []
31+
it.peerTags() >> []
32+
}
3233
ConflatingMetricsAggregator aggregator = new ConflatingMetricsAggregator(
3334
new WellKnownTags("runtimeid","hostname", "env", "service", "version","language"),
3435
[].toSet() as Set<String>,
@@ -37,8 +38,10 @@ class FootprintForkedTest extends DDSpecification {
3738
1000,
3839
1000,
3940
100,
40-
SECONDS)
41-
long baseline = footprint(aggregator)
41+
SECONDS
42+
)
43+
// Removing the 'features' as it's a mock, and mocks are heavyweight, e.g. around 22MiB
44+
def baseline = footprint(aggregator, features)
4245
aggregator.start()
4346

4447
when: "lots of traces are published"
@@ -72,7 +75,8 @@ class FootprintForkedTest extends DDSpecification {
7275
assert latch.await(30, SECONDS)
7376

7477
then:
75-
footprint(aggregator) - baseline <= 10 * 1024 * 1024
78+
def layout = footprint(aggregator, features)
79+
layout.totalSize() - baseline.totalSize() <= 10 * 1024 * 1024
7680

7781
cleanup:
7882
aggregator.close()
@@ -136,9 +140,14 @@ class FootprintForkedTest extends DDSpecification {
136140
}
137141

138142

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

0 commit comments

Comments
 (0)