Created
April 8, 2025 08:47
-
-
Save polarnik/29a9d730c07fbfaa3a61cbd6355a2de5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.jetbrains.youtrack.perftest.scenario.test; | |
| import io.gatling.javaapi.core.*; | |
| import lombok.extern.slf4j.Slf4j; | |
| import java.util.function.Function; | |
| import static io.gatling.javaapi.core.CoreDsl.*; | |
| @Slf4j | |
| public class Chain { | |
| private Function<Session, Session> init = session -> { | |
| log.info("init"); | |
| int integer_value = 1000; | |
| log.info("init {}", integer_value); | |
| return session.set("integer_value", integer_value); | |
| }; | |
| private Function<Session, Session> step_plus_001 = session -> { | |
| log.info("step_plus_001"); | |
| log.info("step_plus_001 {}", session.getInt("integer_value")); | |
| int integer_value = session.getInt("integer_value"); | |
| return session.set("integer_value", integer_value + 1); | |
| }; | |
| private Function<Session, Session> step_plus_010 = session -> { | |
| log.info("step_plus_010"); | |
| log.info("step_plus_010 {}", session.getInt("integer_value")); | |
| int integer_value = session.getInt("integer_value"); | |
| return session.set("integer_value", integer_value + 10); | |
| }; | |
| private Function<Session, Session> step_plus_100 = session -> { | |
| log.info("step_plus_100"); | |
| log.info("step_plus_100 {}", session.getInt("integer_value")); | |
| int integer_value = session.getInt("integer_value"); | |
| return session.set("integer_value", integer_value + 100); | |
| }; | |
| private Function<Session, Session> check = session -> { | |
| log.info("check"); | |
| log.info("check {}", session.getInt("integer_value")); | |
| return session; | |
| }; | |
| private ScenarioBuilder chain_with_comma_user() { | |
| return CoreDsl.scenario("chain_with_comma_user") | |
| .exec(init) | |
| .exec( | |
| exec(step_plus_001), | |
| exec(step_plus_010), | |
| exec(step_plus_100) | |
| ) | |
| .exec(check) | |
| ; | |
| } | |
| private ScenarioBuilder chain_with_dot_user() { | |
| return CoreDsl.scenario("chain_with_dot_user") | |
| .exec(init) | |
| .exec( | |
| exec(step_plus_001). | |
| exec(step_plus_010). | |
| exec(step_plus_100) | |
| ) | |
| .exec(check) | |
| ; | |
| } | |
| public PopulationBuilder chain_with_comma() { | |
| return chain_with_comma_user() | |
| .injectOpen(CoreDsl.atOnceUsers(1) | |
| ) | |
| ; | |
| } | |
| public PopulationBuilder chain_with_dot() { | |
| return chain_with_dot_user() | |
| .injectOpen(CoreDsl.atOnceUsers(1) | |
| ) | |
| ; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.jetbrains.youtrack.perftest.simulation.test; | |
| import com.jetbrains.youtrack.perftest.scenario.test.Chain; | |
| import io.gatling.javaapi.core.Simulation; | |
| import lombok.extern.slf4j.Slf4j; | |
| @Slf4j | |
| public class CommaSimulation extends Simulation { | |
| { | |
| setUp( | |
| new Chain().chain_with_comma() | |
| ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.jetbrains.youtrack.perftest.simulation.test; | |
| import com.jetbrains.youtrack.perftest.scenario.test.Chain; | |
| import io.gatling.javaapi.core.Simulation; | |
| import lombok.extern.slf4j.Slf4j; | |
| @Slf4j | |
| public class DotSimulation extends Simulation { | |
| { | |
| setUp( | |
| new Chain().chain_with_dot() | |
| ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.jetbrains; | |
| import io.gatling.app.Gatling; | |
| import io.gatling.shared.cli.CliOption; | |
| import io.gatling.shared.cli.GatlingCliOptions; | |
| import org.slf4j.LoggerFactory; | |
| import ch.qos.logback.classic.Level; | |
| import ch.qos.logback.classic.Logger; | |
| import org.testng.annotations.*; | |
| import lombok.extern.slf4j.Slf4j; | |
| @Slf4j | |
| public class GatlingTest { | |
| void runSimulation(Class simulationClass) { | |
| runSimulation(simulationClass, ""); | |
| } | |
| void runSimulation(Class simulationClass, String description) { | |
| String[] gatlingArgs = { | |
| config(GatlingCliOptions.Simulation, simulationClass.getCanonicalName()), | |
| config(GatlingCliOptions.ResultsFolder, "target/load-test-results"), | |
| config(GatlingCliOptions.RunDescription, description) | |
| }; | |
| Gatling.main(gatlingArgs); | |
| } | |
| private String config(CliOption option, String value) { | |
| return "--" + option.longName + "=" + value; | |
| } | |
| @Test | |
| public void test_DotSimulation() { | |
| System.setProperty("gatling.ssl.useOpenSsl", "false"); | |
| runSimulation(DotSimulation.class); | |
| } | |
| @Test | |
| public void test_CommaSimulation() { | |
| System.setProperty("gatling.ssl.useOpenSsl", "false"); | |
| runSimulation(CommaSimulation.class); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Simulation com.jetbrains.youtrack.perftest.simulation.test.CommaSimulation started... | |
| 2025-04-08 10:46:49.561 [INFO ] io.gatling.core.stats.writer.ConsoleDataWriter - Initializing | |
| 2025-04-08 10:46:49.561 [INFO ] io.gatling.core.stats.writer.LogFileDataWriter - Initializing | |
| 2025-04-08 10:46:49.563 [INFO ] io.gatling.core.stats.writer.ConsoleDataWriter - Initialized | |
| 2025-04-08 10:46:49.563 [INFO ] io.gatling.core.stats.writer.LogFileDataWriter - Initialized | |
| 2025-04-08 10:46:49.566 [INFO ] io.gatling.core.controller.inject.open.OpenWorkload - Scenario io.gatling.core.scenario.Scenario@2d7ad049 has finished injecting | |
| 2025-04-08 10:46:49.567 [INFO ] io.gatling.core.controller.inject.Injector - All scenarios have finished injecting | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - init | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - init 1000 | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_001 | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_001 1000 | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_010 | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_010 1001 | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_100 | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_100 1011 | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - check | |
| 2025-04-08 10:46:49.567 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - check 1111 | |
| Simulation com.jetbrains.youtrack.perftest.simulation.test.DotSimulation started... | |
| 2025-04-08 10:46:12.454 [INFO ] io.gatling.core.stats.writer.ConsoleDataWriter - Initializing | |
| 2025-04-08 10:46:12.454 [INFO ] io.gatling.core.stats.writer.LogFileDataWriter - Initializing | |
| 2025-04-08 10:46:12.456 [INFO ] io.gatling.core.stats.writer.ConsoleDataWriter - Initialized | |
| 2025-04-08 10:46:12.457 [INFO ] io.gatling.core.stats.writer.LogFileDataWriter - Initialized | |
| 2025-04-08 10:46:12.461 [INFO ] io.gatling.core.controller.inject.open.OpenWorkload - Scenario io.gatling.core.scenario.Scenario@58374fd2 has finished injecting | |
| 2025-04-08 10:46:12.461 [INFO ] io.gatling.core.controller.inject.Injector - All scenarios have finished injecting | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - init | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - init 1000 | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_001 | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_001 1000 | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_010 | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_010 1001 | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_100 | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - step_plus_100 1011 | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - check | |
| 2025-04-08 10:46:12.462 [INFO ] com.jetbrains.youtrack.perftest.scenario.test.Chain - check 1111 | |
| 2025-04-08 10:46:12.465 [INFO ] io.gatling.core.controller.inject.Injector - All users of scenario ch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment