Skip to content

Commit b9006af

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

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
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: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ class FootprintForkedTest extends DDSpecification {
3737
1000,
3838
1000,
3939
100,
40-
SECONDS)
41-
long baseline = footprint(aggregator)
40+
SECONDS
41+
)
42+
// Removing the 'features' as it's a mock, and mocks are heavyweight
43+
def baseline = footprint(aggregator, features)
4244
aggregator.start()
4345

4446
when: "lots of traces are published"
@@ -72,7 +74,8 @@ class FootprintForkedTest extends DDSpecification {
7274
assert latch.await(30, SECONDS)
7375

7476
then:
75-
footprint(aggregator) - baseline <= 10 * 1024 * 1024
77+
def layout = footprint(aggregator, features).subtract(baseline)
78+
layout.totalSize() - baseline.totalSize() <= 10 * 1024 * 1024
7679

7780
cleanup:
7881
aggregator.close()
@@ -136,9 +139,14 @@ class FootprintForkedTest extends DDSpecification {
136139
}
137140

138141

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

0 commit comments

Comments
 (0)