diff --git a/benchmark/src/main/java/org/keycloak/benchmark/Config.java b/benchmark/src/main/java/org/keycloak/benchmark/Config.java index d94badcf8..a5ddcd909 100644 --- a/benchmark/src/main/java/org/keycloak/benchmark/Config.java +++ b/benchmark/src/main/java/org/keycloak/benchmark/Config.java @@ -75,6 +75,11 @@ public class Config { */ public static final String scope = System.getProperty("scope"); + /** + * Used to specify basic endpoint to get + */ + public static final String basicUrl = System.getProperty("basic-url"); + public static final Double usersPerSec; public static final Integer concurrentUsers; diff --git a/benchmark/src/main/scala/keycloak/scenario/KeycloakScenarioBuilder.scala b/benchmark/src/main/scala/keycloak/scenario/KeycloakScenarioBuilder.scala index 951a1528a..a0574833a 100644 --- a/benchmark/src/main/scala/keycloak/scenario/KeycloakScenarioBuilder.scala +++ b/benchmark/src/main/scala/keycloak/scenario/KeycloakScenarioBuilder.scala @@ -324,7 +324,6 @@ class KeycloakScenarioBuilder { this } - def serviceAccountToken(): KeycloakScenarioBuilder = { chainBuilder = chainBuilder .exec(getServiceAccountTokenExec()) @@ -750,5 +749,15 @@ class KeycloakScenarioBuilder { } this } + + def basicGet(endpoint: String): KeycloakScenarioBuilder = { + chainBuilder = chainBuilder + .exec(http("Hello") + .get(endpoint) + .header("Accept", "*/*") + .check(status.is(200))) + .exitHereIfFailed + this + } } diff --git a/benchmark/src/main/scala/keycloak/scenario/basic/Get.scala b/benchmark/src/main/scala/keycloak/scenario/basic/Get.scala new file mode 100644 index 000000000..1f6e66e89 --- /dev/null +++ b/benchmark/src/main/scala/keycloak/scenario/basic/Get.scala @@ -0,0 +1,10 @@ +package keycloak.scenario.basic + +import keycloak.scenario.{CommonSimulation, KeycloakScenarioBuilder} +import org.keycloak.benchmark.Config + +class Get extends CommonSimulation { + setUp("Get - " + Config.basicUrl, new KeycloakScenarioBuilder() + .basicGet(Config.basicUrl) + .userThinkPause()) +} diff --git a/doc/benchmark/modules/ROOT/nav.adoc b/doc/benchmark/modules/ROOT/nav.adoc index 2192a8909..f20041678 100644 --- a/doc/benchmark/modules/ROOT/nav.adoc +++ b/doc/benchmark/modules/ROOT/nav.adoc @@ -18,6 +18,7 @@ ** xref:scenario/authorization-code.adoc[] ** xref:scenario/list-sessions.adoc[] ** xref:scenario/create-realms.adoc[] +** xref:scenario/basic-get.adoc[] * xref:configuration.adoc[] * xref:release.adoc[] * xref:error-messages.adoc[] diff --git a/doc/benchmark/modules/ROOT/pages/configuration.adoc b/doc/benchmark/modules/ROOT/pages/configuration.adoc index fe08e3809..03071fcef 100644 --- a/doc/benchmark/modules/ROOT/pages/configuration.adoc +++ b/doc/benchmark/modules/ROOT/pages/configuration.adoc @@ -251,6 +251,10 @@ Please refer to the xref:scenario-overview.adoc[scenario overview] to review the | Percentage of users to log out at the end of the scenario. Used in xref:scenario/authorization-code.adoc[]. +| [[basic-url]][.nowrap]`--basic-url` +| (not set) +| URL to be called in the xref:scenario/basic-get.adoc[]. + |=== == Further reading diff --git a/doc/benchmark/modules/ROOT/pages/scenario-overview.adoc b/doc/benchmark/modules/ROOT/pages/scenario-overview.adoc index e2d8d66dd..9144187b1 100644 --- a/doc/benchmark/modules/ROOT/pages/scenario-overview.adoc +++ b/doc/benchmark/modules/ROOT/pages/scenario-overview.adoc @@ -37,3 +37,5 @@ xref:scenario/create-realms.adoc[`keycloak.scenario.admin.CreateRealms`]:: Creat xref:scenario/create-realms.adoc[`keycloak.scenario.admin.CreateDeleteRealms`]:: Create and immediately delete realms (requires `--admin-username=` and `--admin-password=`) +xref:scenario/basic-get.adoc[`keycloak.scenario.basic.Get`]:: Repeatedly call a specific URL with HTTP GET and report and check the status code + diff --git a/doc/benchmark/modules/ROOT/pages/scenario/authorization-code.adoc b/doc/benchmark/modules/ROOT/pages/scenario/authorization-code.adoc index 1e6d28ea2..25ac3193e 100644 --- a/doc/benchmark/modules/ROOT/pages/scenario/authorization-code.adoc +++ b/doc/benchmark/modules/ROOT/pages/scenario/authorization-code.adoc @@ -16,7 +16,7 @@ See the source code at link:{github-files}/benchmark/src/main/scala/keycloak/sce == Running an example scenario -=== Prerequisites: +=== Prerequisites * Keycloak is running. * Realm, user and client exist with the values listed on the CLI. diff --git a/doc/benchmark/modules/ROOT/pages/scenario/basic-get.adoc b/doc/benchmark/modules/ROOT/pages/scenario/basic-get.adoc new file mode 100644 index 000000000..9f99bb0da --- /dev/null +++ b/doc/benchmark/modules/ROOT/pages/scenario/basic-get.adoc @@ -0,0 +1,36 @@ += Scenario Get +:description: Repeatedly call a specific URL and report timing and check the response code. + +{description} + +See xref:scenario-overview.adoc[] for a list of all scenarios. + +== Steps of the scenario + +. Call the URL provided via the xref:configuration.adoc#basic-url[on the CLI] with HTTP GET and check the status code to be `200`. + +See the source code at link:{github-files}/benchmark/src/main/scala/keycloak/scenario/basic/Get.scala[Get.scala] for details. + +== Running an example scenario + +=== Prerequisites + +* Target URL known. + +=== Running the scenario + +The following scenario runs with the default settings for 30 seconds. + +See xref:configuration.adoc[] for additional CLI options. + +[source,bash] +---- +bin/kcb.sh \ + --scenario=keycloak.scenario.basic.Get \ + --basic-url=http://localhost:8080/ \ + --log-http-on-failure +---- + +== Further Reading + +* xref:run/running-benchmark-cli.adoc[]