Skip to content

#6295 Document running Kotlin DSL test plans - #6858

Open
orimarko wants to merge 5 commits into
apache:masterfrom
orimarko:gh6295-kotlin-dsl-example
Open

orimarko wants to merge 5 commits into
apache:masterfrom
orimarko:gh6295-kotlin-dsl-example

Conversation

@orimarko

@orimarko orimarko commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Document how to run a Kotlin DSL test plan

Motivation and Context

Part of #6295

Document how to execute a test plan built with the Kotlin DSL and write
sample results to a JTL file. Add a test that builds and runs a plan,
waits for completion, and checks the generated results.

How Has This Been Tested?

./gradlew :src:components:test --tests "*KotlinDslRunTest"

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

@milamberspace milamberspace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on #6295, documenting how to actually run a DSL-built plan is a real gap in this page.

Main points

  1. The new doc section has no code sample. Every other section of this page comes with a <source> block, and the issue reporter explicitly asked for the equivalent of the Java DSL jtlWriter(...) example. As it stands, readers still have to guess configure / runTest / awaitTermination and how to set the JTL path, which is what the issue complained about. See the inline suggestion.
  2. The test largely duplicates OpenModelThreadGroupConfigElementTest (same plan, same scheduleString, same DebugSampler, same engine/await sequence); only the ResultCollector and the JTL check are new. Its main value would be to guarantee that the documented snippet compiles and runs, so I'd suggest keeping the doc snippet and the test code in sync (same code, same idioms). Alternatively, the JTL assertions could be added to the existing test. The threads.openmodel package is also a slightly odd home for a test whose purpose is the DSL usage example.

Minor

  • The JTL check results.contains("Kotlin DSL sample") passes as soon as a single line is written; asserting 5 data lines (plus header) would verify that all samples were persisted.
  • The blank line that used to separate the two sections ended up inside the new section; there's now no blank line between </section> and <section name="Extending Kotlin DSL">.

@orimarko orimarko left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milamberspace Thank you for reviewing, I fixed the issues and move test to package kotlin/org/apache/jmeter/dsl

@milamberspace milamberspace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! The documentation now has a proper code sample, the test lives in a better place, and the snippet uses the idiomatic DSL style.

Two things are still needed, and one is a regression introduced by keeping the test in sync with the docs (my earlier wording probably encouraged that, sorry):

  1. The test no longer asserts anything. All the assertions (number of samples, JTL file content) were removed, so the test would pass even if no sample was run and no file was written. The plan-building code can stay identical to the documentation, but the assertions should come back after it.
  2. The test writes into the source tree. filename = "target/results.jtl" is relative, and Gradle runs the tests from the module directory, so each run creates src/components/target/results.jtl. The repository .gitignore only ignores the top-level /target/, so that file shows up as untracked for contributors. The documentation can keep target/results.jtl, but the test should use a @TempDir.

See the inline comment for a version of the test I ran locally against this branch (passes, and leaves nothing behind).

  1. Minor: the indentation of the <source> block in the documentation is inconsistent (nested blocks are misaligned, and the block starts with 8 spaces whereas the other samples of the page start at column 0). There is a suggestion inline.

Generated-by: GitHub Copilot

@vlsi vlsi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F1 blocks the merge for me: a reader who pastes the new sample into their own program, rather than into a JMeter test that extends JMeterTestCase, gets a NullPointerException from awaitTermination and no JTL file.

F1, F2 and F3 are one change: make the page's sample the code a test compiles and runs without what JMeterTestCase prepares, so the setup and imports it needs show up on the page. The rest are small.

Not inline

F11 nit The description says "Part of #6295" without naming what of the issue stays open: JMeter functions such as __groovy in HTTPSamplerProxy fields, and referencing existing elements with ModuleController.

Problem: A maintainer deciding whether #6295 can close after the merge cannot tell which of its points this change answers; the author's plan for the rest lives only in an issue comment.

Reviewed at b6c92cbb.

Generated-by: GitHub Copilot
@orimarko
orimarko force-pushed the gh6295-kotlin-dsl-example branch from 387b41b to 65686d3 Compare December 5, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants