Add Config and Context JUnit extensions#11076
Add Config and Context JUnit extensions#11076gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits intomasterfrom
Conversation
| private static final int TRACE_PARENT_FLAGS_SAMPLED = 1; | ||
| private static final int TRACE_PARENT_LENGTH = TRACE_PARENT_FLAGS_START + 2; | ||
|
|
||
| // Package-protected for testing |
There was a problem hiding this comment.
suggestion (non-blocking): Shouldn't we introduce a source level annotation VisibleForTesting ?
There was a problem hiding this comment.
We should come up with something like this yes. Maybe have our own?
| * @WithConfig(key = "AGENT_HOST", value = "localhost", env = true) | ||
| * void testWithEnv() { ... } | ||
| * } | ||
| * }</pre> |
There was a problem hiding this comment.
typo:
| * }</pre> | |
| * </pre> |
There was a problem hiding this comment.
There is one to class the class definition, and another to close the {@code …} tag.
| * <p>By default, injects a system property with the {@code dd.} prefix. Use {@code env = true} for | ||
| * environment variables (prefix {@code DD_}). |
There was a problem hiding this comment.
thought (non-blocking): Maybe the code can be smart enough to detect when there's the dd. prefix?
There was a problem hiding this comment.
I thought about it but I did not because our config keys should not have dd. or DD_ prefix so better not due clever things that will hide it.
And that would make edges cases testing, like where you don't want dd. at all, harder.
|
|
||
| private static Properties originalSystemProperties; | ||
|
|
||
| // region JUnit lifecycle callbacks |
| ":dd-java-agent:testing", | ||
| ":utils:config-utils", | ||
| ":utils:container-utils", | ||
| ":utils:junit-utils", |
There was a problem hiding this comment.
thought (non-blocking): I'm thinking that :utils:test-utils will remain, and I feel that junit stuff should eventually land here. So what about moving the groovy / spock in another project (e.g. :utils:test-spock-utils) that we can delete later? Or at least not automatically imported by tests?
There was a problem hiding this comment.
I'm thinking that :utils:test-utils will remain
I think so yes.
I feel that junit stuff should eventually land here
Agreed
So what about moving the groovy / spock in another project (e.g. :utils:test-spock-utils) that we can delete later? Or at least not automatically imported by tests?
That could be a solution yes. I only wanted to do a follow up of @jpbempel PR and tried to avoid changing too many things (I did change a lot in this PR overall 😬 ) because I know he has some more changes wrt to this migration. But yes, I want to get rid of groovy from the default testing module 😉
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 58 metrics, 13 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.056 s) : 0, 1055857
Total [baseline] (11.148 s) : 0, 11148315
Agent [candidate] (1.057 s) : 0, 1057438
Total [candidate] (11.047 s) : 0, 11046698
section appsec
Agent [baseline] (1.262 s) : 0, 1262126
Total [baseline] (11.189 s) : 0, 11189366
Agent [candidate] (1.259 s) : 0, 1258525
Total [candidate] (11.133 s) : 0, 11133346
section iast
Agent [baseline] (1.224 s) : 0, 1223943
Total [baseline] (11.216 s) : 0, 11216100
Agent [candidate] (1.24 s) : 0, 1239583
Total [candidate] (11.346 s) : 0, 11345745
section profiling
Agent [baseline] (1.184 s) : 0, 1183613
Total [baseline] (11.056 s) : 0, 11055560
Agent [candidate] (1.185 s) : 0, 1184727
Total [candidate] (11.145 s) : 0, 11144855
gantt
title petclinic - break down per module: candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.22 ms) : 0, 1220
crashtracking [candidate] (1.22 ms) : 0, 1220
BytebuddyAgent [baseline] (632.847 ms) : 0, 632847
BytebuddyAgent [candidate] (632.52 ms) : 0, 632520
AgentMeter [baseline] (29.286 ms) : 0, 29286
AgentMeter [candidate] (29.469 ms) : 0, 29469
GlobalTracer [baseline] (248.446 ms) : 0, 248446
GlobalTracer [candidate] (248.851 ms) : 0, 248851
AppSec [baseline] (31.979 ms) : 0, 31979
AppSec [candidate] (32.054 ms) : 0, 32054
Debugger [baseline] (59.87 ms) : 0, 59870
Debugger [candidate] (60.114 ms) : 0, 60114
Remote Config [baseline] (602.789 µs) : 0, 603
Remote Config [candidate] (618.292 µs) : 0, 618
Telemetry [baseline] (8.103 ms) : 0, 8103
Telemetry [candidate] (8.032 ms) : 0, 8032
Flare Poller [baseline] (7.397 ms) : 0, 7397
Flare Poller [candidate] (8.351 ms) : 0, 8351
section appsec
crashtracking [baseline] (1.255 ms) : 0, 1255
crashtracking [candidate] (1.247 ms) : 0, 1247
BytebuddyAgent [baseline] (669.794 ms) : 0, 669794
BytebuddyAgent [candidate] (667.702 ms) : 0, 667702
AgentMeter [baseline] (12.238 ms) : 0, 12238
AgentMeter [candidate] (12.112 ms) : 0, 12112
GlobalTracer [baseline] (251.587 ms) : 0, 251587
GlobalTracer [candidate] (250.818 ms) : 0, 250818
AppSec [baseline] (185.797 ms) : 0, 185797
AppSec [candidate] (185.937 ms) : 0, 185937
Debugger [baseline] (66.802 ms) : 0, 66802
Debugger [candidate] (66.371 ms) : 0, 66371
Remote Config [baseline] (613.077 µs) : 0, 613
Remote Config [candidate] (610.266 µs) : 0, 610
Telemetry [baseline] (8.819 ms) : 0, 8819
Telemetry [candidate] (8.658 ms) : 0, 8658
Flare Poller [baseline] (3.663 ms) : 0, 3663
Flare Poller [candidate] (3.632 ms) : 0, 3632
IAST [baseline] (24.797 ms) : 0, 24797
IAST [candidate] (24.714 ms) : 0, 24714
section iast
crashtracking [baseline] (1.232 ms) : 0, 1232
crashtracking [candidate] (1.23 ms) : 0, 1230
BytebuddyAgent [baseline] (800.962 ms) : 0, 800962
BytebuddyAgent [candidate] (810.925 ms) : 0, 810925
AgentMeter [baseline] (11.406 ms) : 0, 11406
AgentMeter [candidate] (11.703 ms) : 0, 11703
GlobalTracer [baseline] (239.148 ms) : 0, 239148
GlobalTracer [candidate] (242.057 ms) : 0, 242057
AppSec [baseline] (30.148 ms) : 0, 30148
AppSec [candidate] (31.482 ms) : 0, 31482
Debugger [baseline] (61.545 ms) : 0, 61545
Debugger [candidate] (61.603 ms) : 0, 61603
Remote Config [baseline] (1.134 ms) : 0, 1134
Remote Config [candidate] (566.915 µs) : 0, 567
Telemetry [baseline] (12.979 ms) : 0, 12979
Telemetry [candidate] (13.234 ms) : 0, 13234
Flare Poller [baseline] (3.469 ms) : 0, 3469
Flare Poller [candidate] (3.557 ms) : 0, 3557
IAST [baseline] (25.702 ms) : 0, 25702
IAST [candidate] (26.129 ms) : 0, 26129
section profiling
crashtracking [baseline] (1.192 ms) : 0, 1192
crashtracking [candidate] (1.174 ms) : 0, 1174
BytebuddyAgent [baseline] (690.872 ms) : 0, 690872
BytebuddyAgent [candidate] (691.856 ms) : 0, 691856
AgentMeter [baseline] (9.075 ms) : 0, 9075
AgentMeter [candidate] (9.145 ms) : 0, 9145
GlobalTracer [baseline] (207.015 ms) : 0, 207015
GlobalTracer [candidate] (207.205 ms) : 0, 207205
AppSec [baseline] (32.378 ms) : 0, 32378
AppSec [candidate] (32.41 ms) : 0, 32410
Debugger [baseline] (65.61 ms) : 0, 65610
Debugger [candidate] (65.463 ms) : 0, 65463
Remote Config [baseline] (568.602 µs) : 0, 569
Remote Config [candidate] (561.909 µs) : 0, 562
Telemetry [baseline] (7.842 ms) : 0, 7842
Telemetry [candidate] (7.799 ms) : 0, 7799
Flare Poller [baseline] (3.571 ms) : 0, 3571
Flare Poller [candidate] (3.6 ms) : 0, 3600
ProfilingAgent [baseline] (94.193 ms) : 0, 94193
ProfilingAgent [candidate] (94.13 ms) : 0, 94130
Profiling [baseline] (94.754 ms) : 0, 94754
Profiling [candidate] (94.689 ms) : 0, 94689
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.057 s) : 0, 1057428
Total [baseline] (8.856 s) : 0, 8856320
Agent [candidate] (1.056 s) : 0, 1055882
Total [candidate] (8.83 s) : 0, 8830160
section iast
Agent [baseline] (1.231 s) : 0, 1230590
Total [baseline] (9.543 s) : 0, 9543329
Agent [candidate] (1.228 s) : 0, 1227883
Total [candidate] (9.607 s) : 0, 9606711
gantt
title insecure-bank - break down per module: candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.249 ms) : 0, 1249
crashtracking [candidate] (1.263 ms) : 0, 1263
BytebuddyAgent [baseline] (632.836 ms) : 0, 632836
BytebuddyAgent [candidate] (633.064 ms) : 0, 633064
AgentMeter [baseline] (29.447 ms) : 0, 29447
AgentMeter [candidate] (29.395 ms) : 0, 29395
GlobalTracer [baseline] (248.885 ms) : 0, 248885
GlobalTracer [candidate] (248.552 ms) : 0, 248552
AppSec [baseline] (32.004 ms) : 0, 32004
AppSec [candidate] (32.033 ms) : 0, 32033
Debugger [baseline] (59.116 ms) : 0, 59116
Debugger [candidate] (59.297 ms) : 0, 59297
Remote Config [baseline] (593.263 µs) : 0, 593
Remote Config [candidate] (585.299 µs) : 0, 585
Telemetry [baseline] (8.102 ms) : 0, 8102
Telemetry [candidate] (8.088 ms) : 0, 8088
Flare Poller [baseline] (8.938 ms) : 0, 8938
Flare Poller [candidate] (7.403 ms) : 0, 7403
section iast
crashtracking [baseline] (1.258 ms) : 0, 1258
crashtracking [candidate] (1.254 ms) : 0, 1254
BytebuddyAgent [baseline] (805.559 ms) : 0, 805559
BytebuddyAgent [candidate] (805.682 ms) : 0, 805682
AgentMeter [baseline] (11.678 ms) : 0, 11678
AgentMeter [candidate] (11.626 ms) : 0, 11626
GlobalTracer [baseline] (240.175 ms) : 0, 240175
GlobalTracer [candidate] (238.574 ms) : 0, 238574
AppSec [baseline] (30.728 ms) : 0, 30728
AppSec [candidate] (32.52 ms) : 0, 32520
Debugger [baseline] (62.334 ms) : 0, 62334
Debugger [candidate] (58.617 ms) : 0, 58617
Remote Config [baseline] (557.628 µs) : 0, 558
Remote Config [candidate] (534.774 µs) : 0, 535
Telemetry [baseline] (12.115 ms) : 0, 12115
Telemetry [candidate] (13.622 ms) : 0, 13622
Flare Poller [baseline] (3.83 ms) : 0, 3830
Flare Poller [candidate] (3.451 ms) : 0, 3451
IAST [baseline] (26.024 ms) : 0, 26024
IAST [candidate] (25.722 ms) : 0, 25722
LoadParameters
See matching parameters
SummaryFound 1 performance improvements and 3 performance regressions! Performance is the same for 16 metrics, 16 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section baseline
no_agent (17.1 ms) : 16927, 17274
. : milestone, 17100,
appsec (18.759 ms) : 18567, 18950
. : milestone, 18759,
code_origins (18.001 ms) : 17822, 18179
. : milestone, 18001,
iast (18.385 ms) : 18200, 18570
. : milestone, 18385,
profiling (19.336 ms) : 19142, 19530
. : milestone, 19336,
tracing (19.039 ms) : 18846, 19232
. : milestone, 19039,
section candidate
no_agent (18.215 ms) : 18030, 18401
. : milestone, 18215,
appsec (18.457 ms) : 18271, 18642
. : milestone, 18457,
code_origins (17.833 ms) : 17659, 18007
. : milestone, 17833,
iast (18.087 ms) : 17905, 18270
. : milestone, 18087,
profiling (19.834 ms) : 19631, 20037
. : milestone, 19834,
tracing (17.874 ms) : 17698, 18051
. : milestone, 17874,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section baseline
no_agent (1.286 ms) : 1273, 1299
. : milestone, 1286,
iast (3.287 ms) : 3241, 3333
. : milestone, 3287,
iast_FULL (5.963 ms) : 5904, 6023
. : milestone, 5963,
iast_GLOBAL (3.602 ms) : 3548, 3657
. : milestone, 3602,
profiling (2.054 ms) : 2036, 2072
. : milestone, 2054,
tracing (1.836 ms) : 1821, 1851
. : milestone, 1836,
section candidate
no_agent (1.301 ms) : 1289, 1313
. : milestone, 1301,
iast (3.437 ms) : 3389, 3485
. : milestone, 3437,
iast_FULL (5.893 ms) : 5833, 5953
. : milestone, 5893,
iast_GLOBAL (3.698 ms) : 3636, 3760
. : milestone, 3698,
profiling (2.033 ms) : 2016, 2050
. : milestone, 2033,
tracing (1.852 ms) : 1837, 1867
. : milestone, 1852,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 2 unstable metrics. Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section baseline
no_agent (15.509 s) : 15509000, 15509000
. : milestone, 15509000,
appsec (14.861 s) : 14861000, 14861000
. : milestone, 14861000,
iast (18.544 s) : 18544000, 18544000
. : milestone, 18544000,
iast_GLOBAL (18.299 s) : 18299000, 18299000
. : milestone, 18299000,
profiling (15.435 s) : 15435000, 15435000
. : milestone, 15435000,
tracing (15.026 s) : 15026000, 15026000
. : milestone, 15026000,
section candidate
no_agent (15.13 s) : 15130000, 15130000
. : milestone, 15130000,
appsec (14.903 s) : 14903000, 14903000
. : milestone, 14903000,
iast (18.129 s) : 18129000, 18129000
. : milestone, 18129000,
iast_GLOBAL (18.684 s) : 18684000, 18684000
. : milestone, 18684000,
profiling (15.533 s) : 15533000, 15533000
. : milestone, 15533000,
tracing (15.093 s) : 15093000, 15093000
. : milestone, 15093000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.62.0-SNAPSHOT~8d909c3d37, baseline=1.62.0-SNAPSHOT~6564199418
dateFormat X
axisFormat %s
section baseline
no_agent (1.495 ms) : 1483, 1506
. : milestone, 1495,
appsec (3.855 ms) : 3631, 4078
. : milestone, 3855,
iast (2.287 ms) : 2218, 2357
. : milestone, 2287,
iast_GLOBAL (2.332 ms) : 2262, 2402
. : milestone, 2332,
profiling (2.11 ms) : 2055, 2165
. : milestone, 2110,
tracing (2.097 ms) : 2043, 2151
. : milestone, 2097,
section candidate
no_agent (1.495 ms) : 1484, 1507
. : milestone, 1495,
appsec (3.849 ms) : 3626, 4073
. : milestone, 3849,
iast (2.284 ms) : 2215, 2354
. : milestone, 2284,
iast_GLOBAL (2.337 ms) : 2267, 2407
. : milestone, 2337,
profiling (2.554 ms) : 2388, 2719
. : milestone, 2554,
tracing (2.09 ms) : 2036, 2144
. : milestone, 2090,
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
5ab378f
into
master
What Does This Do
This PR is a follow up of #11062 and introduces:
junit-utilmodules dedicated to improving the JUnit experience (such module has no groovy / spock dependency on purpose)Here are few examples about how to use it and the various capabilities:
Another interesting usage would be product / feature dedicated composed annotation like:
Note that all programatic calls about setting config values like
WithConfigExtension.injectSysConfig(),WithConfigExtension.injectEnvConfig()will still be available.Additionally, it moves the TableTest type converter to the new module and refine the span links related tests (I can move it into a separate PR if needed).
Motivation
Provide a first class experience using JUnit testing framework.
Additional Notes
I add the idea about JUnit extension model for few years now but I used Claude to implement it faster and reducing the risk of conflicts related to the codebase migration.
There are some product related config checks that I did not moved into the extension on purpose. I want the extension to remains as generic / decoupled as possible.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.