Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions benchmark/src/main/java/org/keycloak/benchmark/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ public class Config {

// user-crawl-scenario properties
/**
* The amount of users to be requested for each page. This number is only used in the user crawl scenario.
* The amount of entries to be requested for each page. This number is only used in scenarios that support pagination.
*/
public static final int userPageSize = Integer.getInteger("user-page-size", 20);
public static final int pagesSize = Integer.getInteger("pages-size", 20);

/**
* The number of pages to iterate over. This number is only used in the user crawl scenario.
* The number of pages to iterate over. This number is only used in scenarios that support pagination.
*/
public static final int userNumberOfPages = Integer.getInteger("user-number-of-pages", 10);
public static final int pagesTotal = Integer.getInteger("pages-total", 10);

// join-group-scenario properties
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,27 @@ class KeycloakScenarioBuilder {
this
}

def viewPagesOfClients(pageSize: Int, numberOfPages: Int): KeycloakScenarioBuilder = {
chainBuilder = chainBuilder
.repeat(numberOfPages, "page") {
exec(session => {
session.set("max", pageSize)
.set("first", session("page").as[Int] * pageSize)
})
.doIf(s => needTokenRefresh(s)) {
getServiceAccountTokenExec()
}
.exec(http("#{realm}/clients?first=#{first}&max=#{max}")
.get(ADMIN_ENDPOINT + "/clients")
.header("Authorization", "Bearer #{token}")
.queryParam("first", "#{first}")
.queryParam("max", "#{max}")
.check(status.is(200)))
.exitHereIfFailed
}
this
}

def createUser(): KeycloakScenarioBuilder = {
chainBuilder = chainBuilder
.feed(Iterator.continually(Map("username" -> randomUUID())))
Expand Down
11 changes: 11 additions & 0 deletions benchmark/src/main/scala/keycloak/scenario/admin/ListClients.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package keycloak.scenario.admin

import keycloak.scenario.{CommonSimulation, KeycloakScenarioBuilder}
import org.keycloak.benchmark.Config

class ListClients extends CommonSimulation {

setUp("List Clients", new KeycloakScenarioBuilder()
.serviceAccountToken()
.viewPagesOfClients(Config.pagesSize, Config.pagesTotal))
}
11 changes: 11 additions & 0 deletions benchmark/src/main/scala/keycloak/scenario/admin/ListUsers.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package keycloak.scenario.admin

import keycloak.scenario.{CommonSimulation, KeycloakScenarioBuilder}
import org.keycloak.benchmark.Config

class ListUsers extends CommonSimulation {

setUp("List Users", new KeycloakScenarioBuilder()
.serviceAccountToken()
.viewPagesOfUsers(Config.pagesSize, Config.pagesTotal))
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UserCrawl extends CommonSimulation {

val userCrawlScenarioBuilder = new KeycloakScenarioBuilder()
.serviceAccountToken()
.viewPagesOfUsers(Config.userPageSize, Config.userNumberOfPages)
.viewPagesOfUsers(Config.pagesSize, Config.pagesTotal)

val userCrawlScenario = scenario("User Crawl").exec(userCrawlScenarioBuilder.chainBuilder)

Expand Down