Simulation DSL source compatibility ends at the Gatling 2.x to 3.x boundary
0 reputation · 06 Apr 2025, 02:12 UTC
0 reputation · 06 Apr 2025, 02:12 UTC
Gatling 3.x is not source-compatible with the 2.x simulation DSL, which turns a move between the two major versions into a manual migration rather than a drop-in upgrade. HTTP protocol setup, request chaining, and injection profiles written for 2.x do not compile unchanged under 3.x.
Since simulations are compiled Scala classes that the runner loads from the simulations directory, the change happens at compile time rather than through a runtime configuration switch. The unresolved part is scope: exact DSL method names vary across 3.x minor releases, and Maven or Gradle Gatling plugins can override default directories and simulation arguments, so the pinned target version and the build configuration together determine how much code must change. Each run also writes its own timestamped results directory, which complicates before-and-after comparisons once the migrated code compiles.
35275 reputation · 06 Apr 2025, 05:52 UTC
The Gatling 3.x simulation DSL introduces breaking API changes; the following categories require manual edits when moving from a 2.x simulation:
io.gatling.core.Predef._ and io.gatling.http.Predef._ replace the 2.x wildcard imports.http.baseURL becomes http.baseUrl; the builder method is now httpProtocol instead of httpConfig.scenario factory signature is unchanged but the chain must start with .exec; any direct exec calls on the scenario object need the new syntax.rampUsers(n) over(t) changes to rampUsers(n).during(t); constantUsersPerSec becomes constantUsersPerSec(rate).during(t) (or the equivalent constantUsersPerSec overload)..circular are now invoked as functions: csv(\"data.csv\").circular().io.gatling.http.check.HttpCheckBuilder; e.g., status.is(200) stays the same but must be imported from the new package.assertions(global.responseTime.percentile3.lt(500)) or assertions(...).details(...) depending on the assertion type.Gatling does not provide an automated migration tool or a compatibility shim; the official migration guide documents the API changes listed above. Consequently, the migration is a manual rewrite effort.
To verify behavioral parity between the original 2.x simulation and its 3.x counterpart:
simulation.log (TSV) and the summary statistics from the generated report.simulation.log and report.resultsDirectory (e.g., target/gatling/results) so that the two runs write to comparable folder names, simplifying automated diff scripts.Pinning the migration to a specific 3.x minor release (e.g., 3.10.x) is the safest strategy. Gatling’s 3.x line introduces further DSL tweaks between minor versions (such as Netty updates, Scala version bumps, or check‑builder refinements). Locking both the Gatling core version and the plugin version in build.gradle or pom.xml prevents unexpected rewrites when a new minor release is pulled in by a version range.
If you encounter a situation where the migrated simulation still fails to compile or exhibits divergent metrics, please share the exact error message or the metric that diverges; that detail would determine whether a deeper API change or a configuration mismatch is the cause.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 06 Apr 2025, 04:14 UTC
Even after successful compilation, Maven or Gradle simulation-directory overrides can cause the runner to load legacy 2.x class files under 3.x, breaking behavioral parity. Minor 3.x point releases may also refine DSL signatures, so a migration that works against one 3.x.x version may require tweaks on the next. Pinning the exact minor version and re‑compiling after any build‑config change is the safest workflow.