Skip to content

Commit

Permalink
Added basic get scenario
Browse files Browse the repository at this point in the history
Closes #512

Co-authored-by: Alexander Schwartz <aschwart@redhat.com>
  • Loading branch information
stianst and ahus1 authored Aug 31, 2023
1 parent d3bab58 commit d28f113
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 2 deletions.
5 changes: 5 additions & 0 deletions benchmark/src/main/java/org/keycloak/benchmark/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ class KeycloakScenarioBuilder {
this
}


def serviceAccountToken(): KeycloakScenarioBuilder = {
chainBuilder = chainBuilder
.exec(getServiceAccountTokenExec())
Expand Down Expand Up @@ -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
}
}

10 changes: 10 additions & 0 deletions benchmark/src/main/scala/keycloak/scenario/basic/Get.scala
Original file line number Diff line number Diff line change
@@ -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())
}
1 change: 1 addition & 0 deletions doc/benchmark/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
4 changes: 4 additions & 0 deletions doc/benchmark/modules/ROOT/pages/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/benchmark/modules/ROOT/pages/scenario-overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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=<admin login>` and `--admin-password=<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

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
36 changes: 36 additions & 0 deletions doc/benchmark/modules/ROOT/pages/scenario/basic-get.adoc
Original file line number Diff line number Diff line change
@@ -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[]

0 comments on commit d28f113

Please sign in to comment.