Add unit and instrumentation test documentation for JUnit#11097
Add unit and instrumentation test documentation for JUnit#11097PerfectSlayer wants to merge 1 commit intomasterfrom
Conversation
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 61 metrics, 10 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.059 s) : 0, 1059475
Total [baseline] (11.124 s) : 0, 11123536
Agent [candidate] (1.065 s) : 0, 1064639
Total [candidate] (11.101 s) : 0, 11100787
section appsec
Agent [baseline] (1.277 s) : 0, 1277440
Total [baseline] (11.015 s) : 0, 11014837
Agent [candidate] (1.257 s) : 0, 1257103
Total [candidate] (11.006 s) : 0, 11005945
section iast
Agent [baseline] (1.249 s) : 0, 1248773
Total [baseline] (11.35 s) : 0, 11349594
Agent [candidate] (1.232 s) : 0, 1231680
Total [candidate] (11.298 s) : 0, 11297774
section profiling
Agent [baseline] (1.192 s) : 0, 1191513
Total [baseline] (11.122 s) : 0, 11121740
Agent [candidate] (1.193 s) : 0, 1192559
Total [candidate] (11.062 s) : 0, 11062180
gantt
title petclinic - break down per module: candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.242 ms) : 0, 1242
crashtracking [candidate] (1.238 ms) : 0, 1238
BytebuddyAgent [baseline] (634.087 ms) : 0, 634087
BytebuddyAgent [candidate] (635.995 ms) : 0, 635995
AgentMeter [baseline] (29.717 ms) : 0, 29717
AgentMeter [candidate] (29.991 ms) : 0, 29991
GlobalTracer [baseline] (249.596 ms) : 0, 249596
GlobalTracer [candidate] (251.06 ms) : 0, 251060
AppSec [baseline] (32.407 ms) : 0, 32407
AppSec [candidate] (32.73 ms) : 0, 32730
Debugger [baseline] (60.027 ms) : 0, 60027
Debugger [candidate] (60.297 ms) : 0, 60297
Remote Config [baseline] (597.915 µs) : 0, 598
Remote Config [candidate] (594.127 µs) : 0, 594
Telemetry [baseline] (8.744 ms) : 0, 8744
Telemetry [candidate] (8.134 ms) : 0, 8134
Flare Poller [baseline] (6.759 ms) : 0, 6759
Flare Poller [candidate] (8.257 ms) : 0, 8257
section appsec
crashtracking [baseline] (1.258 ms) : 0, 1258
crashtracking [candidate] (1.204 ms) : 0, 1204
BytebuddyAgent [baseline] (683.39 ms) : 0, 683390
BytebuddyAgent [candidate] (671.23 ms) : 0, 671230
AgentMeter [baseline] (12.334 ms) : 0, 12334
AgentMeter [candidate] (12.122 ms) : 0, 12122
GlobalTracer [baseline] (251.985 ms) : 0, 251985
GlobalTracer [candidate] (248.003 ms) : 0, 248003
AppSec [baseline] (188.211 ms) : 0, 188211
AppSec [candidate] (185.375 ms) : 0, 185375
Debugger [baseline] (66.792 ms) : 0, 66792
Debugger [candidate] (66.634 ms) : 0, 66634
Remote Config [baseline] (577.985 µs) : 0, 578
Remote Config [candidate] (585.254 µs) : 0, 585
Telemetry [baseline] (8.026 ms) : 0, 8026
Telemetry [candidate] (7.907 ms) : 0, 7907
Flare Poller [baseline] (3.54 ms) : 0, 3540
Flare Poller [candidate] (3.46 ms) : 0, 3460
IAST [baseline] (24.663 ms) : 0, 24663
IAST [candidate] (24.269 ms) : 0, 24269
section iast
crashtracking [baseline] (1.257 ms) : 0, 1257
crashtracking [candidate] (1.223 ms) : 0, 1223
BytebuddyAgent [baseline] (821.695 ms) : 0, 821695
BytebuddyAgent [candidate] (808.982 ms) : 0, 808982
AgentMeter [baseline] (11.623 ms) : 0, 11623
AgentMeter [candidate] (11.449 ms) : 0, 11449
GlobalTracer [baseline] (241.556 ms) : 0, 241556
GlobalTracer [candidate] (238.874 ms) : 0, 238874
AppSec [baseline] (26.966 ms) : 0, 26966
AppSec [candidate] (26.713 ms) : 0, 26713
Debugger [baseline] (66.286 ms) : 0, 66286
Debugger [candidate] (66.644 ms) : 0, 66644
Remote Config [baseline] (543.858 µs) : 0, 544
Remote Config [candidate] (535.813 µs) : 0, 536
Telemetry [baseline] (7.839 ms) : 0, 7839
Telemetry [candidate] (7.836 ms) : 0, 7836
Flare Poller [baseline] (3.474 ms) : 0, 3474
Flare Poller [candidate] (3.453 ms) : 0, 3453
IAST [baseline] (30.323 ms) : 0, 30323
IAST [candidate] (29.891 ms) : 0, 29891
section profiling
ProfilingAgent [baseline] (93.987 ms) : 0, 93987
ProfilingAgent [candidate] (94.056 ms) : 0, 94056
crashtracking [baseline] (1.198 ms) : 0, 1198
crashtracking [candidate] (1.18 ms) : 0, 1180
BytebuddyAgent [baseline] (695.662 ms) : 0, 695662
BytebuddyAgent [candidate] (697.343 ms) : 0, 697343
AgentMeter [baseline] (9.297 ms) : 0, 9297
AgentMeter [candidate] (9.239 ms) : 0, 9239
GlobalTracer [baseline] (208.53 ms) : 0, 208530
GlobalTracer [candidate] (208.36 ms) : 0, 208360
AppSec [baseline] (33.054 ms) : 0, 33054
AppSec [candidate] (32.876 ms) : 0, 32876
Debugger [baseline] (66.227 ms) : 0, 66227
Debugger [candidate] (65.848 ms) : 0, 65848
Remote Config [baseline] (586.562 µs) : 0, 587
Remote Config [candidate] (572.939 µs) : 0, 573
Telemetry [baseline] (7.761 ms) : 0, 7761
Telemetry [candidate] (7.756 ms) : 0, 7756
Flare Poller [baseline] (3.512 ms) : 0, 3512
Flare Poller [candidate] (3.585 ms) : 0, 3585
Profiling [baseline] (94.549 ms) : 0, 94549
Profiling [candidate] (94.628 ms) : 0, 94628
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.061 s) : 0, 1061043
Total [baseline] (8.838 s) : 0, 8838094
Agent [candidate] (1.059 s) : 0, 1058937
Total [candidate] (8.834 s) : 0, 8833599
section iast
Agent [baseline] (1.23 s) : 0, 1230252
Total [baseline] (9.573 s) : 0, 9573047
Agent [candidate] (1.227 s) : 0, 1227253
Total [candidate] (9.615 s) : 0, 9615208
gantt
title insecure-bank - break down per module: candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.244 ms) : 0, 1244
crashtracking [candidate] (1.233 ms) : 0, 1233
BytebuddyAgent [baseline] (636.388 ms) : 0, 636388
BytebuddyAgent [candidate] (633.075 ms) : 0, 633075
AgentMeter [baseline] (29.792 ms) : 0, 29792
AgentMeter [candidate] (29.644 ms) : 0, 29644
GlobalTracer [baseline] (250.092 ms) : 0, 250092
GlobalTracer [candidate] (250.65 ms) : 0, 250650
AppSec [baseline] (32.544 ms) : 0, 32544
AppSec [candidate] (32.581 ms) : 0, 32581
Debugger [baseline] (59.389 ms) : 0, 59389
Debugger [candidate] (59.365 ms) : 0, 59365
Remote Config [baseline] (595.931 µs) : 0, 596
Remote Config [candidate] (596.919 µs) : 0, 597
Telemetry [baseline] (8.054 ms) : 0, 8054
Telemetry [candidate] (8.825 ms) : 0, 8825
Flare Poller [baseline] (6.628 ms) : 0, 6628
Flare Poller [candidate] (6.743 ms) : 0, 6743
section iast
crashtracking [baseline] (1.243 ms) : 0, 1243
crashtracking [candidate] (1.236 ms) : 0, 1236
BytebuddyAgent [baseline] (808.836 ms) : 0, 808836
BytebuddyAgent [candidate] (805.921 ms) : 0, 805921
AgentMeter [baseline] (11.415 ms) : 0, 11415
AgentMeter [candidate] (11.377 ms) : 0, 11377
GlobalTracer [baseline] (238.77 ms) : 0, 238770
GlobalTracer [candidate] (238.152 ms) : 0, 238152
IAST [baseline] (29.97 ms) : 0, 29970
IAST [candidate] (30.027 ms) : 0, 30027
AppSec [baseline] (28.335 ms) : 0, 28335
AppSec [candidate] (29.468 ms) : 0, 29468
Debugger [baseline] (63.903 ms) : 0, 63903
Debugger [candidate] (63.22 ms) : 0, 63220
Remote Config [baseline] (535.925 µs) : 0, 536
Remote Config [candidate] (527.722 µs) : 0, 528
Telemetry [baseline] (7.731 ms) : 0, 7731
Telemetry [candidate] (7.713 ms) : 0, 7713
Flare Poller [baseline] (3.443 ms) : 0, 3443
Flare Poller [candidate] (3.471 ms) : 0, 3471
LoadParameters
See matching parameters
SummaryFound 2 performance improvements and 3 performance regressions! Performance is the same for 14 metrics, 17 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section baseline
no_agent (19.418 ms) : 19218, 19618
. : milestone, 19418,
appsec (18.577 ms) : 18393, 18761
. : milestone, 18577,
code_origins (17.842 ms) : 17664, 18021
. : milestone, 17842,
iast (18.215 ms) : 18030, 18399
. : milestone, 18215,
profiling (18.403 ms) : 18217, 18589
. : milestone, 18403,
tracing (17.944 ms) : 17765, 18124
. : milestone, 17944,
section candidate
no_agent (18.282 ms) : 18094, 18470
. : milestone, 18282,
appsec (18.601 ms) : 18415, 18786
. : milestone, 18601,
code_origins (17.717 ms) : 17542, 17892
. : milestone, 17717,
iast (17.693 ms) : 17517, 17868
. : milestone, 17693,
profiling (19.478 ms) : 19283, 19673
. : milestone, 19478,
tracing (18.843 ms) : 18650, 19036
. : milestone, 18843,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section baseline
no_agent (1.248 ms) : 1236, 1261
. : milestone, 1248,
iast (3.228 ms) : 3187, 3269
. : milestone, 3228,
iast_FULL (6.112 ms) : 6049, 6176
. : milestone, 6112,
iast_GLOBAL (3.642 ms) : 3581, 3703
. : milestone, 3642,
profiling (2.46 ms) : 2434, 2486
. : milestone, 2460,
tracing (1.88 ms) : 1864, 1896
. : milestone, 1880,
section candidate
no_agent (1.22 ms) : 1209, 1231
. : milestone, 1220,
iast (3.251 ms) : 3205, 3298
. : milestone, 3251,
iast_FULL (5.907 ms) : 5847, 5968
. : milestone, 5907,
iast_GLOBAL (3.702 ms) : 3637, 3767
. : milestone, 3702,
profiling (2.091 ms) : 2073, 2108
. : milestone, 2091,
tracing (1.876 ms) : 1861, 1891
. : milestone, 1876,
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 tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section baseline
no_agent (1.492 ms) : 1480, 1503
. : milestone, 1492,
appsec (3.873 ms) : 3648, 4097
. : milestone, 3873,
iast (2.284 ms) : 2214, 2354
. : milestone, 2284,
iast_GLOBAL (2.322 ms) : 2251, 2392
. : milestone, 2322,
profiling (2.543 ms) : 2378, 2708
. : milestone, 2543,
tracing (2.084 ms) : 2029, 2138
. : milestone, 2084,
section candidate
no_agent (1.492 ms) : 1480, 1503
. : milestone, 1492,
appsec (3.855 ms) : 3632, 4078
. : milestone, 3855,
iast (2.272 ms) : 2203, 2342
. : milestone, 2272,
iast_GLOBAL (2.322 ms) : 2252, 2392
. : milestone, 2322,
profiling (2.096 ms) : 2041, 2152
. : milestone, 2096,
tracing (2.081 ms) : 2027, 2135
. : milestone, 2081,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.62.0-SNAPSHOT~240ac19f6e, baseline=1.62.0-SNAPSHOT~534f75e4d6
dateFormat X
axisFormat %s
section baseline
no_agent (15.624 s) : 15624000, 15624000
. : milestone, 15624000,
appsec (14.95 s) : 14950000, 14950000
. : milestone, 14950000,
iast (18.591 s) : 18591000, 18591000
. : milestone, 18591000,
iast_GLOBAL (18.119 s) : 18119000, 18119000
. : milestone, 18119000,
profiling (15.058 s) : 15058000, 15058000
. : milestone, 15058000,
tracing (14.834 s) : 14834000, 14834000
. : milestone, 14834000,
section candidate
no_agent (15.437 s) : 15437000, 15437000
. : milestone, 15437000,
appsec (14.719 s) : 14719000, 14719000
. : milestone, 14719000,
iast (18.661 s) : 18661000, 18661000
. : milestone, 18661000,
iast_GLOBAL (17.684 s) : 17684000, 17684000
. : milestone, 17684000,
profiling (14.82 s) : 14820000, 14820000
. : milestone, 14820000,
tracing (14.641 s) : 14641000, 14641000
. : milestone, 14641000,
|
| | Phase | Scope | What happens | | ||
| |---|---|---| | ||
| | `@BeforeAll initAll()` | Once per class | Creates tracer + writer, installs ByteBuddy agent | | ||
| | `@BeforeEach init()` | Per test | Flushes tracer, resets writer | | ||
| | `@AfterEach tearDown()` | Per test | Flushes tracer | | ||
| | `@AfterAll tearDownAll()` | Once per class | Closes tracer, removes agent transformer | |
There was a problem hiding this comment.
nit: Apply reformat table in IDEA? Here and other tables too.
I know that MD will be rendered correctly, but I personally often read them as pure text...
There was a problem hiding this comment.
Sure thing, will do
| // Properties | ||
| .operationName("http.request") // exact match | ||
| .operationName(Pattern.compile("http.*"))// regex match | ||
| .resourceName("GET /api") // exact match | ||
| .serviceName("my-service") // exact match | ||
| .type("web") // span type |
There was a problem hiding this comment.
nit, apply some spaces:
| // Properties | |
| .operationName("http.request") // exact match | |
| .operationName(Pattern.compile("http.*"))// regex match | |
| .resourceName("GET /api") // exact match | |
| .serviceName("my-service") // exact match | |
| .type("web") // span type | |
| // Properties | |
| .operationName("http.request") // exact match | |
| .operationName(Pattern.compile("http.*")) // regex match | |
| .resourceName("GET /api") // exact match | |
| .serviceName("my-service") // exact match | |
| .type("web") // span type |
There was a problem hiding this comment.
I aligned all comments, not only the ones for this block
| validates(v -> ...) // custom predicate | ||
| any() // accept anything |
There was a problem hiding this comment.
nit: some formatting:
| validates(v -> ...) // custom predicate | |
| any() // accept anything | |
| validates(v -> ...) // custom predicate | |
| any() // accept anything |
| @@ -0,0 +1,350 @@ | |||
| # How to Test With JUnit Guide | |||
|
|
|||
| This guide covers the JUnit 5 testing utilities for writing instrumentation and unit tests. | |||
There was a problem hiding this comment.
praise: This dc is great, I would however add two items that we find in spock tests: mocks and parameterized tests.
About the order I suggest
- Parameterized tests
- Mocks
- Assertion API
- Config
I wonder do we want to follow the "BDD" style, to match what spock did, e.g. with comments
void should_do_this_thing() {
// given
prepare the setup
// when
the tested method, behavior
// then
the assertions
}
There was a problem hiding this comment.
I added the parametrized tests for now as we did some custom work about @TableTest.
About mocks, I left it aside for now as we don't have customization for, so the default documentation should still apply.
About the BDD style, I would rather not re-introduce the "spock style" while my whole effort is to get alternative "JUnit style" capabilities. But if you think it's needed, maybe it could go into the migration guide?
| ### Tag matching | ||
|
|
||
| ```java | ||
| // Default DD tags (thread name, runtime ID, sampling, etc.) | ||
| defaultTags() | ||
|
|
||
| // Exact value | ||
| tag("http.status", is(200)) | ||
|
|
||
| // Custom validation | ||
| tag("response.body", validates(v -> ((String) v).contains("success"))) | ||
|
|
||
| // Any value (just check presence) | ||
| tag("custom.tag", any()) | ||
|
|
||
| // Error tags from exception | ||
| error(IOException.class) | ||
| error(IOException.class, "Connection refused") | ||
| error(new IOException("Connection refused")) | ||
|
|
||
| // Check tag presence without value check | ||
| includes("tag1", "tag2") | ||
| ``` | ||
|
|
||
| ### Value matchers | ||
|
|
||
| ```java | ||
| is("expected") // equality | ||
| isNull() // null check | ||
| isNonNull() // non-null check | ||
| isTrue() // boolean true | ||
| isFalse() // boolean false | ||
| matches("regex.*") // regex match | ||
| matches(Pattern.compile("...")) | ||
| validates(v -> ...) // custom predicate | ||
| any() // accept anything | ||
| ``` |
There was a problem hiding this comment.
suggestion: Maybe format that as a list
AlexeyKuznetsov-DD
left a comment
There was a problem hiding this comment.
LGTM. Left very minor formatting comments.
1d931de to
9d9228c
Compare
fe6b741 to
5e10aca
Compare
5e10aca to
240ac19
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings. Use
The expected merge time in Use ⏳ waiting for a build ahead of yours to finish |
What Does This Do
This PR introduces documentation about JUnit testing tools for instrumentation tests.
It can help refining the usage and the API. It's still very early but it's getting progress.
I would recommend to use the "..." menu and use "view file" while reviewing to render the markdown.
Motivation
Help discovering the new testing features.
Additional Notes
This PR is part of some bigger improvements in stacked PRs:
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: APMLP-1247
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.