From bd4acfe4c68b0f00ca7975fa2abe392c8f989f66 Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Thu, 15 Dec 2022 14:43:24 +0100 Subject: [PATCH] Removing testsuite/performance from main Keycloak repository (#15950) There's a separate repository keycloak-benchmark for this. Closes #14192 --- .gitleaks.toml | 3 +- testsuite/performance/README.datasets.md | 152 --- .../performance/README.docker-compose.md | 35 - testsuite/performance/README.log-tool.md | 78 -- testsuite/performance/README.md | 354 ------- .../README.provisioning-parameters.md | 132 --- testsuite/performance/README.stress-test.md | 79 -- testsuite/performance/db-failover/README.md | 67 -- .../performance/db-failover/check-rows.sh | 22 - testsuite/performance/db-failover/common.sh | 18 - testsuite/performance/db-failover/concat.sql | 3 - .../performance/db-failover/kill-node.sh | 7 - testsuite/performance/db-failover/loop.sh | 35 - .../performance/db-failover/reconnect-node.sh | 7 - testsuite/performance/db-failover/setup.sh | 38 - testsuite/performance/db-failover/teardown.sh | 8 - testsuite/performance/db/mariadb/Dockerfile | 14 - testsuite/performance/db/mariadb/README.md | 1 - .../db/mariadb/docker-entrypoint-wsrep.sh | 22 - .../db/mariadb/mariadb-healthcheck.sh | 25 - .../performance/db/mariadb/wsrep.cnf.template | 30 - .../docker-compose-db-failover.yml | 101 -- .../performance/infinispan/infinispan.xml | 109 -- testsuite/performance/infinispan/pom.xml | 145 --- .../infinispan/src/main/scripts/Dockerfile | 19 - .../main/scripts/docker-entrypoint-custom.sh | 28 - .../infinispan/src/main/scripts/get-ips.sh | 37 - .../main/scripts/infinispan-healthcheck.sh | 12 - .../scripts/jboss-cli/add-keycloak-caches.cli | 32 - .../add-private-network-interface.cli | 33 - testsuite/performance/keycloak/configure.xml | 101 -- testsuite/performance/keycloak/pom.xml | 217 ---- .../keycloak/src/main/resources/module.xml | 31 - .../keycloak/src/main/scripts/Dockerfile | 29 - .../src/main/scripts/docker-entrypoint.sh | 17 - .../keycloak/src/main/scripts/get-ips.sh | 37 - .../jboss-cli/add-remote-cache-stores.cli | 26 - .../jboss-cli/distributed-cache-owners.cli | 13 - .../jboss-cli/infinispan-debug-logging.cli | 8 - .../jboss-cli/io-worker-threads-batch.cli | 5 - .../scripts/jboss-cli/io-worker-threads.cli | 7 - .../modcluster-simple-load-provider.cli | 7 - .../jboss-cli/set-keycloak-ds-batch.cli | 20 - .../scripts/jboss-cli/set-keycloak-ds.cli | 7 - .../main/scripts/jboss-cli/undertow-batch.cli | 2 - .../src/main/scripts/jboss-cli/undertow.cli | 9 - .../src/main/scripts/keycloak-healthcheck.sh | 11 - .../debug-advertise/Advertise.java | 75 -- .../load-balancer/debug-advertise/Dockerfile | 7 - .../debug-advertise/Dockerfile-client | 7 - .../load-balancer/debug-advertise/README.md | 4 - .../debug-advertise/SAdvertise.java | 60 -- .../wildfly-modcluster/configure.xml | 71 -- .../load-balancer/wildfly-modcluster/pom.xml | 155 --- .../src/main/scripts/Dockerfile | 28 - .../src/main/scripts/docker-entrypoint.sh | 14 - .../src/main/scripts/get-ips.sh | 37 - .../scripts/jboss-cli/io-worker-threads.cli | 7 - .../jboss-cli/mod-cluster-balancer.cli | 12 - .../src/main/scripts/jboss-cli/undertow.cli | 2 - .../src/main/scripts/wildfly-healthcheck.sh | 14 - .../monitoring/cadvisor/Dockerfile | 5 - .../performance/monitoring/cadvisor/README.md | 10 - .../monitoring/cadvisor/entrypoint.sh | 18 - .../performance/monitoring/grafana/Dockerfile | 8 - .../performance/monitoring/grafana/README.md | 9 - .../monitoring/grafana/entrypoint.sh | 41 - .../grafana/resource-usage-combined.json | 610 ------------ .../grafana/resource-usage-per-container.json | 669 ------------- testsuite/performance/pom.xml | 59 -- testsuite/performance/stress-test.sh | 179 ---- testsuite/performance/tests/common.sh | 6 - .../performance/tests/create-truststore.sh | 22 - testsuite/performance/tests/docker-compose.sh | 477 --------- testsuite/performance/tests/healthcheck.sh | 49 - testsuite/performance/tests/log-tool.sh | 6 - .../2cpus/singlenode.properties | 25 - .../docker-compose/4cpus/cluster.properties | 34 - .../docker-compose/4cpus/crossdc.properties | 44 - .../4cpus/singlenode.properties | 25 - .../parameters/test/admin-console.properties | 8 - .../test/oidc-login-logout.properties | 10 - .../test/oidc-register-logout.properties | 10 - testsuite/performance/tests/pom.xml | 854 ---------------- .../tests/prepare-provisioning.xml | 24 - testsuite/performance/tests/sar.sh | 132 --- .../cluster/docker-compose-base.yml | 55 - .../cluster/docker-compose-keycloak.yml | 35 - .../crossdc/docker-compose-base.yml | 160 --- .../crossdc/docker-compose-keycloak_dc1.yml | 43 - .../crossdc/docker-compose-keycloak_dc2.yml | 40 - .../docker-compose-monitoring.yml | 79 -- .../main/docker-compose/docker-compose.yml | 59 -- .../tests/src/main/gnuplot/jstat/common.gp | 17 - .../tests/src/main/gnuplot/jstat/gc-all.gp | 8 - .../tests/src/main/gnuplot/jstat/gc-cc.gp | 2 - .../tests/src/main/gnuplot/jstat/gc-e.gp | 2 - .../tests/src/main/gnuplot/jstat/gc-ev.gp | 3 - .../tests/src/main/gnuplot/jstat/gc-m.gp | 2 - .../tests/src/main/gnuplot/jstat/gc-o.gp | 2 - .../tests/src/main/gnuplot/jstat/gc-s0.gp | 2 - .../tests/src/main/gnuplot/jstat/gc-s1.gp | 2 - .../tests/src/main/gnuplot/jstat/gc-t.gp | 3 - .../tests/src/main/gnuplot/sar/common.gplot | 11 - .../tests/src/main/gnuplot/sar/cpu.gplot | 11 - .../tests/src/main/gnuplot/sar/cswch.gplot | 2 - .../tests/src/main/gnuplot/sar/io-data.gplot | 5 - .../src/main/gnuplot/sar/io-requests.gplot | 5 - .../tests/src/main/gnuplot/sar/mem.gplot | 8 - .../tests/src/main/gnuplot/sar/net.gplot | 6 - .../org/keycloak/gatling/MockHttpFacade.java | 171 ---- .../gatling/MockRequestAuthenticator.java | 49 - .../org/keycloak/gatling/MockTokenStore.java | 43 - .../org/keycloak/gatling/log/LogLine.java | 184 ---- .../keycloak/gatling/log/LogProcessor.java | 443 --------- .../org/keycloak/gatling/log/LogReader.java | 30 - .../java/org/keycloak/gatling/log/Stats.java | 102 -- .../org/keycloak/performance/ClientInfo.java | 20 - .../org/keycloak/performance/RealmConfig.java | 14 - .../RealmsConfigurationBuilder.java | 338 ------- .../RealmsConfigurationLoader.java | 936 ------------------ .../org/keycloak/performance/TestConfig.java | 334 ------- .../org/keycloak/performance/UserInfo.java | 21 - .../performance/dataset/Creatable.java | 78 -- .../keycloak/performance/dataset/Dataset.java | 153 --- .../performance/dataset/DatasetLoader.java | 208 ---- .../dataset/DatasetRepresentation.java | 19 - .../keycloak/performance/dataset/Entity.java | 45 - .../performance/dataset/NestedEntity.java | 66 -- .../performance/dataset/Representable.java | 57 -- .../performance/dataset/Updatable.java | 25 - .../performance/dataset/attr/Attribute.java | 17 - .../dataset/attr/AttributeMap.java | 21 - .../dataset/attr/AttributeRepresentation.java | 28 - .../dataset/attr/StringAttribute.java | 21 - .../attr/StringAttributeRepresentation.java | 8 - .../dataset/attr/StringListAttribute.java | 21 - .../StringListAttributeRepresentation.java | 10 - .../performance/dataset/idm/Client.java | 80 -- .../performance/dataset/idm/ClientRole.java | 37 - .../dataset/idm/ClientRoleMappings.java | 40 - .../performance/dataset/idm/Credential.java | 53 - .../performance/dataset/idm/Group.java | 59 -- .../performance/dataset/idm/Realm.java | 119 --- .../performance/dataset/idm/RealmRole.java | 37 - .../performance/dataset/idm/Role.java | 63 -- .../performance/dataset/idm/RoleMapper.java | 23 - .../performance/dataset/idm/RoleMappings.java | 49 - .../idm/RoleMappingsRepresentation.java | 12 - .../performance/dataset/idm/User.java | 101 -- .../idm/authorization/ClientPolicy.java | 64 -- .../dataset/idm/authorization/JsPolicy.java | 52 - .../dataset/idm/authorization/Policy.java | 34 - .../dataset/idm/authorization/Resource.java | 79 -- .../idm/authorization/ResourcePermission.java | 72 -- .../idm/authorization/ResourceServer.java | 150 --- .../idm/authorization/ResourceServerList.java | 46 - .../dataset/idm/authorization/RolePolicy.java | 64 -- .../RolePolicyRoleDefinition.java | 22 - .../RolePolicyRoleDefinitionSet.java | 21 - .../dataset/idm/authorization/Scope.java | 63 -- .../idm/authorization/ScopePermission.java | 72 -- .../dataset/idm/authorization/UserPolicy.java | 64 -- .../iteration/FilteredIterator.java | 50 - .../iteration/Flattened2DList.java | 34 - .../performance/iteration/ListOfLists.java | 48 - .../iteration/LoopingIterator.java | 31 - .../performance/iteration/RandomBooleans.java | 54 - .../performance/iteration/RandomIntegers.java | 96 -- .../performance/iteration/RandomIterator.java | 29 - .../performance/iteration/RandomSublist.java | 53 - .../iteration/UniqueRandomIntegers.java | 41 - .../templates/DatasetTemplate.java | 96 -- .../templates/EntityObjectWrapper.java | 35 - .../performance/templates/EntityTemplate.java | 110 -- .../templates/EntityTemplateModel.java | 88 -- .../templates/NestedEntityTemplate.java | 61 -- .../templates/NestedEntityTemplateModel.java | 45 - .../NestedEntityTemplateWrapperList.java | 35 - .../attr/StringAttributeTemplate.java | 21 - .../attr/StringListAttributeTemplate.java | 30 - .../templates/idm/ClientRoleTemplate.java | 50 - .../templates/idm/ClientTemplate.java | 67 -- .../templates/idm/GroupTemplate.java | 85 -- .../templates/idm/RealmRoleTemplate.java | 50 - .../templates/idm/RealmTemplate.java | 87 -- .../templates/idm/UserTemplate.java | 184 ---- .../authorization/ClientPolicyTemplate.java | 62 -- .../idm/authorization/JsPolicyTemplate.java | 47 - .../idm/authorization/PolicyTemplate.java | 23 - .../ResourcePermissionTemplate.java | 81 -- .../authorization/ResourceServerTemplate.java | 101 -- .../idm/authorization/ResourceTemplate.java | 72 -- .../idm/authorization/RolePolicyTemplate.java | 130 --- .../ScopePermissionTemplate.java | 79 -- .../idm/authorization/ScopeTemplate.java | 44 - .../idm/authorization/UserPolicyTemplate.java | 62 -- .../CombinedConfigurationNoInterpolation.java | 23 - .../performance/util/ConfigurationUtil.java | 54 - .../keycloak/performance/util/Loggable.java | 27 - .../keycloak/performance/util/StringUtil.java | 32 - .../performance/util/ValidateNumber.java | 45 - .../tests/src/main/resources/logback.xml | 45 - .../util/InvalidatableRandomContainer.scala | 51 - .../org/jboss/perf/util/RandomContainer.scala | 92 -- .../main/scala/org/jboss/perf/util/Util.scala | 24 - .../org/keycloak/gatling/Authorize.scala | 123 --- .../scala/org/keycloak/gatling/Blocking.scala | 34 - .../org/keycloak/gatling/ExitOnFailure.scala | 20 - .../scala/org/keycloak/gatling/Oauth.scala | 12 - .../scala/org/keycloak/gatling/Predef.scala | 10 - .../org/keycloak/gatling/RefreshToken.scala | 33 - .../org/keycloak/gatling/Stopwatch.scala | 106 -- .../scala/org/keycloak/gatling/Utils.scala | 34 - .../keycloak/performance/AbstractTest.java | 13 - .../performance/dataset/DatasetTest.java | 109 -- .../performance/dataset/EntityTest.java | 101 -- .../dataset/idm/ClientRoleMappingsTest.java | 18 - .../dataset/idm/ClientRoleTest.java | 18 - .../performance/dataset/idm/ClientTest.java | 18 - .../dataset/idm/CredentialTest.java | 18 - .../dataset/idm/RealmRoleMappingsTest.java | 18 - .../dataset/idm/RealmRoleTest.java | 18 - .../performance/dataset/idm/RealmTest.java | 18 - .../performance/dataset/idm/UserTest.java | 18 - .../idm/authorization/ResourceServerTest.java | 18 - .../idm/authorization/ResourceTest.java | 18 - .../idm/authorization/RolePolicyTest.java | 23 - .../dataset/idm/authorization/ScopeTest.java | 18 - .../iteration/ListOfListsTest.java | 46 - .../iteration/RandomBooleansTest.java | 47 - .../iteration/RandomIntegersTest.java | 76 -- .../tests/src/test/resources/application.conf | 9 - .../tests/src/test/resources/bodies/.gitkeep | 0 .../dataset/100r_100c_100000u.properties | 68 -- .../dataset/100r_100c_100u.properties | 73 -- .../dataset/10r_50c_100000u.properties | 68 -- .../dataset/1r_100c_100000u.properties | 68 -- .../dataset/1r_100c_100000u_1hi.properties | 68 -- .../dataset/1r_100c_10000u.properties | 68 -- .../dataset/1r_100c_10000u_1hi.properties | 68 -- ..._1hi_10000res_100sc_100po_100pe.properties | 153 --- .../dataset/1r_100c_500000u_1hi.properties | 68 -- .../resources/dataset/1r_10c_100u.properties | 68 -- .../dataset/1r_10c_100u_1hi.properties | 68 -- .../dataset/authz/default.properties | 184 ---- .../test/resources/dataset/default.properties | 154 --- .../tests/src/test/resources/gatling.conf | 161 --- .../tests/src/test/resources/logback-test.xml | 40 - .../tests/src/test/scala/Engine.scala | 19 - .../tests/src/test/scala/IDEPathHelper.scala | 22 - .../tests/src/test/scala/Recorder.scala | 13 - .../test/scala/examples/SimpleExample1.scala | 27 - .../test/scala/examples/SimpleExample2.scala | 43 - .../test/scala/examples/SimpleExample3.scala | 25 - .../test/scala/examples/SimpleExample4.scala | 30 - .../AdminConsoleScenarioBuilder.scala | 632 ------------ .../keycloak/AdminConsoleSimulation.scala | 80 -- .../scala/keycloak/CommonSimulation.scala | 57 -- .../OIDCLoginAndLogoutSimulation.scala | 26 - .../OIDCRegisterAndLogoutSimulation.scala | 26 - .../scala/keycloak/OIDCScenarioBuilder.scala | 252 ----- .../org/keycloak/performance/Admin.scala | 114 --- .../org/keycloak/performance/AdminCLI.scala | 91 -- .../keycloak/performance/AdminConsole.scala | 12 - .../keycloak/performance/EmulatedOIDC.scala | 13 - .../org/keycloak/performance/Keycloak.scala | 17 - .../scala/org/keycloak/performance/OIDC.scala | 10 - testsuite/pom.xml | 9 - 269 files changed, 1 insertion(+), 17982 deletions(-) delete mode 100644 testsuite/performance/README.datasets.md delete mode 100644 testsuite/performance/README.docker-compose.md delete mode 100644 testsuite/performance/README.log-tool.md delete mode 100644 testsuite/performance/README.md delete mode 100644 testsuite/performance/README.provisioning-parameters.md delete mode 100644 testsuite/performance/README.stress-test.md delete mode 100644 testsuite/performance/db-failover/README.md delete mode 100755 testsuite/performance/db-failover/check-rows.sh delete mode 100755 testsuite/performance/db-failover/common.sh delete mode 100644 testsuite/performance/db-failover/concat.sql delete mode 100755 testsuite/performance/db-failover/kill-node.sh delete mode 100755 testsuite/performance/db-failover/loop.sh delete mode 100755 testsuite/performance/db-failover/reconnect-node.sh delete mode 100755 testsuite/performance/db-failover/setup.sh delete mode 100755 testsuite/performance/db-failover/teardown.sh delete mode 100644 testsuite/performance/db/mariadb/Dockerfile delete mode 100644 testsuite/performance/db/mariadb/README.md delete mode 100644 testsuite/performance/db/mariadb/docker-entrypoint-wsrep.sh delete mode 100644 testsuite/performance/db/mariadb/mariadb-healthcheck.sh delete mode 100644 testsuite/performance/db/mariadb/wsrep.cnf.template delete mode 100644 testsuite/performance/docker-compose-db-failover.yml delete mode 100644 testsuite/performance/infinispan/infinispan.xml delete mode 100644 testsuite/performance/infinispan/pom.xml delete mode 100644 testsuite/performance/infinispan/src/main/scripts/Dockerfile delete mode 100755 testsuite/performance/infinispan/src/main/scripts/docker-entrypoint-custom.sh delete mode 100755 testsuite/performance/infinispan/src/main/scripts/get-ips.sh delete mode 100755 testsuite/performance/infinispan/src/main/scripts/infinispan-healthcheck.sh delete mode 100644 testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-keycloak-caches.cli delete mode 100644 testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-private-network-interface.cli delete mode 100644 testsuite/performance/keycloak/configure.xml delete mode 100644 testsuite/performance/keycloak/pom.xml delete mode 100644 testsuite/performance/keycloak/src/main/resources/module.xml delete mode 100644 testsuite/performance/keycloak/src/main/scripts/Dockerfile delete mode 100644 testsuite/performance/keycloak/src/main/scripts/docker-entrypoint.sh delete mode 100644 testsuite/performance/keycloak/src/main/scripts/get-ips.sh delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/add-remote-cache-stores.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/distributed-cache-owners.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/infinispan-debug-logging.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads-batch.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/modcluster-simple-load-provider.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds-batch.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow-batch.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow.cli delete mode 100644 testsuite/performance/keycloak/src/main/scripts/keycloak-healthcheck.sh delete mode 100644 testsuite/performance/load-balancer/debug-advertise/Advertise.java delete mode 100644 testsuite/performance/load-balancer/debug-advertise/Dockerfile delete mode 100644 testsuite/performance/load-balancer/debug-advertise/Dockerfile-client delete mode 100644 testsuite/performance/load-balancer/debug-advertise/README.md delete mode 100644 testsuite/performance/load-balancer/debug-advertise/SAdvertise.java delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/configure.xml delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/pom.xml delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/Dockerfile delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/docker-entrypoint.sh delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/get-ips.sh delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/io-worker-threads.cli delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/mod-cluster-balancer.cli delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/undertow.cli delete mode 100644 testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/wildfly-healthcheck.sh delete mode 100644 testsuite/performance/monitoring/cadvisor/Dockerfile delete mode 100644 testsuite/performance/monitoring/cadvisor/README.md delete mode 100755 testsuite/performance/monitoring/cadvisor/entrypoint.sh delete mode 100644 testsuite/performance/monitoring/grafana/Dockerfile delete mode 100644 testsuite/performance/monitoring/grafana/README.md delete mode 100755 testsuite/performance/monitoring/grafana/entrypoint.sh delete mode 100644 testsuite/performance/monitoring/grafana/resource-usage-combined.json delete mode 100644 testsuite/performance/monitoring/grafana/resource-usage-per-container.json delete mode 100644 testsuite/performance/pom.xml delete mode 100755 testsuite/performance/stress-test.sh delete mode 100755 testsuite/performance/tests/common.sh delete mode 100755 testsuite/performance/tests/create-truststore.sh delete mode 100755 testsuite/performance/tests/docker-compose.sh delete mode 100755 testsuite/performance/tests/healthcheck.sh delete mode 100755 testsuite/performance/tests/log-tool.sh delete mode 100644 testsuite/performance/tests/parameters/provisioning/docker-compose/2cpus/singlenode.properties delete mode 100644 testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/cluster.properties delete mode 100644 testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/crossdc.properties delete mode 100644 testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/singlenode.properties delete mode 100644 testsuite/performance/tests/parameters/test/admin-console.properties delete mode 100644 testsuite/performance/tests/parameters/test/oidc-login-logout.properties delete mode 100644 testsuite/performance/tests/parameters/test/oidc-register-logout.properties delete mode 100644 testsuite/performance/tests/pom.xml delete mode 100644 testsuite/performance/tests/prepare-provisioning.xml delete mode 100755 testsuite/performance/tests/sar.sh delete mode 100644 testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-base.yml delete mode 100644 testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-keycloak.yml delete mode 100644 testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml delete mode 100644 testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc1.yml delete mode 100644 testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc2.yml delete mode 100644 testsuite/performance/tests/src/main/docker-compose/docker-compose-monitoring.yml delete mode 100644 testsuite/performance/tests/src/main/docker-compose/docker-compose.yml delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/common.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-all.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-cc.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-e.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-ev.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-m.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-o.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-s0.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-s1.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/jstat/gc-t.gp delete mode 100644 testsuite/performance/tests/src/main/gnuplot/sar/common.gplot delete mode 100644 testsuite/performance/tests/src/main/gnuplot/sar/cpu.gplot delete mode 100644 testsuite/performance/tests/src/main/gnuplot/sar/cswch.gplot delete mode 100644 testsuite/performance/tests/src/main/gnuplot/sar/io-data.gplot delete mode 100644 testsuite/performance/tests/src/main/gnuplot/sar/io-requests.gplot delete mode 100644 testsuite/performance/tests/src/main/gnuplot/sar/mem.gplot delete mode 100644 testsuite/performance/tests/src/main/gnuplot/sar/net.gplot delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockHttpFacade.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockRequestAuthenticator.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockTokenStore.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogLine.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogProcessor.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogReader.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/Stats.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/ClientInfo.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmConfig.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationBuilder.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationLoader.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/TestConfig.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/UserInfo.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Creatable.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Dataset.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetLoader.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetRepresentation.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Entity.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/NestedEntity.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Representable.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Updatable.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/Attribute.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeMap.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeRepresentation.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttribute.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttributeRepresentation.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttribute.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttributeRepresentation.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Client.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRole.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRoleMappings.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Credential.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Group.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Realm.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RealmRole.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Role.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMapper.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappings.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappingsRepresentation.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/User.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ClientPolicy.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/JsPolicy.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Policy.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Resource.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourcePermission.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServer.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerList.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicy.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinition.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinitionSet.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Scope.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ScopePermission.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/UserPolicy.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/FilteredIterator.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/Flattened2DList.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/ListOfLists.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/LoopingIterator.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomBooleans.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIntegers.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIterator.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomSublist.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/UniqueRandomIntegers.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/DatasetTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityObjectWrapper.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplateModel.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateModel.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateWrapperList.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringAttributeTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringListAttributeTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientRoleTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/GroupTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmRoleTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/UserTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ClientPolicyTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/JsPolicyTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/PolicyTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourcePermissionTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceServerTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/RolePolicyTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopePermissionTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopeTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/UserPolicyTemplate.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/util/CombinedConfigurationNoInterpolation.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ConfigurationUtil.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/util/Loggable.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/util/StringUtil.java delete mode 100644 testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ValidateNumber.java delete mode 100644 testsuite/performance/tests/src/main/resources/logback.xml delete mode 100644 testsuite/performance/tests/src/main/scala/org/jboss/perf/util/InvalidatableRandomContainer.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/jboss/perf/util/RandomContainer.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/jboss/perf/util/Util.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Authorize.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Blocking.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/ExitOnFailure.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Oauth.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Predef.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/RefreshToken.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Stopwatch.scala delete mode 100644 testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Utils.scala delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/AbstractTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/DatasetTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/EntityTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleMappingsTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/CredentialTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleMappingsTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/UserTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ScopeTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/ListOfListsTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomBooleansTest.java delete mode 100644 testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomIntegersTest.java delete mode 100644 testsuite/performance/tests/src/test/resources/application.conf delete mode 100644 testsuite/performance/tests/src/test/resources/bodies/.gitkeep delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/100r_100c_100000u.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/100r_100c_100u.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/10r_50c_100000u.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u_1hi.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi_10000res_100sc_100po_100pe.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_100c_500000u_1hi.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u_1hi.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/authz/default.properties delete mode 100644 testsuite/performance/tests/src/test/resources/dataset/default.properties delete mode 100644 testsuite/performance/tests/src/test/resources/gatling.conf delete mode 100644 testsuite/performance/tests/src/test/resources/logback-test.xml delete mode 100644 testsuite/performance/tests/src/test/scala/Engine.scala delete mode 100644 testsuite/performance/tests/src/test/scala/IDEPathHelper.scala delete mode 100644 testsuite/performance/tests/src/test/scala/Recorder.scala delete mode 100644 testsuite/performance/tests/src/test/scala/examples/SimpleExample1.scala delete mode 100644 testsuite/performance/tests/src/test/scala/examples/SimpleExample2.scala delete mode 100644 testsuite/performance/tests/src/test/scala/examples/SimpleExample3.scala delete mode 100644 testsuite/performance/tests/src/test/scala/examples/SimpleExample4.scala delete mode 100644 testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleScenarioBuilder.scala delete mode 100644 testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleSimulation.scala delete mode 100644 testsuite/performance/tests/src/test/scala/keycloak/CommonSimulation.scala delete mode 100644 testsuite/performance/tests/src/test/scala/keycloak/OIDCLoginAndLogoutSimulation.scala delete mode 100644 testsuite/performance/tests/src/test/scala/keycloak/OIDCRegisterAndLogoutSimulation.scala delete mode 100644 testsuite/performance/tests/src/test/scala/keycloak/OIDCScenarioBuilder.scala delete mode 100644 testsuite/performance/tests/src/test/scala/org/keycloak/performance/Admin.scala delete mode 100644 testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminCLI.scala delete mode 100644 testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminConsole.scala delete mode 100644 testsuite/performance/tests/src/test/scala/org/keycloak/performance/EmulatedOIDC.scala delete mode 100644 testsuite/performance/tests/src/test/scala/org/keycloak/performance/Keycloak.scala delete mode 100644 testsuite/performance/tests/src/test/scala/org/keycloak/performance/OIDC.scala diff --git a/.gitleaks.toml b/.gitleaks.toml index d508e010b3..1652825280 100644 --- a/.gitleaks.toml +++ b/.gitleaks.toml @@ -6,6 +6,5 @@ [allowlist] paths = [ - '''saml-core/src/test/java/org/keycloak/saml/processing/core/saml/v2/util/AssertionUtilTest.java''', - '''testsuite/performance/tests/pom.xml''', + '''saml-core/src/test/java/org/keycloak/saml/processing/core/saml/v2/util/AssertionUtilTest.java''' ] diff --git a/testsuite/performance/README.datasets.md b/testsuite/performance/README.datasets.md deleted file mode 100644 index 08d0082d5b..0000000000 --- a/testsuite/performance/README.datasets.md +++ /dev/null @@ -1,152 +0,0 @@ -# Keycloak Datasets - -## Provision Keycloak Server - -Before generating data it is necessary to provision/start Keycloak server. This can -be done automatically by running: - -``` -cd testsuite/performance -mvn clean install -mvn verify -P provision -``` -To tear down the system after testing run: -``` -mvn verify -P teardown -``` -The teardown step will delete the database as well so it is possible to use it between generating different datasets. - -It is also possible to start the server externally (manually). In that case it is necessary -to provide information in file `tests/target/provisioned-system.properties`. -See the main README for details. - -## Generate Data - -To generate the *default dataset* run: -``` -cd testsuite/performance -mvn verify -P generate-data -``` - -To generate a *specific dataset* from within the project run: -``` -mvn verify -P generate-data -Ddataset= -``` -This will load dataset properties from `tests/src/test/resources/dataset/${dataset}.properties`. - -To generate a specific dataset from a *custom properties file* run: -``` -mvn verify -P generate-data -Ddataset.properties.file= -``` - -To delete a dataset run: -``` -mvn verify -P generate-data -Ddataset=… -Ddelete=true -``` -This will delete all realms specified by the dataset. - - -## Indexed Model - -The model is hierarchical with the parent-child relationships determined by primary foreign keys of entities. - -Size of the dataset is determined by specifying a "count per parent" parameter for each entity. - -Number of mappings between entities created by the primary "count per parent" parameters -can be speicied by "count per other entity" parameters. - -Each nested entity has a unique index which identifies it inside its parent entity. - -For example: -- Realm X --> Client Y --> Client Role Z -- Realm X --> Client Y --> Resource Server --> Resource Z -- Realm X --> User Y -- etc. - -Hash code of each entity is computed based on its index coordinates within the model and its class name. - -Each entity holds entity representation, and a list of mappings to other entities in the indexed model. -The attributes and mappings are initialized by a related *entity template* class. -Each entity class also acts as a wrapper around a Keycloak Admin Client using it -to provide CRUD operations for its entity. - -The `id` attribute in the entity representation is set upon entity creation, or in case -an already initialized entity was removed from LRU cache it is reloaded from the server. -This may happen if the number of entities is larger than entity cache size. (see below) - -### Attribute Templating - -Attributes of each supported entity representation can be set via FreeMarker templates. -The process is based on templates defined in a properties configuration file. - -The first template in the list can use the `index` of the entity and any attributes of its parent entity. -Each subsequent attribute template can use any previously set attribute values. - -Note: Output of FreeMarker engine is always a String. Transition to the actual type -of the attribute is done with the Jackson 2.9+ parser using `ObjectMapper.update()` method -which allows a gradual updates of an existing Java object. - -### Randomness - -Randomness in the indexed model is deterministic (pseudorandom) because the -random seeds are based on deterministic hash codes. - -There are 2 types of seeds: one is for using randoms in the FreeMarker templates -via methods `indexBasedRandomInt(int bound)` and `indexBasedRandomBool(int percentage)`. -It is based on class of the current entity + hash code of its parent entity. - -The other seed is for generating mappings to other entities which are just -random sequences of integer indexes. This is based on hash code of the current entity. - -### Generator Settings - -#### Timeouts -- `queue.timeout`: How long to wait for an entity to be processed by a thread-pool executor. Default is `60` seconds. -You might want to increase this setting when deleting many realms with many nested entities using a low number of workers. -- `shutdown.timeout`: How long to wait for the executor thread-pool to shut down. Default is `60` seconds. - -#### Caching and Memory -- `template.cache.size`: Size of cache of FreeMarker template models. Default is `10000`. -- `randoms.cache.size`: Size of cache of random integer sequences which are used for mappings between entities. Default is `10000`. -- `entity.cache.size`: Size of cache of initialized entities. Default is `100000`. -- `max.heap`: Max heap size of the data generator JVM. - - -## Notes: - -- Mappings are random so it can sometimes happen that the same mappings are generated multiple times. -Only distinct mappings are created. -This means for example that if you specify `realmRolesPerUser=5` it can happen -that only 4 or less roles will be actually mapped. - - There is an option to use unique random sequences but is is disabled right now -because checking for uniqueness is CPU-intensive. - -- Mapping of client roles to a user right now is determined by a single parameter: `clientRolesPerUser`. - - Actually created mappings -- each of which contains specific client + a set of its roles -- is created -based on the list of randomly selected client roles of all clients in the realm. -This means the count of the actual client mappings isn't predictable. - - That would require specifying 2 parameters: `clientsPerUser` and `clientRolesPerClientPerUser` -which would say how many clients a user has roles assigned from, and the number of roles per each of these clients. - -- Number of resource servers depends on how the attribute `authorizationServicesEnabled` -is set for each client. This means the number isn't specified by any "perRealm" parameter. -If this is needed it can be implemented via a random mapping from a resource server entity -to a set of existing clients in a similar fashion to how a resource is selected for each resource permission. - -- The "resource type" attribute for each resource and resource-based permission defaults to -the default type of the parent resource server. -If it's needed a separate abstract/non-persistable entity ResourceType can be created in the model -to represent a set of resource types. The "resource type" attributes can then be set based on random mappings into this set. - -- Generating large number of users can take a long time with the default realm settings -which have the password hashing iterations set to a default value of 27500. -If you wish to speed this process up decrease the value of `hashIterations()` in attribute `realm.passwordPolicy`. - - Note that this will also significantly affect the performance results of the tests because -password hashing takes a major part of the server's compute resources. The results may -improve even by a factor of 10 or higher when the hashing is set to the minimum value of 1 itreration. -However it's on the expense of security. - diff --git a/testsuite/performance/README.docker-compose.md b/testsuite/performance/README.docker-compose.md deleted file mode 100644 index b92e545696..0000000000 --- a/testsuite/performance/README.docker-compose.md +++ /dev/null @@ -1,35 +0,0 @@ -# Keycloak Performance Testsuite - Docker Compose Provisioner - -## Supported Deployments - -| Deployment | Available Operations | Orchestration Template | -| ------------ | ----------------------------------------------------- | ------------------------------- | -| `singlenode` | `provision`, `teardown`, `export-dump`, `import-dump` | `docker-compose.yml` | -| `cluster` | `provision`, `teardown`, `export-dump`, `import-dump` | `docker-compose-cluster.yml`* | -| `crossdc` | `provision`, `teardown`, `export-dump`, `import-dump` | `docker-compose-crossdc.yml`* | -| `monitoring` | `provision`, `teardown` | `docker-compose-monitoring.yml` | - -The docker-compose orchestration templates are located in `tests/src/main/docker-compose` directory. - -**[*]** The cluster and crossdc templates are generated dynamically during the `provision` operation based on provided `cpusets` parameter. -One Keycloak service entry is generated for each cpuset. This is a workaround for limitations of the default docker-compose scaling mechanism -which only allows setting `cpuset` per service, not per container. For more predictable performance results it is necessary for each -Keycloak server to have an exclusive access to specific CPU cores. - -## Debugging docker containers: -- List started containers: `docker ps`. It's useful to watch continuously: `watch docker ps`. - To list compose-only containers use: `docker-compose ps`, but this doesn't show container health status. -- Watch logs of a specific container: `docker logs -f crossdc_mariadb_dc1_1`. -- Watch logs of all containers managed by docker-compose: `docker-compose logs -f`. -- List networks: `docker network ls` -- Inspect network: `docker network inspect NETWORK_NAME`. Shows network configuration and currently connected containers. - -## Network Addresses -### KC -`10.i.1.0/24` One network per DC. For single-DC deployments `i = 0`, for cross-DC deployment `i ∈ ℕ` is an index of particular DC. -### Load Balancing -`10.0.2.0/24` Network spans all DCs. -### DB Replication -`10.0.3.0/24` Network spans all DCs. -### ISPN Replication -`10.0.4.0/24` Network spans all DCs. diff --git a/testsuite/performance/README.log-tool.md b/testsuite/performance/README.log-tool.md deleted file mode 100644 index 9414460a84..0000000000 --- a/testsuite/performance/README.log-tool.md +++ /dev/null @@ -1,78 +0,0 @@ -Example of using log-tool.sh ----------------------------- - -Perform the usual test run: - -``` -mvn verify -Pteardown -mvn verify -Pprovision -mvn verify -Pgenerate-data -Ddataset=100users -Dimport.workers=10 -DhashIterations=100 -mvn verify -Ptest -Ddataset=100users -DusersPerSec=5 -DrampUpPeriod=10 -DuserThinkTime=0 -DbadLoginAttempts=1 -DrefreshTokenCount=1 -DmeasurementPeriod=60 -``` - -Now analyze the generated simulation.log (adjust LOG_DIR, FROM, and TO): - -``` -LOG_DIR=$HOME/devel/keycloak/keycloak/testsuite/performance/tests/target/gatling/keycloaksimulation-1502735555123 -``` - -Get general statistics about the run to help with deciding about the interval to extract: -``` -tests/log-tool.sh -s -f $LOG_DIR/simulation.log -tests/log-tool.sh -s -f $LOG_DIR/simulation.log --lastRequest "Browser logout" -``` - -Set start and end times for the extraction, and create new directory for results: -``` -FROM=1502735573285 -TO=1502735581063 - -RESULT_DIR=tests/target/gatling/keycloaksimulation-$FROM\_$TO - -mkdir $RESULT_DIR -``` - -Extract a portion of the original log, and inspect statistics of resulting log: -``` -tests/log-tool.sh -f $LOG_DIR/simulation.log -o $RESULT_DIR/simulation-$FROM\_$TO.log -e --start $FROM --end $TO - -tests/log-tool.sh -f $RESULT_DIR/simulation-$FROM\_$TO.log -s -``` - -Generate another set of reports from extracted log: -``` -GATLING_HOME=$HOME/devel/gatling-charts-highcharts-bundle-2.1.7 - -cd $GATLING_HOME -bin/gatling.sh -ro $RESULT_DIR - -``` - - -Installing Gatling Highcharts 2.1.7 ------------------------------------ - -``` -git clone http://github.com/gatling/gatling -cd gatling -git checkout v2.1.7 -git checkout -b v2.1.7 -sbt clean compile -sbt publishLocal publishM2 -cd .. - -git clone http://github.com/gatling/gatling-highcharts -cd gatling-highcharts/ -git checkout v2.1.7 -git checkout -b v2.1.7 -sbt clean compile -sbt publishLocal publishM2 -cd .. - -unzip ~/.ivy2/local/io.gatling.highcharts/gatling-charts-highcharts-bundle/2.1.7/zips/gatling-charts-highcharts-bundle-bundle.zip -cd gatling-charts-highcharts-bundle-2.1.7 - -bin/gatling.sh -``` - - diff --git a/testsuite/performance/README.md b/testsuite/performance/README.md deleted file mode 100644 index 13bdfc91c1..0000000000 --- a/testsuite/performance/README.md +++ /dev/null @@ -1,354 +0,0 @@ -# Keycloak Performance Testsuite - -## Requirements: -- Bash 2.05+ -- Maven 3.5.4+ -- Keycloak server distribution installed in the local Maven repository. To do this run `mvn install -Pdistribution` from the root of the Keycloak project. - -### Docker Compose Provisioner -- Docker 1.13+ -- Docker Compose 1.14+ - -## Getting started for the impatient - -Here's how to perform a simple tests run: - -``` -# Clone keycloak repository if you don't have it yet -# git clone https://github.com/keycloak/keycloak.git - -# Build Keycloak distribution - needed to build docker image with latest Keycloak server -mvn clean install -DskipTests -Pdistribution - -# Now build, provision and run the test -cd testsuite/performance -mvn clean install - -# Make sure your Docker daemon is running THEN -mvn verify -Pprovision -mvn verify -Pgenerate-data -Ddataset=1r_10c_100u -DnumOfWorkers=10 -mvn verify -Ptest -Ddataset=1r_10c_100u -DusersPerSec=2 -DrampUpPeriod=10 -DuserThinkTime=0 -DbadLoginAttempts=1 -DrefreshTokenCount=1 -DmeasurementPeriod=60 -DfilterResults=true -``` - -Now open the generated report in a browser - the link to .html file is displayed at the end of the test. - -After the test run you may want to tear down the docker instances for the next run to be able to import data: -``` -mvn verify -Pteardown -``` - -You can perform all phases in a single run: -``` -mvn verify -Pprovision,generate-data,test,teardown -Ddataset=1r_10c_100u -DnumOfWorkers=10 -DusersPerSec=4 -DrampUpPeriod=10 -``` -Note: The order in which maven profiles are listed does not determine the order in which profile related plugins are executed. `teardown` profile always executes last. - -Keep reading for more information. - - -## Provisioning - -### Provision - -#### Provisioners - -Depending on the target environment different provisioners may be used. -Provisioner can be selected via property `-Dprovisioner=PROVISIONER`. - -Default value is `docker-compose` which is intended for testing on a local docker host. -This is currently the only implemented option. See [`README.docker-compose.md`](README.docker-compose.md) for more details. - -#### Deployment Types - -Different types of deployment can be provisioned. -The default deployment is `singlenode` with only a single instance of Keycloak server and a database. -Additional options are `cluster` and `crossdc` which can be enabled with a profile (see below). - -#### Usage - -Usage: `mvn verify -P provision[,DEPLOYMENT_PROFILE] [-Dprovisioning.properties=NAMED_PROPERTY_SET]`. - -The properties are loaded from `tests/parameters/provisioning/${provisioning.properties}.properties` file. -Individual parameters can be overriden from command line via `-D` params. - -Default property set is `docker-compose/4cpus/singlenode`. - -To load a custom properties file specify `-Dprovisioning.properties.file=ABSOLUTE_PATH_TO_FILE` instead of `-Dprovisioning.properties`. -This file needs to contain all properties required by the specific combination of provisioner and deployment type. -See examples in folder `tests/parameters/provisioning/docker-compose/4cpus`. - -Available parameters are described in [`README.provisioning-parameters.md`](README.provisioning-parameters.md). - -#### Examples: -- Provision a single-node deployment with docker-compose: `mvn verify -P provision` -- Provision a cluster deployment with docker-compose: `mvn verify -P provision,cluster` -- Provision a cluster deployment with docker-compose, overriding some properties: `mvn verify -P provision,cluster -Dkeycloak.scale=2 -Dlb.worker.task-max-threads=32` -- Provision a cross-DC deployment with docker-compose: `mvn verify -P provision,crossdc` -- Provision a cross-DC deployment with docker-compose using a custom properties file: `mvn verify -P provision,crossdc -Dprovisioning.properties.file=/tmp/custom-crossdc.properties` - - -#### Provisioned System - -The `provision` operation will produce a `provisioned-system.properties` inside the `tests/target` directory -with information about the provisioned system such as the type of deployment and URLs of Keycloak servers and load balancers. -This information is then used by operations `generate-data`, `import-dump`, `test`, `teardown`. - -Provisioning operation is idempotent for a specific combination of provisioner+deployment. -When running multiple times the system will be simply updated based on the new parameters. -However when switching between different provisioiners or deployment types it is **always necessary** -to tear down the currently running system. - -**Note:** When switching deployment type from `singlenode` or `cluster` to `crossdc` (or the other way around) -it is necessary to update the generated Keycloak server configuration (inside `keycloak/target` directory) by -adding a `clean` goal to the provisioning command like so: `mvn clean verify -Pprovision …`. It is *not* necessary to update this configuration -when switching between `singlenode` and `cluster` deployments. - -#### Manual Provisioning - -If you want to generate data or run the test against an already running instance of Keycloak server -you need to provide information about the system in a properties file. - -Create file: `tests/target/provisioned-system.properties` with the following properties: -``` -keycloak.frontend.servers=http://localhost:8080/auth -keycloak.admin.user=admin -keycloak.admin.password=admin -``` -and replace the values with your actual information. Then it will be possible to run tasks: `generate-data` and `test`. - -The tasks: `export-dump`, `import-dump` and `collect` (see below) are only available with the automated provisioning -because they require direct access to the provisioned services. - - -### Collect Artifacts - -Usage: `mvn verify -Pcollect` - -Collects artifacts such as logs from the provisioned system and stores them in `tests/target/collected-artifacts/${deployment}-TIMESTAMP/`. -When used in combination with teardown (see below) the artifacts are collected just before the system is torn down. - -### Teardown - -Usage: `mvn verify -Pteardown [-Dprovisioner=]` - -**Note:** Unless the provisioned system has been properly torn down the maven build will not allow a cleanup of the `tests/target` directory -because it contains the `provisioned-system.properties` with information about the still-running system. - - -## Testing - -### Generate Test Data - -Usage: `mvn verify -P generate-data [-Ddataset=NAMED_PROPERTY_SET] [-DnumOfWorkers=N]`. Workers default to `1`. - -The parameters are loaded from `tests/src/test/resources/dataset/${dataset}.properties` file with `${dataset}` defaulting to `default`. - -To use a custom properties file specify `-Ddataset.properties.file=ABSOLUTE_PATH_TO_FILE` instead of `-Ddataset`. - -To generate data using a different version of Keycloak Admin Client set property `-Dserver.version=SERVER_VERSION` to match the version of the provisioned server. - -To delete the generated dataset add `-Ddelete=true` to the above command. Dataset is deleted by deleting individual realms. - -#### Examples: -- Generate the default dataset. `mvn verify -P generate-data` -- Generate the `1r_10c_100u` dataset. `mvn verify -P generate-data -Ddataset=1r_10c_100u` - -#### Export Database - -To export the generated data to a data-dump file enable profile `-P export-dump`. This will create a `${DATASET}.sql.gz` file next to the dataset properties file. - -Example: `mvn verify -P generate-data,export-dump -Ddataset=1r_10c_100u` - -#### Import Database - -To import data from an existing data-dump file use profile `-P import-dump`. - -Example: `mvn verify -P import-dump -Ddataset=1r_10c_100u` - -If the dump file doesn't exist locally the script will attempt to download it from `${db.dump.download.site}` which defaults to `https://downloads.jboss.org/keycloak-qe/${server.version}` -with `server.version` defaulting to `${project.version}` from `pom.xml`. - -**Warning:** Don't override dataset parameters (with `-Dparam=value`) when running export/import because then the contents of dump file might not match the properties file. - - -### Run Tests - -Usage: `mvn verify -P test [-Dtest.properties=NAMED_PROPERTY_SET]`. Default property set is `oidc-login-logout`. - -The parameters are loaded from `tests/parameters/test/${test.properties}.properties` file. -Individual properties can be overriden from command line via `-D` params. - -To use a custom properties file specify `-Dtest.properties.file=ABSOLUTE_PATH_TO_FILE` instead of `-Dtest.properties`. - -#### Dataset - -When running the tests it is necessary to define the dataset to be used. - -| Parameter | Description | Default Value | -| --- | --- | --- | -| `dataset` | Name of the dataset to use. Individual parameters can be overriden from CLI. For details see the section above. | `default` | -| `sequentialRealmsFrom` | Use sequential realm iteration starting from specific index. Must be lower than `numOfRealms` parameter from dataset properties. Useful for user registration scenario. | `-1` random iteration | -| `sequentialUsersFrom` | Use sequential user iteration starting from specific index. Must be lower than `usersPerRealm` parameter from dataset properties. Useful for user registration scenario. | `-1` random iteration | - -#### Common Test Run Parameters - -| Parameter | Description | Default Value | -| --- | --- | --- | -| `gatling.simulationClass` | Classname of the simulation to be run. | `keycloak.OIDCLoginAndLogoutSimulation` | -| `usersPerSec` | Arrival rate of new users per second. Can be a floating point number. | `1.0` for OIDCLoginAndLogoutSimulation, `0.2` for AdminConsoleSimulation | -| `rampUpPeriod` | Period during which the users will be ramped up. (seconds) | `15` | -| `warmUpPeriod` | Period with steady number of users intended for the system under test to warm up. (seconds) | `15` | -| `measurementPeriod` | A measurement period after the system is warmed up. (seconds) | `30` | -| `filterResults` | Whether to filter out requests which are outside of the `measurementPeriod`. | `false` | -| `userThinkTime` | Pause between individual scenario steps. | `5` | -| `refreshTokenPeriod`| Period after which token should be refreshed. | `10` | -| `logoutPct`| Percentage of users who should log out at the end of scenario. | `100` | - -| Test Assertion | Description | Default Value | -| --- | --- | --- | -| `maxFailedRequests`| Maximum number of failed requests. | `0` | -| `maxMeanReponseTime`| Maximum mean response time of all requests. | `300` | - -#### Test Run Parameters specific to `OIDCLoginAndLogoutSimulation` - -| Parameter | Description | Default Value | -| --- | --- | --- | -| `badLoginAttempts` | | `0` | -| `refreshTokenCount` | | `0` | - -#### Examples: - -- Run test with default test and dataset parameters: - -`mvn verify -P test` - -- Run test specific test and dataset parameters: - -`mvn verify -P test -Dtest.properties=oidc-login-logout -Ddataset=1r_10c_100u` - -- Run test with specific test and dataset parameters, overriding some from command line: - -`mvn verify -P test -Dtest.properties=admin-console -Ddataset=1r_10c_100u -DrampUpPeriod=30 -DwarmUpPeriod=60 -DusersPerSec=0.3` - -#### Running `OIDCRegisterAndLogoutSimulation` - -Running the user registration simulation requires a different approach to dataset and how it's iterated. -- It requires sequential iteration instead of the default random one. -- In case some users are already registered it requires starting the iteration from a specific index . - -##### Example A: -1. Generate dataset with 0 users: `mvn verify -P generate-data -DusersPerRealm=0` -2. Run the registration test: - -`mvn verify -P test -D test.properties=oidc-register-logout -DsequentialUsersFrom=0 -DusersPerRealm=` - -##### Example B: -1. Generate or import dataset with 100 users: `mvn verify -P generate-data -Ddataset=1r_10c_100u`. This will create 1 realm and users 0-99. -2. Run the registration test starting from user 100: - -`mvn verify -P test -D test.properties=oidc-register-logout -DsequentialUsersFrom=100 -DusersPerRealm=` - - -### Testing with HTTPS - -If the provisioned server is secured with HTTPS it is possible to set the truststore which contains the server certificate. -The truststore is used in phases `generate-data` and `test`. - -Usage: `mvn verify -P generate-data,test -DtrustStore= -DtrustStorePassword=` - -To automatically generate the truststore file run a utility script `tests/create-truststore.sh HOST:PORT [TRUSTSTORE_PASSWORD]`. -The script requires `openssl` and `keytool` (included in JDK). - -Example: `tests/create-truststore.sh localhost:8443 truststorepass` - - -## Monitoring - -### JMX - -To enable access to JMX on the WildFly-backed services set properties `management.user` and `management.user.password` during the provisioning phase. - -#### JVisualVM - -- Set `JBOSS_HOME` variable to point to a valid WildFly 10+ installation. -- Start JVisualVM with `jboss-client.jar` on classpath: `./jvisualvm --cp:a $JBOSS_HOME/bin/client/jboss-client.jar`. -- Add a local JMX connection: `service:jmx:remote+http://localhost:9990`. **[*]** -- Check "Use security credentials" and set `admin:admin`. (The default credentials can be overriden by providing env. variables `DEBUG_USER` and `DEBUG_USER_PASSWORD` to the container.) -- Open the added connection. - -**[*]** For `singlenode` this points to the JMX console of the Keycloak server. -To get the connection URLs for `cluster` or `crossdc` deployments see the JMX section in the generated `provisioned-system.properties` file. -- Property `keycloak.frontend.servers.jmx` contains JMX URLs of the Load Balancers. -- Property `keycloak.backend.servers.jmx` contains JMX URLs of the clustered Keycloak servers. -- Property `infinispan.servers.jmx` contains JMX URLs of the Infinispan servers, in Cross-DC deployment. - -### Docker Monitoring - -There is a docker-based solution for monitoring CPU, memory and network usage per container. -It uses CAdvisor service to export container metrics into InfluxDB time series database, and Grafana web app to query the DB and present results as graphs. - -- To enable run: `mvn verify -Pmonitoring` -- To disable run: `mvn verify -Pmonitoring-off[,delete-monitoring-data]`. -By default the monitoring history is preserved. If you wish to delete it enable the `delete-monitoring-data` profile when turning monitoring off. - -To view monitoring dashboard open Grafana UI at: `http://localhost:3000/dashboard/file/resource-usage-combined.json`. - -### Sysstat metrics - -To enable recording of sysstat metrics use `-Psar`. -This will run the `sar` command during the test and process its binary output to produce textual and CSV files with CPU utilisation stats. -To also enable creation of PNG charts use `-Psar,gnuplot`. For this to work Gnuplot needs to be installed on the machine. -To compress the binary output with bzip add `-Dbzip=true` to the commandline. - -Results will be stored in folder: `tests/target/sar`. - -### JStat - JVM memory statistics - -To enable jstat monitoring use `-Pjstat` option. -This will start a `jstat` process in each container with Wildfly-based service (Keycloak, Infinispan, Load balancer) -and record the statistics in the `standalone/log/jstat-gc.log` file. These can be then collected by running the `mvn verify -Pcollect` operation. - -To enable creation of PNG charts based on the jstat output use `-Pgnuplot`. - -## Developing tests in IntelliJ IDEA - -### Add scala support to IDEA - -#### Install the correct Scala SDK - -First you need to install Scala SDK. In Scala land it's very important that all libraries used are compatible with specific version of Scala. -Gatling version that we use uses Scala version 2.11.7. In order to avoid conflicts between Scala used by IDEA, and Scala dependencies in pom.xml -it's very important to use that same version of Scala SDK for development. - -Thus, it's best to download and install [this SDK version](http://scala-lang.org/download/2.11.7.html) - -#### Install IntelliJ's official Scala plugin - -Open Preferences in IntelliJ. Type 'plugins' in the search box. In the right pane click on 'Install JetBrains plugin'. -Type 'scala' in the search box, and click Install button of the Scala plugin. - -#### Run OIDCLoginAndLogoutSimulation from IntelliJ - -Make sure that `performance` maven profile is enabled for IDEA to treat `performance` directory as a project module. - -You may also need to rebuild the module in IDEA for scala objects to become available. - -Then find Engine object In ProjectExplorer (you can use ctrl-N / cmd-O). Right click on class name and select Run or Debug as if it was -a JUnit tests. - -You'll have to edit a test configuration, and set 'VM options' to a list of -Dkey=value pairs to override default configuration values in TestConfig class. - -Make sure to set 'Use classpath of module' to 'performance-test'. - -When tests are executed via maven, the Engine object is not used. It exists only for running tests in IDE. - -If test startup fails due to not being able to find the test classes try reimporting the 'performance' module from pom.xml (right click on 'performance' directory, select 'Maven' at the bottom of context menu, then 'Reimport') - -If you want to run a different simulation - not DefaultSimulation - you can edit Engine object source, or create another Engine object for a different simulation. - -## Troubleshoot - -### Verbose logging -You can find `logback-test.xml` file in `tests/src/test/resources` directory. This files contains logging information in log4j xml format. -Root logger is by default set to WARN, but if you want to increase verbosity you can change it to DEBUG or INFO. - diff --git a/testsuite/performance/README.provisioning-parameters.md b/testsuite/performance/README.provisioning-parameters.md deleted file mode 100644 index 707a40ab5c..0000000000 --- a/testsuite/performance/README.provisioning-parameters.md +++ /dev/null @@ -1,132 +0,0 @@ -# Keycloak Performance Testsuite - Provisioning Parameters - -## Overview of Provisioned Services - -### Testing - -| Deployment | Keycloak Server | Database | Load Balancer | Infinispan Server | -|-----------------|------------------------------------------|--------------------|--------------------|--------------------| -| *Singlenode* | 1 instance | 1 instance | - | - | -| *Cluster* | N instances | 1 instance | 1 instance | - | -| *Cross-DC* | K instances in DC1 + L instances in DC2 | 1 instance per DC | 1 instance per DC | 1 instance per DC | - -### Monitoring - -| Deployment | CAdvisor | Influx DB | Grafana | -|-----------------|-------------|-------------|-------------| -| *Monitoring* | 1 instance | 1 instance | 1 instance | - - -## Service Parameters - -### Keycloak Server - -| Category | Setting | Property | Default Value | -|-------------|-------------------------------|------------------------------------|--------------------------------------------------------------------| -| Keycloak | Server version | `server.version` | `${project.version}` from the project `pom.xml` file. | -| | Admin user | `keycloak.admin.user` | `admin` | -| | Admin user's password | `keycloak.admin.password` | `admin` | -| Scaling[1] | Scale for cluster | `keycloak.scale` | Maximum size[2] of cluster. | -| | Scale for DC1 | `keycloak.dc1.scale` | Maximum size of DC1. | -| | Scale for DC2 | `keycloak.dc2.scale` | Maximum size of DC2. | -| Docker | Allocated CPUs | `keycloak.docker.cpusets` | `2-3` for singlenode, `2 3` for cluster deployment | -| | Allocated CPUs for DC1 | `keycloak.dc1.docker.cpusets` | `2` | -| | Allocated CPUs for DC2 | `keycloak.dc2.docker.cpusets` | `3` | -| | Available memory | `keycloak.docker.memlimit` | `2500m` | -| JVM | Memory settings | `keycloak.jvm.memory` | `-Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m` | -| Undertow | HTTP Listener max connections | `keycloak.http.max-connections` | `50000` | -| | AJP Listener max connections | `keycloak.ajp.max-connections` | `50000` | -| IO | Worker IO thread pool | `keycloak.worker.io-threads` | `2` | -| | Worker Task thread pool | `keycloak.worker.task-max-threads` | `16` | -| Datasources | Connection pool min size | `keycloak.ds.min-pool-size` | `10` | -| | Connection pool max size | `keycloak.ds.max-pool-size` | `100` | -| | Connection pool prefill | `keycloak.ds.pool-prefill` | `true` | -| | Prepared statement cache size | `keycloak.ds.ps-cache-size` | `100` | - -**[ 1 ]** The scaling parameters are optional. They can be set within interval from 1 to the maximum cluster size]. -If not set they are automatically set to the maximum size of the cluster (DC1/DC2 respectively). - -**[ 2 ]** Maximum cluster size is determined by provisioner-specific parameter such as `keycloak.docker.cpusets` for the default *docker-compose* provisioner. -The maximum cluster size corresponds to the number of cpusets. - -### Database - -| Category | Setting | Property | Default Value | -|-------------|-------------------------------|------------------------------------|--------------------------------------------------------------------| -| Docker | Allocated CPUs | `db.docker.cpusets` | `1` | -| | Allocated CPUs for DC1 | `db.dc1.docker.cpusets` | `1` | -| | Allocated CPUs for DC2 | `db.dc2.docker.cpusets` | `1` | -| | Available memory | `db.docker.memlimit` | `2g` | - -### Load Balancer - -| Category | Setting | Property | Default Value | -|-------------|-------------------------------|------------------------------|---------------------------------------------------------------------| -| Docker | Allocated CPUs | `lb.docker.cpusets` | `1` | -| | Allocated CPUs for DC1 | `lb.dc1.docker.cpusets` | `1` | -| | Allocated CPUs for DC2 | `lb.dc2.docker.cpusets` | `1` | -| | Available memory | `lb.docker.memlimit` | `1500m` | -| JVM | Memory settings | `lb.jvm.memory` | `-Xms64m -Xmx1024m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m` | -| Undertow | HTTP Listener max connections | `lb.http.max-connections` | `50000` | -| IO | Worker IO thread pool | `lb.worker.io-threads` | `2` | -| | Worker Task thread pool | `lb.worker.task-max-threads` | `16` | - -### Infinispan Server - -| Category | Setting | Property | Default Value | -|-------------|-------------------------------|---------------------------------|-------------------------------------------------------------------------------------------| -| Docker | Allocated CPUs for DC1 | `infinispan.dc1.docker.cpusets` | `1` | -| | Allocated CPUs for DC2 | `infinispan.dc2.docker.cpusets` | `1` | -| | Available memory | `infinispan.docker.memlimit` | `1500m` | -| JVM | Memory settings | `infinispan.jvm.memory` | `-Xms64m -Xmx1g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -XX:+DisableExplicitGC` | - -### Monitoring - -| Category | Setting | Property | Default Value | -|-------------|-------------------------------|-----------------------------|-----------------| -| Docker | Allocated CPUs | `monitoring.docker.cpusets` | `0` | -| JMX | Management user | `management.user` | Not set. | -| | Management user's password | `management.user.password` | Not set. | - -By setting the `managemen.user` and `management.user.password` parameters it is possible -to add a management user to all WildFly-backed services (*Keycloak Server*, *Infinispan Server* and the *Load Balancer*). -Unless both parameters are explicitly provided during the provisioning phase the user will not be added -and it won't be possible to log into the management console or access JMX. - - -## Note on Docker settings - -By default, there are 4 CPU cores allocated: core 0 for monitoring, core 1 for database (MariaDB), and cores 2 and 3 for Keycloak server. -Default memory limits for database and Keycloak server are 2g. The `cpuset` and `memlimit` parameters set here are set to `cpuset` and -`mem_limit` parameters of docker-compose configuration. See docker-compose documentation for meaning of the values. How to set the parameters -correctly depends on number of factors - number of cpu cores, NUMA, available memory etc., hence it is out of scope of this document. - -### Example CPU Settings - -| HW | Development Machine | "Fat Box" | -|-------------|----------------------|--------------| -| Cores | 4 | 48 | -| NUMA Nodes | 0-3 | 0-23, 24-47 | - -#### Cluster - -| Setting | Development Machine | "Fat Box" | -|------------------------------------|----------------------|-----------------------------| -| `monitoring.docker.cpusets` | 0 | 0 | -| `db.docker.cpusets` | 1 | 1 | -| `lb.docker.cpusets` | 1 | 2 | -| `keycloak.docker.cpusets` | 2-3 | 3-6 7-10 11-16 … 43-46 | - -#### Cross-DC - -| Setting | Development Machine | "Fat Box" | -|------------------------------------|----------------------|--------------------------------| -| `monitoring.docker.cpusets` | 0 | 0 | -| `db.dc1.docker.cpusets` | 1 | 1 | -| `lb.dc1.docker.cpusets` | 1 | 2 | -| `infinispan.dc1.docker.cpusets` | 1 | 3 | -| `keycloak.dc1.docker.cpusets` | 2 | 4-7 8-11 12-15 16-19 20-23 | -| `db.dc2.docker.cpusets` | 1 | 24 | -| `lb.dc2.docker.cpusets` | 1 | 25 | -| `infinispan.dc2.docker.cpusets` | 1 | 26 | -| `keycloak.dc2.docker.cpusets` | 3 | 27-30 31-34 35-38 39-42 43-46 | diff --git a/testsuite/performance/README.stress-test.md b/testsuite/performance/README.stress-test.md deleted file mode 100644 index 95978fc702..0000000000 --- a/testsuite/performance/README.stress-test.md +++ /dev/null @@ -1,79 +0,0 @@ -# Keycloak Performance Testsuite - Stress Testing - -## Requirements - -- Bash -- `bc`: Arbitrary precision calculator. - -## Stress Test - -The performance testsuite contains a stress-testing script: `stress-test.sh`. - -The stress test is implemented as a loop of individual performance test runs. -The script supports two algorithms: -- incremental (default) -- bisection - -The *incremental algorithm* loop starts from a base load and then increases the load by a specified amount in each iteration. -The loop ends when a performance test fails, or when the maximum number of iterations is reached. - -The *bisection algorithm* loop has a lower and an upper bound, and a resolution parameter. -In each iteration the middle of the interval is used as a value for the performance test load. -Depending on whether the test passes or fails the lower or upper half of the interval is used for the next iteration. -The loop ends if size of the interval is lower than the specified resolution, or when the maximum number of iterations is reached. - -## Usage - -``` -export PARAMETER1=value1 -export PARAMETER2=value2 -... -stress-test.sh [-DadditionalTestsuiteParam1=value1 -DadditionalTestsuiteParam2=value2 ...] -``` - -## Parameters - -### Script Execution Parameters - -| Variable | Description | Default Value | -| --- | --- | --- | -| `MVN` | The base Maven command to be used. | `mvn` | -| `KEYCLOAK_PROJECT_HOME` | Root directory of the Keycloak project. | Root directory relative to the location of the `stress-test.sh` script. | -| `DRY_RUN` | Don't execute performance tests. Only print out execution information for each iteration. | `false` | - -### Performance Testuite Parameters - -| Variable | Description | Default Value | -| --- | --- | --- | -| `DATASET` | Dataset to be used. | `1r_10c_100u` | -| `WARMUP_PERIOD` | Value of `warmUpPeriod` testsuite parameter. | `120` seconds | -| `RAMPUP_PERIOD` | Value of `rampUpPeriod` testsuite parameter. | `60` seconds | -| `MEASUREMENT_PERIOD` | Value of `measurementPeriod` testsuite parameter. | `120` seconds | -| `FILTER_RESULTS` | Value of `filterResults` testsuite parameter. Should be enabled. | `true` | -| `@` | Any parameters provided to the `stress-test.sh` script will be passed to the performance testsuite. Optional. | | - -### Stress Test Parameters - -| Variable | Description | Default Value | -| --- | --- | --- | -| `STRESS_TEST_ALGORITHM` | Stress test loop algorithm: `incremental` or `bisection`. | `incremental` | -| `STRESS_TEST_MAX_ITERATIONS` | Maximum number of stress test loop iterations. | `10` iterations | -| `STRESS_TEST_PROVISIONING` | Should the system be re-provisioned in each iteration? If enabled the dataset DB dump is re-imported and the warmup is run in each iteration. | `false` | -| `STRESS_TEST_PROVISIONING_GENERATE_DATASET` | Should the dataset be generated, instead of imported from DB dump? | `false` | -| `STRESS_TEST_PROVISIONING_PARAMETERS` | Additional parameters for the provisioning command. Optional. | | - -#### Incremental Algorithm - -| Variable | Description | Default Value | -| --- | --- | --- | -| `STRESS_TEST_UPS_FIRST` | Value of `usersPerSec` parameter in the first iteration. | `1.000` users per second | -| `STRESS_TEST_UPS_INCREMENT` | Increment of `usersPerSec` parameter for each subsequent iteration. | `1.000` users per second | - -#### Bisection Algorithm - -| Variable | Description | Default Value | -| --- | --- | --- | -| `STRESS_TEST_UPS_LOWER_BOUND` | Lower bound of `usersPerSec` parameter. | `0.000` users per second | -| `STRESS_TEST_UPS_UPPER_BOUND` | Upper bound of `usersPerSec` parameter. | `10.000` users per second | -| `STRESS_TEST_UPS_RESOLUTION` | Required resolution of the bisection algorithm. | `1.000` users per second | - diff --git a/testsuite/performance/db-failover/README.md b/testsuite/performance/db-failover/README.md deleted file mode 100644 index 215652fb34..0000000000 --- a/testsuite/performance/db-failover/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# DB Failover Testing Utilities - -A set of scripts for testing DB failover scenarios. - -The scripts expect to be run with relative execution prefix `./` from within the `db-failover` directory. - -Provisioned services are defined in `../docker-compose-db-failover.yml` template. - - -## Set the size of DB cluster - -Default size is 2 nodes. For a 3-node cluster run: `export NODES=3` before executing any of the scripts. - -For more than 3 nodes more service definitions need to be added to the docker-compose template. - -## Set up the environment - -Run `./setup.sh` - -This script will: -1. Start a bootstrap DB instance of MariaDB cluster -2. Start additional DB instances connected to the bootstrapped cluster -3. Stop the bootstrap DB instance -4. Optionally start Keycloak server - -Parameterized by environment variables: -- `MARIADB_HA_MODE` See: [MariaDB HA parameters](https://mariadb.com/kb/en/library/failover-and-high-availability-with-mariadb-connector-j/#failover-high-availability-parameters) - Defaults to `replication:`. -- `MARIADB_OPTIONS` See: [MariaDB HA options](https://mariadb.com/kb/en/library/failover-and-high-availability-with-mariadb-connector-j/#failover-high-availability-options). - Use format: `?option1=value1[&option2=value2]...`. Default is an empty string. -- `START_KEYCLOAK` Default is `false`. Use `export START_KEYCLOAK=true` to enable. - -More options relevant to MariaDB clustering can be found in `../db/mariadb/wsrep.cnf`. - - -## Test the failover - -### Manual failover - -To induce a failure of specific DB node run: `./kill-node.sh X` where `X ∈ {1..3}` - -To reconnect the node back run: `./reconnect-node.sh X` - - -### Automated failover loop - -Run `./loop.sh` - -This script will run an infinite loop of failover/failback of DB nodes, switching to the next node in each loop. - -Parameterized by environment variables: -- `TIME_BETWEEN_FAILURES` Default is `60` (seconds). -- `FAILURE_DURATION` Default is `60` (seconds). - -To exit the script press `Ctrl+C`. - - -### Check number of table rows across the cluster - -Run: `./check-rows.sh` - - -## Tear down the environment - -Run `./teardown.sh` - -This will stop all services and delete the database. diff --git a/testsuite/performance/db-failover/check-rows.sh b/testsuite/performance/db-failover/check-rows.sh deleted file mode 100755 index 215d387864..0000000000 --- a/testsuite/performance/db-failover/check-rows.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. ./common.sh - -CONCAT_SQL=$(< db-failover/concat.sql) -CONCAT_SQL_COMMAND='mysql -N -B -u keycloak --password=keycloak -e "$CONCAT_SQL" keycloak' -ROWS_SQL=$(eval docker-compose -f docker-compose-db-failover.yml exec mariadb_1 $CONCAT_SQL_COMMAND | tr -dc '[:print:]') -ROWS_SQL=${ROWS_SQL%UNION } -ROWS_SQL_COMMAND='mysql -u keycloak --password=keycloak -e "$ROWS_SQL" keycloak' - -for (( i=1; i <= $NODES; i++)); do - ROWS[i]=$(eval docker-compose -f docker-compose-db-failover.yml exec mariadb_$i $ROWS_SQL_COMMAND) -done - -DIFF=0 -for (( i=2; i <= $NODES; i++)); do - echo Node 1 vs Node $(( i )): - diff -y --suppress-common-lines <(echo "${ROWS[1]}") <(echo "${ROWS[i]}") - if [ $? -eq 0 ]; then echo No difference.; else DIFF=1; fi -done - -exit $DIFF diff --git a/testsuite/performance/db-failover/common.sh b/testsuite/performance/db-failover/common.sh deleted file mode 100755 index abdb8f9836..0000000000 --- a/testsuite/performance/db-failover/common.sh +++ /dev/null @@ -1,18 +0,0 @@ -function killNode { - echo Killing mariadb_${1} - docker-compose -f docker-compose-db-failover.yml kill mariadb_${1} -} - -function reconnectNode { - N=$1 - NR=$(( N + 1 )); if [ "$NR" -gt "$NODES" ]; then NR=1; fi - export MARIADB_RUNNING_HOST=mariadb_${NR} - echo Attempting failback of mariadb_${N}, connecting to running cluster member mariadb_${NR} - docker-compose -f docker-compose-db-failover.yml up -d mariadb_${N} -} - -if [ -z $NODES ]; then export NODES=2; fi -if [ -z $MARIADB_OPTIONS ]; then export MARIADB_OPTIONS=""; fi -if [ -z $START_KEYCLOAK ]; then export START_KEYCLOAK=false; fi - -cd .. diff --git a/testsuite/performance/db-failover/concat.sql b/testsuite/performance/db-failover/concat.sql deleted file mode 100644 index f329ae8590..0000000000 --- a/testsuite/performance/db-failover/concat.sql +++ /dev/null @@ -1,3 +0,0 @@ -SELECT CONCAT( - 'SELECT "', table_name, '" AS table_name, COUNT(*) AS exact_row_count FROM `', table_schema, '`.`', table_name, '` UNION ' -) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'keycloak'; diff --git a/testsuite/performance/db-failover/kill-node.sh b/testsuite/performance/db-failover/kill-node.sh deleted file mode 100755 index b47e39f3b4..0000000000 --- a/testsuite/performance/db-failover/kill-node.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -. ./common.sh - -if [ -z $1 ]; then echo "Specify DB node to kill."; exit 1; fi - -killNode $1 \ No newline at end of file diff --git a/testsuite/performance/db-failover/loop.sh b/testsuite/performance/db-failover/loop.sh deleted file mode 100755 index 79813b24e3..0000000000 --- a/testsuite/performance/db-failover/loop.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -. ./common.sh - -if [ -z "$TIME_BETWEEN_FAILURES" ]; then export TIME_BETWEEN_FAILURES=60; fi -if [ -z "$FAILURE_DURATION" ]; then export FAILURE_DURATION=60; fi - -echo Running DB failover loop with the following parameters: -echo NODES=$NODES -echo TIME_BETWEEN_FAILURES=$TIME_BETWEEN_FAILURES -echo FAILURE_DURATION=$FAILURE_DURATION -echo -echo Press Ctrl+C to interrupt. -echo - -N=1 - -while : -do - - killNode $N - - echo Waiting $FAILURE_DURATION s before attempting to reconnect mariadb_${N} - sleep $FAILURE_DURATION - - reconnectNode $N - - echo Waiting $TIME_BETWEEN_FAILURES s before inducing another failure. - echo - sleep $TIME_BETWEEN_FAILURES - - N=$((N+1)) - if [ "$N" -gt "$NODES" ]; then N=1; fi - -done \ No newline at end of file diff --git a/testsuite/performance/db-failover/reconnect-node.sh b/testsuite/performance/db-failover/reconnect-node.sh deleted file mode 100755 index 6788a79ebd..0000000000 --- a/testsuite/performance/db-failover/reconnect-node.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -. ./common.sh - -if [ -z $1 ]; then echo "Specify DB node to reconnect to cluster."; exit 1; fi - -reconnectNode $1 \ No newline at end of file diff --git a/testsuite/performance/db-failover/setup.sh b/testsuite/performance/db-failover/setup.sh deleted file mode 100755 index 6f407ae055..0000000000 --- a/testsuite/performance/db-failover/setup.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -. ./common.sh - -if [ -z "$DB_BOOTSTRAP_TIMEOUT" ]; then DB_BOOTSTRAP_TIMEOUT=10; fi -if [ -z "$DB_JOIN_TIMEOUT" ]; then DB_JOIN_TIMEOUT=5; fi - -echo Setting up Keycloak DB failover environment: - -echo Starting DB bootstrap instance. -docker-compose -f docker-compose-db-failover.yml up -d --build mariadb_bootstrap -echo Waiting $DB_BOOTSTRAP_TIMEOUT s for the DB to initialize. -sleep $DB_BOOTSTRAP_TIMEOUT - -MARIADB_HOSTS="" -for (( i=1; i<=$NODES; i++ )); do - - MARIADB_HOSTS=$MARIADB_HOSTS,mariadb_$i:3306 - - echo Starting DB node $i. - docker-compose -f docker-compose-db-failover.yml up -d mariadb_$i - echo Waiting $DB_JOIN_TIMEOUT s for the DB node to join - echo - sleep $DB_JOIN_TIMEOUT - -done - -echo Turning off the DB bootstrap instance. -docker-compose -f docker-compose-db-failover.yml stop mariadb_bootstrap - -export MARIADB_HOSTS=${MARIADB_HOSTS/,/} -echo MARIADB_HOSTS=$MARIADB_HOSTS - -if $START_KEYCLOAK; then - echo Starting Keycloak server. - docker-compose -f docker-compose-db-failover.yml up -d --build keycloak - ./healthcheck.sh -fi diff --git a/testsuite/performance/db-failover/teardown.sh b/testsuite/performance/db-failover/teardown.sh deleted file mode 100755 index ac472980f3..0000000000 --- a/testsuite/performance/db-failover/teardown.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -. ./common.sh - -echo Stopping Keycloak DB failover environment. - -docker-compose -f docker-compose-db-failover.yml down -v - diff --git a/testsuite/performance/db/mariadb/Dockerfile b/testsuite/performance/db/mariadb/Dockerfile deleted file mode 100644 index fe1e4ec45a..0000000000 --- a/testsuite/performance/db/mariadb/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM mariadb:10.3.3 - -ARG MAX_CONNECTIONS=100 - -ADD wsrep.cnf.template /etc/mysql/conf.d/ -RUN sed -e s/@MAX_CONNECTIONS@/$MAX_CONNECTIONS/ /etc/mysql/conf.d/wsrep.cnf.template > /etc/mysql/conf.d/wsrep.cnf; cat /etc/mysql/conf.d/wsrep.cnf - -ADD mariadb-healthcheck.sh /usr/local/bin/ -RUN chmod -v +x /usr/local/bin/mariadb-healthcheck.sh -HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["mariadb-healthcheck.sh"] - -ENV DATADIR /var/lib/mysql -ADD docker-entrypoint-wsrep.sh /usr/local/bin/ -RUN chmod -v +x /usr/local/bin/docker-entrypoint-wsrep.sh diff --git a/testsuite/performance/db/mariadb/README.md b/testsuite/performance/db/mariadb/README.md deleted file mode 100644 index 8b13789179..0000000000 --- a/testsuite/performance/db/mariadb/README.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/testsuite/performance/db/mariadb/docker-entrypoint-wsrep.sh b/testsuite/performance/db/mariadb/docker-entrypoint-wsrep.sh deleted file mode 100644 index 1d9b1f78b4..0000000000 --- a/testsuite/performance/db/mariadb/docker-entrypoint-wsrep.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -echo "docker-entrypoint-wsrep.sh: $1" - -if [ "$1" == "--wsrep-new-cluster" ]; then - - echo "docker-entrypoint-wsrep.sh: Cluster 'bootstrap' node." - -else - - echo "docker-entrypoint-wsrep.sh: Cluster 'member' node." - - if [ ! -d "$DATADIR/mysql" ]; then - echo "docker-entrypoint-wsrep.sh: Creating empty datadir to be populated from the cluster 'seed' node." - mkdir -p "$DATADIR/mysql" - chown -R mysql:mysql "$DATADIR" - fi - -fi - -echo "docker-entrypoint-wsrep.sh: Delegating to original mariadb docker-entrypoint.sh" -docker-entrypoint.sh "$@"; diff --git a/testsuite/performance/db/mariadb/mariadb-healthcheck.sh b/testsuite/performance/db/mariadb/mariadb-healthcheck.sh deleted file mode 100644 index 83b053c4a5..0000000000 --- a/testsuite/performance/db/mariadb/mariadb-healthcheck.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -eo pipefail - -if [ "$MYSQL_RANDOM_ROOT_PASSWORD" ] && [ -z "$MYSQL_USER" ] && [ -z "$MYSQL_PASSWORD" ]; then - # there's no way we can guess what the random MySQL password was - echo >&2 'healthcheck error: cannot determine random root password (and MYSQL_USER and MYSQL_PASSWORD were not set)' - exit 0 -fi - -host="$(hostname --ip-address || echo '127.0.0.1')" -user="${MYSQL_USER:-root}" -export MYSQL_PWD="${MYSQL_PASSWORD:-$MYSQL_ROOT_PASSWORD}" - -args=( - # force mysql to not use the local "mysqld.sock" (test "external" connectibility) - -h"$host" - -u"$user" - --silent -) - -if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then - exit 0 -fi - -exit 1 diff --git a/testsuite/performance/db/mariadb/wsrep.cnf.template b/testsuite/performance/db/mariadb/wsrep.cnf.template deleted file mode 100644 index d9fdcc9ca3..0000000000 --- a/testsuite/performance/db/mariadb/wsrep.cnf.template +++ /dev/null @@ -1,30 +0,0 @@ -[mysqld] -general_log=OFF -bind-address=0.0.0.0 - -innodb_flush_log_at_trx_commit=0 -query_cache_size=0 -query_cache_type=0 - -binlog_format=ROW -default_storage_engine=InnoDB -innodb_autoinc_lock_mode=2 -innodb_doublewrite=1 - -innodb_buffer_pool_size=122M - -max_connections=@MAX_CONNECTIONS@ - -wsrep_on=ON -wsrep_provider=/usr/lib/galera/libgalera_smm.so - -wsrep_provider_options="gcache.size=300M; gcache.page_size=300M" -#wsrep_provider_options="gcache.size=300M; gcache.page_size=300M; pc.bootstrap=YES" -#wsrep_provider_options="gcache.size=300M; gcache.page_size=300M; pc.bootstrap=YES; pc.ignore_sb=TRUE" -# See: http://galeracluster.com/documentation-webpages/twonode.html - -wsrep_cluster_address="gcomm://" -wsrep_cluster_name="galera_cluster_keycloak" -wsrep_sst_method=rsync -#wsrep_sst_auth="root:root" -wsrep_slave_threads=16 diff --git a/testsuite/performance/docker-compose-db-failover.yml b/testsuite/performance/docker-compose-db-failover.yml deleted file mode 100644 index 21f7392203..0000000000 --- a/testsuite/performance/docker-compose-db-failover.yml +++ /dev/null @@ -1,101 +0,0 @@ -version: "2.2" - -networks: - keycloak: - ipam: - config: - - subnet: 10.0.1.0/24 - - db_replication: - ipam: - config: - - subnet: 10.0.3.0/24 - -services: - - mariadb_bootstrap: - build: db/mariadb - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - networks: - - db_replication - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_INITDB_SKIP_TZINFO: foo - MYSQL_DATABASE: keycloak - MYSQL_USER: keycloak - MYSQL_PASSWORD: keycloak - entrypoint: docker-entrypoint-wsrep.sh - command: --wsrep-new-cluster - - mariadb_1: - build: db/mariadb - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - networks: - - db_replication - - keycloak - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_INITDB_SKIP_TZINFO: foo - entrypoint: docker-entrypoint-wsrep.sh - command: --wsrep_cluster_address=gcomm://${MARIADB_RUNNING_HOST:-mariadb_bootstrap} - ports: - - "3316:3306" - - mariadb_2: - build: db/mariadb - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - networks: - - db_replication - - keycloak - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_INITDB_SKIP_TZINFO: foo - entrypoint: docker-entrypoint-wsrep.sh - command: --wsrep_cluster_address=gcomm://${MARIADB_RUNNING_HOST:-mariadb_bootstrap} - ports: - - "3326:3306" - - mariadb_3: - build: db/mariadb - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - networks: - - db_replication - - keycloak - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_INITDB_SKIP_TZINFO: foo - entrypoint: docker-entrypoint-wsrep.sh - command: --wsrep_cluster_address=gcomm://${MARIADB_RUNNING_HOST:-mariadb_bootstrap} - ports: - - "3336:3306" - - - keycloak: - build: keycloak/target/docker - image: keycloak_test_keycloak:${KEYCLOAK_VERSION:-latest} - networks: - - keycloak - environment: - MARIADB_HA_MODE: ${MARIADB_HA_MODE:-replication:} - MARIADB_HOSTS: ${MARIADB_HOSTS:-mariadb_1:3306,mariadb_2:3306} - MARIADB_OPTIONS: ${MARIADB_OPTIONS} - MARIADB_DATABASE: keycloak - MARIADB_USER: keycloak - MARIADB_PASSWORD: keycloak - KEYCLOAK_ADMIN_USER: admin - KEYCLOAK_ADMIN_PASSWORD: admin - # docker-compose syntax note: ${ENV_VAR:-} - JAVA_OPTS: ${KEYCLOAK_JVM_MEMORY:--Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${KEYCLOAK_HTTP_MAX_CONNECTIONS:-500} - WORKER_IO_THREADS: ${KEYCLOAK_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${KEYCLOAK_WORKER_TASK_MAX_THREADS:-16} - DS_MIN_POOL_SIZE: ${KEYCLOAK_DS_MIN_POOL_SIZE:-10} - DS_MAX_POOL_SIZE: ${KEYCLOAK_DS_MAX_POOL_SIZE:-100} - DS_POOL_PREFILL: "${KEYCLOAK_DS_POOL_PREFILL:-true}" - DS_PS_CACHE_SIZE: ${KEYCLOAK_DS_PS_CACHE_SIZE:-100} - ports: - - "8080:8080" - - "8443:8443" - - "7989:7989" - - "9990:9990" - - "9999:9999" diff --git a/testsuite/performance/infinispan/infinispan.xml b/testsuite/performance/infinispan/infinispan.xml deleted file mode 100644 index 48aa69690a..0000000000 --- a/testsuite/performance/infinispan/infinispan.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - This artifact was downloaded from: ${infinispan.zip.src}/${infinispan.zip.filename} - - - - - - - configured: ${configured} - management.configured: ${management.configured} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $JBOSS_LOG_DIR/jstat-gc.log & - fi -]]> - - - - - - Adding management user: `${management.user}` - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/performance/infinispan/pom.xml b/testsuite/performance/infinispan/pom.xml deleted file mode 100644 index 7bc2bd4096..0000000000 --- a/testsuite/performance/infinispan/pom.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - org.keycloak.testsuite - performance - 999-SNAPSHOT - ../pom.xml - - 4.0.0 - - performance-keycloak-infinispan-server - Keycloak Performance TestSuite - Infinispan Server - pom - - - org.infinispan.server - infinispan-server-build - - infinispan-server-${infinispan.version} - ${project.build.directory}/${infinispan.unpacked.folder.name} - - sh - ispn-cli.${script.extension} - add-user.${script.extension} - - ${project.build.scriptSourceDirectory} - ${project.basedir}/src/main/resources - - true - false - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - download-infinispan - generate-resources - - run - - - - - - - - - configure-infinispan - process-resources - - run - - - - - - - - - add-management-user - process-resources - - run - - - ${skip.add.management.user} - - - - - - - prepare-docker-config - process-resources - - run - - - ${skip.docker.config} - - - - - - - - - - - - - - add-management-user - - - management.user - - - - false - - ${management.user} - ${management.user.password} - - - - - windows - - - windows - - - - ps1 - - - - - - \ No newline at end of file diff --git a/testsuite/performance/infinispan/src/main/scripts/Dockerfile b/testsuite/performance/infinispan/src/main/scripts/Dockerfile deleted file mode 100644 index 2916fb23be..0000000000 --- a/testsuite/performance/infinispan/src/main/scripts/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM jboss/base-jdk:8 - -ENV LAUNCH_JBOSS_IN_BACKGROUND 1 -ENV JSTAT false -ENV CONFIGURATION clustered.xml -ENV INFINISPAN_SERVER_HOME /opt/jboss/infinispan-server -WORKDIR $INFINISPAN_SERVER_HOME - -USER root -RUN yum -y install iproute - -ADD infinispan-server ./ -ADD *.sh /usr/local/bin/ -RUN chown -R jboss .; chgrp -R jboss .; chmod -R -v ug+x bin/*.sh ; chmod -R -v ug+x /usr/local/bin/ - -USER jboss -EXPOSE 7600 8080 8181 8888 9990 11211 11222 57600 -HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["infinispan-healthcheck.sh"] -ENTRYPOINT [ "docker-entrypoint-custom.sh" ] diff --git a/testsuite/performance/infinispan/src/main/scripts/docker-entrypoint-custom.sh b/testsuite/performance/infinispan/src/main/scripts/docker-entrypoint-custom.sh deleted file mode 100755 index 75895847b5..0000000000 --- a/testsuite/performance/infinispan/src/main/scripts/docker-entrypoint-custom.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -cat $INFINISPAN_SERVER_HOME/standalone/configuration/$CONFIGURATION - -. get-ips.sh - -PARAMS="-b $PUBLIC_IP -bmanagement $PUBLIC_IP -bprivate $PRIVATE_IP -Djgroups.bind_addr=$PUBLIC_IP -c $CONFIGURATION $@" -echo "Server startup params: $PARAMS" - -# Note: External container connectivity is always provided by eth0 -- irrespective of which is considered public/private by KC. -# In case the container needs to be accessible on the host computer override -b $PUBLIC_IP by adding: `-b 0.0.0.0` to the docker command. - -if [ $MGMT_USER ] && [ $MGMT_USER_PASSWORD ]; then - echo Adding mgmt user: $MGMT_USER - $INFINISPAN_SERVER_HOME/bin/add-user.sh -u $MGMT_USER -p $MGMT_USER_PASSWORD -fi - -if [ $APP_USER ] && [ $APP_USER_PASSWORD ]; then - echo Adding app user: $APP_USER - if [ -z $APP_USER_GROUPS ]; then - $INFINISPAN_SERVER_HOME/bin/add-user.sh -a --user $APP_USER --password $APP_USER_PASSWORD - else - $INFINISPAN_SERVER_HOME/bin/add-user.sh -a --user $APP_USER --password $APP_USER_PASSWORD --group $APP_USER_GROUPS - fi -fi - -exec $INFINISPAN_SERVER_HOME/bin/standalone.sh $PARAMS -exit $? diff --git a/testsuite/performance/infinispan/src/main/scripts/get-ips.sh b/testsuite/performance/infinispan/src/main/scripts/get-ips.sh deleted file mode 100755 index ac5c5943b8..0000000000 --- a/testsuite/performance/infinispan/src/main/scripts/get-ips.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# This script: -# - assumes there are 2 network interfaces connected to $PUBLIC_SUBNET and $PRIVATE_SUBNET respectively -# - finds IP addresses from those interfaces using `ip` command -# - exports the IPs as variables - -function getIpForSubnet { - if [ -z $1 ]; then - echo Subnet parameter undefined - exit 1 - else - ip r | grep $1 | sed 's/.*src\ \([^\ ]*\).*/\1/' - fi -} - -if [ -z $PUBLIC_SUBNET ]; then - PUBLIC_IP=0.0.0.0 - echo PUBLIC_SUBNET undefined. PUBLIC_IP defaults to $PUBLIC_IP -else - export PUBLIC_IP=`getIpForSubnet $PUBLIC_SUBNET` -fi - -if [ -z $PRIVATE_SUBNET ]; then - PRIVATE_IP=127.0.0.1 - echo PRIVATE_SUBNET undefined. PRIVATE_IP defaults to $PRIVATE_IP -else - export PRIVATE_IP=`getIpForSubnet $PRIVATE_SUBNET` -fi - -echo Routing table: -ip r -echo PUBLIC_SUBNET=$PUBLIC_SUBNET -echo PRIVATE_SUBNET=$PRIVATE_SUBNET -echo PUBLIC_IP=$PUBLIC_IP -echo PRIVATE_IP=$PRIVATE_IP - diff --git a/testsuite/performance/infinispan/src/main/scripts/infinispan-healthcheck.sh b/testsuite/performance/infinispan/src/main/scripts/infinispan-healthcheck.sh deleted file mode 100755 index 4238be43a1..0000000000 --- a/testsuite/performance/infinispan/src/main/scripts/infinispan-healthcheck.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. get-ips.sh - -CODE=`curl -s -o /dev/null -w "%{http_code}" http://$PUBLIC_IP:9990/console/index.html` - -if [ "$CODE" -eq "200" ]; then - exit 0 -fi - -exit 1 - diff --git a/testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-keycloak-caches.cli b/testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-keycloak-caches.cli deleted file mode 100644 index c119e6d243..0000000000 --- a/testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-keycloak-caches.cli +++ /dev/null @@ -1,32 +0,0 @@ -embed-server --server-config=clustered-@LOCAL_SITE@.xml - -# 2) -cd /subsystem=datagrid-jgroups - -# 2.a) -./channel=xsite:add(stack=tcp-private) - -# 2.b) -./stack=udp/relay=RELAY:add(site="@LOCAL_SITE@", properties={relay_multicasts=false}) -./stack=udp/relay=RELAY/remote-site=@REMOTE_SITE@:add(channel=xsite) - - - -# 3) -cd /subsystem=datagrid-infinispan/cache-container=clustered/configurations=CONFIGURATIONS - -./replicated-cache-configuration=sessions-cfg:add(mode=SYNC, start=EAGER, batching=false) -cd replicated-cache-configuration=sessions-cfg -./transaction=TRANSACTION:add(mode=NON_DURABLE_XA, locking=PESSIMISTIC) -./locking=LOCKING:add(acquire-timeout=0) -./backup=@REMOTE_SITE@:add(failure-policy=FAIL, strategy=SYNC, enabled=true, min-wait=60000, after-failures=3) - -cd /subsystem=datagrid-infinispan/cache-container=clustered -./replicated-cache=work:add(configuration=sessions-cfg) -./replicated-cache=sessions:add(configuration=sessions-cfg) -./replicated-cache=clientSessions:add(configuration=sessions-cfg) -./replicated-cache=offlineSessions:add(configuration=sessions-cfg) -./replicated-cache=offlineClientSessions:add(configuration=sessions-cfg) -./replicated-cache=actionTokens:add(configuration=sessions-cfg) -./replicated-cache=loginFailures:add(configuration=sessions-cfg) - diff --git a/testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-private-network-interface.cli b/testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-private-network-interface.cli deleted file mode 100644 index 8b519b17c9..0000000000 --- a/testsuite/performance/infinispan/src/main/scripts/jboss-cli/add-private-network-interface.cli +++ /dev/null @@ -1,33 +0,0 @@ -embed-server --server-config=clustered.xml - -echo *** Adding private network interface for cross-DC communication - -/interface=private:add(inet-address=${jboss.bind.address.private:127.0.0.1}) - - -echo *** Adding jgroups socket bindings for private network interface - -cd /socket-binding-group=standard-sockets -./socket-binding=jgroups-mping-private:add( interface=private, port=0, multicast-address="${jboss.private.multicast.address:234.99.54.14}", multicast-port="45700") -./socket-binding=jgroups-tcp-private:add( interface=private, port=7600) -./socket-binding=jgroups-tcp-fd-private:add(interface=private, port=57600) -./socket-binding=jgroups-udp-private:add( interface=private, port=55200, multicast-address="${jboss.private.multicast.address:234.99.54.14}", multicast-port="45688") -./socket-binding=jgroups-udp-fd-private:add(interface=private, port=54200) - - -echo *** Adding TCP protocol stack for private network interface - -/subsystem=datagrid-jgroups/stack=tcp-private:add(transport={type=TCP, socket-binding=jgroups-tcp-private}, protocols=[ \ - {type=MPING, socket-binding=jgroups-mping-private}, \ - {type=MERGE3}, \ - {type=FD_SOCK, socket-binding=jgroups-tcp-fd-private}, \ - {type=FD_ALL}, \ - {type=VERIFY_SUSPECT}, \ - {type=pbcast.NAKACK2, properties={"use_mcast_xmit" => "false"}}, \ - {type=UNICAST3}, \ - {type=pbcast.STABLE}, \ - {type=pbcast.GMS}, \ - {type=MFC_NB}, \ - {type=FRAG3} \ -]) -# Note: for Infinispan 8.x change the above FRAG3 to FRAG2 diff --git a/testsuite/performance/keycloak/configure.xml b/testsuite/performance/keycloak/configure.xml deleted file mode 100644 index 2356d54e54..0000000000 --- a/testsuite/performance/keycloak/configure.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - performance.configured: ${performance.configured} - management.configured: ${management.configured} - crossdc.configured: ${crossdc.configured} - - - - Applying keycloak performance configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $JBOSS_LOG_DIR/jstat-gc.log & - fi -]]> - - - - - - Adding management user: `${management.user}` - - - - - - - - - - - - keycloak-crossdc-configuration - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/performance/keycloak/pom.xml b/testsuite/performance/keycloak/pom.xml deleted file mode 100644 index c646c9a527..0000000000 --- a/testsuite/performance/keycloak/pom.xml +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - org.keycloak.testsuite - performance - 999-SNAPSHOT - ../pom.xml - - 4.0.0 - - performance-keycloak-server - Keycloak Performance TestSuite - Keycloak Server - pom - - - Uses maven-dependency-plugin to unpack keycloak-server-dist artifact into `target/keycloak` which is then added to Docker image. - - - - org.keycloak - keycloak-server-dist - - keycloak-${server.version} - ${project.build.directory}/${server.unpacked.folder.name} - - org.mariadb.jdbc - mariadb-java-client - 2.2.4 - org/mariadb/jdbc - - sh - jboss-cli.${script.extension} - add-user.${script.extension} - - true - - false - true - false - - ${project.build.scriptSourceDirectory} - ${project.basedir}/src/main/resources - - - - - - - maven-dependency-plugin - - - unpack-keycloak-server-dist - generate-resources - - unpack - - - true - - - ${server.groupId} - ${server.artifactId} - ${server.version} - zip - ${project.build.directory} - - - - - - copy-jdbc-driver - generate-resources - - copy - - - true - - - ${jdbc.driver.groupId} - ${jdbc.driver.artifactId} - ${jdbc.driver.version} - jar - ${server.unpacked.home}/modules/system/layers/base/${jdbc.driver.module.path}/main - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - keycloak-performance-configuration - process-resources - - run - - - - - - - - - keycloak-crossdc-configuration - process-resources - - run - - - ${skip.crossdc.configuration} - - - - - - - add-management-user - process-resources - - run - - - ${skip.add.management.user} - - - - - - - keycloak-docker - process-resources - - run - - - ${skip.keycloak.docker} - - - - - - - - - - - - - - windows - - - windows - - - - ps1 - - - - - add-management-user - - - management.user - - - - false - - ${management.user} - ${management.user.password} - - - - - crossdc - - false - - - - - integration-testsuite-server - - org.keycloak.testsuite - integration-arquillian-servers-auth-server-wildfly - auth-server-wildfly - - - - - - diff --git a/testsuite/performance/keycloak/src/main/resources/module.xml b/testsuite/performance/keycloak/src/main/resources/module.xml deleted file mode 100644 index 54bec11e72..0000000000 --- a/testsuite/performance/keycloak/src/main/resources/module.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - diff --git a/testsuite/performance/keycloak/src/main/scripts/Dockerfile b/testsuite/performance/keycloak/src/main/scripts/Dockerfile deleted file mode 100644 index 4619dec45d..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM jboss/base-jdk:8 - -ENV JBOSS_HOME /opt/jboss/keycloak -WORKDIR $JBOSS_HOME - -ENV CONFIGURATION standalone.xml - -# Enables signals getting passed from startup script to JVM -# ensuring clean shutdown when container is stopped. -ENV LAUNCH_JBOSS_IN_BACKGROUND 1 -ENV PROXY_ADDRESS_FORWARDING false -ENV JSTAT false - -USER root -RUN yum install -y epel-release jq iproute && yum clean all - -ADD keycloak ./ -ADD *.sh /usr/local/bin/ - -USER root -RUN chown -R jboss .; chgrp -R jboss .; chmod -R -v ug+x bin/*.sh ; \ - chmod -R -v +x /usr/local/bin/ - -USER jboss - -EXPOSE 8080 -EXPOSE 9990 -HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["keycloak-healthcheck.sh"] -ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/testsuite/performance/keycloak/src/main/scripts/docker-entrypoint.sh b/testsuite/performance/keycloak/src/main/scripts/docker-entrypoint.sh deleted file mode 100644 index e3c68e44be..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/docker-entrypoint.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -cat $JBOSS_HOME/standalone/configuration/$CONFIGURATION - -. get-ips.sh - -PARAMS="-b $PUBLIC_IP -bmanagement $PUBLIC_IP -bprivate $PRIVATE_IP -c $CONFIGURATION $@" -echo "Server startup params: $PARAMS" - -# Note: External container connectivity is always provided by eth0 -- irrespective of which is considered public/private by KC. -# In case the container needs to be accessible on the host computer override -b $PUBLIC_IP by adding: `-b 0.0.0.0` to the docker command. - -if [ $KEYCLOAK_ADMIN_USER ] && [ $KEYCLOAK_ADMIN_PASSWORD ]; then - $JBOSS_HOME/bin/add-user-keycloak.sh --user $KEYCLOAK_ADMIN_USER --password $KEYCLOAK_ADMIN_PASSWORD -fi - -exec /opt/jboss/keycloak/bin/standalone.sh $PARAMS diff --git a/testsuite/performance/keycloak/src/main/scripts/get-ips.sh b/testsuite/performance/keycloak/src/main/scripts/get-ips.sh deleted file mode 100644 index ac5c5943b8..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/get-ips.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# This script: -# - assumes there are 2 network interfaces connected to $PUBLIC_SUBNET and $PRIVATE_SUBNET respectively -# - finds IP addresses from those interfaces using `ip` command -# - exports the IPs as variables - -function getIpForSubnet { - if [ -z $1 ]; then - echo Subnet parameter undefined - exit 1 - else - ip r | grep $1 | sed 's/.*src\ \([^\ ]*\).*/\1/' - fi -} - -if [ -z $PUBLIC_SUBNET ]; then - PUBLIC_IP=0.0.0.0 - echo PUBLIC_SUBNET undefined. PUBLIC_IP defaults to $PUBLIC_IP -else - export PUBLIC_IP=`getIpForSubnet $PUBLIC_SUBNET` -fi - -if [ -z $PRIVATE_SUBNET ]; then - PRIVATE_IP=127.0.0.1 - echo PRIVATE_SUBNET undefined. PRIVATE_IP defaults to $PRIVATE_IP -else - export PRIVATE_IP=`getIpForSubnet $PRIVATE_SUBNET` -fi - -echo Routing table: -ip r -echo PUBLIC_SUBNET=$PUBLIC_SUBNET -echo PRIVATE_SUBNET=$PRIVATE_SUBNET -echo PUBLIC_IP=$PUBLIC_IP -echo PRIVATE_IP=$PRIVATE_IP - diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/add-remote-cache-stores.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/add-remote-cache-stores.cli deleted file mode 100644 index b103426f75..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/add-remote-cache-stores.cli +++ /dev/null @@ -1,26 +0,0 @@ -embed-server --server-config=standalone-ha.xml - -/subsystem=jgroups/stack=udp/transport=UDP:write-attribute(name=site, value=${env.SITE:dc1}) -/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=remote-cache:add(host=${env.INFINISPAN_HOST:localhost}, port=${env.INFINISPAN_PORT:11222}) - -cd /subsystem=infinispan/cache-container=keycloak - -:write-attribute(name=module, value=org.keycloak.keycloak-model-infinispan) - -./replicated-cache=work/store=remote:add(cache=work, fetch-state=false, passivation=false, preload=false, purge=false, remote-servers=["remote-cache"], shared=true, properties={rawValues=true, marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, protocolVersion=${env.HOTROD_VERSION:2.8}}) -./distributed-cache=sessions/store=remote:add(cache=sessions, fetch-state=false, passivation=false, preload=false, purge=false, remote-servers=["remote-cache"], shared=true, properties={rawValues=true, marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, protocolVersion=${env.HOTROD_VERSION:2.8}}) -./distributed-cache=offlineSessions/store=remote:add(cache=offlineSessions, fetch-state=false, passivation=false, preload=false, purge=false, remote-servers=["remote-cache"], shared=true, properties={rawValues=true, marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, protocolVersion=${env.HOTROD_VERSION:2.8}}) -./distributed-cache=clientSessions/store=remote:add(cache=clientSessions, fetch-state=false, passivation=false, preload=false, purge=false, remote-servers=["remote-cache"], shared=true, properties={rawValues=true, marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, protocolVersion=${env.HOTROD_VERSION:2.8}}) -./distributed-cache=offlineClientSessions/store=remote:add(cache=offlineClientSessions, fetch-state=false, passivation=false, preload=false, purge=false, remote-servers=["remote-cache"], shared=true, properties={rawValues=true, marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, protocolVersion=${env.HOTROD_VERSION:2.8}}) -./distributed-cache=loginFailures/store=remote:add(cache=loginFailures, fetch-state=false, passivation=false, preload=false, purge=false, remote-servers=["remote-cache"], shared=true, properties={rawValues=true, marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, protocolVersion=${env.HOTROD_VERSION:2.8}}) -./distributed-cache=actionTokens/store=remote:add(cache=actionTokens, fetch-state=false, passivation=false, preload=false, purge=false, remote-servers=["remote-cache"], shared=true, properties={rawValues=true, marshaller=org.keycloak.cluster.infinispan.KeycloakHotRodMarshallerFactory, protocolVersion=${env.HOTROD_VERSION:2.8}}) - - -./replicated-cache=work:write-attribute (name=statistics-enabled, value=${env.CACHE_STATISTICS:true}) -./distributed-cache=sessions:write-attribute (name=statistics-enabled, value=${env.CACHE_STATISTICS:true}) -./distributed-cache=offlineSessions:write-attribute (name=statistics-enabled, value=${env.CACHE_STATISTICS:true}) -./distributed-cache=clientSessions:write-attribute (name=statistics-enabled, value=${env.CACHE_STATISTICS:true}) -./distributed-cache=offlineClientSessions:write-attribute (name=statistics-enabled, value=${env.CACHE_STATISTICS:true}) -./distributed-cache=loginFailures:write-attribute (name=statistics-enabled, value=${env.CACHE_STATISTICS:true}) -./distributed-cache=actionTokens:write-attribute (name=statistics-enabled, value=${env.CACHE_STATISTICS:true}) - diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/distributed-cache-owners.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/distributed-cache-owners.cli deleted file mode 100644 index 6618261c7b..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/distributed-cache-owners.cli +++ /dev/null @@ -1,13 +0,0 @@ -embed-server --server-config=standalone-ha.xml - -# increase number of "owners" for distributed keycloak caches to support failover - -cd /subsystem=infinispan/cache-container=keycloak/ - -./distributed-cache=sessions:write-attribute(name=owners, value=${distributed.cache.owners:2}) -./distributed-cache=offlineSessions:write-attribute(name=owners, value=${distributed.cache.owners:2}) -./distributed-cache=clientSessions:write-attribute(name=owners, value=${distributed.cache.owners:2}) -./distributed-cache=offlineClientSessions:write-attribute(name=owners, value=${distributed.cache.owners:2}) -./distributed-cache=loginFailures:write-attribute(name=owners, value=${distributed.cache.owners:2}) -./distributed-cache=actionTokens:write-attribute(name=owners, value=${distributed.cache.owners:2}) - diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/infinispan-debug-logging.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/infinispan-debug-logging.cli deleted file mode 100644 index ed5d58f2b5..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/infinispan-debug-logging.cli +++ /dev/null @@ -1,8 +0,0 @@ -embed-server --server-config=standalone-ha.xml - -cd subsystem=logging - -./logger=org.keycloak.cluster.infinispan:add(level=DEBUG) -./logger=org.keycloak.connections.infinispan:add(level=DEBUG) -./logger=org.keycloak.models.cache.infinispan:add(level=DEBUG) -./logger=org.keycloak.models.sessions.infinispan:add(level=DEBUG) diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads-batch.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads-batch.cli deleted file mode 100644 index d8972f4c68..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads-batch.cli +++ /dev/null @@ -1,5 +0,0 @@ -# default is cpuCount * 2 -/subsystem=io/worker=default:write-attribute(name=io-threads,value=${env.WORKER_IO_THREADS:2}) - -# default is cpuCount * 16 -/subsystem=io/worker=default:write-attribute(name=task-max-threads,value=${env.WORKER_TASK_MAX_THREADS:16}) diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads.cli deleted file mode 100644 index bea3630e76..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/io-worker-threads.cli +++ /dev/null @@ -1,7 +0,0 @@ -embed-server --server-config=standalone.xml -run-batch --file=io-worker-threads-batch.cli - -stop-embedded-server - -embed-server --server-config=standalone-ha.xml -run-batch --file=io-worker-threads-batch.cli diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/modcluster-simple-load-provider.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/modcluster-simple-load-provider.cli deleted file mode 100644 index be7ac21c21..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/modcluster-simple-load-provider.cli +++ /dev/null @@ -1,7 +0,0 @@ -embed-server --server-config=standalone-ha.xml - -# remove dynamic-load-provider -/subsystem=modcluster/mod-cluster-config=configuration/dynamic-load-provider=configuration:remove - -# add simple-load-provider with factor=1 to assure round-robin balancing -/subsystem=modcluster/mod-cluster-config=configuration:write-attribute(name=simple-load-provider, value=1) \ No newline at end of file diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds-batch.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds-batch.cli deleted file mode 100644 index 396b5866ff..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds-batch.cli +++ /dev/null @@ -1,20 +0,0 @@ -/subsystem=datasources/jdbc-driver=mariadb:add(driver-name=mariadb, driver-module-name=org.mariadb.jdbc, driver-xa-datasource-class-name=org.mariadb.jdbc.MySQLDataSource) - -cd /subsystem=datasources/data-source=KeycloakDS - -:write-attribute(name=connection-url, value=jdbc:mariadb:${env.MARIADB_HA_MODE:}//${env.MARIADB_HOSTS:mariadb:3306}/${env.MARIADB_DATABASE:keycloak}${env.MARIADB_OPTIONS:}) -:write-attribute(name=driver-name, value=mariadb) -:write-attribute(name=user-name, value=${env.MARIADB_USER:keycloak}) -:write-attribute(name=password, value=${env.MARIADB_PASSWORD:keycloak}) - -:write-attribute(name=check-valid-connection-sql, value="SELECT 1") -:write-attribute(name=background-validation, value=true) -:write-attribute(name=background-validation-millis, value=60000) - -:write-attribute(name=min-pool-size, value=${env.DS_MIN_POOL_SIZE:10}) -:write-attribute(name=max-pool-size, value=${env.DS_MAX_POOL_SIZE:100}) -:write-attribute(name=pool-prefill, value=${env.DS_POOL_PREFILL:true}) -:write-attribute(name=prepared-statements-cache-size, value=${env.DS_PS_CACHE_SIZE:100}) - -:write-attribute(name=flush-strategy, value=IdleConnections) -:write-attribute(name=use-ccm, value=true) diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds.cli deleted file mode 100644 index 0582202a3d..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/set-keycloak-ds.cli +++ /dev/null @@ -1,7 +0,0 @@ -embed-server --server-config=standalone.xml -run-batch --file=set-keycloak-ds-batch.cli - -stop-embedded-server - -embed-server --server-config=standalone-ha.xml -run-batch --file=set-keycloak-ds-batch.cli diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow-batch.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow-batch.cli deleted file mode 100644 index dac5833c5e..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow-batch.cli +++ /dev/null @@ -1,2 +0,0 @@ -/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=proxy-address-forwarding, value=${env.PROXY_ADDRESS_FORWARDING}) -/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-connections,value=${env.HTTP_MAX_CONNECTIONS:50000}) diff --git a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow.cli b/testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow.cli deleted file mode 100644 index edfe8eeb62..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/jboss-cli/undertow.cli +++ /dev/null @@ -1,9 +0,0 @@ -embed-server --server-config=standalone.xml -run-batch --file=undertow-batch.cli - -stop-embedded-server - -embed-server --server-config=standalone-ha.xml -run-batch --file=undertow-batch.cli - -/subsystem=undertow/server=default-server/ajp-listener=ajp:write-attribute(name=max-connections,value=${env.AJP_MAX_CONNECTIONS:50000}) diff --git a/testsuite/performance/keycloak/src/main/scripts/keycloak-healthcheck.sh b/testsuite/performance/keycloak/src/main/scripts/keycloak-healthcheck.sh deleted file mode 100644 index ce6c1ca45b..0000000000 --- a/testsuite/performance/keycloak/src/main/scripts/keycloak-healthcheck.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -. get-ips.sh - -CODE=`curl -s -o /dev/null -w "%{http_code}" http://$PUBLIC_IP:8080/auth/realms/master` - -if [ "$CODE" -eq "200" ]; then - exit 0 -fi - -exit 1 diff --git a/testsuite/performance/load-balancer/debug-advertise/Advertise.java b/testsuite/performance/load-balancer/debug-advertise/Advertise.java deleted file mode 100644 index 425d34dcad..0000000000 --- a/testsuite/performance/load-balancer/debug-advertise/Advertise.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright(c) 2010 Red Hat Middleware, LLC, - * and individual contributors as indicated by the @authors tag. - * See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * @author Jean-Frederic Clere - * @version $Revision: 420067 $, $Date: 2006-07-08 09:16:58 +0200 (sub, 08 srp 2006) $ - */ -import java.net.MulticastSocket; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.DatagramPacket; - -public class Advertise -{ - /* - * Client to test Advertize... Run it on node boxes to test for firewall. - */ - public static void main(String[] args) throws Exception - { - if (args.length != 2 && args.length != 3) { - System.out.println("Usage: Advertize multicastaddress port [bindaddress]"); - System.out.println("java Advertize 224.0.1.105 23364"); - System.out.println("or"); - System.out.println("java Advertize 224.0.1.105 23364 10.33.144.3"); - System.out.println("receive from 224.0.1.105:23364"); - System.exit(1); - } - - InetAddress group = InetAddress.getByName(args[0]); - int port = Integer.parseInt(args[1]); - InetAddress socketInterface = null; - if (args.length == 3) - socketInterface = InetAddress.getByName(args[2]); - MulticastSocket s = null; - String value = System.getProperty("os.name"); - if ((value != null) && (value.toLowerCase().startsWith("linux") || value.toLowerCase().startsWith("mac") || value.toLowerCase().startsWith("hp"))) { - System.out.println("Linux like OS"); - s = new MulticastSocket(new InetSocketAddress(group, port)); - } else - s = new MulticastSocket(port); - s.setTimeToLive(0); - if (socketInterface != null) { - s.setInterface(socketInterface); - } - s.joinGroup(group); - boolean ok = true; - System.out.println("ready waiting..."); - while (ok) { - byte[] buf = new byte[1000]; - DatagramPacket recv = new DatagramPacket(buf, buf.length); - s.receive(recv); - String data = new String(buf); - System.out.println("received: " + data); - System.out.println("received from " + recv.getSocketAddress()); - } - s.leaveGroup(group); - } -} diff --git a/testsuite/performance/load-balancer/debug-advertise/Dockerfile b/testsuite/performance/load-balancer/debug-advertise/Dockerfile deleted file mode 100644 index 13aca42a48..0000000000 --- a/testsuite/performance/load-balancer/debug-advertise/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM jboss/base-jdk:8 - -ADD SAdvertise.java . -RUN javac SAdvertise.java - -ENTRYPOINT ["java", "SAdvertise"] -CMD ["0.0.0.0", "224.0.1.105", "23364"] diff --git a/testsuite/performance/load-balancer/debug-advertise/Dockerfile-client b/testsuite/performance/load-balancer/debug-advertise/Dockerfile-client deleted file mode 100644 index e67413a0f9..0000000000 --- a/testsuite/performance/load-balancer/debug-advertise/Dockerfile-client +++ /dev/null @@ -1,7 +0,0 @@ -FROM jboss/base-jdk:8 - -ADD Advertise.java . -RUN javac Advertise.java - -ENTRYPOINT ["java", "Advertise"] -CMD ["224.0.1.105", "23364"] diff --git a/testsuite/performance/load-balancer/debug-advertise/README.md b/testsuite/performance/load-balancer/debug-advertise/README.md deleted file mode 100644 index e28c4f14fb..0000000000 --- a/testsuite/performance/load-balancer/debug-advertise/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# mod_cluster advertize - -Docker container for testing mod_cluster "advertise" functionality. - diff --git a/testsuite/performance/load-balancer/debug-advertise/SAdvertise.java b/testsuite/performance/load-balancer/debug-advertise/SAdvertise.java deleted file mode 100644 index d760b78c94..0000000000 --- a/testsuite/performance/load-balancer/debug-advertise/SAdvertise.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright(c) 2010 Red Hat Middleware, LLC, - * and individual contributors as indicated by the @authors tag. - * See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * @author Jean-Frederic Clere - * @version $Revision: 420067 $, $Date: 2006-07-08 09:16:58 +0200 (sub, 08 srp 2006) $ - */ -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.DatagramPacket; -import java.net.MulticastSocket; - -public class SAdvertise { - - /* - * Server to test Advertize... Run it on httpd box to test for firewall. - */ - public static void main(String[] args) throws Exception { - if (args.length != 3) { - System.out.println("Usage: SAdvertize localaddress multicastaddress port"); - System.out.println("java SAdvertize 10.16.88.178 224.0.1.105 23364"); - System.out.println("send from 10.16.88.178:23364 to 224.0.1.105:23364"); - System.exit(1); - } - InetAddress group = InetAddress.getByName(args[1]); - InetAddress addr = InetAddress.getByName(args[0]); - int port = Integer.parseInt(args[2]); - InetSocketAddress addrs = new InetSocketAddress(addr, port); - - MulticastSocket s = new MulticastSocket(addrs); - s.setTimeToLive(29); - s.joinGroup(group); - boolean ok = true; - while (ok) { - byte[] buf = new byte[1000]; - DatagramPacket recv = new DatagramPacket(buf, buf.length, group, port); - System.out.println("sending from: " + addr); - s.send(recv); - Thread.currentThread().sleep(2000); - } - s.leaveGroup(group); - } -} diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/configure.xml b/testsuite/performance/load-balancer/wildfly-modcluster/configure.xml deleted file mode 100644 index db94bf91b1..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/configure.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - configured: ${configured} - management.configured: ${management.configured} - - - - - - - - - - - - - - - - - - - - - - - - - - - $JBOSS_LOG_DIR/jstat-gc.log & - fi -]]> - - - - - - Adding management user: `${management.user}` - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/pom.xml b/testsuite/performance/load-balancer/wildfly-modcluster/pom.xml deleted file mode 100644 index 5169dab03a..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/pom.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - org.keycloak.testsuite - performance - 999-SNAPSHOT - ../../pom.xml - - 4.0.0 - - performance-keycloak-wildfly-modcluster - Keycloak Performance TestSuite - Wildfly ModCluster Load Balancer - pom - - - org.wildfly - wildfly-server-dist - ${project.build.directory}/wildfly-${wildfly.version} - - sh - jboss-cli.${script.extension} - add-user.${script.extension} - - ${project.build.scriptSourceDirectory} - ${project.basedir}/src/main/resources - - true - false - - - - - - - maven-dependency-plugin - - - unpack-wildfly - generate-resources - - unpack - - - true - - - org.wildfly - wildfly-dist - ${wildfly.version} - zip - ${project.build.directory} - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - configure-modcluster - process-resources - - run - - - - - - - - - add-management-user - process-resources - - run - - - ${skip.add.management.user} - - - - - - - prepare-docker-config - process-resources - - run - - - ${skip.docker.config} - - - - - - - - - - - - - - add-management-user - - - management.user - - - - false - - ${management.user} - ${management.user.password} - - - - - windows - - - windows - - - - ps1 - - - - - - \ No newline at end of file diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/Dockerfile b/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/Dockerfile deleted file mode 100644 index 65862ecfdb..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM jboss/base-jdk:8 - -ENV JBOSS_HOME /opt/jboss/wildfly -WORKDIR $JBOSS_HOME - -ENV CONFIGURATION standalone.xml - -# Ensure signals are forwarded to the JVM process correctly for graceful shutdown -ENV LAUNCH_JBOSS_IN_BACKGROUND 1 -ENV JSTAT false - -USER root -RUN yum -y install iproute - -ADD wildfly ./ -ADD *.sh /usr/local/bin/ - -RUN chown -R jboss . ;\ - chgrp -R jboss . ;\ - chmod -R -v ug+x bin/*.sh ;\ - chmod -R -v ug+x /usr/local/bin/ - -USER jboss - -EXPOSE 8080 -EXPOSE 9990 -HEALTHCHECK --interval=5s --timeout=5s --retries=12 CMD ["wildfly-healthcheck.sh"] -ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/docker-entrypoint.sh b/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/docker-entrypoint.sh deleted file mode 100644 index 10c4ddc47b..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/docker-entrypoint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -cat $JBOSS_HOME/standalone/configuration/standalone.xml - -. get-ips.sh - -PARAMS="-b $PUBLIC_IP -bmanagement $PUBLIC_IP -bprivate $PRIVATE_IP $@" -echo "Server startup params: $PARAMS" - -# Note: External container connectivity is always provided by eth0 -- irrespective of which is considered public/private by KC. -# In case the container needs to be accessible on the host computer override -b $PUBLIC_IP by adding: `-b 0.0.0.0` to the docker command. - -exec /opt/jboss/wildfly/bin/standalone.sh $PARAMS -exit $? diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/get-ips.sh b/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/get-ips.sh deleted file mode 100644 index ac5c5943b8..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/get-ips.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# This script: -# - assumes there are 2 network interfaces connected to $PUBLIC_SUBNET and $PRIVATE_SUBNET respectively -# - finds IP addresses from those interfaces using `ip` command -# - exports the IPs as variables - -function getIpForSubnet { - if [ -z $1 ]; then - echo Subnet parameter undefined - exit 1 - else - ip r | grep $1 | sed 's/.*src\ \([^\ ]*\).*/\1/' - fi -} - -if [ -z $PUBLIC_SUBNET ]; then - PUBLIC_IP=0.0.0.0 - echo PUBLIC_SUBNET undefined. PUBLIC_IP defaults to $PUBLIC_IP -else - export PUBLIC_IP=`getIpForSubnet $PUBLIC_SUBNET` -fi - -if [ -z $PRIVATE_SUBNET ]; then - PRIVATE_IP=127.0.0.1 - echo PRIVATE_SUBNET undefined. PRIVATE_IP defaults to $PRIVATE_IP -else - export PRIVATE_IP=`getIpForSubnet $PRIVATE_SUBNET` -fi - -echo Routing table: -ip r -echo PUBLIC_SUBNET=$PUBLIC_SUBNET -echo PRIVATE_SUBNET=$PRIVATE_SUBNET -echo PUBLIC_IP=$PUBLIC_IP -echo PRIVATE_IP=$PRIVATE_IP - diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/io-worker-threads.cli b/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/io-worker-threads.cli deleted file mode 100644 index 878ca978d0..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/io-worker-threads.cli +++ /dev/null @@ -1,7 +0,0 @@ -embed-server --server-config=standalone.xml - -# default is cpuCount * 2 -/subsystem=io/worker=default:write-attribute(name=io-threads,value=${env.WORKER_IO_THREADS:2}) - -# default is cpuCount * 16 -/subsystem=io/worker=default:write-attribute(name=task-max-threads,value=${env.WORKER_TASK_MAX_THREADS:16}) diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/mod-cluster-balancer.cli b/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/mod-cluster-balancer.cli deleted file mode 100644 index 5f89a470b2..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/mod-cluster-balancer.cli +++ /dev/null @@ -1,12 +0,0 @@ -embed-server --server-config=standalone.xml - -/interface=private:add(inet-address=${jboss.bind.address.private:127.0.0.1}) - -/socket-binding-group=standard-sockets/socket-binding=modcluster-advertise:add(interface=private, multicast-port=23364, multicast-address=${jboss.default.multicast.address:224.0.1.105}) -/socket-binding-group=standard-sockets/socket-binding=modcluster-management:add(interface=private, port=6666) - -/extension=org.jboss.as.modcluster/:add -/subsystem=undertow/configuration=filter/mod-cluster=modcluster:add(advertise-socket-binding=modcluster-advertise, advertise-frequency=${modcluster.advertise-frequency:2000}, management-socket-binding=modcluster-management, enable-http2=true) -/subsystem=undertow/server=default-server/host=default-host/filter-ref=modcluster:add -/subsystem=undertow/server=default-server/http-listener=modcluster:add(socket-binding=modcluster-management, enable-http2=true) - diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/undertow.cli b/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/undertow.cli deleted file mode 100644 index c2140597cc..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/jboss-cli/undertow.cli +++ /dev/null @@ -1,2 +0,0 @@ -embed-server --server-config=standalone.xml -/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-connections,value=${env.HTTP_MAX_CONNECTIONS:500}) diff --git a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/wildfly-healthcheck.sh b/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/wildfly-healthcheck.sh deleted file mode 100644 index 80c98c416c..0000000000 --- a/testsuite/performance/load-balancer/wildfly-modcluster/src/main/scripts/wildfly-healthcheck.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -#$JBOSS_HOME/bin/jboss-cli.sh -c ":read-attribute(name=server-state)" | grep -q "running" - -. get-ips.sh - -CODE=`curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/` - -if [ "$CODE" -eq "200" ]; then - exit 0 -fi - -exit 1 - diff --git a/testsuite/performance/monitoring/cadvisor/Dockerfile b/testsuite/performance/monitoring/cadvisor/Dockerfile deleted file mode 100644 index fa12b1523b..0000000000 --- a/testsuite/performance/monitoring/cadvisor/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM google/cadvisor:v0.26.1 -RUN apk add --no-cache bash curl -ADD entrypoint.sh /entrypoint.sh -RUN chmod +x -v /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] diff --git a/testsuite/performance/monitoring/cadvisor/README.md b/testsuite/performance/monitoring/cadvisor/README.md deleted file mode 100644 index 253f420d2e..0000000000 --- a/testsuite/performance/monitoring/cadvisor/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# CAdvisor configured for InfluxDB - -Google CAdvisor tool configured to export data into InfluxDB service. - -## Customization for InfluxDB - -This image adds a custom `entrypoint.sh` on top of the original CAdvisor image which: -- checks if `$INFLUX_DATABASE` exists on `$INFLUX_HOST` -- creates the DB if it doesn't exist -- starts `cadvisor` with storage driver set for the Influx DB diff --git a/testsuite/performance/monitoring/cadvisor/entrypoint.sh b/testsuite/performance/monitoring/cadvisor/entrypoint.sh deleted file mode 100755 index b78aa0f3f1..0000000000 --- a/testsuite/performance/monitoring/cadvisor/entrypoint.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -if [ -z $INFLUX_HOST ]; then export INFLUX_HOST=influx; fi -if [ -z $INFLUX_DATABASE ]; then export INFLUX_DATABASE=cadvisor; fi - -# Check if DB exists -curl -s -G "http://$INFLUX_HOST:8086/query?pretty=true" --data-urlencode "q=SHOW DATABASES" | grep $INFLUX_DATABASE -DB_EXISTS=$? - -if [ $DB_EXISTS -eq 0 ]; then - echo "Database '$INFLUX_DATABASE' already exists on InfluxDB server '$INFLUX_HOST:8086'" -else - echo "Creating database '$INFLUX_DATABASE' on InfluxDB server '$INFLUX_HOST:8086'" - curl -i -XPOST http://$INFLUX_HOST:8086/query --data-urlencode "q=CREATE DATABASE $INFLUX_DATABASE" -fi - -/usr/bin/cadvisor -logtostderr -docker_only -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=$INFLUX_HOST:8086 $@ - diff --git a/testsuite/performance/monitoring/grafana/Dockerfile b/testsuite/performance/monitoring/grafana/Dockerfile deleted file mode 100644 index 20d2893859..0000000000 --- a/testsuite/performance/monitoring/grafana/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM grafana/grafana:4.4.3 -ENV GF_DASHBOARDS_JSON_ENABLED true -ENV GF_DASHBOARDS_JSON_PATH /etc/grafana/dashboards/ -COPY resource-usage-per-container.json /etc/grafana/dashboards/ -COPY resource-usage-combined.json /etc/grafana/dashboards/ -ADD entrypoint.sh /entrypoint.sh -RUN chmod +x -v /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] diff --git a/testsuite/performance/monitoring/grafana/README.md b/testsuite/performance/monitoring/grafana/README.md deleted file mode 100644 index 525d132c85..0000000000 --- a/testsuite/performance/monitoring/grafana/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Grafana configured with InfluxDB - -## Customization for InfluxDB - -This image adds a custom `entrypoint.sh` on top of the original Grafana image which: -- checks if `$INFLUX_DATASOURCE_NAME` exists in Grafana -- creates the datasource if it doesn't exist -- adds a custom dashboard configured to query for the datasource -- starts Grafana diff --git a/testsuite/performance/monitoring/grafana/entrypoint.sh b/testsuite/performance/monitoring/grafana/entrypoint.sh deleted file mode 100755 index 1311f7fffa..0000000000 --- a/testsuite/performance/monitoring/grafana/entrypoint.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -if [ -z $INFLUX_DATASOURCE_NAME ]; then INFLUX_DATASOURCE_NAME=influx_datasource; fi - -if [ -z $INFLUX_HOST ]; then export INFLUX_HOST=influx; fi -if [ -z $INFLUX_DATABASE ]; then export INFLUX_DATABASE=cadvisor; fi - - -echo Starting Grafana -./run.sh "${@}" & -timeout 10 bash -c "until - - - - - keycloak-testsuite-pom - org.keycloak - 999-SNAPSHOT - ../pom.xml - - 4.0.0 - - org.keycloak.testsuite - performance - Keycloak Performance TestSuite - pom - - - ${project.version} - - - false - ${jstat} - ${jstat} - ${jstat} - - - - keycloak - load-balancer/wildfly-modcluster - tests - - - - - crossdc - - infinispan - - - - - diff --git a/testsuite/performance/stress-test.sh b/testsuite/performance/stress-test.sh deleted file mode 100755 index a2b0797077..0000000000 --- a/testsuite/performance/stress-test.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/bash - -# Execution Parameters -MVN="${MVN:-mvn}" -KEYCLOAK_PROJECT_HOME=${KEYCLOAK_PROJECT_HOME:-$(cd "$(dirname "$0")/../.."; pwd)} -DRY_RUN=${DRY_RUN:-false} - -# Performance Testsuite Parameters -DATASET=${DATASET:-1r_10c_100u} -WARMUP_PERIOD=${WARMUP_PERIOD:-120} -RAMPUP_PERIOD=${RAMPUP_PERIOD:-60} -MEASUREMENT_PERIOD=${MEASUREMENT_PERIOD:-120} -FILTER_RESULTS=${FILTER_RESULTS:-true} - -# Stress Test Parameters -STRESS_TEST_ALGORITHM=${STRESS_TEST_ALGORITHM:-incremental} -STRESS_TEST_MAX_ITERATIONS=${STRESS_TEST_MAX_ITERATIONS:-10} -STRESS_TEST_PROVISIONING=${STRESS_TEST_PROVISIONING:-false} -STRESS_TEST_PROVISIONING_GENERATE_DATASET=${STRESS_TEST_PROVISIONING_GENERATE_DATASET:-false} -STRESS_TEST_PROVISIONING_PARAMETERS=${STRESS_TEST_PROVISIONING_PARAMETERS:-} - -# Stress Test - Incremental Algorithm Parameters -STRESS_TEST_UPS_FIRST=${STRESS_TEST_UPS_FIRST:-1.000} -STRESS_TEST_UPS_INCREMENT=${STRESS_TEST_UPS_INCREMENT:-1.000} - -# Stress Test - Bisection Algorithm Parameters -lower_bound=${STRESS_TEST_UPS_LOWER_BOUND:-0.000} -upper_bound=${STRESS_TEST_UPS_UPPER_BOUND:-10.000} -STRESS_TEST_UPS_RESOLUTION=${STRESS_TEST_UPS_RESOLUTION:-1.000} - -if $STRESS_TEST_PROVISIONING_GENERATE_DATASET; then DATASET_PROFILE="generate-data"; else DATASET_PROFILE="import-dump"; fi -PROVISIONING_COMMAND="$MVN -f $KEYCLOAK_PROJECT_HOME/testsuite/performance/pom.xml verify -P provision,$DATASET_PROFILE $STRESS_TEST_PROVISIONING_PARAMETERS -Ddataset=$DATASET" -TEARDOWN_COMMAND="$MVN -f $KEYCLOAK_PROJECT_HOME/testsuite/performance/pom.xml verify -P teardown" - -function run_command { - echo " $1" - echo - if ! $DRY_RUN; then eval "$1"; fi -} - -function run_test { - - if [[ $i == 0 || $STRESS_TEST_PROVISIONING == true ]]; then # use specified WARMUP_PERIOD only in the first iteration, or if STRESS_TEST_PROVISIONING is enabled - WARMUP_PARAMETER="-DwarmUpPeriod=$WARMUP_PERIOD "; - else - WARMUP_PARAMETER="-DwarmUpPeriod=0 "; - fi - - test_command="$MVN -f $KEYCLOAK_PROJECT_HOME/testsuite/performance/tests/pom.xml verify -Ptest $@ -Ddataset=$DATASET $WARMUP_PARAMETER -DrampUpPeriod=$RAMPUP_PERIOD -DmeasurementPeriod=$MEASUREMENT_PERIOD -DfilterResults=$FILTER_RESULTS -DusersPerSec=$users_per_sec" - - if $STRESS_TEST_PROVISIONING; then - run_command "$PROVISIONING_COMMAND" - if [[ $? != 0 ]]; then - echo "Provisioning failed." - run_command "$TEARDOWN_COMMAND" || break - break - fi - run_command "$test_command" - export test_result=$? - run_command "$TEARDOWN_COMMAND" || exit 1 - else - run_command "$test_command" - export test_result=$? - fi - - [[ $test_result != 0 ]] && echo "Test exit code: $test_result" - -} - -cat < upper_bound. Stopping the loop."; exit 1; fi - - run_test $@ - - if [[ $test_result == 0 ]]; then - users_per_sec_max=$users_per_sec - echo "INFO: Last iteration succeeded. Continuing with the upper half of the interval." - lower_bound=$users_per_sec - else - echo "INFO: Last iteration failed. Continuing with the lower half of the interval." - upper_bound=$users_per_sec - fi - - done - - ;; - - *) - echo "Algorithm '${STRESS_TEST_ALGORITHM}' not supported." - exit 1 - ;; - -esac - -echo "Maximal load with passing test: $users_per_sec_max users per second" - -if ! $DRY_RUN; then # Generate a Jenkins Plot Plugin-compatible data file - mkdir -p "$KEYCLOAK_PROJECT_HOME/testsuite/performance/tests/target" - echo "YVALUE=$users_per_sec_max" > "$KEYCLOAK_PROJECT_HOME/testsuite/performance/tests/target/stress-test-result.properties" -fi diff --git a/testsuite/performance/tests/common.sh b/testsuite/performance/tests/common.sh deleted file mode 100755 index b64f46a897..0000000000 --- a/testsuite/performance/tests/common.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -PROJECT_BASEDIR=${PROJECT_BASEDIR:-$(cd "$(dirname "$0")"; pwd)} -PROJECT_BUILD_DIRECTORY=$PROJECT_BASEDIR/target - -export PROVISIONED_SYSTEM_PROPERTIES_FILE="$PROJECT_BUILD_DIRECTORY/provisioned-system.properties" diff --git a/testsuite/performance/tests/create-truststore.sh b/testsuite/performance/tests/create-truststore.sh deleted file mode 100755 index 89a5efe6f9..0000000000 --- a/testsuite/performance/tests/create-truststore.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")" -. ./common.sh - -HOST_PORT=${1:-localhost:8443} -TRUSTSTORE_PASSWORD=${2:-password} - -#secure-sso-sso-perf-01.apps.summit-aws.sysdeseng.com:443 - -mkdir -p $PROJECT_BUILD_DIRECTORY - -echo "Obtaining certificate from $HOST_PORT" -openssl s_client -showcerts -connect $HOST_PORT /dev/null|openssl x509 -outform PEM >$PROJECT_BUILD_DIRECTORY/keycloak.pem -if [ ! -s "$PROJECT_BUILD_DIRECTORY/keycloak.pem" ]; then echo "Obtaining cerfificate failed."; exit 1; fi -cat $PROJECT_BUILD_DIRECTORY/keycloak.pem - -echo "Importing certificate" -rm $PROJECT_BUILD_DIRECTORY/truststore.jks -keytool -importcert -file $PROJECT_BUILD_DIRECTORY/keycloak.pem -keystore $PROJECT_BUILD_DIRECTORY/truststore.jks -alias "keycloak" -storepass "$TRUSTSTORE_PASSWORD" -noprompt - -echo "Keystore file: $PROJECT_BUILD_DIRECTORY/truststore.jks" diff --git a/testsuite/performance/tests/docker-compose.sh b/testsuite/performance/tests/docker-compose.sh deleted file mode 100755 index 21e9cc5be5..0000000000 --- a/testsuite/performance/tests/docker-compose.sh +++ /dev/null @@ -1,477 +0,0 @@ -#!/bin/bash - -### FUNCTIONS ### - -function runCommand() { - echo "$1" - if ! eval "$1" ; then - echo "Execution of command failed." - echo "Command: \"$1\"" - exit 1; - fi -} - -function generateDockerComposeFile() { - echo "Generating $( basename "$DOCKER_COMPOSE_FILE" )" - local TEMPLATES_PATH=$DEPLOYMENT - cat $TEMPLATES_PATH/docker-compose-base.yml > $DOCKER_COMPOSE_FILE - case "$DEPLOYMENT" in - cluster) - I=0 - for CPUSET in $KEYCLOAK_CPUSETS ; do - I=$((I+1)) - sed -e s/%I%/$I/ -e s/%CPUSET%/$CPUSET/ $TEMPLATES_PATH/docker-compose-keycloak.yml >> $DOCKER_COMPOSE_FILE - done - ;; - crossdc) - I=0 - for CPUSET in $KEYCLOAK_DC1_CPUSETS ; do - I=$((I+1)) - sed -e s/%I%/$I/ -e s/%CPUSET%/$CPUSET/ $TEMPLATES_PATH/docker-compose-keycloak_dc1.yml >> $DOCKER_COMPOSE_FILE - done - I=0 - for CPUSET in $KEYCLOAK_DC2_CPUSETS ; do - I=$((I+1)) - sed -e s/%I%/$I/ -e s/%CPUSET%/$CPUSET/ $TEMPLATES_PATH/docker-compose-keycloak_dc2.yml >> $DOCKER_COMPOSE_FILE - done - ;; - esac -} - -function inspectDockerPortMapping() { - local PORT="$1" - local CONTAINER="$2" - local INSPECT_COMMAND="docker inspect --format='{{(index (index .NetworkSettings.Ports \"$PORT\") 0).HostPort}}' $CONTAINER" - MAPPED_PORT="$( eval "$INSPECT_COMMAND" )" - if [ -z "$MAPPED_PORT" ]; then - echo "Error finding mapped port for $CONTAINER." - exit 1 - fi -} - -function generateProvisionedSystemProperties() { - echo "Generating $PROVISIONED_SYSTEM_PROPERTIES_FILE" - echo "deployment=$DEPLOYMENT" > $PROVISIONED_SYSTEM_PROPERTIES_FILE - echo "# Docker Compose" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - echo "keycloak.docker.services=$KEYCLOAK_SERVICES" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - case "$DEPLOYMENT" in - singlenode) - echo "# HTTP" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - inspectDockerPortMapping 8080/tcp ${PROJECT_NAME}_keycloak_1 - echo "keycloak.frontend.servers=http://localhost:$MAPPED_PORT/auth" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - - echo "# JMX" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_keycloak_1 - echo "keycloak.frontend.servers.jmx=service:jmx:remote+http://localhost:$MAPPED_PORT" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - ;; - cluster) - echo "# HTTP" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - inspectDockerPortMapping 8080/tcp ${PROJECT_NAME}_loadbalancer_1 - echo "keycloak.frontend.servers=http://localhost:$MAPPED_PORT/auth" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - BACKEND_URLS="" - for SERVICE in $KEYCLOAK_SERVICES ; do - inspectDockerPortMapping 8080/tcp ${PROJECT_NAME}_${SERVICE}_1 - BACKEND_URLS="$BACKEND_URLS http://localhost:$MAPPED_PORT/auth" - done - echo "keycloak.backend.servers=$BACKEND_URLS" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - - echo "# JMX" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_loadbalancer_1 - echo "keycloak.frontend.servers.jmx=service:jmx:remote+http://localhost:$MAPPED_PORT" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - BACKEND_URLS="" - for SERVICE in $KEYCLOAK_SERVICES ; do - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_${SERVICE}_1 - BACKEND_URLS="$BACKEND_URLS service:jmx:remote+http://localhost:$MAPPED_PORT" - done - echo "keycloak.backend.servers.jmx=$BACKEND_URLS" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - ;; - crossdc) - echo "# HTTP" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - inspectDockerPortMapping 8080/tcp ${PROJECT_NAME}_loadbalancer_dc1_1 - KC_DC1_PORT=$MAPPED_PORT - inspectDockerPortMapping 8080/tcp ${PROJECT_NAME}_loadbalancer_dc2_1 - KC_DC2_PORT=$MAPPED_PORT - echo "keycloak.frontend.servers=http://localhost:$KC_DC1_PORT/auth http://localhost:$KC_DC2_PORT/auth" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - BACKEND_URLS="" - for SERVICE in $KEYCLOAK_SERVICES ; do - inspectDockerPortMapping 8080/tcp ${PROJECT_NAME}_${SERVICE}_1 - BACKEND_URLS="$BACKEND_URLS http://localhost:$MAPPED_PORT/auth" - done - echo "keycloak.backend.servers=$BACKEND_URLS" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - - echo "# JMX" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_loadbalancer_dc1_1 - KC_DC1_PORT=$MAPPED_PORT - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_loadbalancer_dc2_1 - KC_DC2_PORT=$MAPPED_PORT - echo "keycloak.frontend.servers.jmx=service:jmx:remote+http://localhost:$KC_DC1_PORT service:jmx:remote+http://localhost:$KC_DC2_PORT" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - BACKEND_URLS="" - for SERVICE in $KEYCLOAK_SERVICES ; do - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_${SERVICE}_1 - BACKEND_URLS="$BACKEND_URLS service:jmx:remote+http://localhost:$MAPPED_PORT" - done - echo "keycloak.backend.servers.jmx=$BACKEND_URLS" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_infinispan_dc1_1 - ISPN_DC1_PORT=$MAPPED_PORT - inspectDockerPortMapping 9990/tcp ${PROJECT_NAME}_infinispan_dc2_1 - ISPN_DC2_PORT=$MAPPED_PORT - echo "infinispan.servers.jmx=service:jmx:remote+http://localhost:$ISPN_DC1_PORT service:jmx:remote+http://localhost:$ISPN_DC2_PORT" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - ;; - esac - echo "keycloak.admin.user=$KEYCLOAK_ADMIN_USER" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE - echo "keycloak.admin.password=$KEYCLOAK_ADMIN_PASSWORD" >> $PROVISIONED_SYSTEM_PROPERTIES_FILE -} - -function loadProvisionedSystemProperties() { - if [ -f $PROVISIONED_SYSTEM_PROPERTIES_FILE ]; then - echo "Loading $PROVISIONED_SYSTEM_PROPERTIES_FILE" - export DEPLOYMENT=$( sed -n -e '/deployment=/ s/.*\= *//p' $PROVISIONED_SYSTEM_PROPERTIES_FILE ) - export KEYCLOAK_SERVICES=$( sed -n -e '/keycloak.docker.services=/ s/.*\= *//p' $PROVISIONED_SYSTEM_PROPERTIES_FILE ) - export KEYCLOAK_ADMIN_USER=$( sed -n -e '/keycloak.admin.user=/ s/.*\= *//p' $PROVISIONED_SYSTEM_PROPERTIES_FILE ) - export KEYCLOAK_ADMIN_PASSWORD=$( sed -n -e '/keycloak.admin.password=/ s/.*\= *//p' $PROVISIONED_SYSTEM_PROPERTIES_FILE ) - else - echo "$PROVISIONED_SYSTEM_PROPERTIES_FILE not found." - fi -} - -function removeProvisionedSystemProperties() { - rm -f $PROVISIONED_SYSTEM_PROPERTIES_FILE -} - -function isTestDeployment() { - IS_TEST_DEPLOYMENT=false - case "$DEPLOYMENT" in - singlenode|cluster|crossdc) IS_TEST_DEPLOYMENT=true ;; - esac - $IS_TEST_DEPLOYMENT -} - -function validateNotEmpty() { - VARIABLE_NAME=$1 - VARIABLE_VALUE=$2 -# echo "$VARIABLE_NAME: $VARIABLE_VALUE" - if [ -z "$VARIABLE_VALUE" ]; then echo "$VARIABLE_NAME must contain at least one item."; exit 1; fi -} - - -### SCRIPT ### - -cd "$(dirname "$0")" -. ./common.sh - -cd $PROJECT_BUILD_DIRECTORY/docker-compose - -PROJECT_NAME=performance - - -export DEPLOYMENT="${DEPLOYMENT:-singlenode}" -if isTestDeployment ; then loadProvisionedSystemProperties; fi -export OPERATION="${OPERATION:-provision}" - -echo "DEPLOYMENT: $DEPLOYMENT" - -case "$DEPLOYMENT" in - singlenode) DOCKER_COMPOSE_FILE=docker-compose.yml ;; - cluster) DOCKER_COMPOSE_FILE=docker-compose-cluster.yml ;; - crossdc) DOCKER_COMPOSE_FILE=docker-compose-crossdc.yml ;; - monitoring) DOCKER_COMPOSE_FILE=docker-compose-monitoring.yml ; DELETE_DATA="${DELETE_DATA:-false}" ;; - *) - echo "Deployment '$DEPLOYMENT' not supported by provisioner '$PROVISIONER'." - exit 1 - ;; -esac - - -echo "OPERATION: $OPERATION" - -case "$OPERATION" in - - provision) - - case "$DEPLOYMENT" in - - singlenode) - BASE_SERVICES="mariadb" - KEYCLOAK_SERVICES="keycloak" - - validateNotEmpty DB_CPUSETS $DB_CPUSETS - DB_CPUSETS_ARRAY=( $DB_CPUSETS ) - export DB_CPUSET=${DB_CPUSETS_ARRAY[0]} - - validateNotEmpty KEYCLOAK_CPUSETS $KEYCLOAK_CPUSETS - KEYCLOAK_CPUSETS_ARRAY=( $KEYCLOAK_CPUSETS ) - export KEYCLOAK_CPUSET=${KEYCLOAK_CPUSETS_ARRAY[0]} - - echo "DB_CPUSET: $DB_CPUSET" - echo "KEYCLOAK_CPUSET: $KEYCLOAK_CPUSET" - echo "BASE_SERVICES: $BASE_SERVICES" - echo "KEYCLOAK_SERVICES: $KEYCLOAK_SERVICES" - - ;; - - cluster) - BASE_SERVICES="mariadb loadbalancer" - - validateNotEmpty DB_CPUSETS $DB_CPUSETS - DB_CPUSETS_ARRAY=( $DB_CPUSETS ) - export DB_CPUSET=${DB_CPUSETS_ARRAY[0]} - - validateNotEmpty LB_CPUSETS $LB_CPUSETS - LB_CPUSETS_ARRAY=( $LB_CPUSETS ) - export LB_CPUSET=${LB_CPUSETS_ARRAY[0]} - - validateNotEmpty KEYCLOAK_CPUSETS $KEYCLOAK_CPUSETS - KEYCLOAK_CPUSETS_ARRAY=( $KEYCLOAK_CPUSETS ) - - KEYCLOAK_MAX_SCALE=${#KEYCLOAK_CPUSETS_ARRAY[@]} - KEYCLOAK_SCALE="${KEYCLOAK_SCALE:-$KEYCLOAK_MAX_SCALE}" - if [ $KEYCLOAK_SCALE -gt $KEYCLOAK_MAX_SCALE ]; then KEYCLOAK_SCALE=$KEYCLOAK_MAX_SCALE; fi - if [ $KEYCLOAK_SCALE -lt 1 ]; then KEYCLOAK_SCALE=1; fi - - echo "DB_CPUSET: $DB_CPUSET" - echo "LB_CPUSET: $LB_CPUSET" - echo "KEYCLOAK_CPUSETS: $KEYCLOAK_CPUSETS" - echo "KEYCLOAK_SCALE: ${KEYCLOAK_SCALE} (max ${KEYCLOAK_MAX_SCALE})" - - KEYCLOAK_SERVICES="" - STOPPED_KEYCLOAK_SERVICES="" - for ((i=1; i<=$KEYCLOAK_MAX_SCALE; i++)) ; do - if (( $i <= $KEYCLOAK_SCALE )) ; then - KEYCLOAK_SERVICES="$KEYCLOAK_SERVICES keycloak_$i" - else - STOPPED_KEYCLOAK_SERVICES="$STOPPED_KEYCLOAK_SERVICES keycloak_$i" - fi - done - echo "BASE_SERVICES: $BASE_SERVICES" - echo "KEYCLOAK_SERVICES: $KEYCLOAK_SERVICES" - - generateDockerComposeFile - ;; - - crossdc) - BASE_SERVICES="mariadb_dc1 mariadb_dc2 infinispan_dc1 infinispan_dc2 loadbalancer_dc1 loadbalancer_dc2" - - validateNotEmpty DB_DC1_CPUSETS $DB_DC1_CPUSETS - validateNotEmpty DB_DC2_CPUSETS $DB_DC2_CPUSETS - DB_DC1_CPUSETS_ARRAY=( $DB_DC1_CPUSETS ) - DB_DC2_CPUSETS_ARRAY=( $DB_DC2_CPUSETS ) - export DB_DC1_CPUSET=${DB_DC1_CPUSETS_ARRAY[0]} - export DB_DC2_CPUSET=${DB_DC2_CPUSETS_ARRAY[0]} - echo "DB_DC1_CPUSET: $DB_DC1_CPUSET" - echo "DB_DC2_CPUSET: $DB_DC2_CPUSET" - - validateNotEmpty LB_DC1_CPUSETS $LB_DC1_CPUSETS - validateNotEmpty LB_DC2_CPUSETS $LB_DC2_CPUSETS - LB_DC1_CPUSETS_ARRAY=( $LB_DC1_CPUSETS ) - LB_DC2_CPUSETS_ARRAY=( $LB_DC2_CPUSETS ) - export LB_DC1_CPUSET=${LB_DC1_CPUSETS_ARRAY[0]} - export LB_DC2_CPUSET=${LB_DC2_CPUSETS_ARRAY[0]} - echo "LB_DC1_CPUSET: $LB_DC1_CPUSET" - echo "LB_DC2_CPUSET: $LB_DC2_CPUSET" - - validateNotEmpty INFINISPAN_DC1_CPUSETS $INFINISPAN_DC1_CPUSETS - validateNotEmpty INFINISPAN_DC2_CPUSETS $INFINISPAN_DC2_CPUSETS - INFINISPAN_DC1_CPUSETS_ARRAY=( $INFINISPAN_DC1_CPUSETS ) - INFINISPAN_DC2_CPUSETS_ARRAY=( $INFINISPAN_DC2_CPUSETS ) - export INFINISPAN_DC1_CPUSET=${INFINISPAN_DC1_CPUSETS_ARRAY[0]} - export INFINISPAN_DC2_CPUSET=${INFINISPAN_DC2_CPUSETS_ARRAY[0]} - echo "INFINISPAN_DC1_CPUSET: $INFINISPAN_DC1_CPUSET" - echo "INFINISPAN_DC2_CPUSET: $INFINISPAN_DC2_CPUSET" - - validateNotEmpty KEYCLOAK_DC1_CPUSETS $KEYCLOAK_DC1_CPUSETS - validateNotEmpty KEYCLOAK_DC2_CPUSETS $KEYCLOAK_DC2_CPUSETS - KEYCLOAK_DC1_CPUSETS_ARRAY=( $KEYCLOAK_DC1_CPUSETS ) - KEYCLOAK_DC2_CPUSETS_ARRAY=( $KEYCLOAK_DC2_CPUSETS ) - KEYCLOAK_DC1_MAX_SCALE=${#KEYCLOAK_DC1_CPUSETS_ARRAY[@]} - KEYCLOAK_DC2_MAX_SCALE=${#KEYCLOAK_DC2_CPUSETS_ARRAY[@]} - KEYCLOAK_DC1_SCALE="${KEYCLOAK_DC1_SCALE:-$KEYCLOAK_DC1_MAX_SCALE}" - KEYCLOAK_DC2_SCALE="${KEYCLOAK_DC2_SCALE:-$KEYCLOAK_DC2_MAX_SCALE}" - - if [ $KEYCLOAK_DC1_SCALE -gt $KEYCLOAK_DC1_MAX_SCALE ]; then KEYCLOAK_DC1_SCALE=$KEYCLOAK_DC1_MAX_SCALE; fi - if [ $KEYCLOAK_DC1_SCALE -lt 1 ]; then KEYCLOAK_DC1_SCALE=1; fi - if [ $KEYCLOAK_DC2_SCALE -gt $KEYCLOAK_DC2_MAX_SCALE ]; then KEYCLOAK_DC2_SCALE=$KEYCLOAK_DC2_MAX_SCALE; fi - if [ $KEYCLOAK_DC2_SCALE -lt 1 ]; then KEYCLOAK_DC2_SCALE=1; fi - - echo "KEYCLOAK_DC1_CPUSETS: ${KEYCLOAK_DC1_CPUSETS}" - echo "KEYCLOAK_DC2_CPUSETS: ${KEYCLOAK_DC2_CPUSETS}" - echo "KEYCLOAK_DC1_SCALE: ${KEYCLOAK_DC1_SCALE} (max ${KEYCLOAK_DC1_MAX_SCALE})" - echo "KEYCLOAK_DC2_SCALE: ${KEYCLOAK_DC2_SCALE} (max ${KEYCLOAK_DC2_MAX_SCALE})" - - KEYCLOAK_SERVICES="" - STOPPED_KEYCLOAK_SERVICES="" - for ((i=1; i<=$KEYCLOAK_DC1_MAX_SCALE; i++)) ; do - if (( $i <= $KEYCLOAK_DC1_SCALE )) ; then - KEYCLOAK_SERVICES="$KEYCLOAK_SERVICES keycloak_dc1_$i" - else - STOPPED_KEYCLOAK_SERVICES="$STOPPED_KEYCLOAK_SERVICES keycloak_dc1_$i" - fi - done - for ((i=1; i<=$KEYCLOAK_DC2_MAX_SCALE; i++)) ; do - if (( $i <= $KEYCLOAK_DC2_SCALE )) ; then - KEYCLOAK_SERVICES="$KEYCLOAK_SERVICES keycloak_dc2_$i" - else - STOPPED_KEYCLOAK_SERVICES="$STOPPED_KEYCLOAK_SERVICES keycloak_dc2_$i" - fi - done - echo "BASE_SERVICES: $BASE_SERVICES" - echo "KEYCLOAK_SERVICES: $KEYCLOAK_SERVICES" - - generateDockerComposeFile - - ;; - - monitoring) - - validateNotEmpty MONITORING_CPUSETS "$MONITORING_CPUSETS" - MONITORING_CPUSETS_ARRAY=( $MONITORING_CPUSETS ) - export MONITORING_CPUSET=${MONITORING_CPUSETS_ARRAY[0]} - echo "MONITORING_CPUSET: $MONITORING_CPUSET" - - ;; - - esac - - runCommand "docker-compose -f $DOCKER_COMPOSE_FILE -p ${PROJECT_NAME} up -d --build $BASE_SERVICES $KEYCLOAK_SERVICES" - if [ ! -z "$STOPPED_KEYCLOAK_SERVICES" ] ; then - echo "STOPPED_KEYCLOAK_SERVICES: $STOPPED_KEYCLOAK_SERVICES" - runCommand "docker-compose -f $DOCKER_COMPOSE_FILE -p ${PROJECT_NAME} stop $STOPPED_KEYCLOAK_SERVICES" - fi - - if isTestDeployment ; then - generateProvisionedSystemProperties; - $PROJECT_BASEDIR/healthcheck.sh - fi - - ;; - - - teardown) - - DELETE_DATA="${DELETE_DATA:-true}" - echo "DELETE_DATA: $DELETE_DATA" - if "$DELETE_DATA" ; then VOLUMES_ARG="-v"; else VOLUMES_ARG=""; fi - - runCommand "docker-compose -f $DOCKER_COMPOSE_FILE -p ${PROJECT_NAME} down $VOLUMES_ARG" - - if isTestDeployment ; then removeProvisionedSystemProperties; fi - ;; - - - export-dump|import-dump) - - loadProvisionedSystemProperties - - echo "KEYCLOAK_SERVICES: $KEYCLOAK_SERVICES" - if [ -z "$KEYCLOAK_SERVICES" ]; then echo "Unable to load KEYCLOAK_SERVICES"; exit 1; fi - - case "$DEPLOYMENT" in - singlenode|cluster) export DB_CONTAINER=${PROJECT_NAME}_mariadb_1 ;; - crossdc) export DB_CONTAINER=${PROJECT_NAME}_mariadb_dc1_1 ;; - *) echo "Deployment '$DEPLOYMENT' doesn't support operation '$OPERATION'." ; exit 1 ;; - esac - if [ ! -f "$DATASET_PROPERTIES_FILE" ]; then echo "Operation '$OPERATION' requires a valid DATASET_PROPERTIES_FILE parameter."; exit 1; fi - DATASET_PROPERTIES_FILENAME=`basename $DATASET_PROPERTIES_FILE` - DATASET=${DATASET_PROPERTIES_FILENAME%.properties} - echo "DATASET_PROPERTIES_FILE: $DATASET_PROPERTIES_FILE" - echo "DATASET: $DATASET" - - echo "Stopping Keycloak services." - runCommand "docker-compose -f $DOCKER_COMPOSE_FILE -p ${PROJECT_NAME} stop $KEYCLOAK_SERVICES" - - cd `dirname $DATASET_PROPERTIES_FILE` - case "$OPERATION" in - export-dump) - echo "Exporting $DATASET.sql." - if docker exec $DB_CONTAINER /usr/bin/mysqldump -u root --password=root keycloak > $DATASET.sql ; then - echo "Compressing $DATASET.sql." - gzip $DATASET.sql - fi - ;; - import-dump) - DUMP_DOWNLOAD_SITE=${DUMP_DOWNLOAD_SITE:-https://downloads.jboss.org/keycloak-qe} - if [ ! -f "$DATASET.sql.gz" ]; then - echo "Downloading dump file: $DUMP_DOWNLOAD_SITE/$DATASET.sql.gz" - if ! curl -f -O $DUMP_DOWNLOAD_SITE/$DATASET.properties -O $DUMP_DOWNLOAD_SITE/$DATASET.sql.gz ; then - echo Download failed. - exit 1 - fi - fi - echo "Importing $DATASET.sql.gz" - set -o pipefail - if ! gunzip -c $DATASET.sql.gz | docker exec -i $DB_CONTAINER /usr/bin/mysql -u root --password=root keycloak ; then - echo Import failed. - exit 1 - fi - ;; - esac - cd $PROJECT_BUILD_DIRECTORY/docker-compose - - echo "Starting Keycloak services." - runCommand "docker-compose -f $DOCKER_COMPOSE_FILE -p ${PROJECT_NAME} up -d --no-recreate $KEYCLOAK_SERVICES" - # need to update mapped ports - generateProvisionedSystemProperties - - $PROJECT_BASEDIR/healthcheck.sh - - ;; - - collect) - TIMESTAMP=`date -u "+%Y-%m-%d_%T_%Z"` - ARTIFACTS_DIR="${PROJECT_BUILD_DIRECTORY}/collected-artifacts/${DEPLOYMENT}_${TIMESTAMP}" - SERVICES=`docker-compose -f $DOCKER_COMPOSE_FILE -p ${PROJECT_NAME} config --services` - - GNUPLOT_SCRIPTS_DIR="$PROJECT_BASEDIR/src/main/gnuplot/jstat" - GNUPLOT_COMMON="$GNUPLOT_SCRIPTS_DIR/common.gp" - - echo "Collecting service logs." - rm -rf ${ARTIFACTS_DIR}; mkdir -p ${ARTIFACTS_DIR} - for SERVICE in ${SERVICES}; do - mkdir -p "${ARTIFACTS_DIR}/${SERVICE}" - # log files & configs - if [[ $SERVICE =~ .*keycloak.* ]]; then - docker cp "${PROJECT_NAME}_${SERVICE}_1:/opt/jboss/keycloak/standalone/configuration" "${ARTIFACTS_DIR}/${SERVICE}/configuration" - docker cp "${PROJECT_NAME}_${SERVICE}_1:/opt/jboss/keycloak/standalone/log" "${ARTIFACTS_DIR}/${SERVICE}/log" - elif [[ $SERVICE =~ .*infinispan.* ]]; then - docker cp "${PROJECT_NAME}_${SERVICE}_1:/opt/jboss/infinispan-server/standalone/configuration" "${ARTIFACTS_DIR}/${SERVICE}/configuration" - docker cp "${PROJECT_NAME}_${SERVICE}_1:/opt/jboss/infinispan-server/standalone/log" "${ARTIFACTS_DIR}/${SERVICE}/log" - elif [[ $SERVICE =~ .*loadbalancer.* ]]; then - docker cp "${PROJECT_NAME}_${SERVICE}_1:/opt/jboss/wildfly/standalone/configuration" "${ARTIFACTS_DIR}/${SERVICE}/configuration" - docker cp "${PROJECT_NAME}_${SERVICE}_1:/opt/jboss/wildfly/standalone/log" "${ARTIFACTS_DIR}/${SERVICE}/log" - else - docker logs "${PROJECT_NAME}_${SERVICE}_1" > ${ARTIFACTS_DIR}/${SERVICE}/docker.log 2>&1; - if [[ $? != 0 ]]; then echo "ERROR collecting from: ${SERVICE}"; rm ${ARTIFACTS_DIR}/${SERVICE}/docker.log; fi - fi - -# jstat charts - if ${JSTAT:-false}; then - JSTAT_DATAFILE="${ARTIFACTS_DIR}/${SERVICE}/log/jstat-gc.log" - if [ -f "$JSTAT_DATAFILE" ] && ${GNUPLOT:-false}; then - mkdir -p "${ARTIFACTS_DIR}/${SERVICE}/jstat-charts" - HTML="${ARTIFACTS_DIR}/${SERVICE}/jstat-charts/index.html" - echo "JStat Charts for $SERVICE" > "$HTML" - echo "" >> "$HTML" - echo "

JStat Charts for $SERVICE

" >> "$HTML" - for GP_SCRIPT in gc-all gc-s0 gc-s1 gc-e gc-o gc-m gc-cc gc-ev gc-t ; do - gnuplot -e "datafile='$JSTAT_DATAFILE'" "$GNUPLOT_COMMON" "$GNUPLOT_SCRIPTS_DIR/${GP_SCRIPT}.gp" > "${ARTIFACTS_DIR}/${SERVICE}/jstat-charts/${GP_SCRIPT}.png" - if [ $? == 0 ]; then - echo "
" >> "$HTML" - echo "${GP_SCRIPT}
" >> "$HTML" - echo "" >> "$HTML" - echo "
" >> "$HTML" - fi - done - echo "" >> "$HTML" - fi - fi - done - if [ -z "$(ls -A ${ARTIFACTS_DIR})" ]; then echo "No logs were collected."; rm -rf ${ARTIFACTS_DIR}; fi - ;; - - *) - echo "Unsupported operation: '$OPERATION'" - exit 1 - ;; - -esac - diff --git a/testsuite/performance/tests/healthcheck.sh b/testsuite/performance/tests/healthcheck.sh deleted file mode 100755 index 114c26468c..0000000000 --- a/testsuite/performance/tests/healthcheck.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")" -. ./common.sh - -CHECK_TIMEOUT=${CHECK_TIMEOUT:-5} -function isKeycloakServerReady { - CODE=`curl --connect-timeout $CHECK_TIMEOUT -m $CHECK_TIMEOUT -s -o /dev/null -w "%{http_code}" $1/realms/master` - [ "$CODE" -eq "200" ] -} - - -if [ -f "$PROVISIONED_SYSTEM_PROPERTIES_FILE" ] ; then - - FRONTEND_SERVERS=$( sed -n -e '/keycloak.frontend.servers=/ s/.*\= *//p' "$PROVISIONED_SYSTEM_PROPERTIES_FILE" ) - BACKEND_SERVERS=$( sed -n -e '/keycloak.backend.servers=/ s/.*\= *//p' "$PROVISIONED_SYSTEM_PROPERTIES_FILE" ) - KEYCLOAK_SERVERS="$FRONTEND_SERVERS $BACKEND_SERVERS" - - HEALTHCHECK_ITERATIONS=${HEALTHCHECK_ITERATIONS:-20} - HEALTHCHECK_WAIT=${HEALTHCHECK_WAIT:-6s} - - echo "Waiting for Keycloak servers to be ready." - echo "Check intervals: $HEALTHCHECK_ITERATIONS x $HEALTHCHECK_WAIT." - - C=0 - READY=false - while ! $READY; do - C=$((C+1)) - if [ $C -gt $HEALTHCHECK_ITERATIONS ]; then - echo System healthcheck failed. - exit 1 - fi - echo $( date "+%Y-%m-%d %H:%M:%S" ) - READY=true - for SERVER in $KEYCLOAK_SERVERS ; do - if isKeycloakServerReady $SERVER; then - echo -e "Keycloak server: $SERVER\tREADY" - else - echo -e "Keycloak server: $SERVER\tNOT READY" - READY=false - fi - done - if ! $READY; then sleep $HEALTHCHECK_WAIT ; fi - done - echo All servers ready. - -else - echo Healthcheck skipped. -fi diff --git a/testsuite/performance/tests/log-tool.sh b/testsuite/performance/tests/log-tool.sh deleted file mode 100755 index c36cfe2ece..0000000000 --- a/testsuite/performance/tests/log-tool.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")" -. ./common.sh - -java -cp $PROJECT_BUILD_DIRECTORY/classes org.keycloak.performance.log.LogProcessor "$@" \ No newline at end of file diff --git a/testsuite/performance/tests/parameters/provisioning/docker-compose/2cpus/singlenode.properties b/testsuite/performance/tests/parameters/provisioning/docker-compose/2cpus/singlenode.properties deleted file mode 100644 index 43efbe23c8..0000000000 --- a/testsuite/performance/tests/parameters/provisioning/docker-compose/2cpus/singlenode.properties +++ /dev/null @@ -1,25 +0,0 @@ -#provisioner=docker-compose -#deployment=singlenode - -# Keycloak Settings -keycloak.scale=1 -keycloak.docker.cpusets=1 -keycloak.docker.memlimit=2500m -keycloak.jvm.memory=-Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -keycloak.http.max-connections=50000 -keycloak.worker.io-threads=2 -keycloak.worker.task-max-threads=16 -keycloak.ds.min-pool-size=10 -keycloak.ds.max-pool-size=100 -keycloak.ds.pool-prefill=true -keycloak.ds.ps-cache-size=100 -keycloak.admin.user=admin -keycloak.admin.password=admin - -# Database Settings -db.docker.cpusets=0 -db.docker.memlimit=2g -db.max.connections=100 - -# Monitoring Settings -monitoring.docker.cpusets=0 diff --git a/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/cluster.properties b/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/cluster.properties deleted file mode 100644 index 3ccf9ae50e..0000000000 --- a/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/cluster.properties +++ /dev/null @@ -1,34 +0,0 @@ -#provisioner=docker-compose -#deployment=cluster - -# Keycloak Settings -keycloak.scale=1 -keycloak.docker.cpusets=2 3 -keycloak.docker.memlimit=2500m -keycloak.jvm.memory=-Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -keycloak.http.max-connections=50000 -keycloak.ajp.max-connections=50000 -keycloak.worker.io-threads=2 -keycloak.worker.task-max-threads=16 -keycloak.ds.min-pool-size=10 -keycloak.ds.max-pool-size=100 -keycloak.ds.pool-prefill=true -keycloak.ds.ps-cache-size=100 -keycloak.admin.user=admin -keycloak.admin.password=admin - -# Database Settings -db.docker.cpusets=1 -db.docker.memlimit=2g -db.max.connections=100 - -# Load Balancer Settings -lb.docker.cpusets=1 -lb.docker.memlimit=1500m -lb.jvm.memory=-Xms64m -Xmx1024m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -lb.http.max-connections=50000 -lb.worker.io-threads=2 -lb.worker.task-max-threads=16 - -# Monitoring Settings -monitoring.docker.cpusets=0 diff --git a/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/crossdc.properties b/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/crossdc.properties deleted file mode 100644 index 1548a26bd8..0000000000 --- a/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/crossdc.properties +++ /dev/null @@ -1,44 +0,0 @@ -#provisioner=docker-compose -#deployment=crossdc - -# Keycloak Settings -keycloak.dc1.scale=1 -keycloak.dc2.scale=1 -keycloak.dc1.docker.cpusets=2 -keycloak.dc2.docker.cpusets=3 -keycloak.docker.memlimit=2500m -keycloak.jvm.memory=-Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -keycloak.http.max-connections=50000 -keycloak.ajp.max-connections=50000 -keycloak.worker.io-threads=2 -keycloak.worker.task-max-threads=16 -keycloak.ds.min-pool-size=10 -keycloak.ds.max-pool-size=100 -keycloak.ds.pool-prefill=true -keycloak.ds.ps-cache-size=100 -keycloak.admin.user=admin -keycloak.admin.password=admin - -# Database Settings -db.dc1.docker.cpusets=1 -db.dc2.docker.cpusets=1 -db.docker.memlimit=2g -db.max.connections=100 - -# Load Balancer Settings -lb.dc1.docker.cpusets=1 -lb.dc2.docker.cpusets=1 -lb.docker.memlimit=1500m -lb.jvm.memory=-Xms64m -Xmx1024m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -lb.http.max-connections=50000 -lb.worker.io-threads=2 -lb.worker.task-max-threads=16 - -# Infinispan Settings -infinispan.dc1.docker.cpusets=1 -infinispan.dc2.docker.cpusets=1 -infinispan.docker.memlimit=1500m -infinispan.jvm.memory=-Xms64m -Xmx1g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -XX:+DisableExplicitGC - -# Monitoring Settings -monitoring.docker.cpusets=0 diff --git a/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/singlenode.properties b/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/singlenode.properties deleted file mode 100644 index 5c436ab188..0000000000 --- a/testsuite/performance/tests/parameters/provisioning/docker-compose/4cpus/singlenode.properties +++ /dev/null @@ -1,25 +0,0 @@ -#provisioner=docker-compose -#deployment=singlenode - -# Keycloak Settings -keycloak.scale=1 -keycloak.docker.cpusets=2-3 -keycloak.docker.memlimit=2500m -keycloak.jvm.memory=-Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -keycloak.http.max-connections=50000 -keycloak.worker.io-threads=2 -keycloak.worker.task-max-threads=16 -keycloak.ds.min-pool-size=10 -keycloak.ds.max-pool-size=100 -keycloak.ds.pool-prefill=true -keycloak.ds.ps-cache-size=100 -keycloak.admin.user=admin -keycloak.admin.password=admin - -# Database Settings -db.docker.cpusets=1 -db.docker.memlimit=2g -db.max.connections=100 - -# Monitoring Settings -monitoring.docker.cpusets=0 diff --git a/testsuite/performance/tests/parameters/test/admin-console.properties b/testsuite/performance/tests/parameters/test/admin-console.properties deleted file mode 100644 index c3a2773ebd..0000000000 --- a/testsuite/performance/tests/parameters/test/admin-console.properties +++ /dev/null @@ -1,8 +0,0 @@ -gatling.simulationClass=keycloak.AdminConsoleSimulation -usersPerSec=0.2 -rampUpPeriod=15 -warmUpPeriod=15 -measurementPeriod=30 -filterResults=false -userThinkTime=0 -refreshTokenPeriod=0 diff --git a/testsuite/performance/tests/parameters/test/oidc-login-logout.properties b/testsuite/performance/tests/parameters/test/oidc-login-logout.properties deleted file mode 100644 index fb928793fa..0000000000 --- a/testsuite/performance/tests/parameters/test/oidc-login-logout.properties +++ /dev/null @@ -1,10 +0,0 @@ -gatling.simulationClass=keycloak.OIDCLoginAndLogoutSimulation -usersPerSec=1.0 -rampUpPeriod=15 -warmUpPeriod=15 -measurementPeriod=30 -filterResults=false -userThinkTime=0 -refreshTokenPeriod=0 -refreshTokenCount=1 -badLoginAttempts=1 diff --git a/testsuite/performance/tests/parameters/test/oidc-register-logout.properties b/testsuite/performance/tests/parameters/test/oidc-register-logout.properties deleted file mode 100644 index 38354c7b7a..0000000000 --- a/testsuite/performance/tests/parameters/test/oidc-register-logout.properties +++ /dev/null @@ -1,10 +0,0 @@ -gatling.simulationClass=keycloak.OIDCRegisterAndLogoutSimulation -usersPerSec=1.0 -rampUpPeriod=15 -warmUpPeriod=15 -measurementPeriod=30 -filterResults=false -userThinkTime=0 -refreshTokenPeriod=0 -refreshTokenCount=1 -badLoginAttempts=1 diff --git a/testsuite/performance/tests/pom.xml b/testsuite/performance/tests/pom.xml deleted file mode 100644 index d0e906e045..0000000000 --- a/testsuite/performance/tests/pom.xml +++ /dev/null @@ -1,854 +0,0 @@ - - - - - - org.keycloak.testsuite - performance - 999-SNAPSHOT - ../pom.xml - - 4.0.0 - - performance-tests - Keycloak Performance TestSuite - Tests - - - docker-compose - singlenode - - ${provisioner}/4cpus/${deployment} - default - oidc-login-logout - - ${project.basedir}/parameters/provisioning/${provisioning.properties}.properties - ${project.basedir}/src/test/resources/dataset/${dataset}.properties - ${project.basedir}/parameters/test/${test.properties}.properties - - ${project.build.directory}/provisioned-system.properties - - - - https://downloads.jboss.org/keycloak-qe/${server.version} - 1 - - 2.11.7 - 2.1.7 - 2.2.1 - 3.2.2 - 3.3.0.Final - - keycloak.OIDCLoginAndLogoutSimulation - true - true - - - - - - - - org.keycloak - keycloak-adapter-core - ${server.version} - - - org.keycloak - keycloak-adapter-spi - ${server.version} - - - org.keycloak - keycloak-core - ${server.version} - - - org.keycloak - keycloak-common - ${server.version} - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.annotations.version} - - - org.keycloak - keycloak-admin-client - ${server.version} - - - commons-configuration - commons-configuration - 1.10 - - - commons-validator - commons-validator - 1.6 - - - org.freemarker - freemarker - - - junit - junit - test - - - org.jboss.spec.javax.ws.rs - jboss-jaxrs-api_2.1_spec - - - org.jboss.logging - jboss-logging - - - org.jboss.resteasy - resteasy-core - - - org.jboss.resteasy - resteasy-client - - - org.jboss.resteasy - resteasy-jackson2-provider - - - org.apache.httpcomponents - httpclient - - - org.scala-lang - scala-library - ${scala.version} - - - io.gatling.highcharts - gatling-charts-highcharts - ${gatling.version} - - - - - - - true - src/test/resources - - **/*.gz - **/*.properties - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-teardown-before-clean - - enforce - - pre-clean - - - - - - ${provisioned.system.properties.file} - - - - true - - - - - - - - org.codehaus.mojo - properties-maven-plugin - 1.0.0 - - - read-parameters - initialize - - read-project-properties - - - true - - ${provisioning.properties.file} - ${test.properties.file} - - - - - read-existing-provisioned-system-properties - initialize - - read-project-properties - - - - ${project.build.directory}/provisioned-system.properties - - true - - - - - - - net.alchim31.maven - scala-maven-plugin - ${scala-maven-plugin.version} - - - - add-source - - - add-source - - - - - compile - - - compile - testCompile - - - - -target:jvm-1.8 - -deprecation - -feature - -unchecked - -language:implicitConversions - -language:postfixOps - - - - - - - - - io.gatling - gatling-maven-plugin - ${gatling-plugin.version} - - - ${project.build.testOutputDirectory} - ${gatling.skip.run} - true - true - true - - - -Dproject.build.directory=${project.build.directory} - -Dkeycloak.server.uris=${keycloak.frontend.servers} - -DauthUser=${keycloak.admin.user} - -DauthPassword=${keycloak.admin.password} - - - -Ddataset.properties.file=${dataset.properties.file} - - - - -DusersPerSec=${usersPerSec} - -DrampUpPeriod=${rampUpPeriod} - -DwarmUpPeriod=${warmUpPeriod} - -DmeasurementPeriod=${measurementPeriod} - -DfilterResults=${filterResults} - -DuserThinkTime=${userThinkTime} - -DrefreshTokenPeriod=${refreshTokenPeriod} - -DrefreshTokenCount=${refreshTokenCount} - -DbadLoginAttempts=${badLoginAttempts} - - ${trustStoreArg} - ${trustStorePasswordArg} - - - - - - - integration-test - - integration-test - - - - - - org.codehaus.mojo - exec-maven-plugin - - ${project.basedir} - - - - - maven-surefire-plugin - - - ${dataset.properties.file} - - ${surefire.skip.run} - - - - - - - - - - cluster - - cluster - - - - crossdc - - crossdc - - - - - ssl - - - trustStore - - - - -Djavax.net.ssl.trustStore=${trustStore} - -Djavax.net.ssl.trustStorePassword=${trustStorePassword} - - - - - provision - - ${project.basedir} - ${project.build.directory} - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - prepare-provisioning - generate-resources - - run - - - - - - - - - - - org.codehaus.mojo - exec-maven-plugin - - - provision - process-test-resources - - exec - - - ./${provisioner}.sh - - ${provisioner} - ${deployment} - provision - - ${project.version} - - ${management.user} - ${management.user.password} - ${keycloak.jstat} - - ${keycloak.scale} - ${keycloak.dc1.scale} - ${keycloak.dc2.scale} - ${keycloak.docker.cpusets} - ${keycloak.dc1.docker.cpusets} - ${keycloak.dc2.docker.cpusets} - ${keycloak.docker.memlimit} - ${keycloak.jvm.memory} - ${keycloak.http.max-connections} - ${keycloak.ajp.max-connections} - ${keycloak.worker.io-threads} - ${keycloak.worker.task-max-threads} - ${keycloak.ds.min-pool-size} - ${keycloak.ds.max-pool-size} - ${keycloak.ds.pool-prefill} - ${keycloak.ds.ps-cache-size} - - ${keycloak.admin.user} - ${keycloak.admin.password} - - ${db.docker.cpusets} - ${db.dc1.docker.cpusets} - ${db.dc2.docker.cpusets} - ${db.docker.memlimit} - ${db.max.connections} - - ${lb.docker.cpusets} - ${lb.dc1.docker.cpusets} - ${lb.dc2.docker.cpusets} - ${lb.docker.memlimit} - ${lb.jvm.memory} - ${lb.http.max-connections} - ${lb.worker.io-threads} - ${lb.worker.task-max-threads} - ${lb.jstat} - - ${infinispan.dc1.docker.cpusets} - ${infinispan.dc2.docker.cpusets} - ${infinispan.docker.memlimit} - ${infinispan.jvm.memory} - ${infinispan.jstat} - - - - - - - org.codehaus.mojo - properties-maven-plugin - 1.0.0 - - - read-new-provisioned-system-properties - - read-project-properties - - pre-integration-test - - - ${project.build.directory}/provisioned-system.properties - - - - - - - - - - - generate-data - - false - 5 - 60 - 60 - 10000 - 10000 - 100000 - 2g - - - - - org.codehaus.mojo - exec-maven-plugin - - - load-data - pre-integration-test - - exec - - - java - ${project.build.directory} - - - -classpath - - - -Xms64m - -Xmx${max.heap} - -XX:MetaspaceSize=96M - -XX:MaxMetaspaceSize=256m - - -Dkeycloak.server.uris=${keycloak.frontend.servers} - -DauthUser=${keycloak.admin.user} - -DauthPassword=${keycloak.admin.password} - -DnumOfWorkers=${numOfWorkers} - -Ddataset.properties.file=${dataset.properties.file} - ${trustStoreArg} - ${trustStorePasswordArg} - - -Ddelete=${delete} - -Dlog.every=${log.every} - -Dqueue.timeout=${queue.timeout} - -Dshutdown.timeout=${shutdown.timeout} - -Dtemplate.cache.size=${template.cache.size} - -Drandoms.cache.size=${randoms.cache.size} - -Dentity.cache.size=${entity.cache.size} - - org.keycloak.performance.dataset.DatasetLoader - - - - - - - - - - - - export-dump - - - - org.codehaus.mojo - exec-maven-plugin - - - export-dump - pre-integration-test - - exec - - - ./${provisioner}.sh - - ${provisioner} - ${deployment} - export-dump - ${dataset.properties.file} - - - - - - - - - - - import-dump - - - - org.codehaus.mojo - exec-maven-plugin - - - import-dump - pre-integration-test - - exec - - - ./${provisioner}.sh - - ${provisioner} - ${deployment} - import-dump - ${dataset.properties.file} - ${db.dump.download.site} - - - - - - - - - - - test - - false - - - - - junit - - false - - - - - collect - - false - - - - - org.codehaus.mojo - exec-maven-plugin - - - collect-artifacts - post-integration-test - - exec - - - ./${provisioner}.sh - - ${provisioner} - ${deployment} - collect - ${jstat} - ${gnuplot} - - - - - - - - - - - teardown - - true - - - - - org.codehaus.mojo - exec-maven-plugin - - - teardown - post-integration-test - - exec - - - ./${provisioner}.sh - - ${provisioner} - ${deployment} - teardown - ${delete.data} - - - - - - - - - - keep-data - - false - - - - - - monitoring - - - - org.codehaus.mojo - exec-maven-plugin - - - monitoring-on - pre-integration-test - - exec - - - ./${provisioner}.sh - - ${provisioner} - monitoring - provision - ${monitoring.docker.cpusets} - - - - - - - - - - monitoring-off - - false - - - - - org.codehaus.mojo - exec-maven-plugin - - - monitoring-off - post-integration-test - - exec - - - ./${provisioner}.sh - - ${provisioner} - monitoring - teardown - ${delete.monitoring.data} - - - - - - - - - - delete-monitoring-data - - true - - - - start-sar - - - - org.codehaus.mojo - exec-maven-plugin - - - start-sar - pre-integration-test - - exec - - - ./sar.sh - - start - - - - - - - - - - stop-sar - - false - false - - - - - org.codehaus.mojo - exec-maven-plugin - - - stop-sar - post-integration-test - - exec - - - ./sar.sh - - stop - ${gnuplot} - ${bzip} - - - - - - - - - - gnuplot - - true - - - - jstat - - true - - - - - - diff --git a/testsuite/performance/tests/prepare-provisioning.xml b/testsuite/performance/tests/prepare-provisioning.xml deleted file mode 100644 index 839b567014..0000000000 --- a/testsuite/performance/tests/prepare-provisioning.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/performance/tests/sar.sh b/testsuite/performance/tests/sar.sh deleted file mode 100755 index d95f3ac22d..0000000000 --- a/testsuite/performance/tests/sar.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")" -. ./common.sh - -SAR_OPERATION=${SAR_OPERATION:-stop} - -SAR_FOLDER="$PROJECT_BUILD_DIRECTORY/sar" -PID_FILE="$SAR_FOLDER/sar.pid" -TIMESTAMP_FILE="$SAR_FOLDER/sar.timestamp" -if [[ -f "$TIMESTAMP_FILE" ]]; then - TIMESTAMP=`cat $TIMESTAMP_FILE` -else - TIMESTAMP=`date +%s` -fi -SAR_RESULTS_FOLDER="$SAR_FOLDER/$TIMESTAMP" -SAR_OUTPUT_FILE="$SAR_RESULTS_FOLDER/sar-output.bin" -BZIP=${BZIP:-false} -CPU_COUNT=${CPU_COUNT:-`grep -c ^processor /proc/cpuinfo`} - -GNUPLOT=${GNUPLOT:-false} -GNUPLOT_SCRIPTS_DIR="$PROJECT_BASEDIR/src/main/gnuplot/sar" -GNUPLOT_COMMON="$GNUPLOT_SCRIPTS_DIR/common.gplot" - -function process_cpu_results() { - RESULTS_FOLDER="$SAR_RESULTS_FOLDER/cpu"; mkdir -p "$RESULTS_FOLDER" - CPU=${1:-ALL} - if [ "$CPU" == "ALL" ]; then SAR_PARAMS="-u"; else SAR_PARAMS="-u -P $CPU"; fi - TXT_FILE="$RESULTS_FOLDER/cpu-$CPU.txt" - CSV_FILE="${TXT_FILE%.txt}.csv" - PNG_FILE="${TXT_FILE%.txt}.png" - sar $SAR_PARAMS -f $SAR_OUTPUT_FILE > "$TXT_FILE" - sadf -d -- $SAR_PARAMS $SAR_OUTPUT_FILE > "$CSV_FILE" - if $GNUPLOT; then - gnuplot -e "datafile='$CSV_FILE'" "$GNUPLOT_COMMON" "$GNUPLOT_SCRIPTS_DIR/cpu.gplot" > "$PNG_FILE" - fi -} - -#function process_net_results() { -# IFACE=${IFACE:-docker0} -# RESULTS_FOLDER="$SAR_RESULTS_FOLDER/net"; mkdir -p "$RESULTS_FOLDER" -# TXT_FILE="$RESULTS_FOLDER/net-$IFACE.txt" -# CSV_FILE="${TXT_FILE%.txt}.csv" -# PNG_FILE="${TXT_FILE%.txt}.png" -# sar -n DEV -f $SAR_OUTPUT_FILE > "${TXT_FILE}.tmp" -# sadf -d -- -n DEV $SAR_OUTPUT_FILE > "${CSV_FILE}.tmp" -# head -n 3 "${TXT_FILE}.tmp" > "$TXT_FILE"; grep "$IFACE" "${TXT_FILE}.tmp" >> "$TXT_FILE"; rm "${TXT_FILE}.tmp" -# head -n 1 "${CSV_FILE}.tmp" > "$CSV_FILE"; grep "$IFACE" "${CSV_FILE}.tmp" >> "$CSV_FILE"; rm "${CSV_FILE}.tmp" -# if $GNUPLOT; then -# gnuplot -e "datafile='$CSV_FILE'" "$GNUPLOT_COMMON" "$GNUPLOT_SCRIPTS_DIR/net.gplot" > "$PNG_FILE" -# fi -#} - -function process_io_results() { - RESULTS_FOLDER="$SAR_RESULTS_FOLDER" - TXT_FILE="$RESULTS_FOLDER/io.txt" - CSV_FILE="${TXT_FILE%.txt}.csv" - sar -b -f $SAR_OUTPUT_FILE > "${TXT_FILE}" - sadf -d -- -b $SAR_OUTPUT_FILE > "${CSV_FILE}" - if $GNUPLOT; then - gnuplot -e "datafile='$CSV_FILE'" "$GNUPLOT_COMMON" "$GNUPLOT_SCRIPTS_DIR/io-requests.gplot" > "${TXT_FILE%.txt}-requests.png" - gnuplot -e "datafile='$CSV_FILE'" "$GNUPLOT_COMMON" "$GNUPLOT_SCRIPTS_DIR/io-data.gplot" > "${TXT_FILE%.txt}-data.png" - fi -} - -function process_mem_results() { - RESULTS_FOLDER="$SAR_RESULTS_FOLDER" - TXT_FILE="$RESULTS_FOLDER/mem.txt" - CSV_FILE="${TXT_FILE%.txt}.csv" - PNG_FILE="${TXT_FILE%.txt}.png" - sar -r -f $SAR_OUTPUT_FILE > "${TXT_FILE}" - sadf -d -- -r $SAR_OUTPUT_FILE > "${CSV_FILE}" - if $GNUPLOT; then - gnuplot -e "datafile='$CSV_FILE'" "$GNUPLOT_COMMON" "$GNUPLOT_SCRIPTS_DIR/mem.gplot" > "$PNG_FILE" - fi -} - -function process_cswch_results() { - RESULTS_FOLDER="$SAR_RESULTS_FOLDER" - TXT_FILE="$RESULTS_FOLDER/cswch.txt" - CSV_FILE="${TXT_FILE%.txt}.csv" - PNG_FILE="${TXT_FILE%.txt}.png" - sar -w -f $SAR_OUTPUT_FILE > "${TXT_FILE}" - sadf -d -- -w $SAR_OUTPUT_FILE > "${CSV_FILE}" - if $GNUPLOT; then - gnuplot -e "datafile='$CSV_FILE'" "$GNUPLOT_COMMON" "$GNUPLOT_SCRIPTS_DIR/cswch.gplot" > "$PNG_FILE" - fi -} - - -case "$SAR_OPERATION" in - - start) - if [[ ! -f "$PID_FILE" ]]; then - echo "Starting sar command." - mkdir -p $SAR_RESULTS_FOLDER - echo $TIMESTAMP > $TIMESTAMP_FILE - sar -A -o "$SAR_OUTPUT_FILE" 2 &>/dev/null & SAR_PID=$! && echo $SAR_PID > $PID_FILE - fi - ;; - - stop) - if [[ -f "$PID_FILE" ]]; then - echo "Stopping sar command." - SAR_PID=`cat $PID_FILE` - kill $SAR_PID && rm $PID_FILE && rm $TIMESTAMP_FILE - - echo "Processing sar output. GNUPLOT: $GNUPLOT" - - # CPU - mkdir $SAR_RESULTS_FOLDER/cpu - - process_cpu_results - for CPU in $(seq -f "%02g" 0 $(( CPU_COUNT-1 )) ); do - process_cpu_results $CPU - done - -# for IFACE in $(ls /sys/class/net); do -# process_net_results $IFACE -# done - - process_io_results - process_mem_results - process_cswch_results - - if $BZIP; then bzip2 "$SAR_OUTPUT_FILE"; fi - - echo "Done." - fi - ;; - -esac diff --git a/testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-base.yml b/testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-base.yml deleted file mode 100644 index 7c41e19929..0000000000 --- a/testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-base.yml +++ /dev/null @@ -1,55 +0,0 @@ -version: "2.2" - -networks: - keycloak: - ipam: - config: - - subnet: 10.0.1.0/24 -# loadbalancing: -# ipam: -# config: -# - subnet: 10.0.2.0/24 - -services: - - mariadb: - build: - context: db/mariadb - args: - MAX_CONNECTIONS: ${DB_MAX_CONNECTIONS:-100} - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - cpuset: ${DB_CPUSET:-1} - mem_limit: ${DB_MEMLIMIT:-2g} - networks: - - keycloak - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: keycloak - MYSQL_USER: keycloak - MYSQL_PASSWORD: keycloak - ports: - - "3306:3306" - - loadbalancer: - build: load-balancer/wildfly-modcluster - image: keycloak_test_loadbalancer:${KEYCLOAK_VERSION:-latest} -# depends_on: -# keycloak: -# condition: service_healthy - cpuset: ${LB_CPUSET:-1} - mem_limit: ${LB_MEMLIMIT:-1500m} - networks: - - keycloak -# - loadbalancing - environment: - PRIVATE_SUBNET: 10.0.1.0/24 -# PUBLIC_SUBNET: 10.0.2.0/24 - JAVA_OPTS: ${LB_JVM_MEMORY:--Xms64m -Xmx1024m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${LB_HTTP_MAX_CONNECTIONS:-50000} - WORKER_IO_THREADS: ${LB_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${LB_WORKER_TASK_MAX_THREADS:-16} - JSTAT: "${LB_JSTAT:-false}" - ports: - - "8080:8080" - - "9990:9990" - diff --git a/testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-keycloak.yml b/testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-keycloak.yml deleted file mode 100644 index 5bf0f041e4..0000000000 --- a/testsuite/performance/tests/src/main/docker-compose/cluster/docker-compose-keycloak.yml +++ /dev/null @@ -1,35 +0,0 @@ - keycloak_%I%: - build: keycloak - image: keycloak_test_keycloak:${KEYCLOAK_VERSION:-latest} - depends_on: - mariadb: - condition: service_healthy - cpuset: "%CPUSET%" - mem_limit: ${KEYCLOAK_MEMLIMIT:-2500m} - networks: - - keycloak - environment: - CONFIGURATION: standalone-ha.xml - PUBLIC_SUBNET: 10.0.1.0/24 - PRIVATE_SUBNET: 10.0.1.0/24 - MARIADB_HOSTS: mariadb:3306 - MARIADB_DATABASE: keycloak - MARIADB_USER: keycloak - MARIADB_PASSWORD: keycloak - KEYCLOAK_ADMIN_USER: ${KEYCLOAK_ADMIN_USER:-admin} - KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:-admin} - JSTAT: "${KEYCLOAK_JSTAT:-false}" - - JAVA_OPTS: ${KEYCLOAK_JVM_MEMORY:--Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${KEYCLOAK_HTTP_MAX_CONNECTIONS:-50000} - AJP_MAX_CONNECTIONS: ${KEYCLOAK_AJP_MAX_CONNECTIONS:-50000} - WORKER_IO_THREADS: ${KEYCLOAK_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${KEYCLOAK_WORKER_TASK_MAX_THREADS:-16} - DS_MIN_POOL_SIZE: ${KEYCLOAK_DS_MIN_POOL_SIZE:-10} - DS_MAX_POOL_SIZE: ${KEYCLOAK_DS_MAX_POOL_SIZE:-100} - DS_POOL_PREFILL: "${KEYCLOAK_DS_POOL_PREFILL:-true}" - DS_PS_CACHE_SIZE: ${KEYCLOAK_DS_PS_CACHE_SIZE:-100} - ports: - - "8080" - - "9990" - diff --git a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml b/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml deleted file mode 100644 index 02a55ce8b0..0000000000 --- a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-base.yml +++ /dev/null @@ -1,160 +0,0 @@ -version: "2.2" - -networks: - # DC 1 - dc1_keycloak: - ipam: - config: - - subnet: 10.1.1.0/24 - # DC 2 - dc2_keycloak: - ipam: - config: - - subnet: 10.2.1.0/24 -# # cross-DC -# loadbalancing: -# ipam: -# config: -# - subnet: 10.0.2.0/24 - # cross-DC - db_replication: - ipam: - config: - - subnet: 10.0.3.0/24 - # cross-DC - ispn_replication: - ipam: - config: - - subnet: 10.0.4.0/24 - -services: - - infinispan_dc1: - build: infinispan - image: keycloak_test_infinispan:${KEYCLOAK_VERSION:-latest} - cpuset: ${INFINISPAN_DC1_CPUSET:-1} - mem_limit: ${INFINISPAN_MEMLIMIT:-1500m} - networks: - - ispn_replication - - dc1_keycloak - environment: - CONFIGURATION: clustered-dc1.xml - PUBLIC_SUBNET: 10.1.1.0/24 - PRIVATE_SUBNET: 10.0.4.0/24 - MGMT_USER: admin - MGMT_USER_PASSWORD: admin - TCP_PING_INITIAL_HOSTS: infinispan_dc1[7600] - JAVA_OPTS: ${INFINISPAN_JVM_MEMORY:--Xms64m -Xmx1g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -XX:+DisableExplicitGC} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - JSTAT: "${INFINISPAN_JSTAT:-false}" - ports: - - "9990" - - infinispan_dc2: - build: infinispan - image: keycloak_test_infinispan:${KEYCLOAK_VERSION:-latest} - depends_on: - infinispan_dc1: - condition: service_healthy - cpuset: ${INFINISPAN_DC2_CPUSET:-1} - mem_limit: ${INFINISPAN_MEMLIMIT:-1500m} - networks: - - ispn_replication - - dc2_keycloak - environment: - CONFIGURATION: clustered-dc2.xml - PUBLIC_SUBNET: 10.2.1.0/24 - PRIVATE_SUBNET: 10.0.4.0/24 - MGMT_USER: admin - MGMT_USER_PASSWORD: admin - TCP_PING_INITIAL_HOSTS: infinispan_dc1[7600],infinispan_dc2[7600] - JAVA_OPTS: ${INFINISPAN_JVM_MEMORY:--Xms64m -Xmx1g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -XX:+DisableExplicitGC} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - JSTAT: "${INFINISPAN_JSTAT:-false}" - ports: - - "9990" - - - mariadb_dc1: - build: - context: db/mariadb - args: - MAX_CONNECTIONS: ${DB_MAX_CONNECTIONS:-100} - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - cpuset: ${DB_DC1_CPUSET:-1} - mem_limit: ${DB_MEMLIMIT:-2g} - networks: - - db_replication - - dc1_keycloak - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_INITDB_SKIP_TZINFO: foo - MYSQL_DATABASE: keycloak - MYSQL_USER: keycloak - MYSQL_PASSWORD: keycloak - entrypoint: docker-entrypoint-wsrep.sh - command: --wsrep-new-cluster - ports: - - "3307:3306" - - mariadb_dc2: - build: - context: db/mariadb - args: - MAX_CONNECTIONS: ${DB_MAX_CONNECTIONS:-100} - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - depends_on: - mariadb_dc1: - condition: service_healthy - cpuset: ${DB_DC2_CPUSET:-1} - mem_limit: ${DB_MEMLIMIT:-2g} - networks: - - db_replication - - dc2_keycloak - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_INITDB_SKIP_TZINFO: foo - entrypoint: docker-entrypoint-wsrep.sh - command: --wsrep_cluster_address=gcomm://mariadb_dc1 - ports: - - "3308:3306" - - - loadbalancer_dc1: - build: load-balancer/wildfly-modcluster - image: keycloak_test_loadbalancer:${KEYCLOAK_VERSION:-latest} - cpuset: ${LB_DC1_CPUSET:-1} - mem_limit: ${LB_MEMLIMIT:-1500m} - networks: - - dc1_keycloak -# - loadbalancing - environment: - PRIVATE_SUBNET: 10.1.1.0/24 -# PUBLIC_SUBNET: 10.0.2.0/24 - JAVA_OPTS: ${LB_JVM_MEMORY:--Xms64m -Xmx1024m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${LB_HTTP_MAX_CONNECTIONS:-50000} - WORKER_IO_THREADS: ${LB_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${LB_WORKER_TASK_MAX_THREADS:-16} - JSTAT: "${LB_JSTAT:-false}" - ports: - - "8081:8080" - - "9991:9990" - - loadbalancer_dc2: - build: load-balancer/wildfly-modcluster - image: keycloak_test_loadbalancer:${KEYCLOAK_VERSION:-latest} - cpuset: ${LB_DC2_CPUSET:-1} - mem_limit: ${LB_MEMLIMIT:-1500m} - networks: - - dc2_keycloak -# - loadbalancing - environment: - PRIVATE_SUBNET: 10.2.1.0/24 -# PUBLIC_SUBNET: 10.0.2.0/24 - JAVA_OPTS: ${LB_JVM_MEMORY:--Xms64m -Xmx1024m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${LB_HTTP_MAX_CONNECTIONS:-50000} - WORKER_IO_THREADS: ${LB_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${LB_WORKER_TASK_MAX_THREADS:-16} - JSTAT: "${LB_JSTAT:-false}" - ports: - - "8082:8080" - - "9992:9990" - diff --git a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc1.yml b/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc1.yml deleted file mode 100644 index faf189474b..0000000000 --- a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc1.yml +++ /dev/null @@ -1,43 +0,0 @@ - keycloak_dc1_%I%: - build: ./keycloak - image: keycloak_test_keycloak_dc1:${KEYCLOAK_VERSION:-latest} - depends_on: - # wait for the db cluster to be ready before starting keycloak - mariadb_dc2: - condition: service_healthy - # wait for the ispn cluster to be ready before starting keycloak - infinispan_dc2: - condition: service_healthy - cpuset: "%CPUSET%" - mem_limit: ${KEYCLOAK_MEMLIMIT:-2500m} - networks: - - dc1_keycloak - environment: - CONFIGURATION: standalone-ha.xml - PUBLIC_SUBNET: 10.1.1.0/24 - PRIVATE_SUBNET: 10.1.1.0/24 - MARIADB_HOSTS: mariadb_dc1:3306 - MARIADB_DATABASE: keycloak - MARIADB_USER: keycloak - MARIADB_PASSWORD: keycloak - KEYCLOAK_ADMIN_USER: ${KEYCLOAK_ADMIN_USER:-admin} - KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:-admin} - JSTAT: "${KEYCLOAK_JSTAT:-false}" - INFINISPAN_HOST: infinispan_dc1 - SITE: dc1 - HOTROD_VERSION: 2.8 - CACHE_STATISTICS: "true" - - JAVA_OPTS: ${KEYCLOAK_JVM_MEMORY:--Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${KEYCLOAK_HTTP_MAX_CONNECTIONS:-50000} - AJP_MAX_CONNECTIONS: ${KEYCLOAK_AJP_MAX_CONNECTIONS:-50000} - WORKER_IO_THREADS: ${KEYCLOAK_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${KEYCLOAK_WORKER_TASK_MAX_THREADS:-16} - DS_MIN_POOL_SIZE: ${KEYCLOAK_DS_MIN_POOL_SIZE:-10} - DS_MAX_POOL_SIZE: ${KEYCLOAK_DS_MAX_POOL_SIZE:-100} - DS_POOL_PREFILL: "${KEYCLOAK_DS_POOL_PREFILL:-true}" - DS_PS_CACHE_SIZE: ${KEYCLOAK_DS_PS_CACHE_SIZE:-100} - ports: - - "8080" - - "9990" - diff --git a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc2.yml b/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc2.yml deleted file mode 100644 index ebab452602..0000000000 --- a/testsuite/performance/tests/src/main/docker-compose/crossdc/docker-compose-keycloak_dc2.yml +++ /dev/null @@ -1,40 +0,0 @@ - keycloak_dc2_%I%: - build: ./keycloak - image: keycloak_test_keycloak_dc2:${KEYCLOAK_VERSION:-latest} - depends_on: - # wait for first kc instance to be ready before starting another - keycloak_dc1_1: - condition: service_healthy - cpuset: "%CPUSET%" - mem_limit: ${KEYCLOAK_MEMLIMIT:-2500m} - networks: - - dc2_keycloak - environment: - CONFIGURATION: standalone-ha.xml - PUBLIC_SUBNET: 10.2.1.0/24 - PRIVATE_SUBNET: 10.2.1.0/24 - MARIADB_HOSTS: mariadb_dc2:3306 - MARIADB_DATABASE: keycloak - MARIADB_USER: keycloak - MARIADB_PASSWORD: keycloak - KEYCLOAK_ADMIN_USER: ${KEYCLOAK_ADMIN_USER:-admin} - KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:-admin} - JSTAT: "${KEYCLOAK_JSTAT:-false}" - INFINISPAN_HOST: infinispan_dc2 - SITE: dc2 - HOTROD_VERSION: 2.8 - CACHE_STATISTICS: "true" - - JAVA_OPTS: ${KEYCLOAK_JVM_MEMORY:--Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${KEYCLOAK_HTTP_MAX_CONNECTIONS:-50000} - AJP_MAX_CONNECTIONS: ${KEYCLOAK_AJP_MAX_CONNECTIONS:-50000} - WORKER_IO_THREADS: ${KEYCLOAK_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${KEYCLOAK_WORKER_TASK_MAX_THREADS:-16} - DS_MIN_POOL_SIZE: ${KEYCLOAK_DS_MIN_POOL_SIZE:-10} - DS_MAX_POOL_SIZE: ${KEYCLOAK_DS_MAX_POOL_SIZE:-100} - DS_POOL_PREFILL: "${KEYCLOAK_DS_POOL_PREFILL:-true}" - DS_PS_CACHE_SIZE: ${KEYCLOAK_DS_PS_CACHE_SIZE:-100} - ports: - - "8080" - - "9990" - diff --git a/testsuite/performance/tests/src/main/docker-compose/docker-compose-monitoring.yml b/testsuite/performance/tests/src/main/docker-compose/docker-compose-monitoring.yml deleted file mode 100644 index aeb4afde12..0000000000 --- a/testsuite/performance/tests/src/main/docker-compose/docker-compose-monitoring.yml +++ /dev/null @@ -1,79 +0,0 @@ -#version: '3' -version: '2.2' - -networks: - monitoring: - ipam: - config: - - subnet: 10.0.5.0/24 - -services: - - monitoring_influxdb: - image: influxdb - cpuset: ${MONITORING_CPUSET:-0} - volumes: - - influx:/var/lib/influxdb - networks: - - monitoring - ports: - - "8086:8086" -# deploy: -# replicas: 1 -# placement: -# constraints: -# - node.role == manager - - monitoring_cadvisor: - build: monitoring/cadvisor - image: monitoring_cadvisor - cpuset: ${MONITORING_CPUSET:-0} - hostname: '{{.Node.ID}}' - volumes: - - /:/rootfs:ro - - /var/run:/var/run:rw - - /sys:/sys:ro - - /var/lib/docker/:/var/lib/docker:ro - networks: - - monitoring - environment: - INFLUX_HOST: monitoring_influxdb - INFLUX_DATABASE: cadvisor - privileged: true - depends_on: - - monitoring_influxdb - command: --storage_driver_buffer_duration="5s" - ports: - - "8087:8080" -# deploy: -# mode: global - - - monitoring_grafana: - build: monitoring/grafana - image: monitoring_grafana - cpuset: ${MONITORING_CPUSET:-0} - depends_on: - - monitoring_influxdb - volumes: - - grafana:/var/lib/grafana - networks: - - monitoring - environment: - INFLUX_DATASOURCE_NAME: influxdb_cadvisor - INFLUX_HOST: monitoring_influxdb - INFLUX_DATABASE: cadvisor - ports: - - "3000:3000" -# deploy: -# replicas: 1 -# placement: -# constraints: -# - node.role == manager - - -volumes: - influx: - driver: local - grafana: - driver: local diff --git a/testsuite/performance/tests/src/main/docker-compose/docker-compose.yml b/testsuite/performance/tests/src/main/docker-compose/docker-compose.yml deleted file mode 100644 index 694d9827b2..0000000000 --- a/testsuite/performance/tests/src/main/docker-compose/docker-compose.yml +++ /dev/null @@ -1,59 +0,0 @@ -version: "2.2" - -networks: - keycloak: - ipam: - config: - - subnet: 10.0.1.0/24 - -services: - - mariadb: - build: - context: db/mariadb - args: - MAX_CONNECTIONS: ${DB_MAX_CONNECTIONS:-100} - image: keycloak_test_mariadb:${KEYCLOAK_VERSION:-latest} - cpuset: ${DB_CPUSET:-1} - mem_limit: ${DB_MEMLIMIT:-2g} - networks: - - keycloak - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: keycloak - MYSQL_USER: keycloak - MYSQL_PASSWORD: keycloak - MYSQL_INITDB_SKIP_TZINFO: 1 - ports: - - "3306:3306" - - keycloak: - build: keycloak - image: keycloak_test_keycloak:${KEYCLOAK_VERSION:-latest} - depends_on: - mariadb: - condition: service_healthy - cpuset: ${KEYCLOAK_CPUSET:-2-3} - mem_limit: ${KEYCLOAK_MEMLIMIT:-2500m} - networks: - - keycloak - environment: - MARIADB_HOSTS: mariadb:3306 - MARIADB_DATABASE: keycloak - MARIADB_USER: keycloak - MARIADB_PASSWORD: keycloak - KEYCLOAK_ADMIN_USER: ${KEYCLOAK_ADMIN_USER:-admin} - KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:-admin} - # docker-compose syntax note: ${ENV_VAR:-} - JAVA_OPTS: ${KEYCLOAK_JVM_MEMORY:--Xms64m -Xmx2g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m} -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true - HTTP_MAX_CONNECTIONS: ${KEYCLOAK_HTTP_MAX_CONNECTIONS:-50000} - WORKER_IO_THREADS: ${KEYCLOAK_WORKER_IO_THREADS:-2} - WORKER_TASK_MAX_THREADS: ${KEYCLOAK_WORKER_TASK_MAX_THREADS:-16} - DS_MIN_POOL_SIZE: ${KEYCLOAK_DS_MIN_POOL_SIZE:-10} - DS_MAX_POOL_SIZE: ${KEYCLOAK_DS_MAX_POOL_SIZE:-100} - DS_POOL_PREFILL: "${KEYCLOAK_DS_POOL_PREFILL:-true}" - DS_PS_CACHE_SIZE: ${KEYCLOAK_DS_PS_CACHE_SIZE:-100} - JSTAT: "${KEYCLOAK_JSTAT:-false}" - ports: - - "8080:8080" - - "9990:9990" diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/common.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/common.gp deleted file mode 100644 index de6a85231e..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/common.gp +++ /dev/null @@ -1,17 +0,0 @@ -set datafile separator whitespace -set datafile commentschar "" -set xlabel "Runtime (s)" -set ylabel "Memory (kB)" -set terminal pngcairo size 1280,800 -set xtics rotate -set yrange [0:*] -set key below -set grid - -set style fill solid 1.0 border -1 -set linetype 1 lc rgb '#ff0000' -set linetype 2 lc rgb '#00ff39' -set linetype 3 lc rgb '#4d00ff' -set linetype 4 lc rgb '#ff00fb' -set linetype 5 lc rgb '#00ffff' -set linetype 6 lc rgb '#f7ff00' diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-all.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-all.gp deleted file mode 100644 index 96e9b480f0..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-all.gp +++ /dev/null @@ -1,8 +0,0 @@ -set title "Heap + Non-heap Memory" -plot\ - datafile using 1:(column('S0C')+column('S1C')+column('EC')+column('OC')+column('MC')+column('CCSC')) title 'CCSC' with filledcurves x1, \ - datafile using 1:(column('S0C')+column('S1C')+column('EC')+column('OC')+column('MC')) title 'MC' with filledcurves x1, \ - datafile using 1:(column('S0C')+column('S1C')+column('EC')+column('OC')) title 'OC' with filledcurves x1, \ - datafile using 1:(column('S0C')+column('S1C')+column('EC')) title 'EC' with filledcurves x1, \ - datafile using 1:(column('S0C')+column('S1C')) title 'S1C' with filledcurves x1, \ - datafile using 1:'S0C' title 'S0C' with filledcurves x1 diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-cc.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-cc.gp deleted file mode 100644 index c520555255..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-cc.gp +++ /dev/null @@ -1,2 +0,0 @@ -set title "Utilisation of Compressed Classes space" -plot for [i in "CCSU CCSC"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-e.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-e.gp deleted file mode 100644 index a48236c3a6..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-e.gp +++ /dev/null @@ -1,2 +0,0 @@ -set title "Utilisation of Eden space" -plot for [i in "EU EC"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-ev.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-ev.gp deleted file mode 100644 index 41d1163630..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-ev.gp +++ /dev/null @@ -1,3 +0,0 @@ -set ylabel "Number of events" -set title "Utilisation of Garbage collection events (young, full)" -plot for [i in "YGC FGC"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-m.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-m.gp deleted file mode 100644 index ef50fa567a..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-m.gp +++ /dev/null @@ -1,2 +0,0 @@ -set title "Utilisation of Meta space" -plot for [i in "MU MC"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-o.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-o.gp deleted file mode 100644 index 7cb4f403f6..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-o.gp +++ /dev/null @@ -1,2 +0,0 @@ -set title "Utilisation of Old space" -plot for [i in "OU OC"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-s0.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-s0.gp deleted file mode 100644 index 980047ed2b..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-s0.gp +++ /dev/null @@ -1,2 +0,0 @@ -set title "Utilisation of Survivor 0 space" -plot for [i in "S0U S0C"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-s1.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-s1.gp deleted file mode 100644 index b222814544..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-s1.gp +++ /dev/null @@ -1,2 +0,0 @@ -set title "Utilisation of Survivor 1 space" -plot for [i in "S1U S1C"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-t.gp b/testsuite/performance/tests/src/main/gnuplot/jstat/gc-t.gp deleted file mode 100644 index e1c14ed49f..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/jstat/gc-t.gp +++ /dev/null @@ -1,3 +0,0 @@ -set ylabel "GC time (s)" -set title "Utilisation of Garbage collection time (young, full, total)" -plot for [i in "YGCT FGCT GCT"] datafile using 1:i title columnheader(i) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/sar/common.gplot b/testsuite/performance/tests/src/main/gnuplot/sar/common.gplot deleted file mode 100644 index 8bd59a8eae..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/sar/common.gplot +++ /dev/null @@ -1,11 +0,0 @@ -set datafile separator ";" -set datafile commentschar "" -set xlabel "Time" -set xdata time -set timefmt "%Y-%m-%d %H:%M:%S" -set format x '%H:%M:%S' -set terminal pngcairo size 800,500 -set xtics rotate -set yrange [0:*] -set key below -set grid diff --git a/testsuite/performance/tests/src/main/gnuplot/sar/cpu.gplot b/testsuite/performance/tests/src/main/gnuplot/sar/cpu.gplot deleted file mode 100644 index 8bd00f9cdd..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/sar/cpu.gplot +++ /dev/null @@ -1,11 +0,0 @@ -set ylabel "% Utilization" -set title "Processor Utilization" -plot \ -for [i=5:8:1] \ - datafile using 3:(sum [col=i:8] column(col)) \ - title columnheader(i) \ - with filledcurves x1, \ -for [i=5:8:1] \ - datafile using 3:(sum [col=i:8] column(col)) \ - notitle \ - with lines lc rgb "#000000" lw 1 diff --git a/testsuite/performance/tests/src/main/gnuplot/sar/cswch.gplot b/testsuite/performance/tests/src/main/gnuplot/sar/cswch.gplot deleted file mode 100644 index caf1e3348d..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/sar/cswch.gplot +++ /dev/null @@ -1,2 +0,0 @@ -set title "Context Switches Per Second" -plot datafile using 3:5 title columnheader(5) with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/sar/io-data.gplot b/testsuite/performance/tests/src/main/gnuplot/sar/io-data.gplot deleted file mode 100644 index adaf658d74..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/sar/io-data.gplot +++ /dev/null @@ -1,5 +0,0 @@ -set title "IO Data - Blocks Read/Written Per Second" -plot for [i=7:8:1] \ - datafile using 3:i \ - title columnheader(i) \ - with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/sar/io-requests.gplot b/testsuite/performance/tests/src/main/gnuplot/sar/io-requests.gplot deleted file mode 100644 index 30c7de5d1b..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/sar/io-requests.gplot +++ /dev/null @@ -1,5 +0,0 @@ -set title "IO Requests Per Second" -plot for [i=4:6:1] \ - datafile using 3:i \ - title columnheader(i) \ - with lines diff --git a/testsuite/performance/tests/src/main/gnuplot/sar/mem.gplot b/testsuite/performance/tests/src/main/gnuplot/sar/mem.gplot deleted file mode 100644 index 500b59a876..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/sar/mem.gplot +++ /dev/null @@ -1,8 +0,0 @@ -set title "Memory Utilization" -set ylabel "MB" -plot \ - datafile using 3:($5/1024) title 'Used' with filledcurves x1, \ - datafile using 3:($5/1024) notitle with lines lc rgb "#000000" lw 1, \ - datafile using 3:(($5 - $7 - $8)/1024) title 'Really Used' with filledcurves x1, \ - datafile using 3:(($5 - $7 - $8)/1024) notitle with lines lc rgb "#000000" lw 1 - diff --git a/testsuite/performance/tests/src/main/gnuplot/sar/net.gplot b/testsuite/performance/tests/src/main/gnuplot/sar/net.gplot deleted file mode 100644 index 44dd7e2d5c..0000000000 --- a/testsuite/performance/tests/src/main/gnuplot/sar/net.gplot +++ /dev/null @@ -1,6 +0,0 @@ -set ylabel "kB/S" -set title "Network Usage" -plot for [i=7:8:1] \ - datafile using 3:i \ - title columnheader(i) \ - with lines diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockHttpFacade.java b/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockHttpFacade.java deleted file mode 100644 index 85c7e597a2..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockHttpFacade.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.keycloak.gatling; - -import org.keycloak.adapters.spi.AuthenticationError; -import org.keycloak.adapters.spi.HttpFacade; -import org.keycloak.adapters.spi.LogoutError; - -import javax.security.cert.X509Certificate; - -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URL; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -public class MockHttpFacade implements HttpFacade { - final Request request = new Request(); - final Response response = new Response(); - - @Override - public Request getRequest() { - return request; - } - - @Override - public Response getResponse() { - return response; - } - - @Override - public X509Certificate[] getCertificateChain() { - throw new UnsupportedOperationException(); - } - - static class Request implements HttpFacade.Request { - private String uri; - private String relativePath; - private Map queryParams; - private Map cookies; - - @Override - public String getMethod() { - throw new UnsupportedOperationException(); - } - - @Override - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - this.relativePath = URI.create(uri).getPath(); - List params = Arrays.asList(uri.substring(uri.indexOf('?') + 1).split("&")); - queryParams = params.stream().map(p -> p.split("=")) - .collect(Collectors.toMap(a -> a[0], a -> a.length > 1 ? a[1] : "")); - } - - @Override - public String getRelativePath() { - return relativePath; - } - - @Override - public boolean isSecure() { - return false; - } - - @Override - public String getFirstParam(String param) { - throw new UnsupportedOperationException(); - } - - @Override - public String getQueryParamValue(String param) { - return queryParams.get(param); - } - - @Override - public HttpFacade.Cookie getCookie(String cookieName) { - return cookies.get(cookieName); - } - - public void setCookies(Map cookies) { - this.cookies = cookies; - } - - @Override - public String getHeader(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public List getHeaders(String name) { - return Collections.emptyList(); - } - - @Override - public InputStream getInputStream() { - throw new UnsupportedOperationException(); - } - - @Override - public String getRemoteAddr() { - return "localhost"; // TODO - } - - @Override - public void setError(AuthenticationError error) { - throw new UnsupportedOperationException(); - } - - @Override - public void setError(LogoutError error) { - throw new UnsupportedOperationException(); - } - - @Override - public InputStream getInputStream(boolean buffered) { - throw new UnsupportedOperationException(); - } - } - - static class Response implements HttpFacade.Response { - @Override - public void setStatus(int status) { - } - - @Override - public void addHeader(String name, String value) { - } - - @Override - public void setHeader(String name, String value) { - } - - @Override - public void resetCookie(String name, String path) { - } - - @Override - public void setCookie(String name, String value, String path, String domain, int maxAge, boolean secure, boolean httpOnly) { - throw new UnsupportedOperationException(); - } - - @Override - public OutputStream getOutputStream() { - throw new UnsupportedOperationException(); - } - - @Override - public void sendError(int code) { - throw new UnsupportedOperationException(); - } - - @Override - public void sendError(int code, String message) { - throw new UnsupportedOperationException(); - } - - @Override - public void end() { - } - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockRequestAuthenticator.java b/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockRequestAuthenticator.java deleted file mode 100644 index 5822eb2f12..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockRequestAuthenticator.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.keycloak.gatling; - -import org.keycloak.KeycloakPrincipal; -import org.keycloak.adapters.AdapterTokenStore; -import org.keycloak.adapters.KeycloakDeployment; -import org.keycloak.adapters.OAuthRequestAuthenticator; -import org.keycloak.adapters.RefreshableKeycloakSecurityContext; -import org.keycloak.adapters.RequestAuthenticator; -import org.keycloak.adapters.spi.HttpFacade; - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -public class MockRequestAuthenticator extends RequestAuthenticator { - public static String KEY = MockRequestAuthenticator.class.getName(); - - private RefreshableKeycloakSecurityContext keycloakSecurityContext; - // This is application-specific user session, used for backchannel operations - private final String sessionId; - - public MockRequestAuthenticator(HttpFacade facade, KeycloakDeployment deployment, AdapterTokenStore tokenStore, int sslRedirectPort, String sessionId) { - super(facade, deployment, tokenStore, sslRedirectPort); - this.sessionId = sessionId; - } - - @Override - protected OAuthRequestAuthenticator createOAuthAuthenticator() { - return new OAuthRequestAuthenticator(this, facade, deployment, sslRedirectPort, tokenStore); - } - - @Override - protected void completeOAuthAuthentication(KeycloakPrincipal principal) { - keycloakSecurityContext = principal.getKeycloakSecurityContext(); - } - - @Override - protected void completeBearerAuthentication(KeycloakPrincipal principal, String method) { - throw new UnsupportedOperationException(); - } - - @Override - protected String changeHttpSessionId(boolean create) { - return sessionId; - } - - public RefreshableKeycloakSecurityContext getKeycloakSecurityContext() { - return keycloakSecurityContext; - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockTokenStore.java b/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockTokenStore.java deleted file mode 100644 index 1f0196678f..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/MockTokenStore.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.keycloak.gatling; - -import org.keycloak.adapters.AdapterTokenStore; -import org.keycloak.adapters.OidcKeycloakAccount; -import org.keycloak.adapters.RefreshableKeycloakSecurityContext; -import org.keycloak.adapters.RequestAuthenticator; - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -public class MockTokenStore implements AdapterTokenStore { - @Override - public void checkCurrentToken() { - } - - @Override - public boolean isCached(RequestAuthenticator authenticator) { - return false; - } - - @Override - public void saveAccountInfo(OidcKeycloakAccount account) { - throw new UnsupportedOperationException(); - } - - @Override - public void logout() { - } - - @Override - public void refreshCallback(RefreshableKeycloakSecurityContext securityContext) { - } - - @Override - public void saveRequest() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean restoreRequest() { - throw new UnsupportedOperationException(); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogLine.java b/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogLine.java deleted file mode 100644 index b132391101..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogLine.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.keycloak.gatling.log; - -/** - * @author Marko Strukelj - */ -class LogLine { - - private final String rawLine; - private Type type; - private String simulationClass; - private String simulationId; - private String description; - private String scenario; - private String userId; - private String request; - private long start = -1; - private long end = -1; - private long time2 = -1; - private long time3 = -1; - private boolean ok; - private String status; - - LogLine(String line) { - rawLine = line; - } - - String rawLine() { - return rawLine; - } - - Type type() { - return type != null ? type : parse().type; - } - - String simulationClass() { - return simulationClass; - } - - public String simulationId() { - return simulationId; - } - - public String description() { - return description; - } - - long startTime() { - return type != null ? start : parse().start; - } - - long endTime() { - return type != null ? end : parse().end; - } - - String scenario() { - return type != null ? scenario : parse().scenario; - } - - String userId() { - return type != null ? userId : parse().userId; - } - - String request() { - return type != null ? request : parse().request; - } - - public void setStart(long start) { - this.start = start; - } - - public void setEnd(long end) { - this.end = end; - } - - long logTime() { - if (type == null) { - parse(); - } - return type == Type.RUN || type == Type.USER_START ? start : end; - } - - boolean ok() { - if (type == null) { - parse(); - } - return type != null ? ok : parse().ok; - } - - LogLine parse() { - String[] cols = rawLine.split("\\t"); - - if ("ASSERTION".equals(cols[0])) { - type = Type.ASSERTION; - } else if ("RUN".equals(cols[2])) { - type = Type.RUN; - simulationClass = cols[0]; - simulationId = cols[1]; - start = Long.parseLong(cols[3]); - description = cols[4]; - } else if ("REQUEST".equals(cols[2])) { - type = Type.REQUEST; - scenario = cols[0]; - userId = cols[1]; - request = cols[4]; - start = Long.parseLong(cols[5]); - time2 = Long.parseLong(cols[6]); - time3 = Long.parseLong(cols[7]); - end = Long.parseLong(cols[8]); - ok = "OK".equals(cols[9]); - if (cols.length > 10) { - StringBuilder sb = new StringBuilder(); - for (int i = 10; i < cols.length; i++) { - if (sb.length() > 0) { - sb.append("\t"); - } - sb.append(cols[i]); - } - status = sb.toString(); - } - } else if ("USER".equals(cols[2])) { - if ("START".equals(cols[3])) { - type = Type.USER_START; - } else if ("END".equals(cols[3])) { - type = Type.USER_END; - } else { - throw new RuntimeException("Unknown log entry type: USER " + cols[3]); - } - scenario = cols[0]; - userId = cols[1]; - start = Long.parseLong(cols[4]); - end = Long.parseLong(cols[5]); - } else { - throw new RuntimeException("Unknow log entry type: " + cols[2]); - } - - return this; - } - - /** - * @return Reconstructed LogLine - */ - public String compose() { - switch (type()) { - case ASSERTION: { - return rawLine; - } - case RUN: { - return simulationClass + "\t" + simulationId + "\t" + type.caption() + "\t" + start + "\t"+ description +"\t2.0\t"; - } - case REQUEST: { - return scenario + "\t" + userId + "\t" + type.caption() + "\t" + request + "\t" + start + "\t" + - time2 + "\t" + time3 + "\t" + end + "\t" + (ok ? "OK" : "KO") + "\t" + (status != null ? status : ""); - } - case USER_START: { - return scenario + "\t" + userId + "\t" + type.caption() + "\t" + start + "\t0"; - - } - case USER_END: { - return scenario + "\t" + userId + "\t" + type.caption() + "\t" + start + "\t" + end; - - } - } - throw new IllegalStateException("Unhandled type: " + type()); - } - - - enum Type { - ASSERTION("ASSERTION"), - RUN("RUN"), - REQUEST("REQUEST\t"), - USER_START("USER\tSTART"), - USER_END("USER\tEND"); - - private String caption; - - Type(String caption) { - this.caption = caption; - } - - public String caption() { - return caption; - } - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogProcessor.java b/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogProcessor.java deleted file mode 100644 index 31d59b9fc6..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogProcessor.java +++ /dev/null @@ -1,443 +0,0 @@ -package org.keycloak.gatling.log; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import static org.keycloak.performance.TestConfig.SIMPLE_TIME; - -/** - * To run use the following: - * - * mvn -f testsuite/integration-arquillian/performance/tests exec:java -Dexec.mainClass=org.keycloak.performance.log.LogProcessor -Dexec.args="ARGUMENTS" - * - * @author Marko Strukelj - */ -public class LogProcessor { - - boolean inlayedIncluded = false; - boolean outlayedIncluded = false; - - File simulationLogFile; - String lastRequestLabel; - - HashMap> userIterations = new HashMap<>(); - HashMap currentIterations = new HashMap<>(); - - /** - * Create a log processor that knows how to parse the following format - * - * - * keycloak.AdminSimulation adminsimulation RUN 1502467483145 null 2.0 - * AdminSimulation 1829459789004783445-0 USER START 1502467483171 0 - * AdminSimulation 1829459789004783445-0 REQUEST Console REST - Config 1502467483296 1502467483299 1502467483303 1502467483303 OK - * AdminSimulation 1829459789004783445-1 USER START 1502467483328 0 - * AdminSimulation 1829459789004783445-1 REQUEST Console Home 1502467483331 1502467483335 1502467483340 1502467483340 OK - * AdminSimulation 1829459789004783445-2 REQUEST Console REST - realm_0/users/ID/reset-password PUT 1502467578382 1502467578382 1502467578393 1502467578393 KO status.find.is(204), but actually found 401 - * AdminSimulation 1829459789004783445-40 REQUEST Console REST - realm_0 1502467578386 1502467578386 1502467578397 1502467578397 KO status.find.is(200), but actually found 401 - * AdminSimulation 1829459789004783445-40 USER END 1502467487280 1502467581383 - * AdminSimulation 1829459789004783445-43 REQUEST Console REST - realm_0/users/ID/reset-password PUT 1502467581480 1502467581480 1502467581487 1502467581487 KO status.find.is(204), but actually found 401 - * AdminSimulation 1829459789004783445-43 USER END 1502467487581 1502467581489 - * AdminSimulation 1829459789004783445-42 REQUEST Console REST - realm_0/users/ID/reset-password PUT 1502467582881 1502467582881 1502467582885 1502467582885 KO status.find.is(204), but actually found 401 - */ - public LogProcessor(String logFilePath) { - simulationLogFile = new File(logFilePath); - } - - public LogProcessor(Class simulationClass) { - this(getLatestSimulationLogDir(getSimulationId(simulationClass)).getAbsoluteFile().toString() + "/simulation.log"); - } - - public static String getSimulationId(Class simulationClass) { - return simulationClass.getSimpleName().toLowerCase(); - } - - private static File getLatestSimulationLogDir(String simulationId) { - String buildDirPath = System.getProperty("project.build.directory", "target"); - String resultsDirPath = System.getProperty("gatling.core.directory.results", buildDirPath + "/gatling"); - File resultsDir = new File(resultsDirPath); - - return Arrays.stream(resultsDir.listFiles((dir, name) -> name.startsWith(simulationId))) - .sorted((a, b) -> -a.compareTo(b)) - .findFirst() - .orElseThrow(() -> new IllegalStateException("Latest simulation.log not found.")); - } - - public Stats stats() throws IOException { - - Stats stats = new Stats(); - - LogReader reader = new LogReader(simulationLogFile); - try { - LogLine line; - while ((line = reader.readLine()) != null) { - if (line.type() == LogLine.Type.RUN) { - stats.setStartTime(line.startTime()); - } else if (line.type() == LogLine.Type.USER_START) { - stats.setLastUserStart(line.startTime()); - userStarted(line.scenario(), line.userId()); - } else if (line.type() == LogLine.Type.USER_END) { - if (line.ok() && stats.firstUserEnd() == 0) { - stats.setFirstUserEnd(line.endTime()); - } - stats.setLastUserEnd(line.endTime()); - userCompleted(line.scenario(), line.userId()); - } else if (line.type() == LogLine.Type.REQUEST) { - String scenario = line.scenario(); - stats.addRequest(scenario, line.request()); - if (lastRequestLabel != null && line.request().endsWith(lastRequestLabel)) { - iterationCompleted(scenario, line.userId()); - if (allUsersCompletedIteration(scenario)) { - advanceIteration(scenario); - stats.addIterationCompletedByAll(scenario, line.endTime()); - } - } - } - } - } finally { - reader.close(); - } - - return stats; - } - - - private void iterationCompleted(String scenario, String userId) { - HashMap userMap = userIterations.computeIfAbsent(scenario, k -> new HashMap<>()); - int count = userMap.getOrDefault(userId, 0); - userMap.put(userId, count + 1); - } - - private void userStarted(String scenario, String userId) { - HashMap userMap = userIterations.computeIfAbsent(scenario, k -> new HashMap<>()); - userMap.put(userId, 0); - } - - private void userCompleted(String scenario, String userId) { - HashMap userMap = userIterations.computeIfAbsent(scenario, k -> new HashMap<>()); - userMap.remove(userId); - } - - private boolean allUsersCompletedIteration(String scenario) { - HashMap userMap = userIterations.computeIfAbsent(scenario, k -> new HashMap<>()); - // check if all users have reached currentIteration - for (Integer val: userMap.values()) { - if (val < currentIterations.getOrDefault(scenario, 1)) - return false; - } - return true; - } - - private void advanceIteration(String scenario) { - currentIterations.put(scenario, 1 + currentIterations.getOrDefault(scenario, 1)); - } - - public void filterLog(long start, long end) throws IOException { - filterLog(start, end, inlayedIncluded, outlayedIncluded); - } - - /** - * - * Setting inlayedIncluded to either true or false, results in first second anomaly towards lower values - * Setting outlayedIncluded to true, and inlayedIncluded to false seems to behave best balancing the first second - * downward skew with the last second upward skew. But it varies between test, and it's hard to say. - * - * All requests within time interval will also have their corresponding USER START and USER END entries copied - * over, and adjusted to time interval start and end boundaries. - * - * @param start Time stamp at which to start copying over logged entries - * @param end Time stamp beyond which logging entries are no longer copied over - * @param inlayedIncluded Requests that start before interval start time but end within time interval should be included - * @param outlayedIncluded Requests that start within time interval but end after interval end time should be included - * @throws IOException - */ - public void filterLog(long start, long end, boolean inlayedIncluded, boolean outlayedIncluded) throws IOException { - this.inlayedIncluded = inlayedIncluded; - this.outlayedIncluded = outlayedIncluded; - - System.out.println(String.format("Filtering %s/%s \ninlayedIncluded: %s \noutlayedIncluded: %s", - simulationLogFile.getParentFile().getName(), simulationLogFile.getName(), this.inlayedIncluded, this.outlayedIncluded)); - - File simulationLogFileFiltered = new File(simulationLogFile.getAbsoluteFile() + ".filtered"); - File simulationLogFileUnfiltered = new File(simulationLogFile.getAbsoluteFile() + ".unfiltered"); - - PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(simulationLogFileFiltered), "utf-8")); - copyPartialLog(out, start, end); - - simulationLogFile.renameTo(simulationLogFileUnfiltered); - simulationLogFileFiltered.renameTo(simulationLogFile); - } - - public void copyPartialLog(PrintWriter output, long start, long end) throws IOException { - - System.out.println(String.format("Extracting from: %s to %s (%s - %s)", SIMPLE_TIME.format(start), SIMPLE_TIME.format(end), start, end)); - - HashMap starts = new HashMap<>(); - HashMap sessionTimes = new HashMap<>(); - - - // We adjust log entires so that stats are correctly calculated - // - we add USER START entries for user sessions that cross the time period boundaries - // - we adjust start time of USER START entries to time interval start time - // - we adjust end time of USER END entries that occur beyond the time boundaries to time interval end time - - LogReader reader = new LogReader(simulationLogFile); - try { - LogLine line; - while ((line = reader.readLine()) != null) { - - if (line.type() == LogLine.Type.ASSERTION) { - output.println(line.rawLine()); - continue; - } - - if (line.type() == LogLine.Type.RUN) { - // adjust start time of simulation - line.setStart(start); - output.println(line.compose()); - continue; - } - - long startTime = line.startTime(); - long endTime = line.endTime(); - - - if (line.type() == LogLine.Type.USER_END) { - // if it is a USER_END we should adjust it to end time of the last and start time of the first REQUEST - // for that session within the interval - long[] times = sessionTimes.remove(line.userId()); - - // We ignore USER END entries that end before interval start, and those with start time after interval end - if (endTime >= start && startTime < end && startTime >= start) { - if (times == null) { - throw new IllegalStateException("There should be session info present for user: " + line.userId()); - } - line.setStart(times[0]); - // if USER END ends outside the time interval adjust it to end time of last request - if (line.endTime() >= end) { - line.setEnd(end); - //line.setEnd(times[1]); - ////line.end = times[1] > end ? times[1] : end; - } - - output.println(line.compose()); - } - - // make sure any cached start line is also cleaned - starts.remove(line.userId()); - - } else if (line.type() == LogLine.Type.USER_START) { - if (startTime < start) { - // if it is a USER START before the time period start, we should adjust it to start time of the first - // REQUEST for that session within the interval, so at this point we need to store the entry for later - starts.put(line.userId(), line); - } else if (startTime < end) { - // it's within the interval thus no adjustment needed - starts.put(line.userId(), line); - //output.println(line.rawLine()); - } - - // we ignore USER START entries beyond the time interval - - } else if (line.type() == LogLine.Type.REQUEST) { - - // REQUEST entry needs processing if it starts within the time interval or if it ends within time interval - // - if we process INLAYED - boolean process = (startTime >= start && startTime < end) || - (inlayedIncluded && endTime >= start && endTime < end); - - if (process) { - // store start time of first request entry, and end time of last request entry for session within the interval - long[] times = sessionTimes.get(line.userId()); - if (times == null) { - times = new long[]{line.startTime(), line.endTime()}; - sessionTimes.put(line.userId(), times); - - // if this is the first REQUEST within interval there may be a cached start line - LogLine startLine = starts.remove(line.userId()); - if (startLine != null) { - // fix startLine's start time if necessary and recompose it writing it to output - if (startLine.startTime() < start) { - startLine.setStart(start); - //startLine.setStart(line.startTime()); - ////startLine.start = line.startTime() < start ? line.startTime() : start; - output.println(startLine.compose()); - } else { - output.println(startLine.rawLine()); - } - times[0] = startLine.startTime(); - } - } else { - times[1] = line.endTime(); - } - - if (outlayedIncluded) { - // if entry is started within the time interval we copy it over regardless if ended outside - output.println(line.rawLine()); - } else if (endTime < end) { - // if entry is started within the time interval and ended within a time interval we copy it over - output.println(line.rawLine()); - } - - } - } - } - } finally { - reader.close(); - output.flush(); - } - } - - public void setLastRequestLabel(String lastRequestLabel) { - this.lastRequestLabel = lastRequestLabel; - } - - - public static void main(String [] args) { - if (args == null || args.length == 0) { - printHelp(); - System.exit(1); - } - - boolean debug = false; - boolean help = false; - String inFile = null; - boolean performStat = false; - boolean performExtract = false; - String outFile = null; - long startMillis = -1; - long endMillis = -1; - String lastRequestLabel = null; - - try { - // Gather and print out stats - int i = 0; - for (i = 0; i < args.length; i++) { - String arg = args[i]; - switch (arg) { - case "-X": - debug = true; - break; - case "-f": - case "--file": - if (i == args.length - 1) { - throw new RuntimeException("Argument " + arg + " requires a FILE"); - } - inFile = args[++i]; - break; - case "-s": - case "--stat": - performStat = true; - break; - case "-e": - case "--extract": - performExtract = true; - break; - case "-o": - case "--out": - if (i == args.length - 1) { - throw new RuntimeException("Argument " + arg + " requires a FILE"); - } - outFile = args[++i]; - break; - case "--start": - if (i == args.length - 1) { - throw new RuntimeException("Argument " + arg + " requires a timestamp in milliseconds"); - } - startMillis = Long.valueOf(args[++i]); - break; - case "--end": - if (i == args.length - 1) { - throw new RuntimeException("Argument " + arg + " requires a timestamp in milliseconds"); - } - endMillis = Long.valueOf(args[++i]); - break; - case "--lastRequest": - if (i == args.length - 1) { - throw new RuntimeException("Argument " + arg + " requires a LABEL"); - } - lastRequestLabel = args[++i]; - break; - case "--help": - help = true; - break; - default: - throw new RuntimeException("Unknown argument: " + arg); - } - } - - if (help) { - printHelp(); - System.exit(0); - } - - if (inFile == null) { - throw new RuntimeException("No path to simulation.log file specified. Use -f FILE, or --help to see more help."); - } - - LogProcessor proc = new LogProcessor(inFile); - proc.setLastRequestLabel(lastRequestLabel); - - if (performStat) { - Stats stats = proc.stats(); - // Print out results - System.out.println("Start time: " + stats.getStartTime()); - System.out.println("End time: " + stats.getLastUserEnd()); - System.out.println("Duration (ms): " + (stats.getLastUserEnd() - stats.getStartTime())); - System.out.println("Ramping up completes at: " + stats.getLastUserStart()); - System.out.println("Ramping down starts at: " + stats.getFirstUserEnd()); - System.out.println(); - - System.out.println("HTTP Requests:"); - for (Map.Entry> scenario: stats.requestNames().entrySet()) { - for (String name: scenario.getValue()) { - System.out.println(" [" + scenario.getKey() + "]\t" + name + "\t" + stats.requestCount(scenario.getKey(), name)); - } - } - System.out.println(); - - System.out.println("Times of completed iterations:"); - for (Map.Entry> ent: stats.getCompletedIterations().entrySet()) { - System.out.println(" " + ent.getKey() + ": " + ent.getValue()); - } - } - if (performExtract) { - if (outFile == null) { - throw new RuntimeException("No output file specified for extraction results. Use -o FILE, or --help to see more help."); - } - PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8")); - proc.copyPartialLog(out, startMillis, endMillis); - } - if (!performStat && !performExtract) { - throw new RuntimeException("Nothing to do. Use -s to analyze simulation log, -e to perform time based extraction, or --help to see more help."); - } - } catch (Throwable t) { - System.out.println(t.getMessage()); - if (debug) { - t.printStackTrace(); - } - System.exit(1); - } - } - - public static void printHelp() { - System.out.println("Usage: java org.keycloak.performance.log.LogProcessor ARGUMENTS"); - System.out.println(); - System.out.println("ARGUMENTS:"); - System.out.println(" -f, --file FILE Path to simulation.log file "); - System.out.println(" -s, --stat Perform analysis of the log and output some stats"); - System.out.println(" -e, --extract Copy a portion of the file PATH_TO_SIMULATION_LOG_FILE "); - System.out.println(" -o, --out FILE Output file that will contain extracted portion of the log"); - System.out.println(" --start MILLIS Timestamp at which to start extracting"); - System.out.println(" --end MILLIS Timestamp at which to stop extracting"); - System.out.println(" --lastRequest LABEL Label of last request in the iteration"); - System.out.println(" -X Output a detailed error when something goes wrong"); - System.out.println(); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogReader.java b/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogReader.java deleted file mode 100644 index e560a436c1..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/LogReader.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.keycloak.gatling.log; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.Charset; - -/** - * @author Marko Strukelj - */ -class LogReader { - - private BufferedReader reader; - - LogReader(File file) throws FileNotFoundException { - reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("utf-8"))); - } - - LogLine readLine() throws IOException { - String line = reader.readLine(); - return line != null ? new LogLine(line) : null; - } - - void close() throws IOException { - reader.close(); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/Stats.java b/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/Stats.java deleted file mode 100644 index 698f30d5cd..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/gatling/log/Stats.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.keycloak.gatling.log; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author Marko Strukelj - */ -class Stats { - private long startTime; - - // timestamp at which rampUp is complete - private long lastUserStart; - - // timestamp at which first user completed the simulation - private long firstUserEnd; - - // timestamp at which all users completed the simulation - private long lastUserEnd; - - // timestamps of iteration completions - when all users achieved last step of the scenario - for each scenario in the log file - private ConcurrentHashMap> completedIterations = new ConcurrentHashMap<>(); - - private LinkedHashMap> scenarioRequests = new LinkedHashMap<>(); - - private HashMap requestCounters = new HashMap<>(); - - public void setStartTime(long startTime) { - this.startTime = startTime; - } - - public void setLastUserStart(long lastUserStart) { - this.lastUserStart = lastUserStart; - } - - public void setFirstUserEnd(long firstUserEnd) { - this.firstUserEnd = firstUserEnd; - } - - public long firstUserEnd() { - return firstUserEnd; - } - - public void setLastUserEnd(long lastUserEnd) { - this.lastUserEnd = lastUserEnd; - } - - public long getStartTime() { - return startTime; - } - - public long getLastUserStart() { - return lastUserStart; - } - - public long getFirstUserEnd() { - return firstUserEnd; - } - - public long getLastUserEnd() { - return lastUserEnd; - } - - public Map> getCompletedIterations() { - return completedIterations; - } - - public void addIterationCompletedByAll(String scenario, long time) { - this.completedIterations.computeIfAbsent(scenario, k -> new ArrayList<>()) - .add(time); - } - - public void addRequest(String scenario, String request) { - Set requests = scenarioRequests.get(scenario); - if (requests == null) { - requests = new LinkedHashSet<>(); - scenarioRequests.put(scenario, requests); - } - requests.add(request); - incrementRequestCounter(scenario, request); - } - - public Map> requestNames() { - return scenarioRequests; - } - - private void incrementRequestCounter(String scenario, String requestName) { - String key = scenario + "." + requestName; - int count = requestCounters.getOrDefault(key, 0); - requestCounters.put(key, count + 1); - } - - public int requestCount(String scenario, String requestName) { - String key = scenario + "." + requestName; - return requestCounters.getOrDefault(key, 0); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/ClientInfo.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/ClientInfo.java deleted file mode 100644 index 9bfd5ffc7a..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/ClientInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.keycloak.performance; - -/** - * @author Marko Strukelj - */ -public class ClientInfo { - - public final int index; - public final String clientId; - public final String secret; - public final String appUrl; - - - public ClientInfo(int index, String clientId, String secret, String appUrl) { - this.index = index; - this.clientId = clientId; - this.secret = secret; - this.appUrl = appUrl; - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmConfig.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmConfig.java deleted file mode 100644 index 479330b923..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.keycloak.performance; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * @author Marko Strukelj - */ -public class RealmConfig { - public int accessTokenLifeSpan = 60; - public boolean registrationAllowed = true; - public List requiredCredentials = Collections.unmodifiableList(Arrays.asList("password")); -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationBuilder.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationBuilder.java deleted file mode 100644 index 009487930c..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationBuilder.java +++ /dev/null @@ -1,338 +0,0 @@ -package org.keycloak.performance; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonEncoding; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.keycloak.representations.idm.ClientRepresentation; -import org.keycloak.representations.idm.CredentialRepresentation; -import org.keycloak.representations.idm.UserRepresentation; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; - -import static org.keycloak.common.util.ObjectUtil.capitalize; - -/** - * @author Marko Strukelj - */ -public class RealmsConfigurationBuilder { - - private Random RANDOM = new Random(); - - private JsonGenerator g; - - private String file; - - public static final String EXPORT_FILENAME = "benchmark-realms.json"; - - public RealmsConfigurationBuilder(String filename) { - this.file = filename; - - try { - JsonFactory f = new JsonFactory(); - g = f.createGenerator(new File(file), JsonEncoding.UTF8); - - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - g.setCodec(mapper); - - } catch (Exception e) { - throw new RuntimeException("Failed to create realms export file", e); - } - } - - public void build() throws IOException { - // There are several realms - startRealms(); - for (int i = 0; i < TestConfig.numOfRealms; i++) { - RealmConfig realm = new RealmConfig(); - - String realmName = "realm_" + i; - startRealm(realmName, realm); - - // first create clients, - // then roles, and client roles - // create users at the end - // reason: each next depends on availability of the previous - - // each realm has some clients - startClients(); - for (int j = 0; j < TestConfig.clientsPerRealm; j++) { - ClientRepresentation client = new ClientRepresentation(); - - String clientId = computeClientId(realmName, j); - client.setClientId(clientId); - client.setEnabled(true); - - String baseDir = computeAppUrl(clientId); - client.setBaseUrl(baseDir); - - List uris = new ArrayList<>(); - uris.add(baseDir + "/*"); - - if (isClientConfidential(j)) { - client.setRedirectUris(uris); - client.setSecret(computeSecret(clientId)); - } else if (isClientBearerOnly(j)) { - client.setBearerOnly(true); - } else { - client.setPublicClient(true); - client.setRedirectUris(uris); - } - - addClient(client); - } - - completeClients(); - - // each realm has some realm roles - startRoles(); - startRealmRoles(); - for (int j = 0; j < TestConfig.realmRoles; j++) { - addRole("role_" + j + "_ofRealm_" + i); - } - completeRealmRoles(); - - // each client has some client roles - startClientRoles(); - for (int j = 0; j < TestConfig.clientsPerRealm; j++) { - addClientRoles("client_" + j + "_ofRealm_" + i); - } - completeClientRoles(); - - completeRoles(); - - // each realm so many users - startUsers(); - for (int j = 0; j < TestConfig.usersPerRealm; j++) { - UserRepresentation user = new UserRepresentation(); - user.setUsername(computeUsername(realmName, j)); - user.setEnabled(true); - user.setEmail(computeEmail(user.getUsername())); - user.setFirstName(computeFirstName(j)); - user.setLastName(computeLastName(realmName)); - - CredentialRepresentation creds = new CredentialRepresentation(); - creds.setType("password"); - creds.setValue(computePassword(user.getUsername())); - user.setCredentials(Arrays.asList(creds)); - - // add realm roles - // each user some random realm roles - Set realmRoles = new HashSet(); - while (realmRoles.size() < TestConfig.realmRolesPerUser) { - realmRoles.add("role_" + random(TestConfig.realmRoles) + "_ofRealm_" + i); - } - user.setRealmRoles(new ArrayList<>(realmRoles)); - - // add client roles - // each user some random client roles (random client + random role on that client) - Set clientRoles = new HashSet(); - while (clientRoles.size() < TestConfig.clientRolesPerUser) { - int client = random(TestConfig.clientsPerRealm); - int clientRole = random(TestConfig.clientRolesPerClient); - clientRoles.add("clientrole_" + clientRole + "_ofClient_" + client + "_ofRealm_" + i); - } - Map> clientRoleMappings = new HashMap<>(); - for (String item : clientRoles) { - int s = item.indexOf("_ofClient_"); - int b = s + "_ofClient_".length(); - int e = item.indexOf("_", b); - String key = "client_" + item.substring(b, e) + "_ofRealm_" + i; - List cliRoles = clientRoleMappings.get(key); - if (cliRoles == null) { - cliRoles = new ArrayList<>(); - clientRoleMappings.put(key, cliRoles); - } - cliRoles.add(item); - } - user.setClientRoles(clientRoleMappings); - addUser(user); - } - completeUsers(); - - completeRealm(); - } - completeRealms(); - g.close(); - } - - private void addClientRoles(String client) throws IOException { - g.writeArrayFieldStart(client); - for (int i = 0; i < TestConfig.clientRolesPerClient; i++) { - g.writeStartObject(); - String name = "clientrole_" + i + "_of" + capitalize(client); - g.writeStringField("name", name); - g.writeStringField("description", "Test realm role - " + name); - g.writeEndObject(); - } - g.writeEndArray(); - } - - private void addClient(ClientRepresentation client) throws IOException { - g.writeObject(client); - } - - private void startClients() throws IOException { - g.writeArrayFieldStart("clients"); - } - - private void completeClients() throws IOException { - g.writeEndArray(); - } - - private void startRealms() throws IOException { - g.writeStartArray(); - } - - private void completeRealms() throws IOException { - g.writeEndArray(); - } - - private int random(int max) { - return RANDOM.nextInt(max); - } - - private void startRealm(String realmName, RealmConfig conf) throws IOException { - g.writeStartObject(); - g.writeStringField("realm", realmName); - g.writeBooleanField("enabled", true); - g.writeNumberField("accessTokenLifespan", conf.accessTokenLifeSpan); - g.writeStringField("sslRequired", "none"); - g.writeBooleanField("registrationAllowed", conf.registrationAllowed); - g.writeStringField("passwordPolicy", "hashIterations(" + TestConfig.hashIterations + ")"); - - /* - if (conf.requiredCredentials != null) { - g.writeArrayFieldStart("requiredCredentials"); - //g.writeStartArray(); - for (String item: conf.requiredCredentials) { - g.writeString(item); - } - g.writeEndArray(); - } - */ - } - - private void completeRealm() throws IOException { - g.writeEndObject(); - } - - private void startUsers() throws IOException { - g.writeArrayFieldStart("users"); - } - - private void completeUsers() throws IOException { - g.writeEndArray(); - } - - private void addUser(UserRepresentation user) throws IOException { - g.writeObject(user); - } - - private void startRoles() throws IOException { - g.writeObjectFieldStart("roles"); - } - - private void startRealmRoles() throws IOException { - g.writeArrayFieldStart("realm"); - } - - private void startClientRoles() throws IOException { - g.writeObjectFieldStart("client"); - } - - private void completeClientRoles() throws IOException { - g.writeEndObject(); - } - - private void addRole(String role) throws IOException { - g.writeStartObject(); - g.writeStringField("name", role); - g.writeStringField("description", "Test realm role - " + role); - g.writeEndObject(); - } - - private void completeRealmRoles() throws IOException { - g.writeEndArray(); - } - - private void completeRoles() throws IOException { - g.writeEndObject(); - } - - - static boolean isClientConfidential(int index) { - // every third client starting with 0 - return index % 3 == 0; - } - - static boolean isClientBearerOnly(int index) { - // every third client starting with 1 - return index % 3 == 1; - } - - static boolean isClientPublic(int index) { - // every third client starting with 2 - return index % 3 == 2; - } - - static String computeClientId(String realm, int idx) { - return "client_" + idx + "_of" + capitalize(realm); - } - - static String computeAppUrl(String clientId) { - return "http://keycloak-test-" + clientId.toLowerCase(); - } - - static String computeSecret(String clientId) { - return "secretFor_" + clientId; - } - - static String computeUsername(String realm, int idx) { - return "user_" + idx + "_of" + capitalize(realm); - } - - static String computePassword(String username) { - return "passOfUser_" + username; - } - - static String computeFirstName(int userIdx) { - return "User" + userIdx; - } - - static String computeLastName(String realm) { - return "O'" + realm.replace("_", ""); - } - - static String computeEmail(String username) { - return username + "@example.com"; - } - - - - - public static void main(String[] args) throws IOException { - - File exportFile = new File(EXPORT_FILENAME); - - TestConfig.validateConfiguration(); - System.out.println("Generating test dataset with the following parameters: \n" + TestConfig.toStringDatasetProperties()); - - new RealmsConfigurationBuilder(exportFile.getAbsolutePath()).build(); - - System.out.println("Created " + exportFile.getAbsolutePath()); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationLoader.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationLoader.java deleted file mode 100644 index 2597899451..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/RealmsConfigurationLoader.java +++ /dev/null @@ -1,936 +0,0 @@ -package org.keycloak.performance; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.jboss.logging.Logger; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.representations.idm.ClientRepresentation; -import org.keycloak.representations.idm.CredentialRepresentation; -import org.keycloak.representations.idm.RealmRepresentation; -import org.keycloak.representations.idm.RoleRepresentation; -import org.keycloak.representations.idm.UserRepresentation; - -import javax.ws.rs.ClientErrorException; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.LinkedBlockingQueue; -import static org.keycloak.performance.RealmsConfigurationBuilder.EXPORT_FILENAME; - -import static org.keycloak.performance.TestConfig.ignoreConflicts; -import static org.keycloak.performance.TestConfig.numOfWorkers; -import static org.keycloak.performance.TestConfig.skipClientRoles; -import static org.keycloak.performance.TestConfig.skipRealmRoles; -import static org.keycloak.performance.TestConfig.startAtRealmIdx; -import static org.keycloak.performance.TestConfig.startAtUserIdx; - -/** - * # build - * mvn -f testsuite/performance/tests clean install - * - * # generate benchmark-realms.json file with generated test data - * mvn -f testsuite/performance/tests exec:java -Dexec.mainClass=org.keycloak.performance.RealmsConfigurationBuilder -DnumOfRealms=2 -DusersPerRealm=2 -DclientsPerRealm=2 -DrealmRoles=2 -DrealmRolesPerUser=2 -DclientRolesPerUser=2 -DclientRolesPerClient=2 - * - * # use benchmark-realms.json to load the data up to Keycloak Server listening on localhost:8080 - * mvn -f testsuite/performance/tests exec:java -Dexec.mainClass=org.keycloak.performance.RealmsConfigurationLoader -DnumOfWorkers=5 -Dexec.args=benchmark-realms.json > perf-output.txt - * - * @author Marko Strukelj - */ -public class RealmsConfigurationLoader { - - static Logger log = Logger.getLogger(RealmsConfigurationLoader.class.getName()); - - static final int ERROR_CHECK_INTERVAL = 10; - - static int currentRealm = 0; - static int currentUser = 0; - static int currentClient = 0; - - static boolean started; - - // multi-thread mechanics - static final BlockingQueue queue = new LinkedBlockingQueue<>(numOfWorkers); - static final ArrayList workers = new ArrayList<>(); - static final ConcurrentLinkedQueue pendingResult = new ConcurrentLinkedQueue<>(); - - // realm caches - we completely handle one realm before starting the next - static ConcurrentHashMap clientIdMap = new ConcurrentHashMap<>(); - static ConcurrentHashMap realmRoleIdMap = new ConcurrentHashMap<>(); - static ConcurrentHashMap> clientRoleIdMap = new ConcurrentHashMap<>(); - static boolean realmCreated; - - public static void main(String [] args) throws IOException { - println("Keycloak servers: "+TestConfig.serverUrisList); - - if (args.length == 0) { - args = new String[] {EXPORT_FILENAME}; - } - - if (args.length != 1) { - println("Usage: java " + RealmsConfigurationLoader.class.getName() + " "); - return; - } - - String file = args[0]; - println("Using file: " + new File(args[0]).getAbsolutePath()); - println("Number of workers (numOfWorkers): " + numOfWorkers); - println("Parameters: "); - println(" startAtRealmIdx: " + startAtRealmIdx); -// println(" startAtUserIdx: " + startAtUserIdx); - - JsonParser p = initParser(file); - - initWorkers(); - initProgress(); - - try { - - // read json file using JSON stream API - readRealms(p); - - } finally { - - completeWorkers(); - } - } - - private static void initProgress() { - Thread t = new Thread(() -> { - - for (;;) { - try { - Thread.sleep(60000); - println("At realm: " + currentRealm + ", Clients: " + currentClient + ", Users: " + currentUser); - } catch (InterruptedException e) { - return; - } - - } - - },"Progress Logger"); - t.setDaemon(true); - t.start(); - } - - private static void println(String s) { - System.out.println(s); - } - - private static void completeWorkers() { - - try { - // wait for all jobs to finish - completePending(); - - } finally { - // stop workers - for (Worker w : workers) { - w.exit = true; - try { - w.join(5000); - if (w.isAlive()) { - println("Worker thread failed to stop: "); - dumpThread(w); - } - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted"); - } - } - } - } - - private static void readRealms(JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - - while (t != JsonToken.END_OBJECT && t != JsonToken.END_ARRAY) { - if (t != JsonToken.START_ARRAY) { - readRealm(p); - currentRealm += 1; - } - t = p.nextToken(); - } - } - - private static void initWorkers() { - // configure job queue and worker threads - for (int i = 0; i < numOfWorkers; i++) { - workers.add(new Worker()); - } - } - - private static JsonParser initParser(String file) { - JsonParser p; - try { - JsonFactory f = new JsonFactory(); - p = f.createParser(new File(file)); - - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - p.setCodec(mapper); - - } catch (Exception e) { - throw new RuntimeException("Failed to parse file " + new File(file).getAbsolutePath(), e); - } - return p; - } - - private static void dumpThread(Worker w) { - StringBuilder b = new StringBuilder(); - for (StackTraceElement e: w.getStackTrace()) { - b.append(e.toString()).append("\n"); - } - println(b.toString()); - } - - private static void readRealm(JsonParser p) throws IOException { - - // as soon as we encounter users, roles, clients we create a CreateRealmJob - // TODO: if after that point in a realm we encounter realm attribute, we report a warning but continue - - boolean skip = false; - try { - RealmRepresentation r = new RealmRepresentation(); - JsonToken t = p.nextToken(); - outer: - while (t != JsonToken.END_OBJECT && !skip) { - - //System.out.println(t + ", name: " + p.getCurrentName() + ", text: '" + p.getText() + "', value: " + p.getValueAsString()); - - switch (p.getCurrentName()) { - case "realm": - r.setRealm(getStringValue(p)); - skip = !started && realmSkipped(r.getRealm()) ; - if (skip) { - break outer; - } - break; - case "enabled": - r.setEnabled(getBooleanValue(p)); - break; - case "accessTokenLifespan": - r.setAccessCodeLifespan(getIntegerValue(p)); - break; - case "registrationAllowed": - r.setRegistrationAllowed(getBooleanValue(p)); - break; - case "passwordPolicy": - r.setPasswordPolicy(getStringValue(p)); - break; - case "sslRequired": - r.setSslRequired(getStringValue(p)); - break; - case "users": - ensureRealm(r); - if (seekToStart()) { - enqueueFetchRealmRoles(r); - completePending(); - } - readUsers(r, p); - break; - case "roles": - ensureRealm(r); - readRoles(r, p); - break; - case "clients": - ensureRealm(r); - readClients(r, p); - completePending(); - if (seekToStart()) { - enqueueFetchMissingClients(r); - completePending(); - } - break; - default: { - // if we don't understand the field we ignore it - but report that - log.warn("Realm attribute ignored: " + p.getCurrentName()); - consumeAttribute(p); - continue; // skip p.nextToken() at end of loop - consumeAttribute() already did it - } - } - - t = p.nextToken(); - } - - if (skip) { - log.info("Realm skipped: " + r.getRealm()); - consumeParent(p); - } - - } finally { - // we wait for realm to complete - completePending(); - - // reset realm specific cache - realmCreated = false; - clientIdMap.clear(); - realmRoleIdMap.clear(); - clientRoleIdMap.clear(); - } - } - - private static void consumeParent(JsonParser p) throws IOException { - while (p.currentToken() != JsonToken.END_OBJECT) { - consumeAttribute(p); - } - } - - private static boolean seekToStart() { - return startAtRealmIdx > 0 || startAtUserIdx > 0; - } - - private static boolean seeking() { - return currentRealm < startAtRealmIdx || currentUser < startAtUserIdx; - } - - private static boolean realmSkipped(String realm) { - int pos = realm.lastIndexOf("_"); - int idx = Integer.parseInt(realm.substring(pos+1)); - return idx < startAtRealmIdx; - } - - private static boolean userSkipped(String username) { - int pos = username.indexOf("_"); - int end = username.indexOf("_", pos+1); - int idx = Integer.parseInt(username.substring(pos+1, end)); - return idx < startAtUserIdx; - } - - private static void ensureRealm(RealmRepresentation r) { - if (!realmCreated) { - createRealm(r); - realmCreated = true; - } - } - - private static void createRealm(RealmRepresentation r) { - try { - started = true; - queue.put(new CreateRealmJob(r)); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted", e); - } - - completePending(); - } - - private static void enqueueCreateUser(RealmRepresentation r, UserRepresentation u) { - try { - started = true; - queue.put(new CreateUserJob(r, u)); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted", e); - } - } - - private static void enqueueCreateRealmRole(RealmRepresentation r, RoleRepresentation role) { - try { - started = true; - queue.put(new CreateRealmRoleJob(r, role)); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted", e); - } - } - - private static void enqueueCreateClientRole(RealmRepresentation r, RoleRepresentation role, String client) { - try { - started = true; - queue.put(new CreateClientRoleJob(r, role, client)); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted", e); - } - } - - private static void enqueueCreateClient(RealmRepresentation r, ClientRepresentation client) { - try { - started = true; - queue.put(new CreateClientJob(r, client)); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted", e); - } - } - - private static void enqueueFetchMissingClients(RealmRepresentation r) { - try { - started = true; - queue.put(new FetchMissingClientsJob(r)); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted", e); - } - } - - private static void enqueueFetchRealmRoles(RealmRepresentation r) { - try { - started = true; - queue.put(new FetchRealmRolesJob(r)); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted", e); - } - } - - private static void waitForAwhile() { - waitForAwhile(100, "Interrupted"); - } - - private static void waitForAwhile(int millis) { - waitForAwhile(millis, "Interrupted"); - } - - private static void waitForAwhile(int millis, String interruptMessage) { - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - throw new RuntimeException(interruptMessage); - } - } - - private static void readUsers(RealmRepresentation r, JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - if (t != JsonToken.START_ARRAY) { - throw new RuntimeException("Error reading field 'users'. Expected array of users [" + t + "]"); - } - - t = p.nextToken(); - while (t == JsonToken.START_OBJECT) { - UserRepresentation u = p.readValueAs(UserRepresentation.class); - if (!started && userSkipped(u.getUsername())) { - log.info("User skipped: " + u.getUsername()); - } else { - enqueueCreateUser(r, u); - } - t = p.nextToken(); - currentUser += 1; - - // every some users check to see pending errors - // in order to short-circuit if any errors have occurred - if (currentUser % ERROR_CHECK_INTERVAL == 0) { - checkPendingErrors(u.getUsername()); - } - } - } - - private static void readRoles(RealmRepresentation r, JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - if (t != JsonToken.START_OBJECT) { - throw new RuntimeException("Error reading field 'roles'. Expected start of object [" + t + "]"); - } - - t = p.nextToken(); - if (t != JsonToken.FIELD_NAME) { - throw new RuntimeException("Error reading field 'roles'. Expected field 'realm' or 'client' [" + t + "]"); - } - - while (t != JsonToken.END_OBJECT) { - switch (p.getCurrentName()) { - case "realm": - readRealmRoles(r, p); - break; - case "client": - waitForClientsCompleted(); - readClientRoles(r, p); - break; - default: - throw new RuntimeException("Unexpected field in roles: " + p.getCurrentName()); - } - t = p.nextToken(); - } - } - - private static void waitForClientsCompleted() { - completePending(); - } - - private static void readClientRoles(RealmRepresentation r, JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - - if (t != JsonToken.START_OBJECT) { - throw new RuntimeException("Expected start_of_object on 'roles/client' [" + t + "]"); - } - - t = p.nextToken(); - - int count = 0; - while (t == JsonToken.FIELD_NAME) { - String client = p.getCurrentName(); - - t = p.nextToken(); - if (t != JsonToken.START_ARRAY) { - throw new RuntimeException("Expected start_of_array on 'roles/client/" + client + " [" + t + "]"); - } - - t = p.nextToken(); - while (t != JsonToken.END_ARRAY) { - RoleRepresentation u = p.readValueAs(RoleRepresentation.class); - if (!seeking() || !skipClientRoles) { - enqueueCreateClientRole(r, u, client); - } - t = p.nextToken(); - count += 1; - - // every some roles check to see pending errors - // in order to short-circuit if any errors have occurred - if (count % ERROR_CHECK_INTERVAL == 0) { - checkPendingErrors(u.getName()); - } - } - t = p.nextToken(); - } - } - - private static void readRealmRoles(RealmRepresentation r, JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - - if (t != JsonToken.START_ARRAY) { - throw new RuntimeException("Expected start_of_array on 'roles/realm' [" + t + "]"); - } - - t = p.nextToken(); - - int count = 0; - while (t == JsonToken.START_OBJECT) { - RoleRepresentation u = p.readValueAs(RoleRepresentation.class); - if (!seeking() || !skipRealmRoles) { - enqueueCreateRealmRole(r, u); - } - t = p.nextToken(); - count += 1; - - // every some roles check to see pending errors - // in order to short-circuit if any errors have occurred - if (count % ERROR_CHECK_INTERVAL == 0) { - checkPendingErrors(u.getName()); - } - } - } - - private static void readClients(RealmRepresentation r, JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - if (t != JsonToken.START_ARRAY) { - throw new RuntimeException("Error reading field 'clients'. Expected array of clients [" + t + "]"); - } - - t = p.nextToken(); - while (t == JsonToken.START_OBJECT) { - ClientRepresentation u = p.readValueAs(ClientRepresentation.class); - enqueueCreateClient(r, u); - t = p.nextToken(); - currentClient += 1; - - // every some users check to see pending errors - if (currentClient % ERROR_CHECK_INTERVAL == 0) { - checkPendingErrors(u.getClientId()); - } - } - } - - private static void checkPendingErrors(String label) { - // now wait for job to appear - PendingResult next = pendingResult.peek(); - while (next == null && queue.size() > 0) { - waitForAwhile(); - next = pendingResult.peek(); - } - - // now process then - Iterator it = pendingResult.iterator(); - while (it.hasNext()) { - next = it.next(); - if (next.isDone() && !next.isCompletedExceptionally()) { - it.remove(); - } else if (next.isCompletedExceptionally()) { - try { - next.get(); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted"); - } catch (ExecutionException e) { - throw new RuntimeException("Execution failed in the vicinity of " + label + ": ", e.getCause()); - } - } - } - } - - private static void completePending() { - - // wait for queue to empty up - while (queue.size() > 0) { - waitForAwhile(); - } - - PendingResult next; - while ((next = pendingResult.poll()) != null) { - try { - next.get(); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted"); - } catch (ExecutionException e) { - throw new RuntimeException("Execution failed", e.getCause()); - } - } - } - - private static Integer getIntegerValue(JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - if (t != JsonToken.VALUE_NUMBER_INT) { - throw new RuntimeException("Error while reading field '" + p.getCurrentName() + "'. Expected integer value [" + t + "]"); - } - return p.getValueAsInt(); - } - - private static void consumeAttribute(JsonParser p) throws IOException { - JsonToken t = p.currentToken(); - if (t == JsonToken.START_OBJECT || t == JsonToken.START_ARRAY) { - p.skipChildren(); - p.nextToken(); - } else if (t == JsonToken.FIELD_NAME) { - p.nextToken(); - consumeAttribute(p); - } else { - p.nextToken(); - } - } - - private static Boolean getBooleanValue(JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - if (t != JsonToken.VALUE_TRUE && t != JsonToken.VALUE_FALSE) { - throw new RuntimeException("Error while reading field '" + p.getCurrentName() + "'. Expected boolean value [" + t + "]"); - } - return p.getValueAsBoolean(); - } - - private static String getStringValue(JsonParser p) throws IOException { - JsonToken t = p.nextToken(); - if (t != JsonToken.VALUE_STRING) { - throw new RuntimeException("Error while reading field '" + p.getCurrentName() + "'. Expected string value [" + t + "]"); - } - return p.getText(); - } - - static class Worker extends Thread { - - volatile boolean exit = false; - - Worker() { - start(); - } - - public void run() { - while (!exit) { - Job r = queue.poll(); - if (r == null) { - waitForAwhile(50, "Worker thread " + this.getName() + " interrupted"); - continue; - } - PendingResult pending = new PendingResult(r); - pendingResult.add(pending); - try { - r.run(); - pending.complete(true); - } catch (Throwable t) { - pending.completeExceptionally(t); - } - } - } - } - - static class FetchMissingClientsJob extends AdminJob { - - private RealmRepresentation realm; - - FetchMissingClientsJob(RealmRepresentation r) { - realm = r; - } - - @Override - public void run() { - List clients = admin().realms().realm(realm.getRealm()).clients().findAll(); - for (ClientRepresentation c: clients) { - clientIdMap.put(c.getClientId(), c.getId()); - } - } - } - - static class FetchRealmRolesJob extends AdminJob { - - private RealmRepresentation realm; - - FetchRealmRolesJob(RealmRepresentation r) { - realm = r; - } - - @Override - public void run() { - List roles = admin().realms().realm(realm.getRealm()).roles().list(); - for (RoleRepresentation r: roles) { - realmRoleIdMap.put(r.getName(), r.getId()); - } - } - } - - static class CreateRealmJob extends AdminJob { - - private RealmRepresentation realm; - - CreateRealmJob(RealmRepresentation r) { - this.realm = r; - } - - @Override - public void run() { - try { - admin().realms().create(realm); - } catch (ClientErrorException e) { - if (e.getMessage().endsWith("409 Conflict") && ignoreConflicts) { - log.warn("Ignoring conflict when creating a realm: " + realm.getRealm()); - return; - } - throw e; - } - } - } - - static class CreateUserJob extends AdminJob { - - private RealmRepresentation realm; - private UserRepresentation user; - - CreateUserJob(RealmRepresentation r, UserRepresentation u) { - this.realm = r; - this.user = u; - } - - @Override - public void run() { - Response response = admin().realms().realm(realm.getRealm()).users().create(user); - response.close(); - - if (response.getStatus() == 409 && ignoreConflicts) { - log.warn("Ignoring conflict when creating a user: " + user.getUsername()); - user.setId(admin().realms().realm(realm.getRealm()).users().search(user.getUsername()).get(0).getId()); - } else if (response.getStatus() == 201) { - user.setId(extractIdFromResponse(response)); - } else { - throw new RuntimeException("Failed to create user with status: " + response.getStatusInfo()); - } - - String userId = user.getId(); - - List creds = user.getCredentials(); - for (CredentialRepresentation cred: creds) { - admin().realms().realm(realm.getRealm()).users().get(userId).resetPassword(cred); - } - - List realmRoles = user.getRealmRoles(); - if (realmRoles != null && !realmRoles.isEmpty()) { - List roles = convertRealmRoleNamesToRepresentation(user.getRealmRoles()); - if (!roles.isEmpty()) { - admin().realms().realm(realm.getRealm()).users().get(userId).roles().realmLevel().add(roles); - } - } - - Map> clientRoles = user.getClientRoles(); - if (clientRoles != null && !clientRoles.isEmpty()) { - for (String clientId: clientRoles.keySet()) { - List roleNames = clientRoles.get(clientId); - if (roleNames != null && !roleNames.isEmpty()) { - List reps = convertClientRoleNamesToRepresentation(clientId, roleNames); - if (!reps.isEmpty()) { - String idOfClient = clientIdMap.get(clientId); - if (idOfClient == null) { - throw new RuntimeException("No client created for clientId: " + clientId); - } - admin().realms().realm(realm.getRealm()).users().get(userId).roles().clientLevel(idOfClient).add(reps); - } - } - } - } - } - - private List convertClientRoleNamesToRepresentation(String clientId, List roles) { - LinkedList result = new LinkedList<>(); - Map roleIdMap = clientRoleIdMap.get(clientId); - if (roleIdMap == null || roleIdMap.isEmpty()) { - throw new RuntimeException("No client roles created for clientId: " + clientId); - } - - for (String role: roles) { - RoleRepresentation r = new RoleRepresentation(); - String id = roleIdMap.get(role); - if (id == null) { - throw new RuntimeException("No client role created on client '" + clientId + "' for name: " + role); - } - r.setId(id); - r.setName(role); - result.add(r); - } - return result; - } - - private List convertRealmRoleNamesToRepresentation(List roles) { - LinkedList result = new LinkedList<>(); - for (String role: roles) { - RoleRepresentation r = new RoleRepresentation(); - String id = realmRoleIdMap.get(role); - if (id == null) { - throw new RuntimeException("No realm role created for name: " + role); - } - r.setId(id); - r.setName(role); - result.add(r); - } - return result; - } - } - - static class CreateRealmRoleJob extends AdminJob { - - private RealmRepresentation realm; - private RoleRepresentation role; - - CreateRealmRoleJob(RealmRepresentation r, RoleRepresentation role) { - this.realm = r; - this.role = role; - } - - @Override - public void run() { - try { - admin().realms().realm(realm.getRealm()).roles().create(role); - } catch (ClientErrorException e) { - if (e.getMessage().endsWith("409 Conflict") && ignoreConflicts) { - log.warn("Ignoring conflict when creating a realm role: " + role.getName()); - role = admin().realms().realm(realm.getRealm()).roles().get(role.getName()).toRepresentation(); - } else { - throw e; - } - } - // we need the id but it's not returned by REST API - we have to perform a get on the created role and save the returned id - RoleRepresentation rr = admin().realms().realm(realm.getRealm()).roles().get(role.getName()).toRepresentation(); - realmRoleIdMap.put(rr.getName(), rr.getId()); - } - } - - - static class CreateClientRoleJob extends AdminJob { - - private RealmRepresentation realm; - private RoleRepresentation role; - private String clientId; - - CreateClientRoleJob(RealmRepresentation r, RoleRepresentation role, String clientId) { - this.realm = r; - this.role = role; - this.clientId = clientId; - } - - @Override - public void run() { - String id = clientIdMap.get(clientId); - if (id == null) { - throw new RuntimeException("No client created for clientId: " + clientId); - } - - try { - admin().realms().realm(realm.getRealm()).clients().get(id).roles().create(role); - - } catch (ClientErrorException e) { - if (e.getMessage().endsWith("409 Conflict") && ignoreConflicts) { - log.warn("Ignoring conflict when creating a client role: " + role.getName()); - role = admin().realms().realm(realm.getRealm()).clients().get(id).roles().get(role.getName()).toRepresentation(); - } else { - throw e; - } - } - - // we need the id but it's not returned by REST API - we have to perform a get on the created role and save the returned id - RoleRepresentation rr = admin().realms().realm(realm.getRealm()).clients().get(id).roles().get(role.getName()).toRepresentation(); - - Map roleIdMap = clientRoleIdMap.get(clientId); - if (roleIdMap == null) { - roleIdMap = clientRoleIdMap.computeIfAbsent(clientId, (k) -> new ConcurrentHashMap<>()); - } - - roleIdMap.put(rr.getName(), rr.getId()); - } - - } - - static class CreateClientJob extends AdminJob { - - - private ClientRepresentation client; - private RealmRepresentation realm; - - public CreateClientJob(RealmRepresentation r, ClientRepresentation client) { - this.realm = r; - this.client = client; - } - - @Override - public void run() { - Response response = admin().realms().realm(realm.getRealm()).clients().create(client); - response.close(); - - if (response.getStatus() == 409 && ignoreConflicts) { - log.warn("Ignoring conflict when creating a client: " + client.getClientId()); - client = admin().realms().realm(realm.getRealm()).clients().findByClientId(client.getClientId()).get(0); - } else if (response.getStatus() == 201) { - client.setId(extractIdFromResponse(response)); - } else { - throw new RuntimeException("Failed to create client with status: " + response.getStatusInfo().getReasonPhrase()); - } - clientIdMap.put(client.getClientId(), client.getId()); - } - } - - - static String extractIdFromResponse(Response response) { - String location = response.getHeaderString("Location"); - if (location == null) - return null; - - int last = location.lastIndexOf("/"); - if (last == -1) { - return null; - } - String id = location.substring(last + 1); - if (id == null || "".equals(id)) { - throw new RuntimeException("Failed to extract 'id' of created resource"); - } - - return id; - } - - static abstract class AdminJob extends Job { - - static Keycloak admin = Keycloak.getInstance(TestConfig.serverUrisList.get(0), TestConfig.authRealm, TestConfig.authUser, TestConfig.authPassword, TestConfig.authClient); - - static Keycloak admin() { - return admin; - } - } - - static abstract class Job implements Runnable { - - } - - static class PendingResult extends CompletableFuture { - - Job job; - - PendingResult(Job job) { - this.job = job; - } - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/TestConfig.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/TestConfig.java deleted file mode 100644 index 174e3beb31..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/TestConfig.java +++ /dev/null @@ -1,334 +0,0 @@ -package org.keycloak.performance; - -import java.text.SimpleDateFormat; -import org.keycloak.performance.iteration.FilteredIterator; -import org.keycloak.performance.iteration.LoopingIterator; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ThreadLocalRandom; -import org.apache.commons.configuration.CombinedConfiguration; -import org.jboss.logging.Logger; - -import static org.keycloak.performance.RealmsConfigurationBuilder.computeAppUrl; -import static org.keycloak.performance.RealmsConfigurationBuilder.computeClientId; -import static org.keycloak.performance.RealmsConfigurationBuilder.computeEmail; -import static org.keycloak.performance.RealmsConfigurationBuilder.computeFirstName; -import static org.keycloak.performance.RealmsConfigurationBuilder.computeLastName; -import static org.keycloak.performance.RealmsConfigurationBuilder.computePassword; -import static org.keycloak.performance.RealmsConfigurationBuilder.computeSecret; -import static org.keycloak.performance.RealmsConfigurationBuilder.computeUsername; -import org.keycloak.performance.util.CombinedConfigurationNoInterpolation; - -/** - * @author Marko Strukelj - * @author Tomas Kyjovsky - */ -public class TestConfig { - - private static final Logger LOGGER = Logger.getLogger(TestConfig.class); - - public static final CombinedConfiguration CONFIG; - - static { - CONFIG = new CombinedConfigurationNoInterpolation(); - } - - // - // Settings used by RealmsConfigurationBuilder only - when generating the DATASET - // - public static final int hashIterations = Integer.getInteger("hashIterations", 27500); - - // - // Settings used by RealmsConfigurationLoader only - when loading data into Keycloak - // - public static final int numOfWorkers = Integer.getInteger("numOfWorkers", 1); - public static final int startAtRealmIdx = Integer.getInteger("startAtRealmIdx", 0); - public static final int startAtUserIdx = 0; // doesn't work properly, will be removed later //Integer.getInteger("startAtUserIdx", 0); - public static final boolean ignoreConflicts = "true".equals(System.getProperty("ignoreConflicts", "false")); - public static final boolean skipRealmRoles = "true".equals(System.getProperty("skipRealmRoles", "false")); - public static final boolean skipClientRoles = "true".equals(System.getProperty("skipClientRoles", "false")); - - // - // Settings used by RealmConfigurationLoader to connect to Admin REST API - // - public static final String authRealm = System.getProperty("authRealm", "master"); - public static final String authUser = System.getProperty("authUser", "admin"); - public static final String authPassword = System.getProperty("authPassword", "admin"); - public static final String authClient = System.getProperty("authClient", "admin-cli"); - - // - // Settings used by RealmsConfigurationBuilder to generate the DATASET and by tests to work within constraints of the DATASET - // - public static final int numOfRealms = Integer.getInteger("numOfRealms", 1); - public static final int usersPerRealm = Integer.getInteger("usersPerRealm", 2); - public static final int clientsPerRealm = Integer.getInteger("clientsPerRealm", 2); - public static final int realmRoles = Integer.getInteger("realmRoles", 2); - public static final int realmRolesPerUser = Integer.getInteger("realmRolesPerUser", 2); - public static final int clientRolesPerUser = Integer.getInteger("clientRolesPerUser", 2); - public static final int clientRolesPerClient = Integer.getInteger("clientRolesPerClient", 2); - - // sequential vs random DATASET iteration - public static final int sequentialRealmsFrom = Integer.getInteger("sequentialRealmsFrom", -1); // -1 means random iteration - public static final int sequentialUsersFrom = Integer.getInteger("sequentialUsersFrom", -1); // -1 means random iteration - public static final boolean sequentialRealms = sequentialRealmsFrom >= 0; - public static final boolean sequentialUsers = sequentialUsersFrom >= 0; - - // - // Settings used by tests to control common test parameters - // - public static final double usersPerSec = Double.valueOf(System.getProperty("usersPerSec", "1")); - public static final int rampUpPeriod = Integer.getInteger("rampUpPeriod", 0); - public static final int warmUpPeriod = Integer.getInteger("warmUpPeriod", 0); - public static final int measurementPeriod = Integer.getInteger("measurementPeriod", 30); - public static final boolean filterResults = Boolean.getBoolean("filterResults"); // filter out results outside of measurementPeriod - public static final int userThinkTime = Integer.getInteger("userThinkTime", 0); - public static final int refreshTokenPeriod = Integer.getInteger("refreshTokenPeriod", 0); - public static final double logoutPct = Double.valueOf(System.getProperty("logoutPct", "100")); - - // Computed timestamps - public static final long simulationStartTime = System.currentTimeMillis(); - public static final long warmUpStartTime = simulationStartTime + rampUpPeriod * 1000; - public static final long measurementStartTime = warmUpStartTime + warmUpPeriod * 1000; - public static final long measurementEndTime = measurementStartTime + measurementPeriod * 1000; - - // - // Settings used by OIDCLoginAndLogoutSimulation to control behavior specific to OIDCLoginAndLogoutSimulation - // - public static final int badLoginAttempts = Integer.getInteger("badLoginAttempts", 0); - public static final int refreshTokenCount = Integer.getInteger("refreshTokenCount", 0); - - public static final String serverUris; - public static final List serverUrisList; - - // Round-robin infinite ENTITY_ITERATOR that directs each next session to the next server - public static final Iterator serverUrisIterator; - - static { - // if KEYCLOAK_SERVER_URIS env var is set, and system property serverUris is not set - String serversProp = System.getProperty("keycloak.server.uris"); - if (serversProp == null) { - String serversEnv = System.getenv("KEYCLOAK_SERVERS"); - serverUris = serversEnv != null ? serversEnv : "http://localhost:8080/auth"; - } else { - serverUris = serversProp; - } - - // initialize serverUrisList and serverUrisIterator - serverUrisList = Arrays.asList(serverUris.split(" ")); - serverUrisIterator = new LoopingIterator<>(serverUrisList); - } - - // assertion properties - public static final int maxFailedRequests = Integer.getInteger("maxFailedRequests", 0); - public static final int maxMeanReponseTime = Integer.getInteger("maxMeanReponseTime", 300); - - // Users iterators by realm - private static final ConcurrentMap> usersIteratorMap = new ConcurrentHashMap<>(); - - // Clients iterators by realm - private static final ConcurrentMap> clientsIteratorMap = new ConcurrentHashMap<>(); - - public static Iterator getRealmsIterator() { - return sequentialRealms ? sequentialRealmsIterator() : randomRealmsIterator(); - } - - public static Iterator getUsersIterator(String realm) { - return usersIteratorMap.computeIfAbsent(realm, (k) -> sequentialUsers ? sequentialUsersIterator(realm) : randomUsersIterator(realm)); - } - - public static Iterator getClientsIterator(String realm) { - return clientsIteratorMap.computeIfAbsent(realm, (k) -> randomClientsIterator(realm)); - } - - public static Iterator getConfidentialClientsIterator(String realm) { - Iterator clientsIt = getClientsIterator(realm); - return new FilteredIterator<>(clientsIt, (v) -> RealmsConfigurationBuilder.isClientConfidential(v.index)); - } - - public static String toStringCommonTestParameters() { - return String.format( - " usersPerSec: %s\n" - + " rampUpPeriod: %s\n" - + " warmUpPeriod: %s\n" - + " measurementPeriod: %s\n" - + " filterResults: %s\n" - + " userThinkTime: %s\n" - + " refreshTokenPeriod: %s\n" - + " logoutPct: %s", - usersPerSec, rampUpPeriod, warmUpPeriod, measurementPeriod, filterResults, userThinkTime, refreshTokenPeriod, logoutPct); - } - - public static SimpleDateFormat SIMPLE_TIME = new SimpleDateFormat("HH:mm:ss"); - - public static String toStringTimestamps() { - return String.format(" simulationStartTime: %s\n" - + " warmUpStartTime: %s\n" - + " measurementStartTime: %s\n" - + " measurementEndTime: %s", - SIMPLE_TIME.format(simulationStartTime), - SIMPLE_TIME.format(warmUpStartTime), - SIMPLE_TIME.format(measurementStartTime), - SIMPLE_TIME.format(measurementEndTime)); - } - - public static String toStringDatasetProperties() { - return String.format( - " numOfRealms: %s%s\n" - + " usersPerRealm: %s%s\n" - + " clientsPerRealm: %s\n" - + " realmRoles: %s\n" - + " realmRolesPerUser: %s\n" - + " clientRolesPerUser: %s\n" - + " clientRolesPerClient: %s\n" - + " hashIterations: %s", - numOfRealms, sequentialRealms ? ", sequential iteration starting from " + sequentialRealmsFrom : "", - usersPerRealm, sequentialUsers ? ", sequential iteration starting from " + sequentialUsersFrom : "", - clientsPerRealm, - realmRoles, - realmRolesPerUser, - clientRolesPerUser, - clientRolesPerClient, - hashIterations); - } - - public static String toStringAssertionProperties() { - return String.format(" maxFailedRequests: %s\n" - + " maxMeanReponseTime: %s", - maxFailedRequests, - maxMeanReponseTime); - } - - public static Iterator sequentialUsersIterator(final String realm) { - - return new Iterator() { - - int idx = sequentialUsers ? sequentialUsersFrom : 0; - - @Override - public boolean hasNext() { - return true; - } - - @Override - public synchronized UserInfo next() { - if (idx >= usersPerRealm) { - idx = 0; - } - - String user = computeUsername(realm, idx); - String firstName = computeFirstName(idx); - idx += 1; - return new UserInfo(user, - computePassword(user), - firstName, - computeLastName(realm), - computeEmail(user) - ); - } - }; - } - - public static Iterator randomUsersIterator(final String realm) { - - return new Iterator() { - - @Override - public boolean hasNext() { - return true; - } - - @Override - public UserInfo next() { - int idx = ThreadLocalRandom.current().nextInt(usersPerRealm); - String user = computeUsername(realm, idx); - return new UserInfo(user, - computePassword(user), - computeFirstName(idx), - computeLastName(realm), - computeEmail(user) - ); - } - }; - } - - public static Iterator randomClientsIterator(final String realm) { - - return new Iterator() { - - @Override - public boolean hasNext() { - return true; - } - - @Override - public ClientInfo next() { - int idx = ThreadLocalRandom.current().nextInt(clientsPerRealm); - String clientId = computeClientId(realm, idx); - String appUrl = computeAppUrl(clientId); - return new ClientInfo(idx, clientId, computeSecret(clientId), appUrl); - } - }; - } - - public static Iterator sequentialRealmsIterator() { - - return new Iterator() { - - int idx = sequentialRealms ? sequentialRealmsFrom : 0; - - @Override - public boolean hasNext() { - return true; - } - - @Override - public String next() { - if (idx >= numOfRealms) { - idx = 0; - } - String realm = "realm_" + idx; - idx += 1; - return realm; - } - }; - } - - public static Iterator randomRealmsIterator() { - - return new Iterator() { - - @Override - public boolean hasNext() { - return true; - } - - @Override - public String next() { - return "realm_" + ThreadLocalRandom.current().nextInt(numOfRealms); - } - }; - } - - public static void validateConfiguration() { - if (realmRolesPerUser > realmRoles) { - throw new RuntimeException("Can't have more realmRolesPerUser than there are realmRoles"); - } - if (clientRolesPerUser > clientsPerRealm * clientRolesPerClient) { - throw new RuntimeException("Can't have more clientRolesPerUser than there are all client roles (clientsPerRealm * clientRolesPerClient)"); - } - if (sequentialRealmsFrom < -1 || sequentialRealmsFrom >= numOfRealms) { - throw new RuntimeException("The folowing condition must be met: (-1 <= sequentialRealmsFrom < numOfRealms)."); - } - if (sequentialUsersFrom < -1 || sequentialUsersFrom >= usersPerRealm) { - throw new RuntimeException("The folowing condition must be met: (-1 <= sequentialUsersFrom < usersPerRealm)."); - } - if (logoutPct < 0 || logoutPct > 100) { - throw new RuntimeException("The `logoutPct` needs to be between 0 and 100."); - } - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/UserInfo.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/UserInfo.java deleted file mode 100644 index 9538bd5d42..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/UserInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.keycloak.performance; - -/** - * @author Marko Strukelj - */ -public class UserInfo { - - public final String username; - public final String password; - public final String firstName; - public final String lastName; - public final String email; - - UserInfo(String username, String password, String firstName, String lastName, String email) { - this.username = username; - this.password = password; - this.firstName = firstName; - this.lastName = lastName; - this.email = email; - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Creatable.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Creatable.java deleted file mode 100644 index dfa9b53439..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Creatable.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.keycloak.performance.dataset; - -import java.io.IOException; -import javax.ws.rs.ClientErrorException; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import static org.keycloak.admin.client.CreatedResponseUtil.getCreatedId; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.performance.templates.EntityTemplate; - -/** - * - * @author tkyjovsk - */ -public interface Creatable extends Updatable { - - public static final String HTTP_409_SUFFIX = "409 Conflict"; - - public REP read(Keycloak adminClient); - - public default String getIdAndReadIfNull(Keycloak adminClient) { - if (getId() == null) { - logger().debug("id of entity " + this + " was null, reading from server"); - readAndSetId(adminClient); - } - return getId(); - } - - public default void readAndSetId(Keycloak adminClient) { - setId(getIdFromRepresentation(read(adminClient))); - } - - public Response create(Keycloak adminClient); - - public default boolean createCheckingForConflict(Keycloak adminClient) { - logger().debug("Creating " + this); - boolean conflict = false; - try { - Response response = create(adminClient); - if (response == null) { - readAndSetId(adminClient); - } else { - String responseBody = response.readEntity(String.class); - response.close(); - switch (response.getStatus()) { - case 201: // created - if (responseBody != null && !responseBody.isEmpty()) { - logger().trace(String.format("Response status: %s, body: %s", response.getStatus(), responseBody)); - setRepresentation(EntityTemplate.OBJECT_MAPPER.readValue(responseBody, (Class) getRepresentation().getClass())); - } else { - setId(getCreatedId(response)); - } - break; - case 409: // some client endpoints dont't throw exception on 409 response, throwing from here - throw new ClientErrorException(HTTP_409_SUFFIX, response); - default: - throw new RuntimeException(String.format("Error when creating entity %s.", this), new WebApplicationException(response)); - } - } - } catch (ClientErrorException ex) { - if (ex.getResponse().getStatus() == 409) { - conflict = true; - logger().debug(String.format("Entity %s already exists.", this)); - readAndSetId(adminClient); - } - } catch (IOException ex) { - throw new RuntimeException(ex); - } - return conflict; - } - - public default void createOrUpdateExisting(Keycloak adminClient) { - if (createCheckingForConflict(adminClient)) { - update(adminClient); - } - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Dataset.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Dataset.java deleted file mode 100644 index 32224d792b..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Dataset.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.keycloak.performance.dataset; - -import java.util.Iterator; -import org.keycloak.performance.dataset.idm.Realm; -import java.util.List; -import java.util.stream.Stream; -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.performance.dataset.idm.ClientRole; -import org.keycloak.performance.dataset.idm.ClientRoleMappings; -import org.keycloak.performance.dataset.idm.Credential; -import org.keycloak.performance.dataset.idm.Group; -import org.keycloak.performance.dataset.idm.RealmRole; -import org.keycloak.performance.dataset.idm.RoleMappings; -import org.keycloak.performance.dataset.idm.User; -import org.keycloak.performance.dataset.idm.authorization.ClientPolicy; -import org.keycloak.performance.dataset.idm.authorization.JsPolicy; -import org.keycloak.performance.dataset.idm.authorization.Resource; -import org.keycloak.performance.dataset.idm.authorization.ResourcePermission; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.dataset.idm.authorization.RolePolicy; -import org.keycloak.performance.dataset.idm.authorization.Scope; -import org.keycloak.performance.dataset.idm.authorization.ScopePermission; -import org.keycloak.performance.dataset.idm.authorization.UserPolicy; -import org.keycloak.performance.iteration.RandomIterator; - -/** - * - * @author tkyjovsk - */ -public class Dataset extends Entity { - - private List realms; - - private List allUsers; - private List allClients; - - @Override - public DatasetRepresentation newRepresentation() { - return new DatasetRepresentation(); - } - - @Override - public String toString() { - String s = getRepresentation().getName(); - return s == null || s.isEmpty() ? "dataset" : s; - } - - public List getRealms() { - return realms; - } - - public void setRealms(List realms) { - this.realms = realms; - } - - public List getAllUsers() { - return allUsers; - } - - public void setAllUsers(List allUsers) { - this.allUsers = allUsers; - } - - public Iterator randomUsersIterator() { - return new RandomIterator<>(getAllUsers()); - } - - public List getAllClients() { - return allClients; - } - - public void setAllClients(List allClients) { - this.allClients = allClients; - } - - public Iterator randomRealmIterator() { - return new RandomIterator<>(getRealms()); - } - - public Stream realms() { - return getRealms().stream(); - } - - public Stream realmRoles() { - return getRealms().stream().map(Realm::getRealmRoles).flatMap(List::stream); - } - - public Stream clients() { - return getRealms().stream().map(Realm::getClients).flatMap(List::stream); - } - - public Stream clientRoles() { - return clients().map(Client::getClientRoles).flatMap(List::stream); - } - - public Stream users() { - return getRealms().stream().map(Realm::getUsers).flatMap(List::stream); - } - - public Stream credentials() { - return users().map(User::getCredentials).flatMap(List::stream); - } - - public Stream> userRealmRoleMappings() { - return users().map(User::getRealmRoleMappings); - } - - public Stream> userClientRoleMappings() { - return users().map(User::getClientRoleMappingsList).flatMap(List::stream); - } - - public Stream groups() { - return getRealms().stream().map(Realm::getGroups).flatMap(List::stream); - } - - public Stream resourceServers() { - return clients().filter(c -> c.getRepresentation().getAuthorizationServicesEnabled()) - .map(c -> c.getResourceServer()); - } - - public Stream scopes() { - return resourceServers().map(rs -> rs.getScopes()).flatMap(List::stream); - } - - public Stream resources() { - return resourceServers().map(rs -> rs.getResources()).flatMap(List::stream); - } - - public Stream rolePolicies() { - return resourceServers().map(rs -> rs.getRolePolicies()).flatMap(List::stream); - } - - public Stream jsPolicies() { - return resourceServers().map(rs -> rs.getJsPolicies()).flatMap(List::stream); - } - - public Stream userPolicies() { - return resourceServers().map(rs -> rs.getUserPolicies()).flatMap(List::stream); - } - - public Stream clientPolicies() { - return resourceServers().map(rs -> rs.getClientPolicies()).flatMap(List::stream); - } - - public Stream resourcePermissions() { - return resourceServers().map(rs -> rs.getResourcePermissions()).flatMap(List::stream); - } - - public Stream scopePermissions() { - return resourceServers().map(rs -> rs.getScopePermissions()).flatMap(List::stream); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetLoader.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetLoader.java deleted file mode 100644 index 2bc5a44099..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetLoader.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.keycloak.performance.dataset; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.LinkedBlockingQueue; -import static java.util.concurrent.TimeUnit.SECONDS; -import java.util.concurrent.TimeoutException; -import java.util.stream.Stream; -import org.apache.commons.lang.Validate; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.performance.TestConfig; -import org.keycloak.performance.templates.DatasetTemplate; -import org.keycloak.performance.util.Loggable; - -/** - * - * @author tkyjovsk - */ -public class DatasetLoader implements Loggable { - - private static final boolean DELETE = Boolean.parseBoolean(System.getProperty("delete", "false")); - private static final int LOG_EVERY = Integer.parseInt(System.getProperty("log.every", "5")); - private static final int QUEUE_TIMEOUT = Integer.parseInt(System.getProperty("queue.timeout", "60")); - private static final int THREADPOOL_SHUTDOWN_TIMEOUT = Integer.parseInt(System.getProperty("shutdown.timeout", "60")); - - public static void main(String[] args) throws InterruptedException { - DatasetTemplate template = new DatasetTemplate(); - template.validateConfiguration(); - DatasetLoader loader = new DatasetLoader(template.produce(), DELETE); - loader.processDataset(); - } - - private final Dataset dataset; - private final boolean delete; - - private final BlockingQueue adminClients = new LinkedBlockingQueue<>(); - private Throwable error = null; - - Map counter = new LinkedHashMap<>(); - long startTime; - long nextLoggingTime; - - public DatasetLoader(Dataset dataset, boolean delete) { - Validate.notNull(dataset); - this.dataset = dataset; - this.delete = delete; - logger().info(String.format("Opening %s admin clients.", TestConfig.numOfWorkers)); - for (int i = 0; i < TestConfig.numOfWorkers; i++) { - adminClients.add(Keycloak.getInstance( - TestConfig.serverUrisIterator.next(), - TestConfig.authRealm, - TestConfig.authUser, - TestConfig.authPassword, - TestConfig.authClient)); - } - } - - private void processDataset() throws InterruptedException { - if (delete) { - logger().info("Deleting dataset."); - processEntities(dataset.realms()); - logProcessedEntityCounts(true); - closeAdminClients(); - logger().info("Dataset deleted."); - } else { - logger().info("Creating dataset."); - processEntities(dataset.realms()); - processEntities(dataset.realmRoles()); - processEntities(dataset.clients()); - processEntities(dataset.clientRoles()); - processEntities(dataset.users()); - processEntities(dataset.credentials()); - processEntities(dataset.userRealmRoleMappings()); - processEntities(dataset.userClientRoleMappings()); - processEntities(dataset.groups()); - processEntities(dataset.resourceServers()); - processEntities(dataset.scopes()); - processEntities(dataset.resources()); - processEntities(dataset.rolePolicies()); - processEntities(dataset.jsPolicies()); - processEntities(dataset.userPolicies()); - processEntities(dataset.clientPolicies()); - processEntities(dataset.resourcePermissions()); - processEntities(dataset.scopePermissions()); - logProcessedEntityCounts(true); - closeAdminClients(); - logger().info("Dataset created."); - } - } - - private void processEntities(Stream stream) throws InterruptedException { - if (!errorReported()) { - Iterator iterator = stream.iterator(); - logger().debug("Creating thread pool."); - ExecutorService threadPool = Executors.newFixedThreadPool(TestConfig.numOfWorkers); - BlockingQueue queue = new LinkedBlockingQueue<>(TestConfig.numOfWorkers + 5); - try { - while (iterator.hasNext() && !errorReported()) { - logProcessedEntityCounts(false); - try { - if (queue.offer(iterator.next(), QUEUE_TIMEOUT, SECONDS)) { - threadPool.execute(() -> { - try { - Updatable updatable = queue.take(); - if (!errorReported()) { - Keycloak adminClient = adminClients.take(); - try { - - if (delete) { - updatable.deleteOrIgnoreMissing(adminClient); - } else { - if (updatable instanceof Creatable) { - ((Creatable) updatable).createOrUpdateExisting(adminClient); - } else { - updatable.update(adminClient); - } - } - - confirmEntityAsProcessed(updatable); - - } finally { - adminClients.add(adminClient); // return client for reuse - } - } - } catch (Throwable ex) { - reportError(ex); - } - }); - } else { - reportError(new TimeoutException("Waiting for executor timed out.")); - } - } catch (InterruptedException ex) { - reportError(ex); - } - } - } catch (Exception ex) { - reportError(ex); - } - - logger().debug("Terminating thread pool."); - threadPool.shutdown(); - threadPool.awaitTermination(THREADPOOL_SHUTDOWN_TIMEOUT, SECONDS); - if (!threadPool.isTerminated()) { - logger().error("Failed to terminate the thread pool. Attempting force shutdown."); - threadPool.shutdownNow(); - } - - if (errorReported()) { - closeAdminClients(); - throw new Error(error); - } - } - } - - private synchronized void confirmEntityAsProcessed(Updatable entity) { - String key = entity.getClass().getSimpleName(); - Integer count = counter.get(key); - count = count == null ? 1 : ++count; - counter.put(key, count); - } - - private synchronized void logProcessedEntityCounts(boolean ignoreTimestamp) { - long time = new Date().getTime(); - if (startTime == 0) { - startTime = new Date().getTime(); - } - if (!counter.isEmpty() && (ignoreTimestamp || time > nextLoggingTime)) { - - StringBuilder sb = new StringBuilder(); - counter.entrySet().forEach(e -> sb.append(String.format("\n%-20s %s", e.getKey(), e.getValue()))); - logger().info(String.format("Time: +%s s\n%s entities: %s\n", - (time - startTime) / 1000, - (delete ? "Deleted" : "Created"), - sb.toString() - )); - nextLoggingTime = time + LOG_EVERY * 1000; - } - } - - private synchronized boolean errorReported() { - return error != null; - } - - private synchronized void reportError(Throwable ex) { - logProcessedEntityCounts(true); - - StringWriter sw = new StringWriter(); - ex.printStackTrace(new PrintWriter(sw)); - - logger().error(String.format("Error occured in thread %s: %s", Thread.currentThread().getName(), sw.toString())); - this.error = ex; - } - - public void closeAdminClients() { - logger().info("Closing admin clients."); - while (!adminClients.isEmpty()) { - adminClients.poll().close(); - } - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetRepresentation.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetRepresentation.java deleted file mode 100644 index 3fbe671a35..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/DatasetRepresentation.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.keycloak.performance.dataset; - -/** - * - * @author tkyjovsk - */ -public class DatasetRepresentation { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Entity.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Entity.java deleted file mode 100644 index 988fd9732c..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Entity.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.keycloak.performance.dataset; - -import org.apache.commons.lang.Validate; - -/** - * - * @author tkyjovsk - * @param representation type - */ -public abstract class Entity implements Representable { - - private REP representation; - - public Entity() { - setRepresentation(newRepresentation()); - } - - @Override - public REP getRepresentation() { - return representation; - } - - @Override - public final void setRepresentation(REP representation) { - Validate.notNull(representation); - this.representation = representation; - } - - public String simpleClassName() { - return this.getClass().getSimpleName(); - } - - @Override - public int hashCode() { - return simpleClassName().hashCode(); - } - - @Override - public boolean equals(Object other) { - return this == other || (other != null - && this.getClass() == other.getClass() - && this.hashCode() == ((Entity) other).hashCode()); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/NestedEntity.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/NestedEntity.java deleted file mode 100644 index a8c3a5ad20..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/NestedEntity.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.keycloak.performance.dataset; - -import org.apache.commons.lang.Validate; -import static org.keycloak.performance.iteration.RandomBooleans.getRandomBooleans; -import static org.keycloak.performance.iteration.RandomIntegers.getRandomIntegers; -import org.keycloak.performance.util.ValidateNumber; - -/** - * - * @author tkyjovsk - * @param parent entity - */ -public abstract class NestedEntity extends Entity { - - private final PE parentEntity; - - private final int index; - private final int seed; - - public NestedEntity(PE parentEntity, int index) { - Validate.notNull(parentEntity); - this.parentEntity = parentEntity; - ValidateNumber.minValue(index, 0); - this.index = index; - this.seed = parentEntity.hashCode() + simpleClassName().hashCode(); - } - - public NestedEntity(PE parentEntity) { - this(parentEntity, 0); - } - - public PE getParentEntity() { - return parentEntity; - } - - public synchronized final int getIndex() { - return index; - } - - public synchronized int getSeed() { - return seed; - } - - @Override - public synchronized int hashCode() { - return simpleClassName().hashCode() * getIndex() + getParentEntity().hashCode(); - } - - @Override - public boolean equals(Object other) { - return super.equals(other); - } - - public synchronized int indexBasedRandomInt(int bound) { - return getRandomIntegers(getSeed(), bound).get(getIndex()); - } - - public synchronized boolean indexBasedRandomBool(int truePercentage) { - return getRandomBooleans(getSeed(), truePercentage).get(getIndex()); - } - - public synchronized boolean indexBasedRandomBool() { - return indexBasedRandomBool(50); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Representable.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Representable.java deleted file mode 100644 index e18ecf66c2..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Representable.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.keycloak.performance.dataset; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import org.apache.commons.lang.Validate; -import org.keycloak.performance.util.Loggable; -import static org.keycloak.util.JsonSerialization.writeValueAsString; - -/** - * - * @author tkyjovsk - * @param representation - */ -public interface Representable extends Loggable { - - public REP newRepresentation(); - - public REP getRepresentation(); - - public void setRepresentation(REP representation); - - public default void setId(String uuid) { - if (uuid == null) { - logger().debug(this.getClass().getSimpleName() + " " + this + " " + " setId " + uuid); - throw new IllegalArgumentException(); - } - try { - Class c = (Class) getRepresentation().getClass(); - Method setId = c.getMethod("setId", String.class); - setId.invoke(getRepresentation(), uuid); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - throw new RuntimeException(ex); - } - } - - public default String getIdFromRepresentation(REP representation) { - Validate.notNull(representation); - try { - Class c = (Class) representation.getClass(); - Method getId = c.getMethod("getId"); - Validate.notNull(getId); - return (String) getId.invoke(representation); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - throw new RuntimeException(ex); - } - } - - public default String getId() { - return getIdFromRepresentation(getRepresentation()); - } - - public default String toJSON() throws IOException { - return writeValueAsString(getRepresentation()); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Updatable.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Updatable.java deleted file mode 100644 index c6d92f8723..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/Updatable.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.keycloak.performance.dataset; - -import javax.ws.rs.NotFoundException; -import org.keycloak.admin.client.Keycloak; - -/** - * For entities with no id. - * - * @author tkyjovsk - */ -public interface Updatable extends Representable { - - public void update(Keycloak adminClient); - - public void delete(Keycloak adminClient); - - public default void deleteOrIgnoreMissing(Keycloak adminClient) { - try { - delete(adminClient); - } catch (NotFoundException ex) { - logger().info(String.format("Entity %s not found. Considering as deleted.", this)); - } - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/Attribute.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/Attribute.java deleted file mode 100644 index c1d59d6342..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/Attribute.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.keycloak.performance.dataset.attr; - -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.NestedEntity; - -/** - * - * @author tkyjovsk - * @param parent entity - * @param representation - */ -public abstract class Attribute extends NestedEntity { - - public Attribute(PE attributeOwner, int index) { - super(attributeOwner, index); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeMap.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeMap.java deleted file mode 100644 index 509d795867..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeMap.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.keycloak.performance.dataset.attr; - -import java.util.HashMap; -import java.util.List; - -/** - * - * @author tkyjovsk - */ -public class AttributeMap extends HashMap { - - public AttributeMap(List>> attributes) { - attributes.forEach(attribute -> { - put( - attribute.getRepresentation().getName(), - attribute.getRepresentation().getValue() - ); - }); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeRepresentation.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeRepresentation.java deleted file mode 100644 index df4c812dde..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/AttributeRepresentation.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.keycloak.performance.dataset.attr; - -/** - * - * @author tkyjovsk - */ -public abstract class AttributeRepresentation { - - private String name; - private V value; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public V getValue() { - return value; - } - - public void setValue(V value) { - this.value = value; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttribute.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttribute.java deleted file mode 100644 index ae109c934a..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttribute.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.keycloak.performance.dataset.attr; - -import org.keycloak.performance.dataset.Entity; - -/** - * - * @author tkyjovsk - * @param - */ -public class StringAttribute extends Attribute { - - public StringAttribute(PE attributeOwner, int index) { - super(attributeOwner, index); - } - - @Override - public StringAttributeRepresentation newRepresentation() { - return new StringAttributeRepresentation(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttributeRepresentation.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttributeRepresentation.java deleted file mode 100644 index 69ceea78f1..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringAttributeRepresentation.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.keycloak.performance.dataset.attr; - -/** - * - * @author tkyjovsk - */ -public class StringAttributeRepresentation extends AttributeRepresentation { -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttribute.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttribute.java deleted file mode 100644 index 20ba930ed8..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttribute.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.keycloak.performance.dataset.attr; - -import org.keycloak.performance.dataset.Entity; - -/** - * - * @author tkyjovsk - * @param owner entity - */ -public class StringListAttribute extends Attribute { - - public StringListAttribute(PE attributeOwner, int index) { - super(attributeOwner, index); - } - - @Override - public StringListAttributeRepresentation newRepresentation() { - return new StringListAttributeRepresentation(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttributeRepresentation.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttributeRepresentation.java deleted file mode 100644 index 6effadfbbc..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/attr/StringListAttributeRepresentation.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.keycloak.performance.dataset.attr; - -import java.util.List; - -/** - * - * @author tkyjovsk - */ -public class StringListAttributeRepresentation extends AttributeRepresentation> { -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Client.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Client.java deleted file mode 100644 index 4c010e19ec..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Client.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.ClientResource; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.representations.idm.ClientRepresentation; -import org.keycloak.performance.dataset.Creatable; - -/** - * - * @author tkyjovsk - */ -public class Client extends NestedEntity - implements Creatable { - - private List clientRoles; - private ResourceServer resourceServer; - - public Client(Realm realm, int index) { - super(realm, index); - } - - @Override - public ClientRepresentation newRepresentation() { - return new ClientRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getClientId(); - } - - public Realm getRealm() { - return getParentEntity(); - } - - public List getClientRoles() { - return clientRoles; - } - - public void setClientRoles(List clientRoles) { - this.clientRoles = clientRoles; - } - - public ResourceServer getResourceServer() { - return resourceServer; - } - - public void setResourceServer(ResourceServer resourceServer) { - this.resourceServer = resourceServer; - } - - public synchronized ClientResource resource(Keycloak adminClient) { - return getRealm().resource(adminClient).clients().get(getIdAndReadIfNull(adminClient)); - } - - @Override - public synchronized ClientRepresentation read(Keycloak adminClient) { - return getRealm().resource(adminClient).clients().findByClientId(getRepresentation().getClientId()).get(0); - } - - @Override - public synchronized Response create(Keycloak adminClient) { - return getRealm().resource(adminClient).clients().create(getRepresentation()); - } - - @Override - public synchronized void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public synchronized void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRole.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRole.java deleted file mode 100644 index 0476fe9d4c..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRole.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RoleByIdResource; -import org.keycloak.admin.client.resource.RolesResource; -import org.keycloak.representations.idm.RoleRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ClientRole extends Role { - - public ClientRole(Client client, int index) { - super(client, index); - } - - public Client getClient() { - return getParentEntity(); - } - - @Override - public RolesResource rolesResource(Keycloak adminClient) { - return getClient().resource(adminClient).roles(); - } - - @Override - public RoleByIdResource roleByIdResource(Keycloak adminClient) { - return getClient().getRealm().resource(adminClient).rolesById(); - } - - @Override - public RoleRepresentation newRepresentation() { - return new RoleRepresentation(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRoleMappings.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRoleMappings.java deleted file mode 100644 index c5cc278dcc..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/ClientRoleMappings.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import org.keycloak.admin.client.Keycloak; - -/** - * - * @author tkyjovsk - */ -public class ClientRoleMappings extends RoleMappings { - - private final Client client; - - public ClientRoleMappings(RM roleMapper, Client client, RoleMappingsRepresentation representation) { - super(roleMapper, representation); - this.client = client; - } - - @Override - public String toString() { - return String.format("%s/role-mappings/%s", getRoleMapper(), getClient()); - } - - @Override - public RoleMapper getRoleMapper() { - return getParentEntity(); - } - - public Client getClient() { - return client; - } - - @Override - public void update(Keycloak adminClient) { - getRoleMapper() - .roleMappingResource(adminClient) - .clientLevel(getClient().getId()) - .add(getRepresentation()); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Credential.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Credential.java deleted file mode 100644 index 28026c3aab..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Credential.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.UserResource; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.representations.idm.CredentialRepresentation; -import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD; -import org.keycloak.performance.dataset.Updatable; - -/** - * - * @author tkyjovsk - */ -public class Credential extends NestedEntity - implements Updatable { - - public Credential(User user, int index) { - super(user, index); - } - - @Override - public CredentialRepresentation newRepresentation() { - return new CredentialRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getType(); - } - - public User getUser() { - return getParentEntity(); - } - - @Override - public void update(Keycloak adminClient) { - if (getRepresentation().getType().equals(PASSWORD)) { - resource(adminClient).resetPassword(getRepresentation()); - } else { - logger().warn("Cannot reset password. Non-password credetial type."); - } - } - - public UserResource resource(Keycloak adminClient) { - return getUser().resource(adminClient); - } - - @Override - public void delete(Keycloak adminClient) { - throw new UnsupportedOperationException(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Group.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Group.java deleted file mode 100644 index ab8c3d075d..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Group.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.GroupResource; -import org.keycloak.admin.client.resource.RoleMappingResource; -import org.keycloak.representations.idm.GroupRepresentation; -import org.keycloak.performance.dataset.Creatable; - -/** - * - * @author tkyjovsk - */ -public class Group extends RoleMapper implements Creatable { - - public Group(Realm realm, int index) { - super(realm, index); - } - - @Override - public GroupRepresentation newRepresentation() { - return new GroupRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getName(); - } - - @Override - public RoleMappingResource roleMappingResource(Keycloak adminClient) { - throw new UnsupportedOperationException(); - } - - public GroupResource resource(Keycloak adminClient) { - return getRealm().resource(adminClient).groups().group(getIdAndReadIfNull(adminClient)); - } - - @Override - public GroupRepresentation read(Keycloak adminClient) { - return getRealm().resource(adminClient).groups().groups(getRepresentation().getName(), 0, 1).get(0); - } - - @Override - public Response create(Keycloak adminClient) { - return getRealm().resource(adminClient).groups().add(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Realm.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Realm.java deleted file mode 100644 index 2dd2fe8737..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Realm.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RealmResource; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.representations.idm.RealmRepresentation; -import org.keycloak.performance.dataset.Creatable; - -/** - * - * @author tkyjovsk - */ -public class Realm extends NestedEntity - implements Creatable { - - private List clients; - private List realmRoles; - private List users; - private List groups; - - private List clientRoles; // all clients' roles - private List resourceServers; // filtered clients - - public Realm(Dataset dataset, int index) { - super(dataset, index); - } - - @Override - public RealmRepresentation newRepresentation() { - return new RealmRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getRealm(); - } - - public Dataset getDataset() { - return getParentEntity(); - } - - public List getUsers() { - return users; - } - - public void setUsers(List users) { - this.users = users; - } - - public List getGroups() { - return groups; - } - - public void setGroups(List groups) { - this.groups = groups; - } - - public List getClients() { - return clients; - } - - public void setClients(List clients) { - this.clients = clients; - } - - public List getRealmRoles() { - return realmRoles; - } - - public void setRealmRoles(List realmRoles) { - this.realmRoles = realmRoles; - } - - public List getClientRoles() { - return clientRoles; - } - - public void setClientRoles(List clientRoles) { - this.clientRoles = clientRoles; - } - - public List getResourceServers() { - return resourceServers; - } - - public void setResourceServers(List resourceServers) { - this.resourceServers = resourceServers; - } - - public RealmResource resource(Keycloak adminClient) { - return adminClient.realm(getRepresentation().getRealm()); - } - - @Override - public synchronized RealmRepresentation read(Keycloak adminClient) { - return adminClient.realms().realm(getRepresentation().getRealm()).toRepresentation(); - } - - @Override - public synchronized Response create(Keycloak adminClient) { - adminClient.realms().create(getRepresentation()); - return null; - } - - @Override - public synchronized void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public synchronized void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RealmRole.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RealmRole.java deleted file mode 100644 index e03df5ad0c..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RealmRole.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RoleByIdResource; -import org.keycloak.admin.client.resource.RolesResource; -import org.keycloak.representations.idm.RoleRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RealmRole extends Role { - - public RealmRole(Realm realm, int index) { - super(realm, index); - } - - public Realm getRealm() { - return getParentEntity(); - } - - @Override - public RolesResource rolesResource(Keycloak adminClient) { - return getRealm().resource(adminClient).roles(); - } - - @Override - public RoleByIdResource roleByIdResource(Keycloak adminClient) { - return getRealm().resource(adminClient).rolesById(); - } - - @Override - public RoleRepresentation newRepresentation() { - return new RoleRepresentation(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Role.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Role.java deleted file mode 100644 index 6fd30b8421..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/Role.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RoleByIdResource; -import org.keycloak.admin.client.resource.RoleResource; -import org.keycloak.admin.client.resource.RolesResource; -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.representations.idm.RoleRepresentation; -import org.keycloak.performance.dataset.Creatable; - -/** - * - * @author tkyjovsk - * @param - */ -public abstract class Role extends NestedEntity - implements Creatable { - - public Role(PE parentEntity, int index) { - super(parentEntity, index); - } - - @Override - public RoleRepresentation newRepresentation() { - return new RoleRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getName(); - } - - public abstract RolesResource rolesResource(Keycloak adminClient); - - public abstract RoleByIdResource roleByIdResource(Keycloak adminClient); - - public RoleResource resource(Keycloak adminClient) { - return rolesResource(adminClient).get(getRepresentation().getName()); - } - - @Override - public RoleRepresentation read(Keycloak adminClient) { - return resource(adminClient).toRepresentation(); - } - - @Override - public Response create(Keycloak adminClient) { // FIXME - rolesResource(adminClient).create(getRepresentation()); - return null; - } - - @Override - public void update(Keycloak adminClient) { - roleByIdResource(adminClient).updateRole(getId(), getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - roleByIdResource(adminClient).deleteRole(getId()); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMapper.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMapper.java deleted file mode 100644 index a86e2cd20b..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RoleMappingResource; -import org.keycloak.performance.dataset.NestedEntity; - -/** - * - * @author tkyjovsk - */ -public abstract class RoleMapper extends NestedEntity { - - public RoleMapper(Realm realm, int index) { - super(realm, index); - } - - public Realm getRealm() { - return getParentEntity(); - } - - public abstract RoleMappingResource roleMappingResource(Keycloak adminClient); - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappings.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappings.java deleted file mode 100644 index 3cf061cc05..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappings.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RoleScopeResource; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.performance.dataset.Updatable; - -/** - * - * @author tkyjovsk - * @param role-mapper parent entity (user or group) - */ -public class RoleMappings extends NestedEntity - implements Updatable { - - public RoleMappings(RM roleMapper, RoleMappingsRepresentation representation) { - super(roleMapper); - setRepresentation(representation); - } - - @Override - public RoleMappingsRepresentation newRepresentation() { - return new RoleMappingsRepresentation(); - } - - public RoleMapper getRoleMapper() { - return getParentEntity(); - } - - @Override - public String toString() { - return String.format("%s/role-mappings/realm", getRoleMapper()); - } - - public RoleScopeResource resource(Keycloak adminClient) { - return getRoleMapper().roleMappingResource(adminClient).realmLevel(); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).add(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(getRepresentation()); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappingsRepresentation.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappingsRepresentation.java deleted file mode 100644 index 6526ba7ad3..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/RoleMappingsRepresentation.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.LinkedList; -import org.keycloak.representations.idm.RoleRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RoleMappingsRepresentation extends LinkedList { - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/User.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/User.java deleted file mode 100644 index 3d075d9840..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/User.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.Iterator; -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RoleMappingResource; -import org.keycloak.admin.client.resource.UserResource; -import org.keycloak.representations.idm.UserRepresentation; -import org.keycloak.performance.dataset.Creatable; -import org.keycloak.performance.iteration.FilteredIterator; -import org.keycloak.performance.iteration.RandomIterator; - -/** - * - * @author tkyjovsk - */ -public class User extends RoleMapper implements Creatable { - - private List credentials; - private RoleMappings realmRoleMappings; - private List> clientRoleMappingsList; - - public User(Realm realm, int index) { - super(realm, index); - } - - @Override - public UserRepresentation newRepresentation() { - return new UserRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getUsername(); - } - - public void setRealmRoleMappings(RoleMappings realmRoleMappings) { - this.realmRoleMappings = realmRoleMappings; - } - - public void setClientRoleMappingsList(List> clientRoleMappingsList) { - this.clientRoleMappingsList = clientRoleMappingsList; - } - - public RoleMappings getRealmRoleMappings() { - return realmRoleMappings; - } - - public List> getClientRoleMappingsList() { - return clientRoleMappingsList; - } - - public List getCredentials() { - return credentials; - } - - public void setCredentials(List credentials) { - this.credentials = credentials; - } - - public UserResource resource(Keycloak adminClient) { - return getRealm().resource(adminClient).users().get(getIdAndReadIfNull(adminClient)); - } - - @Override - public UserRepresentation read(Keycloak adminClient) { - return getRealm().resource(adminClient).users().search(getRepresentation().getUsername()).get(0); - } - - @Override - public Response create(Keycloak adminClient) { - return getRealm().resource(adminClient).users().create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - - @Override - public RoleMappingResource roleMappingResource(Keycloak adminClient) { - return resource(adminClient).roles(); - } - - public Iterator randomClientIterator() { - return new RandomIterator<>(getRealm().getClients()); - } - - public Iterator randomConfidentialClientIterator() { - return new FilteredIterator<>(new RandomIterator<>(getRealm().getClients()), - c -> !c.getRepresentation().isPublicClient() && !c.getRepresentation().isBearerOnly() - ); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ClientPolicy.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ClientPolicy.java deleted file mode 100644 index a2673b655c..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ClientPolicy.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.ClientPoliciesResource; -import org.keycloak.admin.client.resource.ClientPolicyResource; -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.representations.idm.authorization.ClientPolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ClientPolicy extends Policy { - - private List clients; - - public ClientPolicy(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public ClientPolicyRepresentation newRepresentation() { - return new ClientPolicyRepresentation(); - } - - public List getClients() { - return clients; - } - - public void setClients(List clients) { - this.clients = clients; - } - - public ClientPoliciesResource clientPoliciesResource(Keycloak adminClient) { - return policies(adminClient).client(); - } - - public ClientPolicyResource resource(Keycloak adminClient) { - return getResourceServer().resource(adminClient).policies().client().findById(getIdAndReadIfNull(adminClient)); - } - - @Override - public ClientPolicyRepresentation read(Keycloak adminClient) { - return clientPoliciesResource(adminClient).findByName(getRepresentation().getName()); - } - - @Override - public Response create(Keycloak adminClient) { - return clientPoliciesResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/JsPolicy.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/JsPolicy.java deleted file mode 100644 index e2cae17fca..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/JsPolicy.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.JSPoliciesResource; -import org.keycloak.admin.client.resource.JSPolicyResource; -import org.keycloak.representations.idm.authorization.JSPolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class JsPolicy extends Policy { - - public JsPolicy(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public JSPolicyRepresentation newRepresentation() { - return new JSPolicyRepresentation(); - } - - public JSPoliciesResource jsPoliciesResource(Keycloak adminClient) { - return getResourceServer().resource(adminClient).policies().js(); - } - - public JSPolicyResource resource(Keycloak adminClient) { - return jsPoliciesResource(adminClient).findById(getIdAndReadIfNull(adminClient)); - } - - @Override - public JSPolicyRepresentation read(Keycloak adminClient) { - return jsPoliciesResource(adminClient).findByName(getRepresentation().getName()); - } - - @Override - public Response create(Keycloak adminClient) { - return jsPoliciesResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Policy.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Policy.java deleted file mode 100644 index f0b34337d9..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Policy.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.PoliciesResource; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.representations.idm.authorization.AbstractPolicyRepresentation; -import org.keycloak.performance.dataset.Creatable; - -/** - * - * @author tkyjovsk - */ -public abstract class Policy - extends NestedEntity - implements Creatable { - - public Policy(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public String toString() { - return getRepresentation().getName(); - } - - public ResourceServer getResourceServer() { - return getParentEntity(); - } - - public PoliciesResource policies(Keycloak adminClient) { - return getResourceServer().resource(adminClient).policies(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Resource.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Resource.java deleted file mode 100644 index 85d891cb72..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Resource.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.apache.commons.lang.Validate; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.ResourceResource; -import org.keycloak.admin.client.resource.ResourcesResource; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.representations.idm.authorization.ResourceRepresentation; -import org.keycloak.performance.dataset.Creatable; - -/** - * - * @author tkyjovsk - */ -public class Resource extends NestedEntity - implements Creatable { - - private List scopes; - - public Resource(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public ResourceRepresentation newRepresentation() { - return new ResourceRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getName(); - } - - public ResourceServer getResourceServer() { - return getParentEntity(); - } - - public ResourcesResource resourcesResource(Keycloak adminClient) { - return getResourceServer().resource(adminClient).resources(); - } - - public ResourceResource resource(Keycloak adminClient) { - return resourcesResource(adminClient).resource(getIdAndReadIfNull(adminClient)); - } - - @Override - public ResourceRepresentation read(Keycloak adminClient) { - return resourcesResource(adminClient).findByName(getRepresentation().getName()).get(0); - } - - @Override - public Response create(Keycloak adminClient) { - Validate.notNull(getResourceServer()); - Validate.notNull(getResourceServer().getClient()); - Validate.notNull(getResourceServer().getClient().getRepresentation().getBaseUrl()); - return resourcesResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - - public List getScopes() { - return scopes; - } - - public void setScopes(List scopes) { - this.scopes = scopes; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourcePermission.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourcePermission.java deleted file mode 100644 index 5392e7321d..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourcePermission.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.ResourcePermissionResource; -import org.keycloak.admin.client.resource.ResourcePermissionsResource; -import org.keycloak.representations.idm.authorization.ResourcePermissionRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ResourcePermission extends Policy { - - private List resources; - private List policies; - - public ResourcePermission(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public ResourcePermissionRepresentation newRepresentation() { - return new ResourcePermissionRepresentation(); - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getPolicies() { - return policies; - } - - public void setPolicies(List policies) { - this.policies = policies; - } - - public ResourcePermissionsResource resourcePermissionsResource(Keycloak adminClient) { - return getResourceServer().resource(adminClient).permissions().resource(); - } - - public ResourcePermissionResource resource(Keycloak adminClient) { - return resourcePermissionsResource(adminClient).findById(getIdAndReadIfNull(adminClient)); - } - - @Override - public ResourcePermissionRepresentation read(Keycloak adminClient) { - return resourcePermissionsResource(adminClient).findByName(getRepresentation().getName()); - } - - @Override - public Response create(Keycloak adminClient) { - return resourcePermissionsResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServer.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServer.java deleted file mode 100644 index 84cc72cd42..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServer.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.AuthorizationResource; -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.representations.idm.authorization.DecisionStrategy; -import org.keycloak.representations.idm.authorization.ResourceServerRepresentation; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.performance.dataset.Updatable; - -/** - * - * @author tkyjovsk - */ -public class ResourceServer extends NestedEntity - implements Updatable { - - private List scopes; - private List resources; - private List rolePolicies; - private List jsPolicies; - private List userPolicies; - private List clientPolicies; - private List resourcePermissions; - private List scopePermissions; - - private List allPolicies; - - public ResourceServer(Client client) { - super(client); - } - - @Override - public ResourceServerRepresentation newRepresentation() { - return new ResourceServerRepresentation(); - } - - public Client getClient() { - return getParentEntity(); - } - - @Override - public ResourceServerRepresentation getRepresentation() { - ResourceServerRepresentation r = super.getRepresentation(); - r.setId(getClient().getRepresentation().getId()); - r.setClientId(getClient().getRepresentation().getClientId()); - r.setName(getClient().getRepresentation().getName()); - r.setDecisionStrategy(DecisionStrategy.UNANIMOUS); - return r; - } - - @Override - public String getId() { - return getClient().getId(); - } - - @Override - public String toString() { - return getClient().toString(); - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getScopes() { - return scopes; - } - - public void setScopes(List scopes) { - this.scopes = scopes; - } - - public List getRolePolicies() { - return rolePolicies; - } - - public void setRolePolicies(List rolePolicies) { - this.rolePolicies = rolePolicies; - } - - public AuthorizationResource resource(Keycloak adminClient) { - return getClient().resource(adminClient).authorization(); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - getClient().delete(adminClient); - } - - public List getJsPolicies() { - return jsPolicies; - } - - public void setJsPolicies(List jsPolicies) { - this.jsPolicies = jsPolicies; - } - - public List getUserPolicies() { - return userPolicies; - } - - public void setUserPolicies(List userPolicies) { - this.userPolicies = userPolicies; - } - - public List getClientPolicies() { - return clientPolicies; - } - - public void setClientPolicies(List clientPolicies) { - this.clientPolicies = clientPolicies; - } - - public List getResourcePermissions() { - return resourcePermissions; - } - - public void setResourcePermissions(List resourcePermissions) { - this.resourcePermissions = resourcePermissions; - } - - public List getAllPolicies() { - return allPolicies; - } - - public void setAllPolicies(List allPolicies) { - this.allPolicies = allPolicies; - } - - public List getScopePermissions() { - return scopePermissions; - } - - public void setScopePermissions(List scopePermissions) { - this.scopePermissions = scopePermissions; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerList.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerList.java deleted file mode 100644 index 3cc04f7951..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerList.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.AbstractList; -import java.util.List; -import static java.util.stream.Collectors.toList; -import org.keycloak.performance.dataset.idm.Client; - -/** - * - * @author tkyjovsk - */ -public class ResourceServerList extends AbstractList { - - List clients; - List resourceServers; - - public ResourceServerList(List clients) { - this.clients = clients; - } - - public void update() { - resourceServers = clients.stream() - .filter(c -> c.getRepresentation().getAuthorizationServicesEnabled()) - .map(c -> c.getResourceServer()) - .collect(toList()); - } - - public void updateIfNull() { - if (resourceServers == null) { - update(); - } - } - - @Override - public ResourceServer get(int index) { - updateIfNull(); - return resourceServers.get(index); - } - - @Override - public int size() { - updateIfNull(); - return resourceServers.size(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicy.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicy.java deleted file mode 100644 index f613338ba6..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicy.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.RolePoliciesResource; -import org.keycloak.admin.client.resource.RolePolicyResource; -import org.keycloak.performance.dataset.idm.Role; -import org.keycloak.representations.idm.authorization.RolePolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RolePolicy extends Policy { - - private List roles; - - public RolePolicy(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public RolePolicyRepresentation newRepresentation() { - return new RolePolicyRepresentation(); - } - - public List getRoles() { - return roles; - } - - public void setRoles(List roles) { - this.roles = roles; - } - - public RolePoliciesResource rolePoliciesResource(Keycloak adminClient) { - return getResourceServer().resource(adminClient).policies().role(); - } - - public RolePolicyResource resource(Keycloak adminClient) { - return rolePoliciesResource(adminClient).findById(getIdAndReadIfNull(adminClient)); - } - - @Override - public RolePolicyRepresentation read(Keycloak adminClient) { - return rolePoliciesResource(adminClient).findByName(getRepresentation().getName()); - } - - @Override - public Response create(Keycloak adminClient) { - return rolePoliciesResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinition.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinition.java deleted file mode 100644 index 03db5d2e75..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinition.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.representations.idm.authorization.RolePolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RolePolicyRoleDefinition extends NestedEntity { - - public RolePolicyRoleDefinition(RolePolicy parentEntity, int index, RolePolicyRepresentation.RoleDefinition representation) { - super(parentEntity, index); - setRepresentation(representation); - } - - @Override - public RolePolicyRepresentation.RoleDefinition newRepresentation() { - return new RolePolicyRepresentation.RoleDefinition(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinitionSet.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinitionSet.java deleted file mode 100644 index 8d05ede488..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyRoleDefinitionSet.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.Collection; -import java.util.HashSet; -import org.keycloak.representations.idm.authorization.RolePolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RolePolicyRoleDefinitionSet extends HashSet { - - public RolePolicyRoleDefinitionSet(Collection roleDefinitions) { - roleDefinitions.forEach(rd -> add( - new RolePolicyRepresentation.RoleDefinition( - rd.getRepresentation().getId(), - rd.getRepresentation().isRequired() - ))); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Scope.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Scope.java deleted file mode 100644 index c8d8a5b7f5..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/Scope.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.ResourceScopeResource; -import org.keycloak.admin.client.resource.ResourceScopesResource; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.representations.idm.authorization.ScopeRepresentation; -import org.keycloak.performance.dataset.Creatable; - -/** - * - * @author tkyjovsk - */ -public class Scope extends NestedEntity - implements Creatable { - - public Scope(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public ScopeRepresentation newRepresentation() { - return new ScopeRepresentation(); - } - - @Override - public String toString() { - return getRepresentation().getName(); - } - - public ResourceServer getResourceServer() { - return getParentEntity(); - } - - public ResourceScopesResource scopesResource(Keycloak adminClient) { - return getResourceServer().resource(adminClient).scopes(); - } - - public ResourceScopeResource resource(Keycloak adminClient) { - return scopesResource(adminClient).scope(getIdAndReadIfNull(adminClient)); - } - - @Override - public ScopeRepresentation read(Keycloak adminClient) { - return scopesResource(adminClient).findByName(getRepresentation().getName()); - } - - @Override - public Response create(Keycloak adminClient) { - return scopesResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ScopePermission.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ScopePermission.java deleted file mode 100644 index 1f4a16fd57..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/ScopePermission.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.ScopePermissionResource; -import org.keycloak.admin.client.resource.ScopePermissionsResource; -import org.keycloak.representations.idm.authorization.ScopePermissionRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ScopePermission extends Policy { - - private List scopes; - private List policies; - - public ScopePermission(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public ScopePermissionRepresentation newRepresentation() { - return new ScopePermissionRepresentation(); - } - - public ScopePermissionsResource scopePermissionsResource(Keycloak adminClient) { - return getResourceServer().resource(adminClient).permissions().scope(); - } - - public ScopePermissionResource resource(Keycloak adminClient) { - return scopePermissionsResource(adminClient).findById(getIdAndReadIfNull(adminClient)); - } - - @Override - public ScopePermissionRepresentation read(Keycloak adminClient) { - return scopePermissionsResource(adminClient).findByName(getRepresentation().getName()); - } - - @Override - public Response create(Keycloak adminClient) { - return scopePermissionsResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - - public List getPolicies() { - return policies; - } - - public void setPolicies(List policies) { - this.policies = policies; - } - - public List getScopes() { - return scopes; - } - - public void setScopes(List scopes) { - this.scopes = scopes; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/UserPolicy.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/UserPolicy.java deleted file mode 100644 index 2b160fc7f4..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/dataset/idm/authorization/UserPolicy.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.List; -import javax.ws.rs.core.Response; -import org.keycloak.admin.client.Keycloak; -import org.keycloak.admin.client.resource.UserPoliciesResource; -import org.keycloak.admin.client.resource.UserPolicyResource; -import org.keycloak.performance.dataset.idm.User; -import org.keycloak.representations.idm.authorization.UserPolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class UserPolicy extends Policy { - - private List users; - - public UserPolicy(ResourceServer resourceServer, int index) { - super(resourceServer, index); - } - - @Override - public UserPolicyRepresentation newRepresentation() { - return new UserPolicyRepresentation(); - } - - public List getUsers() { - return users; - } - - public void setUsers(List users) { - this.users = users; - } - - public UserPoliciesResource userPoliciesResource(Keycloak adminClient) { - return policies(adminClient).user(); - } - - public UserPolicyResource resource(Keycloak adminClient) { - return userPoliciesResource(adminClient).findById(getIdAndReadIfNull(adminClient)); - } - - @Override - public UserPolicyRepresentation read(Keycloak adminClient) { - return userPoliciesResource(adminClient).findByName(getRepresentation().getName()); - } - - @Override - public Response create(Keycloak adminClient) { - return userPoliciesResource(adminClient).create(getRepresentation()); - } - - @Override - public void update(Keycloak adminClient) { - resource(adminClient).update(getRepresentation()); - } - - @Override - public void delete(Keycloak adminClient) { - resource(adminClient).remove(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/FilteredIterator.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/FilteredIterator.java deleted file mode 100644 index 83e09761ce..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/FilteredIterator.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.function.Predicate; - -/** - * @author Marko Strukelj - */ -public class FilteredIterator implements Iterator { - - private final Iterator delegate; - private final Predicate filter; - private T next; - - public FilteredIterator(Iterator delegate, Predicate filter) { - this.delegate = delegate; - this.filter = filter; - } - - @Override - public synchronized boolean hasNext() { - // check matching one - if (next != null) { - return true; - } - if (delegate.hasNext()) { - T v = delegate.next(); - if (filter.test(v)) { - next = v; - return true; - } else { - // for infinite iterators it's up to provided 'filter' to make sure looping is not infinite - // otherwise this may result in StackOverflowError - return hasNext(); - } - } - return false; - } - - @Override - public synchronized T next() { - if (hasNext()) { - T v = next; - next = null; - return v; - } - throw new NoSuchElementException(); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/Flattened2DList.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/Flattened2DList.java deleted file mode 100644 index f0cdc6a500..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/Flattened2DList.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.AbstractList; -import java.util.List; - -/** - * 2D list of lists of the same size represented as a single list. - * Useful for proxying lists of nested entities for example client roles of clients. - * - * @author tkyjovsk - * @param type of X-list items - * @param type of Y-list items - */ -public abstract class Flattened2DList extends AbstractList { - - public abstract List getXList(); - - @Override - public int size() { - return getXList().size() * getYListSize(); - } - - @Override - public YT get(int index) { - int x = index % getXList().size(); - int y = index / getXList().size(); - return getYList(getXList().get(x)).get(y); - } - - public abstract List getYList(XT xList); - - public abstract int getYListSize(); - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/ListOfLists.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/ListOfLists.java deleted file mode 100644 index 74a74055a7..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/ListOfLists.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.AbstractList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import org.apache.commons.lang.Validate; -import org.keycloak.performance.util.Loggable; - -/** - * - * @author tkyjovsk - */ -public class ListOfLists extends AbstractList implements Loggable { - - private final List> listOfLists = new LinkedList<>(); - - public ListOfLists(List> listOfLists) { - this.listOfLists.addAll(listOfLists); - } - - public ListOfLists(List... lists) { - this(Arrays.asList(lists)); - } - - @Override - public E get(int index) { - E e = null; - int rIndex = index; - for (List l : listOfLists) { - int s = l.size(); - if (s > rIndex) { - e = l.get(rIndex); - break; - } else { - rIndex -= s; - } - } - Validate.notNull(e); - return e; - } - - @Override - public int size() { - return listOfLists.stream().mapToInt(List::size).sum(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/LoopingIterator.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/LoopingIterator.java deleted file mode 100644 index d28fcb187c..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/LoopingIterator.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.Collection; -import java.util.Iterator; - -/** - * @author Marko Strukelj - */ -public class LoopingIterator implements Iterator { - - private Collection collection; - private Iterator it; - - public LoopingIterator(Collection collection) { - this.collection = collection; - it = collection.iterator(); - } - - @Override - public synchronized boolean hasNext() { - return true; - } - - @Override - public synchronized T next() { - if (!it.hasNext()) { - it = collection.iterator(); - } - return it.next(); - } -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomBooleans.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomBooleans.java deleted file mode 100644 index c4934dcaa1..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomBooleans.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.AbstractList; -import java.util.Collections; -import java.util.Map; -import org.apache.commons.collections.map.LRUMap; -import static org.keycloak.performance.iteration.RandomIntegers.RANDOMS_CACHE_SIZE; -import static org.keycloak.performance.iteration.RandomIntegers.getRandomIntegers; -import org.keycloak.performance.util.ValidateNumber; - -/** - * - * @author tkyjovsk - */ -public class RandomBooleans extends AbstractList { - - private final RandomIntegers randomIntegers; - private final int truesPercentage; - - /** - * - * @param seed Random sequence seed. - * @param truesPercentage Percentage of the sequence values which should be - * true. Valid range is 0-100. - */ - public RandomBooleans(int seed, int truesPercentage) { - randomIntegers = getRandomIntegers(seed, 100); - ValidateNumber.isInRange(truesPercentage, 0, 100); - this.truesPercentage = truesPercentage; - } - - public RandomBooleans(int seed) { - this(seed, 50); - } - - @Override - public Boolean get(int index) { - return randomIntegers.get(index) < truesPercentage; - } - - @Override - public int size() { - return Integer.MAX_VALUE; - } - - private static final Map RANDOM_BOOLS_CACHE - = Collections.synchronizedMap(new LRUMap(RANDOMS_CACHE_SIZE)); - - public static synchronized RandomBooleans getRandomBooleans(int seed, int percent) { - return RANDOM_BOOLS_CACHE - .computeIfAbsent(RandomIntegers.hashCode(seed, percent), (p) -> new RandomBooleans(seed, percent)); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIntegers.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIntegers.java deleted file mode 100644 index 9c418946f2..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIntegers.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Random; -import org.apache.commons.collections.map.LRUMap; -import org.keycloak.performance.util.ValidateNumber; - -/** - * - * @author tkyjovsk - */ -public class RandomIntegers extends AbstractList { - - protected final List randoms; - protected final int seed; - protected final int bound; - - private final Random random; - - public RandomIntegers(int seed, int bound) { - this.randoms = new ArrayList<>(); - this.seed = seed; - ValidateNumber.minValue(bound, 1); - this.bound = bound; - this.random = new Random(seed); - } - - protected int nextInt() { - return bound == 0 ? random.nextInt() : random.nextInt(bound); - } - - private void generateRandomsUpTo(int index) { - int mIndex = randoms.size() - 1; - for (int i = mIndex; i < index; i++) { - randoms.add(nextInt()); - } - } - - @Override - public Integer get(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(); - } - generateRandomsUpTo(index); - return randoms.get(index); - } - - @Override - public int size() { - return Integer.MAX_VALUE; - } - - @Override - public int hashCode() { - return hashCode(seed, bound); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final RandomIntegers other = (RandomIntegers) obj; - if (this.seed != other.seed) { - return false; - } - return this.bound == other.bound; - } - - public static int hashCode(int seed, int bound) { - int hash = 5; - hash = 41 * hash + seed; - hash = 41 * hash + bound; - return hash; - } - - public static final int RANDOMS_CACHE_SIZE = Integer.parseInt(System.getProperty("randoms.cache.size", "10000")); - - private static final Map RANDOM_INTS_CACHE - = Collections.synchronizedMap(new LRUMap(RANDOMS_CACHE_SIZE)); - - public static synchronized RandomIntegers getRandomIntegers(int seed, int bound) { - return RANDOM_INTS_CACHE.computeIfAbsent(hashCode(seed, bound), r -> new RandomIntegers(seed, bound)); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIterator.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIterator.java deleted file mode 100644 index 6072a84e98..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomIterator.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ThreadLocalRandom; - -/** - * - * @author tkyjovsk - */ -public class RandomIterator implements Iterator { - - List list; - - public RandomIterator(List iteratedList) { - this.list = iteratedList; - } - - @Override - public boolean hasNext() { - return true; - } - - @Override - public T next() { - return list.get(ThreadLocalRandom.current().nextInt(list.size())); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomSublist.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomSublist.java deleted file mode 100644 index 846f6df6d6..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/RandomSublist.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.AbstractList; -import java.util.Collections; -import java.util.List; -import org.apache.commons.lang.Validate; -import static org.keycloak.performance.iteration.RandomIntegers.getRandomIntegers; -import static org.keycloak.performance.iteration.UniqueRandomIntegers.getUniqueRandomIntegers; -import org.keycloak.performance.util.ValidateNumber; - -/** - * - * @author tkyjovsk - * @param - */ -public class RandomSublist extends AbstractList { - - private final List originalList; - - private final List randomIndexesOfOriginalList; - - private final int size; - - public RandomSublist(List originalList, int seed, int sublistSize, boolean unique) { - Validate.notNull(originalList); - this.originalList = originalList; - ValidateNumber.isInRange(sublistSize, 0, originalList.size()); - this.size = sublistSize; - this.randomIndexesOfOriginalList = originalList.isEmpty() - ? Collections.emptyList() - : (unique - ? getUniqueRandomIntegers(seed, originalList.size()) - : getRandomIntegers(seed, originalList.size())); - } - - public RandomSublist(List originalList, int seed, int sublistSize) { - this(originalList, seed, sublistSize, false); - } - - @Override - public T get(int index) { - if (index < 0 || index >= size) { - throw new IndexOutOfBoundsException(); - } - return originalList.get(randomIndexesOfOriginalList.get(index)); - } - - @Override - public int size() { - return size; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/UniqueRandomIntegers.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/UniqueRandomIntegers.java deleted file mode 100644 index 6b4255f7a9..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/iteration/UniqueRandomIntegers.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author tkyjovsk - */ -public class UniqueRandomIntegers extends RandomIntegers { - - private static final Map> UNIQUE_RANDOM_INTS_CACHE = new HashMap<>(); - - public UniqueRandomIntegers(int seed, int bound) { - super(seed, bound); - } - - @Override - protected int nextInt() { - int n = super.nextInt(); - return randoms.contains(n) ? nextInt() : n; - } - - @Override - public Integer get(int index) { - if (index >= bound) { - throw new IndexOutOfBoundsException(String.format( - "Sequence of unique random integers from interval [0,%s) only contains %s items. Requested index: %s, is out of bounds.", - bound, bound, index - )); - } - return super.get(index); - } - - public static synchronized UniqueRandomIntegers getUniqueRandomIntegers(int seed, int bound) { - return UNIQUE_RANDOM_INTS_CACHE - .computeIfAbsent(seed, (s) -> new HashMap<>()) - .computeIfAbsent(bound, (b) -> new UniqueRandomIntegers(seed, b)); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/DatasetTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/DatasetTemplate.java deleted file mode 100644 index 51e5167807..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/DatasetTemplate.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.keycloak.performance.templates; - -import java.io.File; -import java.util.List; -import org.apache.commons.configuration.CombinedConfiguration; -import org.keycloak.performance.templates.idm.RealmTemplate; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.lang.Validate; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.DatasetRepresentation; -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.performance.dataset.idm.Realm; -import org.keycloak.performance.dataset.idm.User; -import org.keycloak.performance.iteration.Flattened2DList; -import org.keycloak.performance.util.CombinedConfigurationNoInterpolation; -import static org.keycloak.performance.util.ConfigurationUtil.loadFromFile; - -/** - * - * @author tkyjovsk - */ -public class DatasetTemplate extends EntityTemplate { - - protected final RealmTemplate realmTemplate; - - public DatasetTemplate(Configuration configuration) { - super(configuration); - this.realmTemplate = new RealmTemplate(this); - } - - public DatasetTemplate() { - this(loadConfiguration()); - } - - protected static Configuration loadConfiguration() { - try { - CombinedConfiguration configuration = new CombinedConfigurationNoInterpolation(); - String datasetPropertiesFile = System.getProperty("dataset.properties.file"); - Validate.notEmpty(datasetPropertiesFile); - configuration.addConfiguration(loadFromFile(new File(datasetPropertiesFile))); - return configuration; - } catch (ConfigurationException ex) { - throw new RuntimeException(ex); - } - } - - @Override - public Dataset newEntity() { - return new Dataset(); - } - - @Override - public void processMappings(Dataset dataset) { - dataset.setRealms(new NestedEntityTemplateWrapperList<>(dataset, realmTemplate)); - dataset.setAllUsers(new Flattened2DList() { - @Override - public List getXList() { - return dataset.getRealms(); - } - - @Override - public List getYList(Realm realm) { - return realm.getUsers(); - } - - @Override - public int getYListSize() { - return realmTemplate.userTemplate.usersPerRealm; - } - }); - dataset.setAllClients(new Flattened2DList() { - @Override - public List getXList() { - return dataset.getRealms(); - } - - @Override - public List getYList(Realm realm) { - return realm.getClients(); - } - - @Override - public int getYListSize() { - return realmTemplate.clientTemplate.clientsPerRealm; - } - }); - } - - @Override - public void validateConfiguration() { - realmTemplate.validateConfiguration(); - logger().info(""); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityObjectWrapper.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityObjectWrapper.java deleted file mode 100644 index e48e61b743..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityObjectWrapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.keycloak.performance.templates; - -import freemarker.template.DefaultObjectWrapper; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; -import java.util.Collections; -import java.util.Map; -import org.apache.commons.collections.map.LRUMap; -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.NestedEntity; -import org.keycloak.performance.util.Loggable; - -/** - * - * @author tkyjovsk - */ -public class EntityObjectWrapper extends DefaultObjectWrapper implements Loggable { - - public static final int TEMPLATE_CACHE_SIZE = Integer.parseInt(System.getProperty("template.cache.size", "10000")); - public static final EntityObjectWrapper INSTANCE = new EntityObjectWrapper(); - - private final Map modelCache = Collections.synchronizedMap(new LRUMap(TEMPLATE_CACHE_SIZE)); - - @Override - protected TemplateModel handleUnknownType(Object obj) throws TemplateModelException { - if (obj instanceof NestedEntity) { - return modelCache.computeIfAbsent(obj, t -> new NestedEntityTemplateModel((NestedEntity) obj, modelCache)); - } - if (obj instanceof Entity) { - return modelCache.computeIfAbsent(obj, t -> new EntityTemplateModel((Entity) obj)); - } - return super.handleUnknownType(obj); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplate.java deleted file mode 100644 index d298af72f4..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplate.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.keycloak.performance.templates; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import freemarker.template.Template; -import freemarker.template.TemplateException; -import java.io.IOException; -import java.io.StringWriter; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import org.apache.commons.configuration.Configuration; -import org.keycloak.performance.util.Loggable; -import org.keycloak.performance.dataset.Entity; -import static org.keycloak.performance.util.StringUtil.firstLetterToLowerCase; - -/** - * - * @author tkyjovsk - * @param entity - * @param representation - */ -public abstract class EntityTemplate, R> implements Loggable { - - public static final freemarker.template.Configuration FREEMARKER_CONFIG; - - public static final TypeReference MAP_TYPE_REFERENCE = new TypeReference>() { - }; - public static final ObjectMapper OBJECT_MAPPER; - - static { - FREEMARKER_CONFIG = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_26); - FREEMARKER_CONFIG.setBooleanFormat("true,false"); - FREEMARKER_CONFIG.setNumberFormat("computer"); - FREEMARKER_CONFIG.setObjectWrapper(EntityObjectWrapper.INSTANCE); - OBJECT_MAPPER = new ObjectMapper(); - OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); - OBJECT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - OBJECT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); - } - - private final Configuration configuration; - private final Map attributeTemplates = new LinkedHashMap<>(); - String configPrefix; - - public EntityTemplate(Configuration configuration) { - this.configuration = configuration; - this.configPrefix = firstLetterToLowerCase(this.getClass().getSimpleName().replaceFirst("Template$", "")); - registerAttributeTemplates(); - } - - public Configuration getConfiguration() { - return configuration; - } - - private void registerAttributeTemplates() { - Iterator configKeys = getConfiguration().getKeys(configPrefix); - while (configKeys.hasNext()) { - String configKey = configKeys.next(); - String attributeName = configKey.replaceFirst(configPrefix + ".", ""); - String attributeTemplateDefinition = getConfiguration().getString(configKey); - logger().trace("template: " + configPrefix + " -> " + attributeName + ": " + attributeTemplateDefinition); - try { - attributeTemplates.put(attributeName, new Template(configKey, attributeTemplateDefinition, FREEMARKER_CONFIG)); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - } - - protected void processAtributeTemplates(E entity) { - Map updateMap = new HashMap<>(); - attributeTemplates.keySet().forEach((attributeName) -> { - updateMap.clear(); - try (StringWriter stringWriter = new StringWriter()) { - logger().trace("processing template for " + attributeName); - attributeTemplates.get(attributeName).process(entity, stringWriter); - updateMap.put(attributeName, stringWriter.toString()); - OBJECT_MAPPER.updateValue(entity.getRepresentation(), updateMap); - } catch (IOException | TemplateException ex) { - throw new RuntimeException(ex); - } - }); - } - - public E processEntity(E entity) { - processAttributes(entity); - processMappings(entity); - return entity; - } - - public synchronized E produce() { - return processEntity(newEntity()); - } - - public abstract E newEntity(); - - public E processAttributes(E entity) { - processAtributeTemplates(entity); - return entity; - } - - public abstract void processMappings(E entity); - - public abstract void validateConfiguration(); - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplateModel.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplateModel.java deleted file mode 100644 index a1690375e3..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/EntityTemplateModel.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.keycloak.performance.templates; - -import freemarker.template.AdapterTemplateModel; -import freemarker.template.Configuration; -import freemarker.template.DefaultObjectWrapperBuilder; -import freemarker.template.ObjectWrapper; -import freemarker.template.TemplateHashModel; -import freemarker.template.TemplateHashModelEx; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateModelIterator; -import org.apache.commons.lang.Validate; -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.util.Loggable; - -/** - * Merges template models of entity object and representation into a single - * model. - * - * @author tkyjovsk - */ -public class EntityTemplateModel implements TemplateHashModel, AdapterTemplateModel, Loggable { - - private static final DefaultObjectWrapperBuilder DOWB = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_26); - private static final ObjectWrapper DEFAULT_OBJECT_WRAPPER = DOWB.build(); - - private Entity entity; - private TemplateHashModel entityModel; - private TemplateHashModel representationModel; - - public EntityTemplateModel(Entity entity) { -// logger().debug("model for: " + entity.simpleClassName() + ", r: " + entity.getRepresentation().getClass().getSimpleName()); - try { - Validate.notNull(entity); - this.entity = entity; - this.entityModel = (TemplateHashModel) DEFAULT_OBJECT_WRAPPER.wrap(entity); - this.representationModel = (TemplateHashModel) DEFAULT_OBJECT_WRAPPER.wrap(entity.getRepresentation()); - } catch (TemplateModelException ex) { - throw new RuntimeException(ex); - } - } - - public Entity getEntity() { - return entity; - } - - @Override - public TemplateModel get(String key) throws TemplateModelException { - TemplateModel m = null; - if (m == null) { - m = representationModel.get(key); - } - if (m == null) { - m = entityModel.get(key); - } - if (m == null) { - logger().error("key " + key + " not found for entity: " + entity); - } - return m; - } - - @Override - public boolean isEmpty() throws TemplateModelException { - return entityModel.isEmpty() && representationModel.isEmpty(); - } - - @Override - public Entity getAdaptedObject(Class hint) { - return entity; - } - - public static String modelExToString(TemplateHashModelEx thme) { - StringBuilder sb = new StringBuilder(); - TemplateModelIterator i; - try { - i = thme.keys().iterator(); - while (i.hasNext()) { - TemplateModel k = i.next(); - TemplateModel v = thme.get(k.toString()); - sb.append(" - ").append(k).append("=").append(v).append('\n'); - } - } catch (TemplateModelException ex) { - throw new RuntimeException(ex); - } - return sb.toString(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplate.java deleted file mode 100644 index a3310b40a1..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplate.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.keycloak.performance.templates; - -import java.util.Collections; -import java.util.Map; -import org.apache.commons.collections.map.LRUMap; -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.NestedEntity; - -/** - * - * @author tkyjovsk - * @param - * @param - * @param - */ -public abstract class NestedEntityTemplate, R> - extends EntityTemplate { - - private final EntityTemplate parentEntityTemplate; - - public static final int ENTITY_CACHE_SIZE = Integer.parseInt(System.getProperty("entity.cache.size", "100000")); - - private final Map cache = Collections.synchronizedMap(new LRUMap(ENTITY_CACHE_SIZE)); - - public NestedEntityTemplate(EntityTemplate parentEntityTemplate) { - super(parentEntityTemplate.getConfiguration()); - this.parentEntityTemplate = parentEntityTemplate; - } - - public EntityTemplate getParentEntityTemplate() { - return parentEntityTemplate; - } - - public abstract int getEntityCountPerParent(); - - public abstract NE newEntity(PE parentEntity, int index); - - public NE newEntity(PE parentEntity) { - return newEntity(parentEntity, 0); - } - - @Override - public NE newEntity() { - throw new UnsupportedOperationException("Nested entity must have a parent entity."); - } - - public NE produce(PE parentEntity, int index) { - int entityHashcode = configPrefix.hashCode() * index + parentEntity.hashCode(); - return cache.computeIfAbsent(entityHashcode, e -> processEntity(newEntity(parentEntity, index))); - } - - public NE produce(PE parentEntity) { - return produce(parentEntity, 0); - } - - @Override - public NE produce() { - throw new UnsupportedOperationException("Nested entity must have a parent entity."); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateModel.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateModel.java deleted file mode 100644 index 0ddf1e4731..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateModel.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.keycloak.performance.templates; - -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; -import java.util.Map; -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.NestedEntity; -import static org.keycloak.performance.util.StringUtil.firstLetterToLowerCase; - -/** - * - * @author tkyjovsk - */ -public class NestedEntityTemplateModel extends EntityTemplateModel { - - private TemplateModel parentEntityModel; - private String parentKey = null; - - public NestedEntityTemplateModel(NestedEntity entity, Map modelCache) { - super(entity); - try { - Entity parent = ((NestedEntity) entity).getParentEntity(); - this.parentEntityModel = (modelCache == null || !modelCache.containsKey(parent)) - ? EntityObjectWrapper.INSTANCE.wrap(parent) - : modelCache.get(parent); - this.parentKey = firstLetterToLowerCase(parent.simpleClassName()); - } catch (TemplateModelException ex) { - throw new RuntimeException(ex); - } - } - - public NestedEntityTemplateModel(NestedEntity entity) { - this(entity, null); - } - - @Override - public TemplateModel get(String key) throws TemplateModelException { - TemplateModel m = super.get(key); - if (key.equals(parentKey)) { - m = parentEntityModel; - } - return m; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateWrapperList.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateWrapperList.java deleted file mode 100644 index 03bb6dcc99..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/NestedEntityTemplateWrapperList.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.keycloak.performance.templates; - -import java.util.AbstractList; -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.NestedEntity; - -/** - * A wrapper list for NestedEntityTemplate which delegates to the - template if requested element is absent in cache. - * - * @author tkyjovsk - * @param parent entity type - * @param child entity type - */ -public class NestedEntityTemplateWrapperList, R> extends AbstractList { - - PE parentEntity; - NestedEntityTemplate nestedEntityTemplate; - - public NestedEntityTemplateWrapperList(PE parentEntity, NestedEntityTemplate nestedEntityTemplate) { - this.parentEntity = parentEntity; - this.nestedEntityTemplate = nestedEntityTemplate; - } - - @Override - public int size() { - return nestedEntityTemplate.getEntityCountPerParent(); - } - - @Override - public NIE get(int index) { - return nestedEntityTemplate.produce(parentEntity, index); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringAttributeTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringAttributeTemplate.java deleted file mode 100644 index 42f523be16..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringAttributeTemplate.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.keycloak.performance.templates.attr; - -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.attr.StringAttribute; -import org.keycloak.performance.dataset.attr.StringAttributeRepresentation; -import org.keycloak.performance.templates.EntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplate; - -/** - * - * @author tkyjovsk - * @param owner entity - */ -public abstract class StringAttributeTemplate - extends NestedEntityTemplate, StringAttributeRepresentation> { - - public StringAttributeTemplate(EntityTemplate parentEntityTemplate) { - super(parentEntityTemplate); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringListAttributeTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringListAttributeTemplate.java deleted file mode 100644 index 47669a09ab..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/attr/StringListAttributeTemplate.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.keycloak.performance.templates.attr; - -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.attr.StringListAttribute; -import org.keycloak.performance.dataset.attr.StringListAttributeRepresentation; -import org.keycloak.performance.templates.EntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplate; - -/** - * - * @author tkyjovsk - * @param owner entity - */ -public abstract class StringListAttributeTemplate - extends NestedEntityTemplate, StringListAttributeRepresentation> { - - public StringListAttributeTemplate(EntityTemplate parentEntityTemplate) { - super(parentEntityTemplate); - } - - @Override - public void processMappings(StringListAttribute entity) { - } - - @Override - public StringListAttribute newEntity(PE parentEntity, int index) { - return new StringListAttribute<>(parentEntity, index); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientRoleTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientRoleTemplate.java deleted file mode 100644 index 70b9fefce0..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientRoleTemplate.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.keycloak.performance.templates.idm; - -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.performance.dataset.idm.ClientRole; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.RoleRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ClientRoleTemplate extends NestedEntityTemplate { - - public static final String CLIENT_ROLES_PER_CLIENT = "clientRolesPerClient"; - - public final int clientRolesPerClient; - public final int clientRolesTotal; - - public ClientRoleTemplate(ClientTemplate clientTemplate) { - super(clientTemplate); - this.clientRolesPerClient = getConfiguration().getInt(CLIENT_ROLES_PER_CLIENT, 0); - this.clientRolesTotal = clientRolesPerClient * clientTemplate.clientsTotal; - } - - public ClientTemplate clientTemplate() { - return (ClientTemplate) getParentEntityTemplate(); - } - - @Override - public int getEntityCountPerParent() { - return clientRolesPerClient; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s, total: %s", CLIENT_ROLES_PER_CLIENT, clientRolesPerClient, clientRolesTotal)); - ValidateNumber.minValue(clientRolesPerClient, 0); - } - - @Override - public ClientRole newEntity(Client parentEntity, int index) { - return new ClientRole(parentEntity, index); - } - - @Override - public void processMappings(ClientRole entity) { - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientTemplate.java deleted file mode 100644 index 0aae179e91..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/ClientTemplate.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.keycloak.performance.templates.idm; - -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.performance.dataset.idm.Realm; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplateWrapperList; -import org.keycloak.performance.templates.idm.authorization.ResourceServerTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.ClientRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ClientTemplate extends NestedEntityTemplate { - - public static final String CLIENTS_PER_REALM = "clientsPerRealm"; - - public final int clientsPerRealm; - public final int clientsTotal; - - public final ClientRoleTemplate clientRoleTemplate; - public final ResourceServerTemplate resourceServerTemplate; - - public ClientTemplate(RealmTemplate realmTemplate) { - super(realmTemplate); - - this.clientsPerRealm = getConfiguration().getInt(CLIENTS_PER_REALM, 0); - this.clientsTotal = clientsPerRealm * realmTemplate.realms; - - this.clientRoleTemplate = new ClientRoleTemplate(this); - this.resourceServerTemplate = new ResourceServerTemplate(this); - } - - public RealmTemplate realmTemplate() { - return (RealmTemplate) getParentEntityTemplate(); - } - - @Override - public int getEntityCountPerParent() { - return clientsPerRealm; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s, total: %s", CLIENTS_PER_REALM, clientsPerRealm, clientsTotal)); - ValidateNumber.minValue(clientsPerRealm, 0); - - clientRoleTemplate.validateConfiguration(); - resourceServerTemplate.validateConfiguration(); - } - - @Override - public Client newEntity(Realm parentEntity, int index) { - return new Client(parentEntity, index); - } - - @Override - public void processMappings(Client client) { - client.setClientRoles(new NestedEntityTemplateWrapperList<>(client, clientRoleTemplate)); - - if (client.getRepresentation().getAuthorizationServicesEnabled()) { - client.setResourceServer(resourceServerTemplate.produce(client)); - } - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/GroupTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/GroupTemplate.java deleted file mode 100644 index 46b7ee22bb..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/GroupTemplate.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.keycloak.performance.templates.idm; - -import org.keycloak.performance.dataset.attr.AttributeMap; -import org.keycloak.performance.dataset.idm.Group; -import org.keycloak.performance.dataset.idm.Realm; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplateWrapperList; -import org.keycloak.performance.templates.attr.StringListAttributeTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.GroupRepresentation; - -/** - * - * @author tkyjovsk - */ -public class GroupTemplate extends NestedEntityTemplate { - - public static final String GROUPS_PER_REALM = "groupsPerRealm"; - - public final int groupsPerRealm; - public final int groupsTotal; - - public final GroupAttributeTemplate attributeTemplate; - - public GroupTemplate(RealmTemplate realmTemplate) { - super(realmTemplate); - this.groupsPerRealm = getConfiguration().getInt(GROUPS_PER_REALM, 0); - this.groupsTotal = groupsPerRealm * realmTemplate.realms; - this.attributeTemplate = new GroupAttributeTemplate(); - } - - public RealmTemplate realmTemplate() { - return (RealmTemplate) getParentEntityTemplate(); - } - - @Override - public Group newEntity(Realm parentEntity, int index) { - return new Group(parentEntity, index); - } - - @Override - public void processMappings(Group group) { - group.getRepresentation().setAttributes(new AttributeMap(new NestedEntityTemplateWrapperList<>(group, attributeTemplate))); - } - - @Override - public int getEntityCountPerParent() { - return groupsPerRealm; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s, total: %s", GROUPS_PER_REALM, groupsPerRealm, groupsTotal)); - ValidateNumber.minValue(groupsPerRealm, 0); - - attributeTemplate.validateConfiguration(); - } - - public class GroupAttributeTemplate extends StringListAttributeTemplate { - - public static final String ATTRIBUTES_PER_GROUP = "attributesPerGroup"; - - public final int attributesPerGroup; - public final int attributesTotal; - - public GroupAttributeTemplate() { - super(GroupTemplate.this); - this.attributesPerGroup = getConfiguration().getInt(ATTRIBUTES_PER_GROUP, 0); - this.attributesTotal = attributesPerGroup * groupsTotal; - } - - @Override - public int getEntityCountPerParent() { - return attributesPerGroup; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", ATTRIBUTES_PER_GROUP, attributesPerGroup)); - ValidateNumber.minValue(attributesPerGroup, 0); - } - - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmRoleTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmRoleTemplate.java deleted file mode 100644 index 10437590e4..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmRoleTemplate.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.keycloak.performance.templates.idm; - -import org.keycloak.performance.dataset.idm.Realm; -import org.keycloak.performance.dataset.idm.RealmRole; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.RoleRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RealmRoleTemplate extends NestedEntityTemplate { - - public static final String REALM_ROLES_PER_REALM = "realmRolesPerRealm"; - - public final int realmRolesPerRealm; - public final int realmRolesTotal; - - public RealmRoleTemplate(RealmTemplate realmTemplate) { - super(realmTemplate); - this.realmRolesPerRealm = getConfiguration().getInt(REALM_ROLES_PER_REALM, 0); - this.realmRolesTotal = realmRolesPerRealm * realmTemplate.realms; - } - - public RealmTemplate realmTemplate() { - return (RealmTemplate) getParentEntityTemplate(); - } - - @Override - public int getEntityCountPerParent() { - return realmRolesPerRealm; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s, total: %s", REALM_ROLES_PER_REALM, realmRolesPerRealm, realmRolesTotal)); - ValidateNumber.minValue(realmRolesPerRealm, 0); - } - - @Override - public RealmRole newEntity(Realm parentEntity, int index) { - return new RealmRole(parentEntity, index); - } - - @Override - public void processMappings(RealmRole role) { - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmTemplate.java deleted file mode 100644 index 150477060a..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/RealmTemplate.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.keycloak.performance.templates.idm; - -import java.util.List; -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.performance.dataset.idm.ClientRole; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.iteration.Flattened2DList; -import org.keycloak.performance.dataset.idm.Realm; -import org.keycloak.performance.dataset.idm.authorization.ResourceServerList; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplateWrapperList; -import org.keycloak.performance.templates.DatasetTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.RealmRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RealmTemplate extends NestedEntityTemplate { - - public static final String REALMS = "realms"; - - public final int realms; - - public final ClientTemplate clientTemplate; - public final RealmRoleTemplate realmRoleTemplate; - public final UserTemplate userTemplate; - public final GroupTemplate groupTemplate; - - public RealmTemplate(DatasetTemplate datasetTemplate) { - super(datasetTemplate); - this.realms = getConfiguration().getInt(REALMS, 0); - this.clientTemplate = new ClientTemplate(this); - this.realmRoleTemplate = new RealmRoleTemplate(this); - this.userTemplate = new UserTemplate(this); - this.groupTemplate = new GroupTemplate(this); - } - - @Override - public int getEntityCountPerParent() { - return realms; - } - - @Override - public void validateConfiguration() { - // sizing - logger().info(String.format("%s: %s", REALMS, realms)); - ValidateNumber.minValue(realms, 0); - - clientTemplate.validateConfiguration(); - realmRoleTemplate.validateConfiguration(); - userTemplate.validateConfiguration(); - groupTemplate.validateConfiguration(); - } - - @Override - public Realm newEntity(Dataset parentEntity, int index) { - return new Realm(parentEntity, index); - } - - @Override - public void processMappings(Realm realm) { - realm.setClients(new NestedEntityTemplateWrapperList<>(realm, clientTemplate)); - realm.setResourceServers(new ResourceServerList(realm.getClients())); - realm.setClientRoles(new Flattened2DList() { - @Override - public List getXList() { - return realm.getClients(); - } - - @Override - public List getYList(Client client) { - return client.getClientRoles(); - } - - @Override - public int getYListSize() { - return clientTemplate.clientRoleTemplate.clientRolesPerClient; - } - }); - realm.setRealmRoles(new NestedEntityTemplateWrapperList<>(realm, realmRoleTemplate)); - realm.setUsers(new NestedEntityTemplateWrapperList<>(realm, userTemplate)); - realm.setGroups(new NestedEntityTemplateWrapperList<>(realm, groupTemplate)); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/UserTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/UserTemplate.java deleted file mode 100644 index 89fef03e05..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/UserTemplate.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.keycloak.performance.templates.idm; - -import java.util.LinkedList; -import java.util.List; -import static java.util.stream.Collectors.toList; -import org.keycloak.performance.dataset.attr.AttributeMap; -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.performance.dataset.idm.ClientRole; -import org.keycloak.performance.dataset.idm.ClientRoleMappings; -import org.keycloak.performance.dataset.idm.Credential; -import org.keycloak.performance.dataset.idm.Realm; -import org.keycloak.performance.dataset.idm.RealmRole; -import org.keycloak.performance.dataset.idm.RoleMappings; -import org.keycloak.performance.dataset.idm.RoleMappingsRepresentation; -import org.keycloak.performance.dataset.idm.User; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplateWrapperList; -import org.keycloak.performance.templates.attr.StringListAttributeTemplate; -import org.keycloak.performance.iteration.RandomSublist; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.CredentialRepresentation; -import org.keycloak.representations.idm.UserRepresentation; - -/** - * - * @author tkyjovsk - */ -public class UserTemplate extends NestedEntityTemplate { - - public static final String USERS_PER_REALM = "usersPerRealm"; - public static final String REALM_ROLES_PER_USER = "realmRolesPerUser"; - public static final String CLIENT_ROLES_PER_USER = "clientRolesPerUser"; - - public final int usersPerRealm; - public final int usersTotal; - public final int realmRolesPerUser; - public final int clientRolesPerUser; - - public final UserAttributeTemplate attributeTemplate; - public final CredentialTemplate credentialTemplate; - - public UserTemplate(RealmTemplate realmTemplate) { - super(realmTemplate); - - this.usersPerRealm = getConfiguration().getInt(USERS_PER_REALM, 0); - this.usersTotal = usersPerRealm * realmTemplate.realms; - this.realmRolesPerUser = getConfiguration().getInt(REALM_ROLES_PER_USER, 0); - this.clientRolesPerUser = getConfiguration().getInt(CLIENT_ROLES_PER_USER, 0); - - this.attributeTemplate = new UserAttributeTemplate(); - this.credentialTemplate = new CredentialTemplate(); - } - - public RealmTemplate realmTemplate() { - return (RealmTemplate) getParentEntityTemplate(); - } - - @Override - public User newEntity(Realm parentEntity, int index) { - return new User(parentEntity, index); - } - - @Override - public void processMappings(User user) { - - user.setCredentials(new NestedEntityTemplateWrapperList<>(user, credentialTemplate)); - - // note: attributes are embedded in user rep. - user.getRepresentation().setAttributes(new AttributeMap(new NestedEntityTemplateWrapperList<>(user, attributeTemplate))); - - // REALM ROLE MAPPINGS - List realmRoles = new RandomSublist( - user.getRealm().getRealmRoles(), // original list - user.hashCode(), // random seed - realmRolesPerUser, // sublist size - false // unique randoms? - ); - RoleMappingsRepresentation rmr = new RoleMappingsRepresentation(); - realmRoles.forEach(rr -> rmr.add(rr.getRepresentation())); - user.setRealmRoleMappings(new RoleMappings<>(user, rmr)); - - // CLIENT ROLE MAPPINGS - List clientRoles = new RandomSublist( - user.getRealm().getClientRoles(), // original list - user.hashCode(), // random seed - clientRolesPerUser, // sublist size - false // unique randoms? - ); - - List> clientRoleMappingsList = new LinkedList<>(); - List clients = clientRoles.stream().map(ClientRole::getClient).distinct().collect(toList()); - clients.forEach(client -> { - List clientClientRoles = clientRoles.stream().filter(clientRole - -> client.equals(clientRole.getClient())) - .collect(toList()); - - RoleMappingsRepresentation cmr = new RoleMappingsRepresentation(); - clientClientRoles.forEach(cr -> cmr.add(cr.getRepresentation())); - - ClientRoleMappings crm = new ClientRoleMappings(user, client, cmr); - clientRoleMappingsList.add(crm); - }); - user.setClientRoleMappingsList(clientRoleMappingsList); - } - - @Override - public int getEntityCountPerParent() { - return usersPerRealm; - } - - @Override - public void validateConfiguration() { - - // sizing - logger().info(String.format("%s: %s, total: %s", USERS_PER_REALM, usersPerRealm, usersTotal)); - ValidateNumber.minValue(usersPerRealm, 0); - - // mappings - attributeTemplate.validateConfiguration(); - - logger().info(String.format("%s: %s", REALM_ROLES_PER_USER, realmRolesPerUser)); - ValidateNumber.isInRange(realmRolesPerUser, 0, - realmTemplate().realmRoleTemplate.realmRolesPerRealm); - - logger().info(String.format("%s: %s", CLIENT_ROLES_PER_USER, clientRolesPerUser)); - ClientTemplate ct = realmTemplate().clientTemplate; - ValidateNumber.isInRange(clientRolesPerUser, 0, - ct.clientsPerRealm * ct.clientRoleTemplate.clientRolesPerClient); - - } - - public class CredentialTemplate extends NestedEntityTemplate { - - public CredentialTemplate() { - super(UserTemplate.this); - } - - @Override - public int getEntityCountPerParent() { - return 1; - } - - @Override - public void validateConfiguration() { - } - - @Override - public Credential newEntity(User parentEntity, int index) { - return new Credential(parentEntity, index); - } - - @Override - public void processMappings(Credential entity) { - } - - } - - public class UserAttributeTemplate extends StringListAttributeTemplate { - - public static final String ATTRIBUTES_PER_USER = "attributesPerUser"; - - public final int attributesPerUser; - public final int attributesTotal; - - public UserAttributeTemplate() { - super(UserTemplate.this); - this.attributesPerUser = getConfiguration().getInt(ATTRIBUTES_PER_USER, 0); - this.attributesTotal = attributesPerUser * usersTotal; - } - - @Override - public int getEntityCountPerParent() { - return attributesPerUser; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", ATTRIBUTES_PER_USER, attributesPerUser)); - ValidateNumber.minValue(attributesPerUser, 0); - } - - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ClientPolicyTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ClientPolicyTemplate.java deleted file mode 100644 index 9da91e6f27..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ClientPolicyTemplate.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import static java.util.stream.Collectors.toSet; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.dataset.idm.authorization.ClientPolicy; -import org.keycloak.performance.iteration.RandomSublist; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.ClientPolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ClientPolicyTemplate extends PolicyTemplate { - - public static final String CLIENT_POLICIES_PER_RESOURCE_SERVER = "clientPoliciesPerResourceServer"; - public static final String CLIENTS_PER_CLIENT_POLICY = "clientsPerClientPolicy"; - - public final int clientPoliciesPerResourceServer; - public final int clientsPerClientPolicy; - - public ClientPolicyTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.clientPoliciesPerResourceServer = getConfiguration().getInt(CLIENT_POLICIES_PER_RESOURCE_SERVER, 0); - this.clientsPerClientPolicy = getConfiguration().getInt(CLIENTS_PER_CLIENT_POLICY, 0); - } - - @Override - public int getEntityCountPerParent() { - return clientPoliciesPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", CLIENT_POLICIES_PER_RESOURCE_SERVER, clientPoliciesPerResourceServer)); - ValidateNumber.minValue(clientPoliciesPerResourceServer, 0); - - logger().info(String.format("%s: %s", CLIENTS_PER_CLIENT_POLICY, clientsPerClientPolicy)); - ValidateNumber.isInRange(clientsPerClientPolicy, 0, - resourceServerTemplate().clientTemplate().realmTemplate().clientTemplate.clientsPerRealm); - } - - @Override - public ClientPolicy newEntity(ResourceServer parentEntity, int index) { - return new ClientPolicy(parentEntity, index); - } - - @Override - public void processMappings(ClientPolicy policy) { - policy.setClients(new RandomSublist<>( - policy.getResourceServer().getClient().getRealm().getClients(), // original list - policy.hashCode(), // random seed - clientsPerClientPolicy, // sublist size - false // unique randoms? - )); - policy.getRepresentation().setClients(policy.getClients() - .stream().map(u -> u.getId()) - .filter(id -> id != null) // need non-null policy IDs - .collect(toSet())); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/JsPolicyTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/JsPolicyTemplate.java deleted file mode 100644 index 71def1b720..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/JsPolicyTemplate.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import org.keycloak.performance.dataset.idm.authorization.JsPolicy; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.JSPolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class JsPolicyTemplate extends PolicyTemplate { - - public static final String JS_POLICIES_PER_RESOURCE_SERVER = "jsPoliciesPerResourceServer"; - - public final int jsPoliciesPerResourceServer; - - public JsPolicyTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.jsPoliciesPerResourceServer = getConfiguration().getInt(JS_POLICIES_PER_RESOURCE_SERVER, 0); - } - - public int getJsPoliciesPerResourceServer() { - return jsPoliciesPerResourceServer; - } - - @Override - public int getEntityCountPerParent() { - return jsPoliciesPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", JS_POLICIES_PER_RESOURCE_SERVER, jsPoliciesPerResourceServer)); - ValidateNumber.minValue(jsPoliciesPerResourceServer, 0); - } - - @Override - public JsPolicy newEntity(ResourceServer parentEntity, int index) { - return new JsPolicy(parentEntity, index); - } - - @Override - public void processMappings(JsPolicy policy) { - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/PolicyTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/PolicyTemplate.java deleted file mode 100644 index a75654e87e..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/PolicyTemplate.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import org.keycloak.performance.dataset.idm.authorization.Policy; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.representations.idm.authorization.AbstractPolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public abstract class PolicyTemplate, R extends AbstractPolicyRepresentation> - extends NestedEntityTemplate { - - public PolicyTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - } - - public ResourceServerTemplate resourceServerTemplate() { - return (ResourceServerTemplate) getParentEntityTemplate(); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourcePermissionTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourcePermissionTemplate.java deleted file mode 100644 index 4d021e76a6..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourcePermissionTemplate.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import static java.util.stream.Collectors.toSet; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.dataset.idm.authorization.ResourcePermission; -import org.keycloak.performance.iteration.RandomSublist; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.ResourcePermissionRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ResourcePermissionTemplate extends PolicyTemplate { - - public static final String RESOURCE_PERMISSIONS_PER_RESOURCE_SERVER = "resourcePermissionsPerResourceServer"; - public static final String RESOURCES_PER_RESOURCE_PERMISSION = "resourcesPerResourcePermission"; - public static final String POLICIES_PER_RESOURCE_PERMISSION = "policiesPerResourcePermission"; - - public final int resourcePermissionsPerResourceServer; - public final int resourcesPerResourcePermission; - public final int policiesPerResourcePermission; - - public ResourcePermissionTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.resourcePermissionsPerResourceServer = getConfiguration().getInt(RESOURCE_PERMISSIONS_PER_RESOURCE_SERVER, 0); - this.resourcesPerResourcePermission = getConfiguration().getInt(RESOURCES_PER_RESOURCE_PERMISSION, 0); // should be 1 but that doesn't work with 0 resource servers - this.policiesPerResourcePermission = getConfiguration().getInt(POLICIES_PER_RESOURCE_PERMISSION, 0); - } - - @Override - public int getEntityCountPerParent() { - return resourcePermissionsPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", RESOURCE_PERMISSIONS_PER_RESOURCE_SERVER, resourcePermissionsPerResourceServer)); - ValidateNumber.minValue(resourcePermissionsPerResourceServer, 0); - - logger().info(String.format("%s: %s", RESOURCES_PER_RESOURCE_PERMISSION, resourcesPerResourcePermission)); - ValidateNumber.isInRange(resourcesPerResourcePermission, 0, resourceServerTemplate().resourceTemplate.resourcesPerResourceServer); // TODO should be >=1 but that doesn't work with 0 resource servers - - logger().info(String.format("%s: %s", POLICIES_PER_RESOURCE_PERMISSION, policiesPerResourcePermission)); - ValidateNumber.isInRange(policiesPerResourcePermission, 0, resourceServerTemplate().maxPolicies); - } - - @Override - public ResourcePermission newEntity(ResourceServer parentEntity, int index) { - return new ResourcePermission(parentEntity, index); - } - - @Override - public void processMappings(ResourcePermission permission) { - String resourceType = permission.getRepresentation().getResourceType(); - if (resourceType == null || "".equals(resourceType)) { - permission.setResources(new RandomSublist<>( - permission.getResourceServer().getResources(), // original list - permission.hashCode(), // random seed - resourcesPerResourcePermission, // sublist size - false // unique randoms? - )); - permission.getRepresentation().setResources( - permission.getResources().stream() - .map(r -> r.getId()).filter(id -> id != null).collect(toSet()) - ); - } - - permission.setPolicies(new RandomSublist<>( - permission.getResourceServer().getAllPolicies(), // original list - permission.hashCode(), // random seed - policiesPerResourcePermission, // sublist size - false // unique randoms? - )); - permission.getRepresentation().setPolicies(permission.getPolicies() - .stream().map(p -> p.getId()) - .filter(id -> id != null) // need non-null policy IDs - .collect(toSet())); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceServerTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceServerTemplate.java deleted file mode 100644 index 07ac7d393b..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceServerTemplate.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import org.apache.commons.lang.Validate; -import org.keycloak.performance.templates.idm.*; -import org.keycloak.performance.dataset.idm.Client; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.iteration.ListOfLists; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplateWrapperList; -import org.keycloak.representations.idm.authorization.ResourceServerRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ResourceServerTemplate extends NestedEntityTemplate { - - public final ScopeTemplate scopeTemplate; - public final ResourceTemplate resourceTemplate; - public final RolePolicyTemplate rolePolicyTemplate; - public final JsPolicyTemplate jsPolicyTemplate; - public final UserPolicyTemplate userPolicyTemplate; - public final ClientPolicyTemplate clientPolicyTemplate; - public final ResourcePermissionTemplate resourcePermissionTemplate; - public final ScopePermissionTemplate scopePermissionTemplate; - - public final int maxPolicies; - - public ResourceServerTemplate(ClientTemplate clientTemplate) { - super(clientTemplate); - this.scopeTemplate = new ScopeTemplate(this); - this.resourceTemplate = new ResourceTemplate(this); - this.rolePolicyTemplate = new RolePolicyTemplate(this); - this.jsPolicyTemplate = new JsPolicyTemplate(this); - this.userPolicyTemplate = new UserPolicyTemplate(this); - this.clientPolicyTemplate = new ClientPolicyTemplate(this); - this.resourcePermissionTemplate = new ResourcePermissionTemplate(this); - this.scopePermissionTemplate = new ScopePermissionTemplate(this); - - this.maxPolicies = rolePolicyTemplate.rolePoliciesPerResourceServer - + jsPolicyTemplate.jsPoliciesPerResourceServer - + userPolicyTemplate.userPoliciesPerResourceServer - + clientPolicyTemplate.clientPoliciesPerResourceServer; - } - - public ClientTemplate clientTemplate() { - return (ClientTemplate) getParentEntityTemplate(); - } - - @Override - public void validateConfiguration() { - scopeTemplate.validateConfiguration(); - resourceTemplate.validateConfiguration(); - rolePolicyTemplate.validateConfiguration(); - jsPolicyTemplate.validateConfiguration(); - userPolicyTemplate.validateConfiguration(); - clientPolicyTemplate.validateConfiguration(); - resourcePermissionTemplate.validateConfiguration(); - scopePermissionTemplate.validateConfiguration(); - } - - @Override - public ResourceServer newEntity(Client client) { - Validate.notNull(client); - Validate.notNull(client.getRepresentation()); - Validate.notNull(client.getRepresentation().getBaseUrl()); - return new ResourceServer(client); - } - - @Override - public void processMappings(ResourceServer resourceServer) { - resourceServer.setScopes(new NestedEntityTemplateWrapperList<>(resourceServer, scopeTemplate)); - resourceServer.setResources(new NestedEntityTemplateWrapperList<>(resourceServer, resourceTemplate)); - - resourceServer.setRolePolicies(new NestedEntityTemplateWrapperList<>(resourceServer, rolePolicyTemplate)); - resourceServer.setJsPolicies(new NestedEntityTemplateWrapperList<>(resourceServer, jsPolicyTemplate)); - resourceServer.setUserPolicies(new NestedEntityTemplateWrapperList<>(resourceServer, userPolicyTemplate)); - resourceServer.setClientPolicies(new NestedEntityTemplateWrapperList<>(resourceServer, clientPolicyTemplate)); - resourceServer.setAllPolicies(new ListOfLists( // proxy list - resourceServer.getRolePolicies(), - resourceServer.getJsPolicies(), - resourceServer.getUserPolicies(), - resourceServer.getClientPolicies() - )); - - resourceServer.setResourcePermissions(new NestedEntityTemplateWrapperList<>(resourceServer, resourcePermissionTemplate)); - resourceServer.setScopePermissions(new NestedEntityTemplateWrapperList<>(resourceServer, scopePermissionTemplate)); - - } - - @Override - public int getEntityCountPerParent() { // parent is Client - return 1; - } - - @Override - public ResourceServer newEntity(Client parentEntity, int index) { - return newEntity(parentEntity); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceTemplate.java deleted file mode 100644 index 0af6d00d9c..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ResourceTemplate.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import java.util.List; -import static java.util.stream.Collectors.toSet; -import org.apache.commons.lang.Validate; -import org.keycloak.performance.dataset.idm.User; -import org.keycloak.performance.dataset.idm.authorization.Resource; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.iteration.RandomSublist; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.ResourceRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ResourceTemplate extends NestedEntityTemplate { - - public static final String RESOURCES_PER_RESOURCE_SERVER = "resourcesPerResourceServer"; - public static final String SCOPES_PER_RESOURCE = "scopesPerResource"; - - public final int resourcesPerResourceServer; - public final int scopesPerResource; - - public ResourceTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.resourcesPerResourceServer = getConfiguration().getInt(RESOURCES_PER_RESOURCE_SERVER, 0); - this.scopesPerResource = getConfiguration().getInt(SCOPES_PER_RESOURCE, 0); - } - - @Override - public int getEntityCountPerParent() { - return resourcesPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", RESOURCES_PER_RESOURCE_SERVER, resourcesPerResourceServer)); - ValidateNumber.minValue(resourcesPerResourceServer, 0); - - logger().info(String.format("%s: %s", SCOPES_PER_RESOURCE, scopesPerResource)); - ValidateNumber.isInRange(scopesPerResource, 0, - ((ResourceServerTemplate) getParentEntityTemplate()).scopeTemplate.scopesPerResourceServer); - } - - @Override - public Resource newEntity(ResourceServer parentEntity, int index) { - return new Resource(parentEntity, index); - } - - @Override - public void processMappings(Resource resource) { - - if (resource.getRepresentation().getOwnerManagedAccess()) { - List users = resource.getResourceServer().getClient().getRealm().getUsers(); - String ownerId = users.get(resource.indexBasedRandomInt(users.size())).getId(); // random user from the realm - Validate.notNull(ownerId, "Unable to assign user as owner of resource. Id not set."); - resource.getRepresentation().setOwner(ownerId); - } - - resource.setScopes(new RandomSublist<>( - resource.getResourceServer().getScopes(), // original list - resource.hashCode(), // random seed - scopesPerResource, // sublist size - false // unique randoms? - )); - resource.getRepresentation().setScopes( - resource.getScopes().stream().map(s -> s.getRepresentation()).collect(toSet())); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/RolePolicyTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/RolePolicyTemplate.java deleted file mode 100644 index 2f78f90f98..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/RolePolicyTemplate.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import org.apache.commons.lang.Validate; -import org.keycloak.performance.dataset.Entity; -import org.keycloak.performance.dataset.idm.Role; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.dataset.idm.authorization.RolePolicyRoleDefinition; -import org.keycloak.performance.dataset.idm.authorization.RolePolicy; -import org.keycloak.performance.dataset.idm.authorization.RolePolicyRoleDefinitionSet; -import org.keycloak.performance.iteration.ListOfLists; -import org.keycloak.performance.iteration.RandomSublist; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.templates.NestedEntityTemplateWrapperList; -import org.keycloak.performance.templates.idm.ClientRoleTemplate; -import org.keycloak.performance.templates.idm.ClientTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.RolePolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class RolePolicyTemplate extends PolicyTemplate { - - public static final String ROLE_POLICIES_PER_RESOURCE_SERVER = "rolePoliciesPerResourceServer"; - - public final int rolePoliciesPerResourceServer; - - public final RolePolicyRoleDefinitionTemplate roleDefinitionTemplate; - - public RolePolicyTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.rolePoliciesPerResourceServer = getConfiguration().getInt(ROLE_POLICIES_PER_RESOURCE_SERVER, 0); - this.roleDefinitionTemplate = new RolePolicyRoleDefinitionTemplate(); - } - - @Override - public ResourceServerTemplate resourceServerTemplate() { - return (ResourceServerTemplate) getParentEntityTemplate(); - } - - @Override - public int getEntityCountPerParent() { - return rolePoliciesPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", ROLE_POLICIES_PER_RESOURCE_SERVER, rolePoliciesPerResourceServer)); - ValidateNumber.minValue(rolePoliciesPerResourceServer, 0); - - roleDefinitionTemplate.validateConfiguration(); - } - - @Override - public RolePolicy newEntity(ResourceServer parentEntity, int index) { - return new RolePolicy(parentEntity, index); - } - - @Override - public void processMappings(RolePolicy rolePolicy) { - rolePolicy.setRoles(new ListOfLists<>( - new RandomSublist( - rolePolicy.getResourceServer().getClient().getRealm().getRealmRoles(), // original list - rolePolicy.hashCode(), // random seed - roleDefinitionTemplate.realmRolesPerRolePolicy, // sublist size - false // unique randoms? - ), - new RandomSublist( - rolePolicy.getResourceServer().getClient().getRealm().getClientRoles(), // original list - rolePolicy.hashCode(), // random seed - roleDefinitionTemplate.clientRolesPerRolePolicy, // sublist size - false // unique randoms? - ) - )); - - rolePolicy.getRepresentation().setRoles(new RolePolicyRoleDefinitionSet( - new NestedEntityTemplateWrapperList<>(rolePolicy, roleDefinitionTemplate) - )); - } - - public class RolePolicyRoleDefinitionTemplate - extends NestedEntityTemplate { - - public static final String REALM_ROLES_PER_ROLE_POLICY = "realmRolesPerRolePolicy"; - public static final String CLIENT_ROLES_PER_ROLE_POLICY = "clientRolesPerRolePolicy"; - - public final int realmRolesPerRolePolicy; - public final int clientRolesPerRolePolicy; - - public RolePolicyRoleDefinitionTemplate() { - super(RolePolicyTemplate.this); - this.realmRolesPerRolePolicy = getConfiguration().getInt(REALM_ROLES_PER_ROLE_POLICY, 0); - this.clientRolesPerRolePolicy = getConfiguration().getInt(CLIENT_ROLES_PER_ROLE_POLICY, 0); - } - - @Override - public int getEntityCountPerParent() { - return realmRolesPerRolePolicy + clientRolesPerRolePolicy; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", REALM_ROLES_PER_ROLE_POLICY, realmRolesPerRolePolicy)); - logger().info(String.format("%s: %s", CLIENT_ROLES_PER_ROLE_POLICY, clientRolesPerRolePolicy)); - - ClientTemplate ct = resourceServerTemplate().clientTemplate(); - ClientRoleTemplate crt = ct.clientRoleTemplate; - int realmRolesMax = ct.realmTemplate().realmRoleTemplate.realmRolesPerRealm; - int clientRolesMax = ct.clientsPerRealm * crt.clientRolesPerClient; - - ValidateNumber.isInRange(realmRolesPerRolePolicy, 0, realmRolesMax); - ValidateNumber.isInRange(clientRolesPerRolePolicy, 0, clientRolesMax); - - } - - @Override - public RolePolicyRoleDefinition newEntity(RolePolicy rolePolicy, int index) { - Validate.isTrue(rolePolicy.getRoles().size() == getEntityCountPerParent()); - String roleUUID = ((Role) rolePolicy.getRoles().get(index)).getRepresentation().getId(); - return new RolePolicyRoleDefinition(rolePolicy, index, new RolePolicyRepresentation.RoleDefinition(roleUUID, false)); - } - - @Override - public void processMappings(RolePolicyRoleDefinition entity) { - } - - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopePermissionTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopePermissionTemplate.java deleted file mode 100644 index 3c267c7c7f..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopePermissionTemplate.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import static java.util.stream.Collectors.toSet; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.dataset.idm.authorization.ScopePermission; -import org.keycloak.performance.iteration.RandomSublist; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.ScopePermissionRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ScopePermissionTemplate extends PolicyTemplate { - - public static final String SCOPE_PERMISSIONS_PER_RESOURCE_SERVER = "scopePermissionsPerResourceServer"; - public static final String SCOPES_PER_SCOPE_PERMISSION = "scopesPerScopePermission"; - public static final String POLICIES_PER_SCOPE_PERMISSION = "policiesPerScopePermission"; - - public final int scopePermissionsPerResourceServer; - public final int scopesPerScopePermission; - public final int policiesPerScopePermission; - - public ScopePermissionTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.scopePermissionsPerResourceServer = getConfiguration().getInt(SCOPE_PERMISSIONS_PER_RESOURCE_SERVER, 0); - this.scopesPerScopePermission = getConfiguration().getInt(SCOPES_PER_SCOPE_PERMISSION, 0); // should be 1 but that doesn't work with 0 resource servers - this.policiesPerScopePermission = getConfiguration().getInt(POLICIES_PER_SCOPE_PERMISSION, 0); - } - - @Override - public int getEntityCountPerParent() { - return scopePermissionsPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", SCOPE_PERMISSIONS_PER_RESOURCE_SERVER, scopePermissionsPerResourceServer)); - ValidateNumber.minValue(scopePermissionsPerResourceServer, 0); - - logger().info(String.format("%s: %s", SCOPES_PER_SCOPE_PERMISSION, scopesPerScopePermission)); - ValidateNumber.isInRange(scopesPerScopePermission, 0, resourceServerTemplate().scopeTemplate.scopesPerResourceServer); // TODO should be >=1 but that doesn't work with 0 resource servers - - logger().info(String.format("%s: %s", POLICIES_PER_SCOPE_PERMISSION, policiesPerScopePermission)); - ValidateNumber.isInRange(policiesPerScopePermission, 0, resourceServerTemplate().maxPolicies); - } - - @Override - public ScopePermission newEntity(ResourceServer parentEntity, int index) { - return new ScopePermission(parentEntity, index); - } - - @Override - public void processMappings(ScopePermission permission) { - - permission.setScopes(new RandomSublist<>( - permission.getResourceServer().getScopes(), // original list - permission.hashCode(), // random seed - scopesPerScopePermission, // sublist size - false // unique randoms? - )); - permission.getRepresentation().setScopes( - permission.getScopes().stream() - .map(r -> r.getId()).filter(id -> id != null).collect(toSet()) - ); - - permission.setPolicies(new RandomSublist<>( - permission.getResourceServer().getAllPolicies(), // original list - permission.hashCode(), // random seed - policiesPerScopePermission, // sublist size - false // unique randoms? - )); - permission.getRepresentation().setPolicies(permission.getPolicies() - .stream().map(p -> p.getId()) - .filter(id -> id != null) // need non-null policy IDs - .collect(toSet())); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopeTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopeTemplate.java deleted file mode 100644 index 7b76acfa7d..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/ScopeTemplate.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.dataset.idm.authorization.Scope; -import org.keycloak.performance.templates.NestedEntityTemplate; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.ScopeRepresentation; - -/** - * - * @author tkyjovsk - */ -public class ScopeTemplate extends NestedEntityTemplate { - - public static final String SCOPES_PER_RESOURCE_SERVER = "scopesPerResourceServer"; - - public final int scopesPerResourceServer; - - public ScopeTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.scopesPerResourceServer = getConfiguration().getInt(SCOPES_PER_RESOURCE_SERVER, 0); - } - - @Override - public int getEntityCountPerParent() { - return scopesPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", SCOPES_PER_RESOURCE_SERVER, scopesPerResourceServer)); - ValidateNumber.minValue(scopesPerResourceServer, 0); - } - - @Override - public Scope newEntity(ResourceServer parentEntity, int index) { - return new Scope(parentEntity, index); - } - - @Override - public void processMappings(Scope entity) { - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/UserPolicyTemplate.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/UserPolicyTemplate.java deleted file mode 100644 index 42200de839..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/templates/idm/authorization/UserPolicyTemplate.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.keycloak.performance.templates.idm.authorization; - -import static java.util.stream.Collectors.toSet; -import org.keycloak.performance.dataset.idm.authorization.ResourceServer; -import org.keycloak.performance.dataset.idm.authorization.UserPolicy; -import org.keycloak.performance.iteration.RandomSublist; -import org.keycloak.performance.util.ValidateNumber; -import org.keycloak.representations.idm.authorization.UserPolicyRepresentation; - -/** - * - * @author tkyjovsk - */ -public class UserPolicyTemplate extends PolicyTemplate { - - public static final String USER_POLICIES_PER_RESOURCE_SERVER = "userPoliciesPerResourceServer"; - public static final String USERS_PER_USER_POLICY = "usersPerUserPolicy"; - - public final int userPoliciesPerResourceServer; - public final int usersPerUserPolicy; - - public UserPolicyTemplate(ResourceServerTemplate resourceServerTemplate) { - super(resourceServerTemplate); - this.userPoliciesPerResourceServer = getConfiguration().getInt(USER_POLICIES_PER_RESOURCE_SERVER, 0); - this.usersPerUserPolicy = getConfiguration().getInt(USERS_PER_USER_POLICY, 0); - } - - @Override - public int getEntityCountPerParent() { - return userPoliciesPerResourceServer; - } - - @Override - public void validateConfiguration() { - logger().info(String.format("%s: %s", USER_POLICIES_PER_RESOURCE_SERVER, userPoliciesPerResourceServer)); - ValidateNumber.minValue(userPoliciesPerResourceServer, 0); - - logger().info(String.format("%s: %s", USERS_PER_USER_POLICY, usersPerUserPolicy)); - ValidateNumber.isInRange(usersPerUserPolicy, 0, - resourceServerTemplate().clientTemplate().realmTemplate().userTemplate.usersPerRealm); - } - - @Override - public UserPolicy newEntity(ResourceServer parentEntity, int index) { - return new UserPolicy(parentEntity, index); - } - - @Override - public void processMappings(UserPolicy policy) { - policy.setUsers(new RandomSublist<>( - policy.getResourceServer().getClient().getRealm().getUsers(), // original list - policy.hashCode(), // random seed - usersPerUserPolicy, // sublist size - false // unique randoms? - )); - policy.getRepresentation().setUsers(policy.getUsers() - .stream().map(u -> u.getId()) - .filter(id -> id != null) // need non-null policy IDs - .collect(toSet())); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/CombinedConfigurationNoInterpolation.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/CombinedConfigurationNoInterpolation.java deleted file mode 100644 index d325339337..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/CombinedConfigurationNoInterpolation.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.keycloak.performance.util; - -import org.apache.commons.configuration.CombinedConfiguration; - -/** - * CombinedConfigurationNoInterpolation. This class disables variable interpolation (substution) - * because Freemarker which is used for entity templating uses the same syntax: ${property}. - * - * @author tkyjovsk - */ -public class CombinedConfigurationNoInterpolation extends CombinedConfiguration { - - @Override - protected Object interpolate(Object value) { - return value; - } - - @Override - protected String interpolate(String base) { - return base; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ConfigurationUtil.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ConfigurationUtil.java deleted file mode 100644 index b5955837a8..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ConfigurationUtil.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.keycloak.performance.util; - -import java.io.File; -import java.util.Iterator; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.jboss.logging.Logger; -import org.jboss.logging.Logger.Level; -import static org.jboss.logging.Logger.Level.INFO; - -/** - * - * @author tkyjovsk - */ -public class ConfigurationUtil { - - public static void logConfigurationState(Configuration c, Logger logger) { - logConfigurationState(c, logger, INFO); - } - - public static void logConfigurationState(Configuration c, Logger logger, Level logLevel) { - Iterator configKeys = c.getKeys(); - while (configKeys.hasNext()) { - String k = configKeys.next(); - logger.log(logLevel, String.format("Configuration: %s: %s", k, c.getProperty(k))); - } - } - - public static PropertiesConfiguration newPropertiesConfiguration() { - return newPropertiesConfiguration(false); - } - - public static PropertiesConfiguration newPropertiesConfiguration(boolean listParsing) { - PropertiesConfiguration configuration = new PropertiesConfiguration(); - configuration.setDelimiterParsingDisabled(!listParsing); - return configuration; - } - - public static PropertiesConfiguration loadFromFile(File file) throws ConfigurationException { - // this is needed to disable interpreting comma-delimited string properties as lists - return loadFromFile(file, false); - } - - public static PropertiesConfiguration loadFromFile(File file, boolean listParsing) throws ConfigurationException { - PropertiesConfiguration configuration = newPropertiesConfiguration(listParsing); - String path = file.isAbsolute() ? file.getParent() : null; - String filename = file.isAbsolute() ? file.getName() : file.getPath(); - configuration.setBasePath(path); - configuration.load(filename); - return configuration; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/Loggable.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/Loggable.java deleted file mode 100644 index 07a85fc97d..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/Loggable.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.keycloak.performance.util; - -import org.jboss.logging.Logger; - -/** - * - * @author tkyjovsk - */ -public interface Loggable { - - default public Logger logger() { - return Logger.getLogger(this.getClass()); - } - - default public void info(String message) { - logger().info(message); - } - - default public void debug(String message) { - logger().debug(message); - } - - default public void warn(String message) { - logger().warn(message); - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/StringUtil.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/StringUtil.java deleted file mode 100644 index fea709479e..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/StringUtil.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.keycloak.performance.util; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author tkyjovsk - */ -public class StringUtil { - - public static String firstLetterToLowerCase(String string) { - return string.substring(0, 1).toLowerCase() + string.substring(1); - } - - public static String firstLetterToUpperCase(String string) { - return string.substring(0, 1).toUpperCase() + string.substring(1); - } - - public static List parseStringList(String string) { - return parseStringList(string, ","); - } - - public static List parseStringList(String string, String delimiter) { - List list = new ArrayList<>(); - for (String s : string.split(delimiter)) { - list.add(s.trim()); - } - return list; - } - -} diff --git a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ValidateNumber.java b/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ValidateNumber.java deleted file mode 100644 index 84831561ce..0000000000 --- a/testsuite/performance/tests/src/main/java/org/keycloak/performance/util/ValidateNumber.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.keycloak.performance.util; - -import org.apache.commons.validator.routines.IntegerValidator; - -/** - * - * @author tkyjovsk - */ -public class ValidateNumber { - - private static IntegerValidator validate() { - return IntegerValidator.getInstance(); - } - - public static void minValue(int i, int min, String message) { - if (!validate().minValue(i, min)) { - throw new IllegalArgumentException(String.format("Value '%s' lower than the expected minimum: %s. %s", i, min, message)); - } - } - - public static void minValue(int i, int min) { - minValue(i, min, ""); - } - - public static void maxValue(int i, int max, String message) { - if (!validate().maxValue(i, max)) { - throw new IllegalArgumentException(String.format("Value '%s' greater than the expected maximum: %s. %s", i, max, message)); - } - } - - public static void maxValue(int i, int max) { - maxValue(i, max, ""); - } - - public static void isInRange(int i, int min, int max, String message) { - if (!validate().isInRange(i, min, max)) { - throw new IllegalArgumentException(String.format("Value '%s' is outside of the expected range: <%s, %s>. %s", i, min, max, message)); - } - } - - public static void isInRange(int i, int min, int max) { - isInRange(i, min, max, ""); - } - -} diff --git a/testsuite/performance/tests/src/main/resources/logback.xml b/testsuite/performance/tests/src/main/resources/logback.xml deleted file mode 100644 index 0259fbc0eb..0000000000 --- a/testsuite/performance/tests/src/main/resources/logback.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - true - - - - - %d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx - - false - - - - - %d{HH:mm:ss} %msg%n%rEx - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/InvalidatableRandomContainer.scala b/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/InvalidatableRandomContainer.scala deleted file mode 100644 index 778198ee96..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/InvalidatableRandomContainer.scala +++ /dev/null @@ -1,51 +0,0 @@ -package org.jboss.perf.util - -trait Invalidatable[T] { - def invalidate(): Boolean - def apply(): T -} - -/** - * Extends {@link RandomContainer} by storing {@link Invalidatable} entries - - * when adding an entry an {@link Invalidatable} reference is returned, which could be - * later removed from the collection in O(1). - * - * @author Radim Vansa <rvansa@redhat.com> - */ -class InvalidatableRandomContainer[T >: Null <: AnyRef : Manifest](cap: Int = 16) - extends RandomContainer[Invalidatable[T]](IndexedSeq(), cap) { - - def add(elem: T): Invalidatable[T] = { - val entry = new Entry(elem) - this += entry - entry - } - - private def remove(entry : Entry): Boolean = this.synchronized { - if (entry.getPos >= 0) { - removeInternal(entry.getPos) - true - } else false - } - - protected override def move(elem : Invalidatable[T], from: Int, to: Int): Unit = { - elem.asInstanceOf[Entry].updatePos(to) - } - - private class Entry(value : T) extends Invalidatable[T] { - private var pos: Int = 0 - - override def invalidate(): Boolean = { - remove(this) - } - - override def apply() = value - - private[InvalidatableRandomContainer] def updatePos(pos: Int): Unit = { - this.pos = pos - } - - private[InvalidatableRandomContainer] def getPos = pos - } - -} diff --git a/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/RandomContainer.scala b/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/RandomContainer.scala deleted file mode 100644 index b687e781f0..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/RandomContainer.scala +++ /dev/null @@ -1,92 +0,0 @@ -package org.jboss.perf.util - -import scala.util.Random - -/** - * Allows O(1) random removals and also adding in O(1), though these - * operations can be blocked by another thread. - * {@link #size} is non-blocking. - * - * Does not implement any collection interface/trait for simplicity reasons. - * - * @author Radim Vansa <rvansa@redhat.com> - */ -class RandomContainer[T >: Null <: AnyRef : Manifest]( - seq: IndexedSeq[T], - cap: Int = 0 - ) { - private var data = new Array[T](if (cap > 0) cap else seq.length * 2) - private var takeIndex = 0 - private var putIndex = seq.length - @volatile private var count = seq.length // volatile as we want to read size without lock - - { - var pos = 0 - for (e <- seq) { - data(pos) = e - pos = pos + 1 - } - } - - def +=(elem: T): RandomContainer[T] = this.synchronized { - if (count == data.length) { - val tmp = new Array[T](data.length * 2) - for (i <- 0 until data.length) { - tmp(i) = data(i) - } - tmp(data.length) = elem; - move(elem, -1, data.length) - putIndex = data.length + 1 - takeIndex = 0 - data = tmp; - } else { - data(putIndex) = elem - move(elem, -1, putIndex) - putIndex = (putIndex + 1) % data.length - } - count += 1 - this - } - - /** - * Executed under lock, allows to track position of element - * - * @param elem - * @param from - * @param to - */ - protected def move(elem: T, from: Int, to: Int): Unit = {} - - def removeRandom(random: Random): T = this.synchronized { - if (count == 0) { - return null; - } - removeInternal((takeIndex + random.nextInt(count)) % data.length) - } - - protected def removeInternal(index: Int): T = { - assert(count > 0) - count -= 1 - if (index == takeIndex) { - val elem = data(takeIndex); - assert(elem != null) - move(elem, takeIndex, -1) - data(takeIndex) = null - takeIndex = (takeIndex + 1) % data.length - return elem - } else { - val elem = data(index) - assert(elem != null) - move(elem, index, -1) - val moved = data(takeIndex) - assert(moved != null) - data(index) = moved - move(moved, takeIndex, index) - data(takeIndex) = null // unnecessary - takeIndex = (takeIndex + 1) % data.length - return elem - } - } - - def size() = count -} diff --git a/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/Util.scala b/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/Util.scala deleted file mode 100644 index eef4d95835..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/jboss/perf/util/Util.scala +++ /dev/null @@ -1,24 +0,0 @@ -package org.jboss.perf.util - -import java.util.UUID - -import scala.concurrent.forkjoin.ThreadLocalRandom -import scala.util.Random - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -object Util { - val random = new Random(1234); // keep fixed seed - - def randomString(length: Int, rand: Random = ThreadLocalRandom.current()): String = { - val sb = new StringBuilder; - for (i <- 0 until length) { - sb.append((rand.nextInt(26) + 'a').toChar) - } - sb.toString() - } - - def randomUUID(rand: Random = ThreadLocalRandom.current()): String = - new UUID(rand.nextLong(), rand.nextLong()).toString -} diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Authorize.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Authorize.scala deleted file mode 100644 index cf5f5878a6..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Authorize.scala +++ /dev/null @@ -1,123 +0,0 @@ -package org.keycloak.gatling - -import java.text.SimpleDateFormat -import java.util.{Collections, Date} - -import akka.actor.ActorDSL.actor -import akka.actor.ActorRef -import io.gatling.core.action.Interruptable -import io.gatling.core.action.builder.ActionBuilder -import io.gatling.core.config.Protocols -import io.gatling.core.result.writer.DataWriterClient -import io.gatling.core.session._ -import io.gatling.core.validation._ -import org.jboss.logging.Logger -import org.keycloak.adapters.KeycloakDeploymentBuilder -import org.keycloak.adapters.spi.AuthOutcome -import org.keycloak.adapters.spi.HttpFacade.Cookie -import org.keycloak.common.enums.SslRequired -import org.keycloak.representations.adapters.config.AdapterConfig - -import scala.collection.JavaConverters._ - -case class AuthorizeAttributes( - requestName: Expression[String], - uri: Expression[String], - cookies: Expression[List[Cookie]], - sslRequired: SslRequired = SslRequired.EXTERNAL, - resource: Option[Expression[String]] = None, - secret: Option[Expression[String]] = None, - isPublic: Option[Expression[Boolean]] = None, - realm: Option[Expression[String]] = None, - realmKey: Option[String] = None, - authServerUrl: Expression[String] = _ => Failure("no server url") -) { - def toAdapterConfig(session: Session) = { - val adapterConfig = new AdapterConfig - adapterConfig.setSslRequired(sslRequired.toString) - - adapterConfig.setResource( resource match { - case Some(expr) => expr(session).get - case None => null - }) - adapterConfig.setPublicClient( isPublic match { - case Some(expr) => expr(session).get - case None => false - }) - adapterConfig.setCredentials( secret match { - case Some(expr) => Collections.singletonMap("secret", expr(session).get) - case None => null - }) - adapterConfig.setRealm(realm match { - case Some(expr) => expr(session).get - case None => null - }) - adapterConfig.setRealmKey(realmKey match { - case Some(key) => key - case None => null - }) - adapterConfig.setAuthServerUrl(authServerUrl(session).get) - - adapterConfig - } -} - -class AuthorizeActionBuilder(attributes: AuthorizeAttributes) extends ActionBuilder { - def newInstance(attributes: AuthorizeAttributes) = new AuthorizeActionBuilder(attributes) - - def sslRequired(sslRequired: SslRequired) = newInstance(attributes.copy(sslRequired = sslRequired)) - def resource(resource: Expression[String]) = newInstance(attributes.copy(resource = Option(resource))) - def clientCredentials(secret: Expression[String]) = newInstance(attributes.copy(secret = Option(secret))) - def publicClient(isPublic: Expression[Boolean]) = newInstance(attributes.copy(isPublic = Option(isPublic))) - def realm(realm: Expression[String]) = newInstance(attributes.copy(realm = Option(realm))) - def realmKey(realmKey: String) = newInstance(attributes.copy(realmKey = Option(realmKey))) - def authServerUrl(authServerUrl: Expression[String]) = newInstance(attributes.copy(authServerUrl = authServerUrl)) - - override def build(next: ActorRef, protocols: Protocols): ActorRef = { - actor(actorName("authorize"))(new AuthorizeAction(attributes, next)) - } -} - -object AuthorizeAction { - val logger = Logger.getLogger(classOf[AuthorizeAction]) - - def init(session: Session) : Session = { - session.remove(MockRequestAuthenticator.KEY) - } -} - -class AuthorizeAction( - attributes: AuthorizeAttributes, - val next: ActorRef - ) extends Interruptable with ExitOnFailure with DataWriterClient { - override def executeOrFail(session: Session): Validation[_] = { - val facade = new MockHttpFacade() - val deployment = KeycloakDeploymentBuilder.build(attributes.toAdapterConfig(session)) - val url = attributes.uri(session).get - facade.request.setURI(if (attributes.isPublic.isDefined && attributes.isPublic.get(session).get) rewriteFragmentToQuery(url) else url) - facade.request.setCookies(attributes.cookies(session).get.map(c => (c.getName, c)).toMap.asJava) - var nextSession = session - val requestAuth: MockRequestAuthenticator = session(MockRequestAuthenticator.KEY).asOption[MockRequestAuthenticator] match { - case Some(ra) => ra - case None => - val tmp = new MockRequestAuthenticator(facade, deployment, new MockTokenStore, -1, session.userId) - nextSession = session.set(MockRequestAuthenticator.KEY, tmp) - tmp - } - - Blocking(() => { - AuthorizeAction.logger.debugf("%s: Authenticating %s%n", new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()).asInstanceOf[Any], session("username").as[Any], Unit) - Stopwatch(() => requestAuth.authenticate()) - .check(result => result == AuthOutcome.AUTHENTICATED, result => { - AuthorizeAction.logger.warnf("%s: Failed auth %s%n", new SimpleDateFormat("HH:mm:ss,SSS").format(new Date()).asInstanceOf[Any], session("username").as[Any], Unit) - "AuthorizeAction: authenticate() failed with status: " + result.toString - }) - .recordAndContinue(this, nextSession, attributes.requestName(session).get) - }) - } - - def rewriteFragmentToQuery(str: String): String = { - str.replaceFirst("#", "?") - } -} - diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Blocking.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Blocking.scala deleted file mode 100644 index a0ebaa8f4e..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Blocking.scala +++ /dev/null @@ -1,34 +0,0 @@ -package org.keycloak.gatling - -import java.util.concurrent.atomic.AtomicInteger -import java.util.concurrent.{Executors, ThreadFactory} - -import io.gatling.core.akka.GatlingActorSystem -import io.gatling.core.validation.Success - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -object Blocking { - GatlingActorSystem.instance.registerOnTermination(() => shutdown()) - - private val threadPool = Executors.newCachedThreadPool(new ThreadFactory { - val counter = new AtomicInteger(); - - override def newThread(r: Runnable): Thread = - new Thread(r, "blocking-thread-" + counter.incrementAndGet()) - }) - - def apply(f: () => Unit) = { - threadPool.execute(new Runnable() { - override def run = { - f() - } - }) - Success(()) - } - - def shutdown() = { - threadPool.shutdownNow() - } -} diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/ExitOnFailure.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/ExitOnFailure.scala deleted file mode 100644 index 484143e0f2..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/ExitOnFailure.scala +++ /dev/null @@ -1,20 +0,0 @@ -package org.keycloak.gatling - -import io.gatling.core.action.{Chainable, UserEnd} -import io.gatling.core.session.Session -import io.gatling.core.validation.Validation - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -trait ExitOnFailure extends Chainable { - override def execute(session: Session): Unit = { - executeOrFail(session).onFailure { message => - logger.error(s"'${self.path.name}' failed to execute: $message") - UserEnd.instance ! session.markAsFailed - } - } - - def executeOrFail(session: Session): Validation[_] -} - diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Oauth.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Oauth.scala deleted file mode 100644 index 2ce47a554d..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Oauth.scala +++ /dev/null @@ -1,12 +0,0 @@ -package org.keycloak.gatling - -import io.gatling.core.session._ -import org.keycloak.adapters.spi.HttpFacade.Cookie - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -case class Oauth(requestName: Expression[String]) { - def authorize(uri: Expression[String], cookies: Expression[List[Cookie]]) = new AuthorizeActionBuilder(new AuthorizeAttributes(requestName, uri, cookies)); - def refresh() = new RefreshTokenActionBuilder(requestName); -} diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Predef.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Predef.scala deleted file mode 100644 index b72b95e240..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Predef.scala +++ /dev/null @@ -1,10 +0,0 @@ -package org.keycloak.gatling - -import io.gatling.core.session.Expression - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -object Predef { - def oauth(requestName: Expression[String]) = new Oauth(requestName) -} diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/RefreshToken.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/RefreshToken.scala deleted file mode 100644 index 7e9f1d8b4a..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/RefreshToken.scala +++ /dev/null @@ -1,33 +0,0 @@ -package org.keycloak.gatling - -import akka.actor.ActorDSL._ -import akka.actor.ActorRef -import io.gatling.core.action.Interruptable -import io.gatling.core.action.builder.ActionBuilder -import io.gatling.core.config.Protocols -import io.gatling.core.result.writer.DataWriterClient -import io.gatling.core.session.{Expression, Session} -import io.gatling.core.validation.Validation - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -class RefreshTokenActionBuilder(requestName: Expression[String]) extends ActionBuilder{ - override def build(next: ActorRef, protocols: Protocols): ActorRef = { - actor(actorName("refresh-token"))(new RefreshTokenAction(requestName, next)) - } -} - -class RefreshTokenAction( - requestName: Expression[String], - val next: ActorRef - ) extends Interruptable with ExitOnFailure with DataWriterClient { - override def executeOrFail(session: Session): Validation[_] = { - val requestAuth: MockRequestAuthenticator = session(MockRequestAuthenticator.KEY).as[MockRequestAuthenticator] - Blocking(() => - Stopwatch(() => requestAuth.getKeycloakSecurityContext.refreshExpiredToken(false)) - .check(identity, _ => "AuthorizeAction: refreshToken() failed") - .recordAndContinue(this, session, requestName(session).get) - ) - } -} diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Stopwatch.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Stopwatch.scala deleted file mode 100644 index 68d69f0151..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Stopwatch.scala +++ /dev/null @@ -1,106 +0,0 @@ -package org.keycloak.gatling - -import com.typesafe.scalalogging.StrictLogging -import io.gatling.core.action.{Chainable, UserEnd} -import io.gatling.core.akka.GatlingActorSystem -import io.gatling.core.result.message.{KO, OK, Status} -import io.gatling.core.result.writer.DataWriterClient -import io.gatling.core.session.Session -import io.gatling.core.util.TimeHelper -import io.gatling.core.validation.{Failure, Success, Validation} - -/** - * @author Radim Vansa <rvansa@redhat.com> - */ -object Stopwatch extends StrictLogging { - @volatile var recording: Boolean = true; - GatlingActorSystem.instance.registerOnTermination(() => recording = true) - - def apply[T](f: () => T): Result[T] = { - val start = TimeHelper.nowMillis - try { - val result = f() - Result(Success(result), OK, start, TimeHelper.nowMillis, false) - } catch { - case ie: InterruptedException => { - Result(Failure("Interrupted"), KO, start, start, true) - } - case e: Throwable => { - Stopwatch.log.error("Operation failed with exception", e) - Result(Failure(e.toString), KO, start, TimeHelper.nowMillis, false) - } - } - } - - def log = logger; -} - -case class Result[T]( - val value: Validation[T], - val status: Status, - val startTime: Long, - val endTime: Long, - val interrupted: Boolean -) { - def check(check: T => Boolean, fail: T => String): Result[T] = { - value match { - case Success(v) => - if (!check(v)) { - Result(Failure(fail(v)), KO, startTime, endTime, interrupted); - } else { - this - } - case _ => this - } - } - - def isSuccess = - value match { - case Success(_) => true - case _ => false - } - - private def record(client: DataWriterClient, session: Session, name: String): Validation[T] = { - if (!interrupted && Stopwatch.recording) { - var msg = value match { - case Failure(m) => Some(m) - case _ => None - } - client.writeRequestData(session, name, startTime, startTime, endTime, endTime, status, msg) - } - value - } - - def recordAndStopOnFailure(client: DataWriterClient with Chainable, session: Session, name: String): Validation[T] = { - val validation = record(client, session, name) - validation.onFailure(message => { - Stopwatch.log.error(s"'${client.self.path.name}', ${session.userId} failed to execute: $message") - UserEnd.instance ! session.markAsFailed - }) - validation - } - - def recordAndContinue(client: DataWriterClient with Chainable, session: Session, name: String): Unit = { - // can't specify follow function as default arg since it uses another parameter - recordAndContinue(client, session, name, _ => session); - } - - def recordAndContinue(client: DataWriterClient with Chainable, session: Session, name: String, follow: T => Session): Unit = { - // 'follow' intentionally does not get session as arg, since caller site already has the reference - record(client, session, name) match { - case Success(value) => try { - client.next ! follow(value) - } catch { - case t: Throwable => { - Stopwatch.log.error(s"'${client.self.path.name}' failed processing", t) - UserEnd.instance ! session.markAsFailed - } - } - case Failure(message) => { - Stopwatch.log.error(s"'${client.self.path.name}' failed to execute: $message") - UserEnd.instance ! session.markAsFailed - } - } - } -} - diff --git a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Utils.scala b/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Utils.scala deleted file mode 100644 index 9ed985eb00..0000000000 --- a/testsuite/performance/tests/src/main/scala/org/keycloak/gatling/Utils.scala +++ /dev/null @@ -1,34 +0,0 @@ -package org.keycloak.gatling - -import java.net.URLEncoder -import java.security.{MessageDigest, SecureRandom} -import org.apache.commons.codec.binary.Base64 - -/** - * @author Marko Strukelj - */ -object Utils { - - def urlencode(url: String) = { - URLEncoder.encode(url, "utf-8") - } - - def urlEncodedRoot(url: String) = { - URLEncoder.encode(url.split("/auth")(0), "utf-8") - } - - def generateCodeVerifier(): String = { - val secureRandom = new SecureRandom() - val code = new Array[Byte](32) - secureRandom.nextBytes(code) - Base64.encodeBase64URLSafeString(code) - } - - def generateCodeChallenge(codeVerifier: String): String = { - val codeVerifierBytes = codeVerifier.getBytes("US-ASCII") - val md = MessageDigest.getInstance("SHA-256") - md.update(codeVerifierBytes, 0, codeVerifierBytes.length) - Base64.encodeBase64URLSafeString(md.digest) - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/AbstractTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/AbstractTest.java deleted file mode 100644 index a1d163e535..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/AbstractTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.keycloak.performance; - -import org.jboss.logging.Logger; - -/** - * - * @author tkyjovsk - */ -public abstract class AbstractTest { - - protected final Logger logger = Logger.getLogger(this.getClass()); - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/DatasetTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/DatasetTest.java deleted file mode 100644 index cfda09995a..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/DatasetTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.keycloak.performance.dataset; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.Map; -import static java.util.stream.Collectors.toList; -import java.util.stream.Stream; -import org.junit.Ignore; -import org.junit.Test; -import org.keycloak.performance.dataset.idm.Credential; -import org.keycloak.performance.dataset.idm.authorization.Resource; -import org.keycloak.performance.dataset.idm.authorization.ResourcePermission; -import org.keycloak.performance.templates.DatasetTemplate; -import org.keycloak.performance.util.Loggable; -import org.keycloak.representations.idm.RealmRepresentation; -import static org.keycloak.util.JsonSerialization.writeValueAsString; - -/** - * - * @author tkyjovsk - */ -public class DatasetTest extends EntityTest implements Loggable { - - DatasetTemplate dt = new DatasetTemplate(); - Dataset dataset = dt.produce(); - - @Test - @Ignore - public void toJSON() throws IOException { - logger().info("REALM JSON: \n" + dataset.getRealms().get(0).toJSON()); - logger().info("CLIENT JSON: \n" + dataset.getRealms().get(0).getClients().get(0).toJSON()); - logger().info("USER JSON: \n" + dataset.getRealms().get(0).getUsers().get(0).toJSON()); - logger().info("CREDENTIAL JSON: \n" + dataset.getRealms().get(0).getUsers().get(0).getCredentials().get(0).toJSON()); - logger().info("REALM ROLE MAPPINGS: \n" + dataset.getRealms().get(0).getUsers().get(0).getRealmRoleMappings().toJSON()); - - if (dataset.getRealms().get(0).getResourceServers().isEmpty()) { - } else { - logger().info("RESOURCE SERVER: \n" + dataset.getRealms().get(0).getResourceServers().get(0).toJSON()); - logger().info("RESOURCE: \n" + dataset.getRealms().get(0).getResourceServers().get(0).getResources().get(0).toJSON()); - } - - } - - @Test - @Ignore - public void pojoToMap() throws IOException { - RealmRepresentation realm = new RealmRepresentation(); - realm.setRealm("realm_0"); - realm.setEnabled(true); - - logger().info("REP JSON:"); - logger().info(writeValueAsString(realm)); - - TypeReference typeRef = new TypeReference>() { - }; - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - Map map = (Map) mapper.convertValue(realm, typeRef); - map.put("index", 1000); - - logger().info("MAP:"); - logger().info(map); - - logger().info("MAP JSON:"); - logger().info(writeValueAsString(map)); - - } - - @Test - @Ignore - public void testStreams() throws IOException { - - dataset.realms().forEach(r -> logger().info(r.toString())); - dataset.realmRoles().forEach(rr -> logger().info(rr.toString())); - dataset.clients().forEach(c -> logger().info(c.toString())); - dataset.clientRoles().forEach(cr -> logger().info(cr.toString())); - dataset.users().forEach(u -> logger().info(u.toString())); - for (Credential c : dataset.credentials().collect(toList())) { - logger().info(c.toJSON()); - } - - dataset.resourceServers().forEach(rs -> logger().info(rs.toString())); - dataset.resources().forEach(r -> logger().info(r.toString())); - for (Resource r : dataset.resources().collect(toList())) { - logger().info(r.toJSON()); - } - for (ResourcePermission rp : dataset.resourcePermissions().collect(toList())) { - logger().info(rp.toString()); - logger().info(rp.toJSON()); - } - - } - - @Override - public void testHashCode() { - String d1sn = getD1().getClass().getSimpleName(); - String d2sn = getD2().getClass().getSimpleName(); - logger().info(String.format("'%s' - '%s' '%s' - '%s'", d1sn, d2sn, d1sn.hashCode(), d2sn.hashCode())); - super.testHashCode(); - } - - @Override - public Stream entityStream(Dataset dataset) { - return Stream.of(dataset); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/EntityTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/EntityTest.java deleted file mode 100644 index 2f635975a2..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/EntityTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.keycloak.performance.dataset; - -import java.util.Iterator; -import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; -import org.keycloak.performance.templates.DatasetTemplate; -import org.keycloak.performance.util.Loggable; - -/** - * - * @author tkyjovsk - */ -public abstract class EntityTest implements Loggable { - - private Dataset d1; - private Dataset d2; - - @Before - public void prepareDatasets() { - freemarker.template.Configuration fmc = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_26); - fmc.setBooleanFormat("true,false"); - fmc.setNumberFormat("computer"); - - DatasetTemplate dt = new DatasetTemplate(); - d1 = dt.produce(); -// logger().info("created: " + d1); - d2 = dt.produce(); -// logger().info("created: " + d2); - } - - public Dataset getD1() { - return d1; - } - - public Dataset getD2() { - return d2; - } - - public abstract Stream entityStream(Dataset dataset); - - public Stream d1EntityStream() { - return entityStream(getD1()); - } - - public Stream d2EntityStream() { - return entityStream(getD2()); - } - - @Test - public void testHashCode() { - logger().info(this.getClass().getSimpleName() + " testHashCode()"); - Iterator e1i = d1EntityStream().iterator(); - Iterator e2i = d2EntityStream().iterator(); - int checkCount = 0; - while (e1i.hasNext()) { - T e1 = e1i.next(); - assertTrue(e2i.hasNext()); - T e2 = e2i.next(); - -// logger().info(String.format("entities: %s %s", e1, e2)); -// logger().info(String.format("hashCodes: %s %s", e1.hashCode(), e2.hashCode())); - assertEquals(e1.hashCode(), e1.hashCode()); - assertEquals(e2.hashCode(), e2.hashCode()); - assertEquals(e1.hashCode(), e2.hashCode()); - - checkCount++; -// if (checkCount > 10) { -// break; -// } - } - logger().info("checkCount: " + checkCount); -// assertTrue(checkCount > 0); - } - - @Test - public void testEquals() { - logger().info(this.getClass().getSimpleName() + " testEquals()"); - Iterator e1i = d1EntityStream().iterator(); - Iterator e2i = d2EntityStream().iterator(); - int checkCount = 0; - while (e1i.hasNext()) { - T e1 = e1i.next(); - assertTrue(e2i.hasNext()); - T e2 = e2i.next(); -// logger().info(String.format("entities: %s %s", e1, e2)); - assertTrue(e1.equals(e2)); - assertTrue(e2.equals(e1)); - - checkCount++; -// if (checkCount > 10) { -// break; -// } - } - logger().info("checkCount: " + checkCount); -// assertTrue(checkCount > 0); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleMappingsTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleMappingsTest.java deleted file mode 100644 index fb56de9333..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleMappingsTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class ClientRoleMappingsTest extends EntityTest> { - - @Override - public Stream> entityStream(Dataset dataset) { - return dataset.userClientRoleMappings(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleTest.java deleted file mode 100644 index 8311969776..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientRoleTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class ClientRoleTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.clientRoles(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientTest.java deleted file mode 100644 index 31f221177e..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/ClientTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class ClientTest extends EntityTest{ - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.clients(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/CredentialTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/CredentialTest.java deleted file mode 100644 index 860aba5740..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/CredentialTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class CredentialTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.credentials(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleMappingsTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleMappingsTest.java deleted file mode 100644 index bf3ae831db..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleMappingsTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class RealmRoleMappingsTest extends EntityTest> { - - @Override - public Stream> entityStream(Dataset dataset) { - return dataset.userRealmRoleMappings(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleTest.java deleted file mode 100644 index fad8c1f53b..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmRoleTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class RealmRoleTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.realmRoles(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmTest.java deleted file mode 100644 index 674cbecce5..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/RealmTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class RealmTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.realms(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/UserTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/UserTest.java deleted file mode 100644 index 614b811ae8..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/UserTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class UserTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.users(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerTest.java deleted file mode 100644 index b50bebc5cd..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceServerTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class ResourceServerTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.resourceServers(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceTest.java deleted file mode 100644 index a22e8c13d9..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ResourceTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class ResourceTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.resources(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyTest.java deleted file mode 100644 index ba6220be17..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/RolePolicyTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.stream.Stream; -import org.junit.Test; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class RolePolicyTest extends EntityTest { - - @Test - public void testRoles() { - } - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.rolePolicies(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ScopeTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ScopeTest.java deleted file mode 100644 index 837f5a071e..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/dataset/idm/authorization/ScopeTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.keycloak.performance.dataset.idm.authorization; - -import java.util.stream.Stream; -import org.keycloak.performance.dataset.Dataset; -import org.keycloak.performance.dataset.EntityTest; - -/** - * - * @author tkyjovsk - */ -public class ScopeTest extends EntityTest { - - @Override - public Stream entityStream(Dataset dataset) { - return dataset.scopes(); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/ListOfListsTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/ListOfListsTest.java deleted file mode 100644 index b34791b781..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/ListOfListsTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.Test; -import org.keycloak.performance.util.Loggable; - -/** - * - * @author tkyjovsk - */ -public class ListOfListsTest implements Loggable { - - int[] sizes; - List> lists; - List items; - - @Before - public void prepareLists() { - sizes = new Random().ints(10, 1, 10).toArray(); - lists = new LinkedList<>(); - items = new LinkedList<>(); - for (int l = 0; l < sizes.length; l++) { - List list = new LinkedList<>(); - for (int i = 0; i < sizes[l]; i++) { - list.add(String.format("list %s item %s", l, i)); - } - lists.add(list); - items.addAll(list); - } - } - - @Test - public void testSize() { - lists.forEach(l -> logger().debug(l)); - ListOfLists lol = new ListOfLists<>(lists); - assertEquals(items.size(), lol.size()); - for (int i = 0; i < items.size(); i++) { - assertEquals(items.get(i), lol.get(i)); - } - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomBooleansTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomBooleansTest.java deleted file mode 100644 index 73e774736c..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomBooleansTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.List; -import java.util.Random; -import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import org.junit.Before; -import org.junit.Test; -import org.keycloak.performance.AbstractTest; - -/** - * - * @author tkyjovsk - */ -public class RandomBooleansTest extends AbstractTest { - - Random r; - - @Before - public void before() { - r = new Random(); - } - - @Test -// @Ignore - public void testRandoms() { - int seed1 = r.nextInt(); - int seed2 = r.nextInt(); - - List list1 = new RandomBooleans(seed1, 50).stream().limit(10).collect(Collectors.toList()); - List list2 = new RandomBooleans(seed1, 50).stream().limit(10).collect(Collectors.toList()); - List list3 = new RandomBooleans(seed2, 50).stream().limit(10).collect(Collectors.toList()); - - logger.info(String.format("List1(seed: %s): %s", seed1, list1)); - logger.info(String.format("List2(seed: %s): %s", seed1, list2)); - logger.info(String.format("List3(seed: %s): %s", seed2, list3)); - - assertFalse(list1.isEmpty()); - assertFalse(list2.isEmpty()); - assertFalse(list3.isEmpty()); - assertEquals(list1, list2); - assertNotEquals(list2, list3); - } - -} diff --git a/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomIntegersTest.java b/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomIntegersTest.java deleted file mode 100644 index f1991a85b9..0000000000 --- a/testsuite/performance/tests/src/test/java/org/keycloak/performance/iteration/RandomIntegersTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.keycloak.performance.iteration; - -import java.util.List; -import java.util.Random; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.keycloak.performance.AbstractTest; - -/** - * - * @author tkyjovsk - */ -public class RandomIntegersTest extends AbstractTest { - - Random r; - - @Before - public void before() { - r = new Random(); - } - - @Test - @Ignore - public void testRandoms() { - int seed1 = r.nextInt(); - int seed2 = r.nextInt(); - - List l1 = new RandomIntegers(seed1, 20).stream().limit(10).collect(Collectors.toList()); - List l2 = new RandomIntegers(seed1, 20).stream().limit(10).collect(Collectors.toList()); - List l3 = new RandomIntegers(seed2, 20).stream().limit(10).collect(Collectors.toList()); - - logger.info("L1: " + l1); - logger.info("L2: " + l2); - logger.info("L3: " + l3); - - assertFalse(l1.isEmpty()); - assertFalse(l2.isEmpty()); - assertFalse(l3.isEmpty()); - assertEquals(l1, l2); - assertNotEquals(l2, l3); - } - - @Test - @Ignore - public void testUniqueRandoms() { - int seed1 = r.nextInt(); - int seed2 = r.nextInt(); - - List l1 = new UniqueRandomIntegers(seed1, 20).stream().limit(10).collect(Collectors.toList()); - List l2 = new UniqueRandomIntegers(seed1, 20).stream().limit(10).collect(Collectors.toList()); - List l3 = new UniqueRandomIntegers(seed2, 20).stream().limit(10).collect(Collectors.toList()); - - logger.info("unique L1: " + l1); - logger.info("unique L2: " + l2); - logger.info("unique L3: " + l3); - - assertFalse(l1.isEmpty()); - assertFalse(l2.isEmpty()); - assertFalse(l3.isEmpty()); - assertEquals(l1, l2); - assertNotEquals(l2, l3); - } - - @Test - @Ignore - public void testStream() { - ThreadLocalRandom.current().ints(0, 100).distinct().limit(5).forEach(System.out::println); - } - -} diff --git a/testsuite/performance/tests/src/test/resources/application.conf b/testsuite/performance/tests/src/test/resources/application.conf deleted file mode 100644 index d7b564a380..0000000000 --- a/testsuite/performance/tests/src/test/resources/application.conf +++ /dev/null @@ -1,9 +0,0 @@ -#################################### -# Akka Actor Config File # -#################################### - -akka { - scheduler { - tick-duration = 50ms - } -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/resources/bodies/.gitkeep b/testsuite/performance/tests/src/test/resources/bodies/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/testsuite/performance/tests/src/test/resources/dataset/100r_100c_100000u.properties b/testsuite/performance/tests/src/test/resources/dataset/100r_100c_100000u.properties deleted file mode 100644 index 8e5b491f46..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/100r_100c_100000u.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=100 -realm.realm=realm_${index?string("00")} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(27500) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=100 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=100000 -user.username=user_${index?string("00000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/100r_100c_100u.properties b/testsuite/performance/tests/src/test/resources/dataset/100r_100c_100u.properties deleted file mode 100644 index 7ed6c778d3..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/100r_100c_100u.properties +++ /dev/null @@ -1,73 +0,0 @@ -# REALM -realms=100 -realm.realm=realm_${index?string("00")} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(1) -#realm.passwordPolicy=hashIterations(27500) - -# REALM ROLE -realmRolesPerRealm=3 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=3 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -# TODO support for multiple uris -#client.redirectUris=${baseUrl}/* http://load-balancing-domain.test/${clientId}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=3 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=100 -user.username=user_${index?string("00")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -#userAttribute.value=value_of_${name} -#userAttribute.value=value0_of_${name},value1_of_${name},value2_of_${name} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/10r_50c_100000u.properties b/testsuite/performance/tests/src/test/resources/dataset/10r_50c_100000u.properties deleted file mode 100644 index 5bab1b4756..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/10r_50c_100000u.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=10 -realm.realm=realm_${index?string("0")} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(27500) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=50 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=100000 -user.username=user_${index?string("00000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u.properties deleted file mode 100644 index 6bb948454c..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(27500) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=100 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=100000 -user.username=user_${index?string("00000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u_1hi.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u_1hi.properties deleted file mode 100644 index 69b9088214..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_100000u_1hi.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(1) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=100 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=100000 -user.username=user_${index?string("00000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=0 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u.properties deleted file mode 100644 index 71bbe0d17c..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(27500) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=100 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=10000 -user.username=user_${index?string("0000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi.properties deleted file mode 100644 index 84b4dc56de..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(1) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=100 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=10000 -user.username=user_${index?string("0000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi_10000res_100sc_100po_100pe.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi_10000res_100sc_100po_100pe.properties deleted file mode 100644 index 2cbca5c19d..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_10000u_1hi_10000res_100sc_100po_100pe.properties +++ /dev/null @@ -1,153 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(1) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=100 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=${(!isPublicClient() && !isBearerOnly())?c} -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=10000 -user.username=user_${index?string("0000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - - - -### AUTHZ -# RESOURCE SERVER -resourceServer.allowRemoteResourceManagement=false -resourceServer.policyEnforcementMode=ENFORCING - -# SCOPE -scopesPerResourceServer=100 -scope.name=scope_${index}_of_${resourceServer.clientId} -scope.displayName=Scope ${index} of ${resourceServer.clientId} - -# RESOURCE -resourcesPerResourceServer=10000 -resource.name=resource_${index?string("0000")}_of_${resourceServer.clientId} -resource.displayName=Resource ${index} of ${resourceServer.clientId} -resource.uri=${resourceServer.client.baseUrl}/resource_${index} -resource.type=urn:${resourceServer.clientId}:resources:default -resource.ownerManagedAccess=${indexBasedRandomBool(50)?c} - -# RESOURCE MAPPINGS -scopesPerResource=1 - - -# ROLE POLICY -rolePoliciesPerResourceServer=100 -rolePolicy.name=role_policy_${index}_of_${resourceServer.clientId} -rolePolicy.description=Role Policy ${index} of ${resourceServer.name} -rolePolicy.logic=POSITIVE - -# ROLE POLICY ROLE DEFINITION -rolePolicyRoleDefinition.required=${indexBasedRandomBool(50)?c} -realmRolesPerRolePolicy=1 -clientRolesPerRolePolicy=3 - - -# JS POLICY -jsPoliciesPerResourceServer=0 -jsPolicy.name=js_policy_${index}_of_${resourceServer.clientId} -jsPolicy.description=JavaScript Policy ${index} of ${resourceServer.name} -jsPolicy.code=// TODO add some JavaScript code\n// for JavaScript Policy ${index}\n// more\n// lines ... -jsPolicy.logic=POSITIVE - -# USER POLICY -userPoliciesPerResourceServer=100 -userPolicy.name=user_policy_${index}_of_${resourceServer.clientId} -userPolicy.description=User Policy ${index} of ${resourceServer.name} -userPolicy.logic=POSITIVE - -# USER POLICY MAPPINGS -usersPerUserPolicy=1 - - -# CLIENT POLICY -clientPoliciesPerResourceServer=100 -clientPolicy.name=client_policy_${index}_of_${resourceServer.clientId} -clientPolicy.description=Client Policy ${index} of ${resourceServer.name} -clientPolicy.logic=POSITIVE - -# CLIENT POLICY MAPPINGS -clientsPerClientPolicy=1 - - -# RESOURCE PERMISSION -resourcePermissionsPerResourceServer=100 -resourcePermission.name=resource_permission_${index}_of_${resourceServer.clientId} -resourcePermission.description=Resource Permisison ${index} of ${resourceServer.name} -resourcePermission.resourceType=<#if indexBasedRandomBool(50)>urn:${resourceServer.clientId}:resources:default<#else> -resourcePermission.decisionStrategy=UNANIMOUS - -# RESOURCE PERMISSION MAPPINGS -resourcesPerResourcePermission=1 -policiesPerResourcePermission=3 - - -# SCOPE PERMISSION -scopePermissionsPerResourceServer=100 -scopePermission.name=scope_permission_${index}_of_${resourceServer.clientId} -scopePermission.description=Scope Permisison ${index} of ${resourceServer.name} -scopePermission.decisionStrategy=UNANIMOUS - -# SCOPE PERMISSION MAPPINGS -scopesPerScopePermission=1 -policiesPerScopePermission=3 diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_500000u_1hi.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_100c_500000u_1hi.properties deleted file mode 100644 index a3ef337d5e..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_100c_500000u_1hi.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(1) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=100 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=500000 -user.username=user_${index?string("000000")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=0 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=0 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u.properties deleted file mode 100644 index e23f386b0f..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(27500) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=10 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=100 -user.username=user_${index?string("00")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=3 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u_1hi.properties b/testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u_1hi.properties deleted file mode 100644 index 218b1e4c65..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/1r_10c_100u_1hi.properties +++ /dev/null @@ -1,68 +0,0 @@ -# REALM -realms=1 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(1) - -# REALM ROLE -realmRolesPerRealm=10 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=10 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=false -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=10 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=100 -user.username=user_${index?string("00")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=3 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, diff --git a/testsuite/performance/tests/src/test/resources/dataset/authz/default.properties b/testsuite/performance/tests/src/test/resources/dataset/authz/default.properties deleted file mode 100644 index 8b1a05954f..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/authz/default.properties +++ /dev/null @@ -1,184 +0,0 @@ -# -# * Copyright 2018 Red Hat, Inc. and/or its affiliates -# * and other contributors as indicated by the @author tags. -# * -# * Licensed under the Apache License, Version 2.0 (the "License"); -# * you may not use this file except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# - -# This dataset provides a default realm configuration using role-based policies which can be extended to create more test scenarios: -# -# - 1 realm -# - 1 client -# - 1 user -# - 1k resources -# - Each resource with 10 scopes -# - Each resource associated with a single resource permission -# - 500 Scopes -# - 100 role policies -# - 1000 resource permissions -# - Each resource permissions associated with 10 role policies - -# REALM -realms=1 -realm.realm=authz-perf-tests -realm.displayName=AuthZ Performance Tests -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(1000) - -# REALM ROLE -realmRolesPerRealm=100 -realmRole.name=role_${index?string("00")} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=1 -client.clientId=client_${index?string("00")} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret -# TODO support for multiple redirect uris -#client.redirectUris=${baseUrl}/* http://load-balancing-domain.test/${clientId}/* -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=false -client.bearerOnly=false -client.authorizationServicesEnabled=true -client.serviceAccountsEnabled=true - -# CLIENT ROLE -clientRolesPerClient=1 -clientRole.name=clientrole_${index?string("00")} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=1 -user.username=user_${index?string("00")} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=50 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=50 -clientRolesPerUser=0 - - -# GROUP -groupsPerRealm=100 -group.name=group_${index?string("00")} - -# GROUP ATTRIBUTE -attributesPerGroup=50 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - - -### AUTHZ -# RESOURCE SERVER -resourceServer.allowRemoteResourceManagement=true -resourceServer.policyEnforcementMode=ENFORCING - -# SCOPE -scopesPerResourceServer=10 -scope.name=scope_${index} -scope.displayName=Scope ${index} of ${resourceServer.clientId} - -# RESOURCE -resourcesPerResourceServer=1000 -resource.name=resource_${index} -resource.displayName=Resource ${index} -resource.uri=${resourceServer.client.baseUrl}/resource_${index} -resource.type=<#if index == 0>urn:${resourceServer.clientId}:resources:default -resource.ownerManagedAccess=false - -# RESOURCE MAPPINGS -scopesPerResource=10 - - -# ROLE POLICY -rolePoliciesPerResourceServer=100 -rolePolicy.name=role_policy_${index} -rolePolicy.description=Role Policy ${index} of ${resourceServer.name} -rolePolicy.logic=POSITIVE - -# ROLE POLICY ROLE DEFINITION -rolePolicyRoleDefinition.required=false -realmRolesPerRolePolicy=10 -clientRolesPerRolePolicy=0 - - -# JS POLICY -jsPoliciesPerResourceServer=0 -jsPolicy.name=js_policy_${index} -jsPolicy.description=JavaScript Policy ${index} of ${resourceServer.name} -jsPolicy.code=// TODO add some JavaScript code\n// for JavaScript Policy ${index}\n// more\n// lines ... -jsPolicy.logic=POSITIVE - -# USER POLICY -userPoliciesPerResourceServer=0 -userPolicy.name=user_policy_${index} -userPolicy.description=User Policy ${index} of ${resourceServer.name} -userPolicy.logic=POSITIVE - -# USER POLICY MAPPINGS -usersPerUserPolicy=0 - - -# CLIENT POLICY -clientPoliciesPerResourceServer=0 -clientPolicy.name=client_policy_${index} -clientPolicy.description=Client Policy ${index} of ${resourceServer.name} -clientPolicy.logic=POSITIVE - -# CLIENT POLICY MAPPINGS -clientsPerClientPolicy=0 - - -# RESOURCE PERMISSION -resourcePermissionsPerResourceServer=1000 -resourcePermission.name=resource_permission_${index} -resourcePermission.description=Resource Permisison ${index} of ${resourceServer.name} -resourcePermission.resourceType=<#if index == 0>urn:${resourceServer.clientId}:resources:default -resourcePermission.decisionStrategy=UNANIMOUS - -# RESOURCE PERMISSION MAPPINGS -resourcesPerResourcePermission=1 -policiesPerResourcePermission=10 - - -# SCOPE PERMISSION -scopePermissionsPerResourceServer=0 -scopePermission.name=scope_permission_${index} -scopePermission.description=Scope Permisison ${index} of ${resourceServer.name} -scopePermission.decisionStrategy=UNANIMOUS - -# SCOPE PERMISSION MAPPINGS -scopesPerScopePermission=10 -policiesPerScopePermission=5 diff --git a/testsuite/performance/tests/src/test/resources/dataset/default.properties b/testsuite/performance/tests/src/test/resources/dataset/default.properties deleted file mode 100644 index 150b10f9ac..0000000000 --- a/testsuite/performance/tests/src/test/resources/dataset/default.properties +++ /dev/null @@ -1,154 +0,0 @@ -# REALM -realms=3 -realm.realm=realm_${index} -realm.displayName=Realm ${index} -realm.enabled=true -realm.registrationAllowed=true -realm.accessTokenLifeSpan=60 -realm.passwordPolicy=hashIterations(27500) - -# REALM ROLE -realmRolesPerRealm=3 -realmRole.name=role_${index?string("00")}_of_${realm.realm} -realmRole.description=Role ${index} of ${realm.displayName} - -# CLIENT -clientsPerRealm=3 -client.clientId=client_${index?string("00")}_of_${realm.realm} -client.name=Client ${index} of ${realm.displayName} -client.description=Description of ${name} -client.rootUrl= -client.adminUrl= -client.baseUrl=http://clients.${realm.realm}.test/client_${index} -client.enabled=true -client.secret=secret_of_${clientId} -# TODO support for multiple redirect uris -#client.redirectUris=${baseUrl}/* http://load-balancing-domain.test/${clientId}/* -client.redirectUris=${baseUrl}/* -client.webOrigins= -client.protocol=openid-connect -client.publicClient=<#if index % 3 == 0>true<#else>false -client.bearerOnly=<#if index % 3 == 1>true<#else>false -client.authorizationServicesEnabled=${(!isPublicClient() && !isBearerOnly())?c} -client.serviceAccountsEnabled=${authorizationServicesEnabled?c} - -# CLIENT ROLE -clientRolesPerClient=3 -clientRole.name=clientrole_${index?string("00")}_of_${client.clientId} -clientRole.description=Role ${index} of ${client.name} - -# USER -usersPerRealm=3 -user.username=user_${index?string("00")}_of_${realm.realm} -user.enabled=true -user.email=${username}@email.test -user.emailVerified=true -user.firstName=User_${index} -user.lastName=O'Realm_${realm.index} - -credential.type=password -credential.value=password_${index}_of_${user.username} -credential.temporary=false - -# USER ATTRIBUTE -attributesPerUser=3 -userAttribute.name=attribute_${index?string("00")} -userAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - -# USER ROLE MAPPINGS -realmRolesPerUser=1 -clientRolesPerUser=3 - - -# GROUP -groupsPerRealm=3 -group.name=group_${index?string("00")}_of ${realm.realm} - -# GROUP ATTRIBUTE -attributesPerGroup=3 -groupAttribute.name=attribute_${index?string("00")} -groupAttribute.value=<#list 0..2 as i>value_${i}_of_${name}<#sep>, - - -### AUTHZ -# RESOURCE SERVER -resourceServer.allowRemoteResourceManagement=false -resourceServer.policyEnforcementMode=ENFORCING - -# SCOPE -scopesPerResourceServer=3 -scope.name=scope_${index}_of_${resourceServer.clientId} -scope.displayName=Scope ${index} of ${resourceServer.clientId} - -# RESOURCE -resourcesPerResourceServer=3 -resource.name=resource_${index}_of_${resourceServer.clientId} -resource.displayName=Resource ${index} of ${resourceServer.clientId} -resource.uri=${resourceServer.client.baseUrl}/resource_${index} -resource.type=urn:${resourceServer.clientId}:resources:default -resource.ownerManagedAccess=${indexBasedRandomBool(50)?c} - -# RESOURCE MAPPINGS -scopesPerResource=1 - - -# ROLE POLICY -rolePoliciesPerResourceServer=3 -rolePolicy.name=role_policy_${index}_of_${resourceServer.clientId} -rolePolicy.description=Role Policy ${index} of ${resourceServer.name} -rolePolicy.logic=POSITIVE - -# ROLE POLICY ROLE DEFINITION -rolePolicyRoleDefinition.required=${indexBasedRandomBool(50)?c} -realmRolesPerRolePolicy=1 -clientRolesPerRolePolicy=3 - - -# JS POLICY -jsPoliciesPerResourceServer=0 -jsPolicy.name=js_policy_${index}_of_${resourceServer.clientId} -jsPolicy.description=JavaScript Policy ${index} of ${resourceServer.name} -jsPolicy.code=// TODO add some JavaScript code\n// for JavaScript Policy ${index}\n// more\n// lines ... -jsPolicy.logic=POSITIVE - -# USER POLICY -userPoliciesPerResourceServer=3 -userPolicy.name=user_policy_${index}_of_${resourceServer.clientId} -userPolicy.description=User Policy ${index} of ${resourceServer.name} -userPolicy.logic=POSITIVE - -# USER POLICY MAPPINGS -usersPerUserPolicy=1 - - -# CLIENT POLICY -clientPoliciesPerResourceServer=3 -clientPolicy.name=client_policy_${index}_of_${resourceServer.clientId} -clientPolicy.description=Client Policy ${index} of ${resourceServer.name} -clientPolicy.logic=POSITIVE - -# CLIENT POLICY MAPPINGS -clientsPerClientPolicy=1 - - -# RESOURCE PERMISSION -resourcePermissionsPerResourceServer=3 -resourcePermission.name=resource_permission_${index}_of_${resourceServer.clientId} -resourcePermission.description=Resource Permisison ${index} of ${resourceServer.name} -resourcePermission.resourceType=<#if indexBasedRandomBool(50)>urn:${resourceServer.clientId}:resources:default<#else> -resourcePermission.decisionStrategy=UNANIMOUS - -# RESOURCE PERMISSION MAPPINGS -resourcesPerResourcePermission=1 -policiesPerResourcePermission=3 - - -# SCOPE PERMISSION -scopePermissionsPerResourceServer=3 -scopePermission.name=scope_permission_${index}_of_${resourceServer.clientId} -scopePermission.description=Scope Permisison ${index} of ${resourceServer.name} -scopePermission.decisionStrategy=UNANIMOUS - -# SCOPE PERMISSION MAPPINGS -scopesPerScopePermission=1 -policiesPerScopePermission=3 diff --git a/testsuite/performance/tests/src/test/resources/gatling.conf b/testsuite/performance/tests/src/test/resources/gatling.conf deleted file mode 100644 index 6fbe38b2d7..0000000000 --- a/testsuite/performance/tests/src/test/resources/gatling.conf +++ /dev/null @@ -1,161 +0,0 @@ -######################### -# Gatling Configuration # -######################### - -# This file contains all the settings configurable for Gatling with their default values - -gatling { - core { - #outputDirectoryBaseName = "" # The prefix for each simulation result folder (then suffixed by the report generation timestamp) - #runDescription = "" # The description for this simulation run, displayed in each report - #encoding = "utf-8" # Encoding to use throughout Gatling for file and string manipulation - #simulationClass = "" # The FQCN of the simulation to run (when used in conjunction with noReports, the simulation for which assertions will be validated) - #mute = false # When set to true, don't ask for simulation name nor run description (currently only used by Gatling SBT plugin) - - extract { - regex { - #cacheMaxCapacity = 200 # Cache size for the compiled regexes, set to 0 to disable caching - } - xpath { - #cacheMaxCapacity = 200 # Cache size for the compiled XPath queries, set to 0 to disable caching - } - jsonPath { - #cacheMaxCapacity = 200 # Cache size for the compiled jsonPath queries, set to 0 to disable caching - #preferJackson = false # When set to true, prefer Jackson over Boon for JSON-related operations - jackson { - #allowComments = false # Allow comments in JSON files - #allowUnquotedFieldNames = false # Allow unquoted JSON fields names - #allowSingleQuotes = false # Allow single quoted JSON field names - } - - } - css { - #cacheMaxCapacity = 200 # Cache size for the compiled CSS selectors queries, set to 0 to disable caching - } - } - - timeOut { - #simulation = 8640000 # Absolute timeout, in seconds, of a simulation - } - directory { - #data = src/test/resource/data # Folder where user's data (e.g. files used by Feeders) is located - #bodies = src/test/resource/bodies # Folder where bodies are located - #simulations = user-src/test/java/simulations # Folder where the bundle's simulations are located< - #reportsOnly = "" # If set, name of report folder to look for in order to generate its report - #binaries = "" # If set, name of the folder where compiles classes are located: Defaults to GATLING_HOME/target. - - # this property will be replaced with absolute path to "target/test-classes" by maven resources plugin - binaries = ${project.build.testOutputDirectory} - - #results = results # Name of the folder where all reports folder are located - } - } - charting { - #noReports = false # When set to true, don't generate HTML reports - #maxPlotPerSeries = 1000 # Number of points per graph in Gatling reports - #accuracy = 10 # Accuracy, in milliseconds, of the report's stats - indicators { - #lowerBound = 800 # Lower bound for the requests' response time to track in the reports and the console summary - #higherBound = 1200 # Higher bound for the requests' response time to track in the reports and the console summary - #percentile1 = 50 # Value for the 1st percentile to track in the reports, the console summary and GraphiteDataWriter - #percentile2 = 75 # Value for the 2nd percentile to track in the reports, the console summary and GraphiteDataWriter - #percentile3 = 95 # Value for the 3rd percentile to track in the reports, the console summary and GraphiteDataWriter - #percentile4 = 99 # Value for the 4th percentile to track in the reports, the console summary and GraphiteDataWriter - } - } - http { - #elFileBodiesCacheMaxCapacity = 200 # Cache size for request body EL templates, set to 0 to disable - #rawFileBodiesCacheMaxCapacity = 200 # Cache size for request body Raw templates, set to 0 to disable - #fetchedCssCacheMaxCapacity = 200 # Cache size for CSS parsed content, set to 0 to disable - #fetchedHtmlCacheMaxCapacity = 200 # Cache size for HTML parsed content, set to 0 to disable - #redirectPerUserCacheMaxCapacity = 200 # Per virtual user cache size for permanent redirects, set to 0 to disable - #expirePerUserCacheMaxCapacity = 200 # Per virtual user cache size for permanent 'Expire' headers, set to 0 to disable - #lastModifiedPerUserCacheMaxCapacity = 200 # Per virtual user cache size for permanent 'Last-Modified' headers, set to 0 to disable - #etagPerUserCacheMaxCapacity = 200 # Per virtual user cache size for permanent ETag headers, set to 0 to disable - #warmUpUrl = "http://gatling.io" # The URL to use to warm-up the HTTP stack (blank means disabled) - #enableGA = true # Very light Google Analytics, please support - ssl { - trustStore { - #type = "" # Type of SSLContext's TrustManagers store - #file = "" # Location of SSLContext's TrustManagers store - #password = "" # Password for SSLContext's TrustManagers store - #algorithm = "" # Algorithm used by SSLContext's TrustManagers store - } - keyStore { - #type = "" # Type of SSLContext's KeyManagers store - #file = "" # Location of SSLContext's KeyManagers store - #password = "" # Password for SSLContext's KeyManagers store - #algorithm = "" # Algorithm used SSLContext's KeyManagers store - } - } - ahc { - #allowPoolingConnections = true # Allow pooling HTTP connections (keep-alive header automatically added) - #allowPoolingSslConnections = true # Allow pooling HTTPS connections (keep-alive header automatically added) - #compressionEnforced = false # Enforce gzip/deflate when Accept-Encoding header is not defined - #connectTimeout = 60000 # Timeout when establishing a connection - #pooledConnectionIdleTimeout = 60000 # Timeout when a connection stays unused in the pool - #readTimeout = 60000 # Timeout when a used connection stays idle - #connectionTTL = -1 # Max duration a connection can stay open (-1 means no limit) - #ioThreadMultiplier = 2 # Number of Netty worker threads per core - #maxConnectionsPerHost = -1 # Max number of connections per host (-1 means no limit) - #maxConnections = -1 # Max number of connections (-1 means no limit) - #maxRetry = 2 # Number of times that a request should be tried again - #requestTimeout = 60000 # Timeout of the requests - #useProxyProperties = false # When set to true, supports standard Proxy System properties - #webSocketTimeout = 60000 # Timeout when a used websocket connection stays idle - #useRelativeURIsWithConnectProxies = true # When set to true, use relative URIs when talking with an SSL proxy or a WebSocket proxy - #acceptAnyCertificate = true # When set to true, doesn't validate SSL certificates - #httpClientCodecMaxInitialLineLength = 4096 # Maximum length of the initial line of the response (e.g. "HTTP/1.0 200 OK") - #httpClientCodecMaxHeaderSize = 8192 # Maximum size, in bytes, of each request's headers - #httpClientCodecMaxChunkSize = 8192 # Maximum length of the content or each chunk - #keepEncodingHeader = true # Don't drop Encoding response header after decoding - #webSocketMaxFrameSize = 10240 # Maximum frame payload size - #httpsEnabledProtocols = "" # Comma separated enabled protocols for HTTPS, if empty use the JDK defaults - #httpsEnabledCipherSuites = "" # Comma separated enabled cipher suites for HTTPS, if empty use the JDK defaults - #sslSessionCacheSize = 20000 # SSLSession cache size (set to 0 to disable) - #sslSessionTimeout = 86400 # SSLSession timeout (default is 24, like Hotspot) - } - } - data { - #writers = "console, file" # The lists of DataWriters to which Gatling write simulation data (currently supported : "console", "file", "graphite", "jdbc") - #reader = file # The DataReader used by the charting engine for reading simulation results - console { - #light = false # When set to true, displays a light version without detailed request stats - } - file { - #bufferSize = 8192 # FileDataWriter's internal data buffer size, in bytes - } - leak { - #noActivityTimeout = 30 # Period, in seconds, for which Gatling may have no activity before considering a leak may be happening - } - jdbc { - db { - #url = "jdbc:mysql://localhost:3306/temp" # The JDBC URL used by the JDBC DataWriter - #username = "root" # The database user used by the JDBC DataWriter - #password = "123123q" # The password for the specified user - } - #bufferSize = 20 # The size for each batch of SQL inserts to send to the database - create { - #createRunRecordTable = "CREATE TABLE IF NOT EXISTS `RunRecords` ( `id` INT NOT NULL AUTO_INCREMENT , `runDate` DATETIME NULL , `simulationId` VARCHAR(45) NULL , `runDescription` VARCHAR(45) NULL , PRIMARY KEY (`id`) )" - #createRequestRecordTable = "CREATE TABLE IF NOT EXISTS `RequestRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenario` varchar(45) DEFAULT NULL, `userId` VARCHAR(30) NULL, `name` varchar(50) DEFAULT NULL, `requestStartDate` bigint DEFAULT NULL, `requestEndDate` bigint DEFAULT NULL, `responseStartDate` bigint DEFAULT NULL, `responseEndDate` bigint DEFAULT NULL, `status` varchar(2) DEFAULT NULL, `message` varchar(4500) DEFAULT NULL, `responseTime` bigint DEFAULT NULL, PRIMARY KEY (`id`) )" - #createScenarioRecordTable = "CREATE TABLE IF NOT EXISTS `ScenarioRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenarioName` varchar(45) DEFAULT NULL, `userId` VARCHAR(30) NULL, `event` varchar(50) DEFAULT NULL, `startDate` bigint DEFAULT NULL, `endDate` bigint DEFAULT NULL, PRIMARY KEY (`id`) )" - #createGroupRecordTable = "CREATE TABLE IF NOT EXISTS `GroupRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenarioName` varchar(45) DEFAULT NULL, `userId` VARCHAR(30) NULL, `entryDate` bigint DEFAULT NULL, `exitDate` bigint DEFAULT NULL, `status` varchar(2) DEFAULT NULL, PRIMARY KEY (`id`) )" - } - insert { - #insertRunRecord = "INSERT INTO RunRecords (runDate, simulationId, runDescription) VALUES (?,?,?)" - #insertRequestRecord = "INSERT INTO RequestRecords (runId, scenario, userId, name, requestStartDate, requestEndDate, responseStartDate, responseEndDate, status, message, responseTime) VALUES (?,?,?,?,?,?,?,?,?,?,?)" - #insertScenarioRecord = "INSERT INTO ScenarioRecords (runId, scenarioName, userId, event, startDate, endDate) VALUES (?,?,?,?,?,?)" - #insertGroupRecord = "INSERT INTO GroupRecords (runId, scenarioName, userId, entryDate, exitDate, status) VALUES (?,?,?,?,?,?)" - } - } - graphite { - #light = false # only send the all* stats - #host = "localhost" # The host where the Carbon server is located - #port = 2003 # The port to which the Carbon server listens to - #protocol = "tcp" # The protocol used to send data to Carbon (currently supported : "tcp", "udp") - #rootPathPrefix = "gatling" # The common prefix of all metrics sent to Graphite - #bufferSize = 8192 # GraphiteDataWriter's internal data buffer size, in bytes - #writeInterval = 1 # GraphiteDataWriter's write interval, in seconds - } - } -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/resources/logback-test.xml b/testsuite/performance/tests/src/test/resources/logback-test.xml deleted file mode 100644 index 65bd8df526..0000000000 --- a/testsuite/performance/tests/src/test/resources/logback-test.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - true - - - - - %d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx - - - - - - %msg%n%rEx - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/Engine.scala b/testsuite/performance/tests/src/test/scala/Engine.scala deleted file mode 100644 index ae9aaecc9a..0000000000 --- a/testsuite/performance/tests/src/test/scala/Engine.scala +++ /dev/null @@ -1,19 +0,0 @@ - -import io.gatling.app.Gatling -import io.gatling.core.config.GatlingPropertiesBuilder - -object Engine extends App { - - val sim = classOf[keycloak.OIDCLoginAndLogoutSimulation] - //val sim = classOf[keycloak.AdminConsoleSimulation] - - val props = new GatlingPropertiesBuilder - props.dataDirectory(IDEPathHelper.dataDirectory.toString) - props.resultsDirectory(IDEPathHelper.resultsDirectory.toString) - props.bodiesDirectory(IDEPathHelper.bodiesDirectory.toString) - props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString) - - props.simulationClass(sim.getName) - - Gatling.fromMap(props.build) -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/IDEPathHelper.scala b/testsuite/performance/tests/src/test/scala/IDEPathHelper.scala deleted file mode 100644 index 076a152390..0000000000 --- a/testsuite/performance/tests/src/test/scala/IDEPathHelper.scala +++ /dev/null @@ -1,22 +0,0 @@ - -import java.nio.file.Path -import io.gatling.core.util.PathHelper._ - -object IDEPathHelper { - - val gatlingConfUrl: Path = getClass.getClassLoader.getResource("gatling.conf").toURI - val projectRootDir = gatlingConfUrl.ancestor(3) - - val mavenSourcesDirectory = projectRootDir / "src" / "test" / "scala" - val mavenResourcesDirectory = projectRootDir / "src" / "test" / "resources" - val mavenTargetDirectory = projectRootDir / "target" - val mavenBinariesDirectory = mavenTargetDirectory / "test-classes" - - val dataDirectory = mavenResourcesDirectory / "data" - val bodiesDirectory = mavenResourcesDirectory / "bodies" - - val recorderOutputDirectory = mavenSourcesDirectory - val resultsDirectory = mavenTargetDirectory / "gatling" - - val recorderConfigFile = mavenResourcesDirectory / "recorder.conf" -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/Recorder.scala b/testsuite/performance/tests/src/test/scala/Recorder.scala deleted file mode 100644 index 195896e7b5..0000000000 --- a/testsuite/performance/tests/src/test/scala/Recorder.scala +++ /dev/null @@ -1,13 +0,0 @@ - -import io.gatling.recorder.GatlingRecorder -import io.gatling.recorder.config.RecorderPropertiesBuilder - -object Recorder extends App { - - val props = new RecorderPropertiesBuilder - props.simulationOutputFolder(IDEPathHelper.recorderOutputDirectory.toString) - props.simulationPackage("computerdatabase") - props.bodiesFolder(IDEPathHelper.bodiesDirectory.toString) - - GatlingRecorder.fromMap(props.build, Some(IDEPathHelper.recorderConfigFile)) -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/examples/SimpleExample1.scala b/testsuite/performance/tests/src/test/scala/examples/SimpleExample1.scala deleted file mode 100644 index 7e1946e0c3..0000000000 --- a/testsuite/performance/tests/src/test/scala/examples/SimpleExample1.scala +++ /dev/null @@ -1,27 +0,0 @@ -package examples - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ - -/** - * @author Marko Strukelj - */ -class SimpleExample1 extends Simulation { - - // Create a scenario with three steps: - // - first perform an HTTP GET - // - then pause for 10 seconds - // - then perform a different HTTP GET - - val scn = scenario("Simple") - .exec(http("Home") - .get("http://localhost:8080") - .check(status is 200)) - .pause(10) - .exec(http("Auth Home") - .get("http://localhost:8080/auth") - .check(status is 200)) - - // Run the scenario with 100 parallel users, all starting at the same time - setUp(scn.inject(atOnceUsers(100))) -} diff --git a/testsuite/performance/tests/src/test/scala/examples/SimpleExample2.scala b/testsuite/performance/tests/src/test/scala/examples/SimpleExample2.scala deleted file mode 100644 index 6773b0a558..0000000000 --- a/testsuite/performance/tests/src/test/scala/examples/SimpleExample2.scala +++ /dev/null @@ -1,43 +0,0 @@ -package examples - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ - -/** - * @author Marko Strukelj - */ -class SimpleExample2 extends Simulation { - - // Create two scenarios - // First one called Simple with three steps: - // - first perform an HTTP GET - // - then pause for 10 seconds - // - then perform a different HTTP GET - - val scn = scenario("Simple") - .exec(http("Home") - .get("http://localhost:8080") - .check(status is 200)) - .pause(10) - .exec(http("Auth Home") - .get("http://localhost:8080/auth") - .check(status is 200)) - - - // The second scenario called Account with only one step: - // - perform an HTTP GET - - val scn2 = scenario("Account") - .exec(http("Account") - .get("http://localhost:8080/auth/realms/master/account") - .check(status is 200)) - - // Run both scenarios: - // - first scenario with 100 parallel users, starting all at the same time - // - second scenario with 50 parallel users, starting all at the same time - - setUp( - scn.inject(atOnceUsers(100)), - scn2.inject(atOnceUsers(50)) - ) -} diff --git a/testsuite/performance/tests/src/test/scala/examples/SimpleExample3.scala b/testsuite/performance/tests/src/test/scala/examples/SimpleExample3.scala deleted file mode 100644 index a881128101..0000000000 --- a/testsuite/performance/tests/src/test/scala/examples/SimpleExample3.scala +++ /dev/null @@ -1,25 +0,0 @@ -package examples - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ - -/** - * @author Marko Strukelj - */ -class SimpleExample3 extends Simulation { - - // Create a scenario where user performs the same operation in a loop without any pause - // Each loop iteration will be displayed as individual request in the report - val rapidlyRefreshAccount = repeat(10, "i") { - exec(http("Account ${i}") - .get("http://localhost:8080/auth/realms/master/account") - .check(status is 200)) - } - - val scn = scenario("Account Refresh") - .exec(rapidlyRefreshAccount) - - setUp( - scn.inject(atOnceUsers(100)) - ) -} diff --git a/testsuite/performance/tests/src/test/scala/examples/SimpleExample4.scala b/testsuite/performance/tests/src/test/scala/examples/SimpleExample4.scala deleted file mode 100644 index f15f75902f..0000000000 --- a/testsuite/performance/tests/src/test/scala/examples/SimpleExample4.scala +++ /dev/null @@ -1,30 +0,0 @@ -package examples - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ - -/** - * @author Marko Strukelj - */ -class SimpleExample4 extends Simulation { - - // Specify defaults for http requests - val httpConf = http - .baseURL("http://localhost:8080/auth") // This is the root for all relative URLs - .acceptHeader("text/html,application/xhtml+xml,application/xml") - .acceptEncodingHeader("gzip, deflate") - .acceptLanguageHeader("en-US,en;q=0.5") - .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0") - - val account = exec(http("Account") - .get("/realms/master/account") // URL is appended to baseURL - .check(status is 200)) - - val scn = scenario("Account") - .exec(account) - - setUp( - // rather than starting all 100 users at once, increase the count over a period of 10 seconds - scn.inject(rampUsers(100) over 10).protocols(httpConf) - ) -} diff --git a/testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleScenarioBuilder.scala b/testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleScenarioBuilder.scala deleted file mode 100644 index c4ad36e3f9..0000000000 --- a/testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleScenarioBuilder.scala +++ /dev/null @@ -1,632 +0,0 @@ -package keycloak - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ -import keycloak.AdminConsoleScenarioBuilder._ - -import java.time.ZonedDateTime -import java.time.format.DateTimeFormatter -import io.gatling.core.pause.Normal -import io.gatling.http.request.StringBody -import org.jboss.perf.util.Util -import org.jboss.perf.util.Util.randomUUID -import org.keycloak.gatling.Utils.{generateCodeChallenge, generateCodeVerifier, urlEncodedRoot, urlencode} -import org.keycloak.performance.TestConfig -import org.keycloak.performance.templates.DatasetTemplate - - -/** - * @author Marko Strukelj - */ - -object AdminConsoleScenarioBuilder { - - val UI_HEADERS = Map( - "Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - "Upgrade-Insecure-Requests" -> "1") - - val ACCEPT_JSON = Map("Accept" -> "application/json") - val ACCEPT_ALL = Map("Accept" -> "*/*") - val AUTHORIZATION = Map("Authorization" -> "Bearer ${accessToken}") - - val APP_URL = "${keycloakServer}/admin/master/console/" - val DATE_FMT = DateTimeFormatter.RFC_1123_DATE_TIME - - - def getRandomUser() : String = { - "user_" + (Util.random.nextDouble() * TestConfig.usersPerRealm).toInt - } - - def needTokenRefresh(sess: Session): Boolean = { - val lastRefresh = sess("accessTokenRefreshTime").as[Long] - - // 5 seconds before expiry is time to refresh - lastRefresh + sess("expiresIn").as[String].toInt * 1000 - 5000 < System.currentTimeMillis() || - // or if refreshTokenPeriod is set force refresh even if not necessary - (TestConfig.refreshTokenPeriod > 0 && - lastRefresh + TestConfig.refreshTokenPeriod * 1000 < System.currentTimeMillis()) - } - - val datasetTemplate = new DatasetTemplate() - datasetTemplate.validateConfiguration - val dataset = datasetTemplate.produce - val realmsIterator = dataset.randomRealmIterator - -} - -class AdminConsoleScenarioBuilder { - - var chainBuilder = exec(s => { - val realm = realmsIterator.next - val serverUrl = TestConfig.serverUrisIterator.next() - val codeVerifier = generateCodeVerifier() - val codeChallenge = generateCodeChallenge(codeVerifier) - s.setAll( - "keycloakServer" -> serverUrl, - "keycloakServerUrlEncoded" -> urlencode(serverUrl), - "keycloakServerRootEncoded" -> urlEncodedRoot(serverUrl), - "state" -> randomUUID(), - "nonce" -> randomUUID(), - "randomClientId" -> ("client_" + randomUUID()), - "realm" -> realm.getRepresentation.getRealm, - "username" -> TestConfig.authUser, - "password" -> TestConfig.authPassword, - "clientId" -> "security-admin-console", - "codeVerifier" -> codeVerifier, - "codeChallenge" -> codeChallenge - ) - }).exitHereIfFailed - - - - def thinkPause() : AdminConsoleScenarioBuilder = { - chainBuilder = chainBuilder.pause(TestConfig.userThinkTime, Normal(TestConfig.userThinkTime * 0.2)) - this - } - - def needTokenRefresh(sess: Session): Boolean = { - val lastRefresh = sess("accessTokenRefreshTime").as[Long] - - // 5 seconds before expiry is time to refresh - lastRefresh + sess("expiresIn").as[String].toInt * 1000 - 5000 < System.currentTimeMillis() || - // or if refreshTokenPeriod is set force refresh even if not necessary - (TestConfig.refreshTokenPeriod > 0 && - lastRefresh + TestConfig.refreshTokenPeriod * 1000 < System.currentTimeMillis()) - } - - def refreshTokenIfExpired() : AdminConsoleScenarioBuilder = { - chainBuilder = chainBuilder - .doIf(s => needTokenRefresh(s)) { - exec(http("JS Adapter Token - Refresh tokens") - .post("/auth/realms/master/protocol/openid-connect/token") - .headers(ACCEPT_ALL) - .formParam("grant_type", "refresh_token") - .formParam("refresh_token", "${refreshToken}") - .formParam("client_id", "security-admin-console") - .check(status.is(200), - jsonPath("$.access_token").saveAs("accessToken"), - jsonPath("$.refresh_token").saveAs("refreshToken"), - jsonPath("$.expires_in").saveAs("expiresIn"), - header("Date").saveAs("tokenTime"))) - - .exec(s => { - s.set("accessTokenRefreshTime", ZonedDateTime.parse(s("tokenTime").as[String], DATE_FMT).toEpochSecond * 1000) - }) - } - this - } - - def openAdminConsoleHome() : AdminConsoleScenarioBuilder = { - chainBuilder = chainBuilder - .exec(http("Console Home") - .get("/auth/admin/") - .headers(UI_HEADERS) - .check(status.is(302)) - .resources( - http("Console Redirect") - .get("/auth/admin/master/console/") - .headers(UI_HEADERS) - .check(status.is(200), regex("").saveAs("resourceVersion")), - http("Console REST - Config") - .get("/auth/admin/master/console/config") - .headers(ACCEPT_JSON) - .check(status.is(200)) - )) - this - } - - def loginThroughLoginForm() : AdminConsoleScenarioBuilder = { - chainBuilder = chainBuilder - .exec(http("JS Adapter Auth - Login Form Redirect") - .get("/auth/realms/master/protocol/openid-connect/auth?client_id=security-admin-console&redirect_uri=${keycloakServerUrlEncoded}%2Fadmin%2Fmaster%2Fconsole%2F&state=${state}&nonce=${nonce}&response_mode=fragment&response_type=code&scope=openid&code_challenge=${codeChallenge}&code_challenge_method=S256") - .headers(UI_HEADERS) - .check(status.is(200), regex("action=\"([^\"]*)\"").find.transform(_.replaceAll("&", "&")).saveAs("login-form-uri"))) - .exitHereIfFailed - - // thinkPause - thinkPause() - - // Successful login - chainBuilder = chainBuilder - .exec(http("Login Form - Submit Correct Credentials") - .post("${login-form-uri}") - .formParam("username", "${username}") - .formParam("password", "${password}") - .formParam("login", "Log in") - .check(status.is(302), - header("Location").saveAs("login-redirect"), - headerRegex("Location", "code=([^&]+)").saveAs("code"))) - // TODO store AUTH_SESSION_ID cookie for use with oauth.authorize? - .exitHereIfFailed - - .exec(http("Console Redirect") - .get("/auth/admin/master/console/") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - http("Console REST - Config") - .get("/auth/admin/master/console/config") - .headers(ACCEPT_JSON) - .check(status.is(200)), - - http("JS Adapter Token - Exchange code for tokens") - .post("/auth/realms/master/protocol/openid-connect/token") - .headers(ACCEPT_ALL) - .formParam("code", "${code}") - .formParam("code_verifier", "${codeVerifier}") - .formParam("grant_type", "authorization_code") - .formParam("client_id", "security-admin-console") - .formParam("redirect_uri", APP_URL) - .check(status.is(200), - jsonPath("$.access_token").saveAs("accessToken"), - jsonPath("$.refresh_token").saveAs("refreshToken"), - jsonPath("$.expires_in").saveAs("expiresIn"), - header("Date").saveAs("tokenTime")), - - http("Console REST - messages.json") - .get("/auth/admin/master/console/messages.json?lang=en") - .headers(ACCEPT_JSON) - .check(status.is(200)), - - // iframe status listener - // TODO: properly set Referer - http("IFrame Status Init") - .get("/auth/realms/master/protocol/openid-connect/login-status-iframe.html/init?client_id=security-admin-console&origin=${keycloakServerRootEncoded}") // ${keycloakServerUrlEncoded} - .headers(ACCEPT_ALL) // ++ Map("Referer" -> "/auth/realms/master/protocol/openid-connect/login-status-iframe.html?version=3.3.0.cr1-201708011508") ${resourceVersion} - .check(status.is(204)) - ) - ) - .exec(s => { - // How to not have to duplicate this block of code? - s.set("accessTokenRefreshTime", ZonedDateTime.parse(s("tokenTime").as[String], DATE_FMT).toEpochSecond * 1000) - }) - .exec(http("Console REST - whoami") - .get("/auth/admin/master/console/whoami") - .headers(ACCEPT_JSON ++ AUTHORIZATION) - .check(status.is(200))) - - .exec(http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200))) - - .exec(http("Console REST - serverinfo") - .get("/auth/admin/serverinfo") - .headers(AUTHORIZATION) - .check(status.is(200))) - - .exec(http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200))) - - .exec(http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200))) - - .exec(http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200))) - this - } - - def openRealmSettings() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder.exec(http("Console Realm Settings") - .get("/auth/resources/${resourceVersion}/admin/keycloak/partials/realm-detail.html") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console - kc-tabs-realm.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/templates/kc-tabs-realm.html") - //.headers(UI_HEADERS ++ Map("Referer" -> "")) // TODO fix referer - .headers(UI_HEADERS) - .check(status.is(200)), - - http("Console - kc-menu.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/templates/kc-menu.html") - //.headers(UI_HEADERS ++ Map("Referer" -> "")) // TODO fix referer - .headers(UI_HEADERS) - .check(status.is(200)) - ) - ) - .exitHereIfFailed - this - } - - def openClients() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console - client-list.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/partials/client-list.html") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)), - http("Console - kc-paging.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/templates/kc-paging.html") - .headers(UI_HEADERS) - .check(status.is(200)), - http("Console REST - ${realm}/clients") - .get("/auth/admin/realms/${realm}/clients?viewableOnly=true") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - ) - this - } - - def openCreateNewClient() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console - create-client.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/partials/create-client.html") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - http("Console REST - ${realm}/clients") - .get("/auth/admin/realms/${realm}/clients") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - ) - this - } - - def submitNewClient() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console REST - ${realm}/clients POST") - .post("/auth/admin/realms/${realm}/clients") - .headers(AUTHORIZATION) - .header("Content-Type", "application/json") - .body(StringBody( - """ - {"enabled":true,"attributes":{},"redirectUris":[],"clientId":"${randomClientId}","rootUrl":"http://localhost:8081/myapp","protocol":"openid-connect"} - """.stripMargin)) - .check(status.is(201), headerRegex("Location", "\\/([^\\/]+)$").saveAs("idOfClient"))) - - .exec(http("Console REST - ${realm}/clients/ID") - .get("/auth/admin/realms/${realm}/clients/${idOfClient}") - .headers(AUTHORIZATION) - .check(status.is(200), bodyString.saveAs("clientJson")) - .resources( - http("Console REST - ${realm}/clients") - .get("/auth/admin/realms/${realm}/clients") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}/client-templates") - .get("/auth/admin/realms/${realm}/client-templates") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - ) - this - } - - def updateClient() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder.exec(s => { - s.set("updateClientJson", s("clientJson").as[String].replace("\"publicClient\":false", "\"publicClient\":true")) - }) - .exec(http("Console REST - ${realm}/clients/ID PUT") - .put("/auth/admin/realms/${realm}/clients/${idOfClient}") - .headers(AUTHORIZATION) - .header("Content-Type", "application/json") - .body(StringBody("${updateClientJson}")) - .check(status.is(204))) - - .exec(http("Console REST - ${realm}/clients/ID") - .get("/auth/admin/realms/${realm}/clients/${idOfClient}") - .headers(AUTHORIZATION) - .check(status.is(200), bodyString.saveAs("clientJson")) - .resources( - http("Console REST - ${realm}/clients") - .get("/auth/admin/realms/${realm}/clients") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}/client-templates") - .get("/auth/admin/realms/${realm}/client-templates") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - ) - this - } - - def openClientDetails() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console - client-detail.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/partials/client-detail.html") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - http("Console REST - ${realm}/client-templates") - .get("/auth/admin/realms/${realm}/client-templates") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}/clients") - .get("/auth/admin/realms/${realm}/clients") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}/clients/ID") - .get("/auth/admin/realms/${realm}/clients/${idOfClient}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console - kc-tabs-client.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/templates/kc-tabs-client.html") - .headers(UI_HEADERS) - .check(status.is(200)) - ) - ) - this - } - - def openUsers() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console - user-list.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/partials/user-list.html") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)), - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - http("Console - kc-tabs-users.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/templates/kc-tabs-users.html") - .headers(UI_HEADERS) - .check(status.is(200)) - ) - ) - this - } - - def viewAllUsers() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console REST - ${realm}/users") - .get("/auth/admin/realms/${realm}/users?first=0&max=20") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - this - } - - def viewTenPagesOfUsers() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .repeat(10, "i") { - exec(s => s.set("offset", s("i").as[Int] * 20)) - .pause(1) - .exec(http("Console REST - ${realm}/users?first=${offset}") - .get("/auth/admin/realms/${realm}/users?first=${offset}&max=20") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - } - this - } - - def find20Users() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console REST - ${realm}/users?first=0&max=20&search=user") - .get("/auth/admin/realms/${realm}/users?first=0&max=20&search=user") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - this - } - - def findUnlimitedUsers() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console REST - ${realm}/users?search=user") - .get("/auth/admin/realms/${realm}/users?search=user") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - this - } - - def findRandomUser() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(s => s.set("randomUsername", getRandomUser())) - .exec(http("Console REST - ${realm}/users?first=0&max=20&search=USERNAME") - .get("/auth/admin/realms/${realm}/users?first=0&max=20&search=${randomUsername}") - .headers(AUTHORIZATION) - .check(status.is(200), jsonPath("$[0]['id']").saveAs("userId")) - ) - this - } - - def openUser() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console - user-detail.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/partials/user-detail.html") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}/users/ID") - .get("/auth/admin/realms/${realm}/users/${userId}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console - kc-tabs-user.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/templates/kc-tabs-user.html") - .headers(UI_HEADERS) - .check(status.is(200)), - - http("Console REST - ${realm}/authentication/required-actions") - .get("/auth/admin/realms/${realm}/authentication/required-actions") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}/attack-detection/brute-force/users/ID") - .get("/auth/admin/realms/${realm}/attack-detection/brute-force/users/${userId}") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - ) - this - } - - def openUserCredentials() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console - user-credentials.html") - .get("/auth/resources/${resourceVersion}/admin/keycloak/partials/user-credentials.html") - .headers(UI_HEADERS) - .check(status.is(200)) - .resources( - - http("Console REST - ${realm}/users/ID") - .get("/auth/admin/realms/${realm}/users/${userId}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}") - .get("/auth/admin/realms/${realm}") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - realms") - .get("/auth/admin/realms") - .headers(AUTHORIZATION) - .check(status.is(200)), - - http("Console REST - ${realm}/authentication/required-actions") - .get("/auth/admin/realms/${realm}/authentication/required-actions") - .headers(AUTHORIZATION) - .check(status.is(200)) - ) - ) - this - } - - def setTemporaryPassword() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Console REST - ${realm}/users/ID/reset-password PUT") - .put("/auth/admin/realms/${realm}/users/${userId}/reset-password") - .headers(AUTHORIZATION) - .header("Content-Type", "application/json") - .body(StringBody("""{"type":"password","value":"testtest","temporary":true}""")) - .check(status.is(204) - ) - ) - this - } - - def logout() : AdminConsoleScenarioBuilder = { - refreshTokenIfExpired() - chainBuilder = chainBuilder - .exec(http("Browser logout") - .get("/auth/realms/master/protocol/openid-connect/logout") - .headers(UI_HEADERS) - .queryParam("redirect_uri", APP_URL) - .check(status.is(302), header("Location").is(APP_URL) - ) - ) - this - } -} diff --git a/testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleSimulation.scala b/testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleSimulation.scala deleted file mode 100644 index 485465bb55..0000000000 --- a/testsuite/performance/tests/src/test/scala/keycloak/AdminConsoleSimulation.scala +++ /dev/null @@ -1,80 +0,0 @@ -package keycloak - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ - -/** - * @author Marko Strukelj - */ -class AdminConsoleSimulation extends CommonSimulation { - - val httpProtocol = http - .baseURL("http://localhost:8080") - .disableFollowRedirect - .inferHtmlResources() - .acceptHeader("application/json, text/plain, */*") - .acceptEncodingHeader("gzip, deflate") - .acceptLanguageHeader("en-US,en;q=0.5") - .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0") - - val adminSession = new AdminConsoleScenarioBuilder() - .openAdminConsoleHome() - .thinkPause() - .loginThroughLoginForm() - - .openRealmSettings() - - .thinkPause() - .openClients() - - .thinkPause() - .openCreateNewClient() - - .thinkPause() - .submitNewClient() - - .thinkPause() - .updateClient() - - .thinkPause() - .openClients() - - .thinkPause() - .openClientDetails() - - .thinkPause() - .openUsers() - - .thinkPause() - .viewAllUsers() - - .thinkPause() - .viewTenPagesOfUsers() - - .thinkPause() - .find20Users() - - .thinkPause() - .findUnlimitedUsers() - - .thinkPause() - .findRandomUser() - .openUser() - - .thinkPause() - .openUserCredentials() - - .thinkPause() - .setTemporaryPassword() - - .thinkPause() - .logout() - - .thinkPause() - - - val adminScenario = scenario("AdminConsole").exec(adminSession.chainBuilder) - - setUp(adminScenario.inject(defaultInjectionProfile).protocols(httpProtocol)) - -} diff --git a/testsuite/performance/tests/src/test/scala/keycloak/CommonSimulation.scala b/testsuite/performance/tests/src/test/scala/keycloak/CommonSimulation.scala deleted file mode 100644 index 3f9613fc52..0000000000 --- a/testsuite/performance/tests/src/test/scala/keycloak/CommonSimulation.scala +++ /dev/null @@ -1,57 +0,0 @@ -package keycloak - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ -import org.keycloak.gatling.log.LogProcessor -import io.gatling.core.validation.Validation - -import io.gatling.core.controller.inject.InjectionStep - -import org.keycloak.performance.TestConfig - - -/** - * @author tomas Kyjovsky <tkyjovsk@redhat.com> - */ -abstract class CommonSimulation extends Simulation { - - println() - println("Target servers: " + TestConfig.serverUrisList) - println() - println("Using test parameters:\n" + TestConfig.toStringCommonTestParameters); - printSpecificTestParameters - println() -// println("Using dataset properties:\n" + TestConfig.toStringDatasetProperties) -// println() - println("Using assertion properties:\n" + TestConfig.toStringAssertionProperties) - println() - println("Timestamps: \n" + TestConfig.toStringTimestamps) - println() - - var defaultInjectionProfile = Array[InjectionStep] ( - rampUsersPerSec(0.001) to TestConfig.usersPerSec during(TestConfig.rampUpPeriod), - constantUsersPerSec(TestConfig.usersPerSec) during(TestConfig.warmUpPeriod + TestConfig.measurementPeriod) - ) - - def printSpecificTestParameters { - // override in subclass - } - - def rampDownNotStarted(): Validation[Boolean] = { - System.currentTimeMillis < TestConfig.measurementEndTime - } - - before { - TestConfig.validateConfiguration - } - - after { - if (TestConfig.filterResults) { - new LogProcessor(getClass).filterLog( - TestConfig.measurementStartTime, - TestConfig.measurementEndTime, - false, false) - } - } - -} diff --git a/testsuite/performance/tests/src/test/scala/keycloak/OIDCLoginAndLogoutSimulation.scala b/testsuite/performance/tests/src/test/scala/keycloak/OIDCLoginAndLogoutSimulation.scala deleted file mode 100644 index 7dfedf4a8d..0000000000 --- a/testsuite/performance/tests/src/test/scala/keycloak/OIDCLoginAndLogoutSimulation.scala +++ /dev/null @@ -1,26 +0,0 @@ -package keycloak - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ -import keycloak.OIDCScenarioBuilder._ - -import org.keycloak.performance.TestConfig - - -class OIDCLoginAndLogoutSimulation extends CommonSimulation { - - override def printSpecificTestParameters { - println(" refreshTokenCount: " + TestConfig.refreshTokenCount) - println(" badLoginAttempts: " + TestConfig.badLoginAttempts) - } - - val usersScenario = scenario("Logging-in Users").exec(loginAndLogoutScenario.chainBuilder) - - setUp(usersScenario.inject(defaultInjectionProfile).protocols(httpDefault)) - - .assertions( - global.failedRequests.count.lessThan(TestConfig.maxFailedRequests + 1), - global.responseTime.mean.lessThan(TestConfig.maxMeanReponseTime) - ) - -} diff --git a/testsuite/performance/tests/src/test/scala/keycloak/OIDCRegisterAndLogoutSimulation.scala b/testsuite/performance/tests/src/test/scala/keycloak/OIDCRegisterAndLogoutSimulation.scala deleted file mode 100644 index 7c2eb79cc4..0000000000 --- a/testsuite/performance/tests/src/test/scala/keycloak/OIDCRegisterAndLogoutSimulation.scala +++ /dev/null @@ -1,26 +0,0 @@ -package keycloak - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ -import keycloak.OIDCScenarioBuilder._ - -import org.keycloak.performance.TestConfig - - -class OIDCRegisterAndLogoutSimulation extends CommonSimulation { - - override def printSpecificTestParameters { - println(" refreshTokenCount: " + TestConfig.refreshTokenCount) - println(" badLoginAttempts: " + TestConfig.badLoginAttempts) - } - - val usersScenario = scenario("Registering Users").exec(registerAndLogoutScenario.chainBuilder) - - setUp(usersScenario.inject(defaultInjectionProfile).protocols(httpDefault)) - - .assertions( - global.failedRequests.count.lessThan(TestConfig.maxFailedRequests + 1), - global.responseTime.mean.lessThan(TestConfig.maxMeanReponseTime) - ) - -} diff --git a/testsuite/performance/tests/src/test/scala/keycloak/OIDCScenarioBuilder.scala b/testsuite/performance/tests/src/test/scala/keycloak/OIDCScenarioBuilder.scala deleted file mode 100644 index b1b1af6623..0000000000 --- a/testsuite/performance/tests/src/test/scala/keycloak/OIDCScenarioBuilder.scala +++ /dev/null @@ -1,252 +0,0 @@ -package keycloak - -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ -import org.keycloak.gatling.Predef._ -import keycloak.OIDCScenarioBuilder._ - -import java.util.concurrent.atomic.AtomicInteger - -import io.gatling.core.pause.Normal -import io.gatling.core.session.Session -import io.gatling.core.structure.ChainBuilder -import io.gatling.core.validation.Validation -import org.jboss.perf.util.Util -import org.jboss.perf.util.Util.randomUUID -import org.keycloak.adapters.spi.HttpFacade.Cookie -import org.keycloak.gatling.AuthorizeAction -import org.keycloak.performance.TestConfig -import org.keycloak.performance.templates.DatasetTemplate - - -/** - * @author Marko Strukelj - */ -object OIDCScenarioBuilder { - - val BASE_URL = "${keycloakServer}/realms/${realm}" - val LOGIN_ENDPOINT = BASE_URL + "/protocol/openid-connect/auth" - val LOGOUT_ENDPOINT = BASE_URL + "/protocol/openid-connect/logout" - - // Specify defaults for http requests - val UI_HEADERS = Map( - "Accept" -> "text/html,application/xhtml+xml,application/xml", - "Accept-Encoding" -> "gzip, deflate", - "Accept-Language" -> "en-US,en;q=0.5", - "User-Agent" -> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0") - - val ACCEPT_JSON = Map("Accept" -> "application/json") - val ACCEPT_ALL = Map("Accept" -> "*/*") - - def downCounterAboveZero(session: Session, attrName: String): Validation[Boolean] = { - val missCounter = session.attributes.get(attrName) match { - case Some(result) => result.asInstanceOf[AtomicInteger] - case None => new AtomicInteger(0) - } - missCounter.getAndDecrement() > 0 - } - - val httpDefault = http - .acceptHeader("application/json") - .disableFollowRedirect - .inferHtmlResources - - val loginAndLogoutScenario = new OIDCScenarioBuilder() - .browserOpensLoginPage() - .thinkPause() - .browserPostsWrongCredentials() - .browserPostsCorrectCredentials() - - // Act as client adapter - exchange code for keys - .adapterExchangesCodeForTokens() - - .refreshTokenSeveralTimes() - - .thinkPause() - .randomLogout() - - val registerAndLogoutScenario = new OIDCScenarioBuilder() - .browserOpensLoginPage() - .thinkPause() - .browserOpensRegistrationPage() - .thinkPause() - .browserPostsRegistrationDetails() - .adapterExchangesCodeForTokens() - .thinkPause() - .randomLogout() - - val datasetTemplate = new DatasetTemplate() - datasetTemplate.validateConfiguration - val dataset = datasetTemplate.produce - val usersIterator = dataset.randomUsersIterator - -} - - -class OIDCScenarioBuilder { - - var chainBuilder = exec(s => { - - val user = usersIterator.next - val client = user.randomConfidentialClientIterator.next - - AuthorizeAction.init(s) - .setAll("keycloakServer" -> TestConfig.serverUrisIterator.next(), - "state" -> randomUUID(), - "wrongPasswordCount" -> new AtomicInteger(TestConfig.badLoginAttempts), - "refreshTokenCount" -> new AtomicInteger(TestConfig.refreshTokenCount), - "realm" -> user.getRealm.toString, - "firstName" -> user.getRepresentation.getFirstName, - "lastName" -> user.getRepresentation.getLastName, - "email" -> user.getRepresentation.getEmail, - "username" -> user.getRepresentation.getUsername, - "password" -> user.getCredentials.get(0).getRepresentation.getValue, - "clientId" -> client.getRepresentation.getClientId, - "secret" -> client.getRepresentation.getSecret, - "appUrl" -> client.getRepresentation.getBaseUrl - ) - }) - .exitHereIfFailed - - def thinkPause() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder.pause(TestConfig.userThinkTime, Normal(TestConfig.userThinkTime * 0.2)) - this - } - - def thinkPause(builder: ChainBuilder) : ChainBuilder = { - builder.pause(TestConfig.userThinkTime, Normal(TestConfig.userThinkTime * 0.2)) - } - - def newThinkPause() : ChainBuilder = { - pause(TestConfig.userThinkTime, Normal(TestConfig.userThinkTime * 0.2)) - } - - def browserOpensLoginPage() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .exec(http("Browser to Log In Endpoint") - .get(LOGIN_ENDPOINT) - .headers(UI_HEADERS) - .queryParam("login", "true") - .queryParam("response_type", "code") - .queryParam("client_id", "${clientId}") - .queryParam("state", "${state}") - .queryParam("redirect_uri", "${appUrl}") - .check(status.is(200), - regex("action=\"([^\"]*)\"").find.transform(_.replaceAll("&", "&")).saveAs("login-form-uri"), - regex("href=\"/auth(/realms/[^\"]*/login-actions/registration[^\"]*)\"").find.transform(_.replaceAll("&", "&")).saveAs("registration-link"))) - // if already logged in the check will fail with: - // status.find.is(200), but actually found 302 - // The reason is that instead of returning the login page we are immediately redirected to the app that requested authentication - .exitHereIfFailed - this - } - - def browserPostsWrongCredentials() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .asLongAs(s => downCounterAboveZero(s, "wrongPasswordCount")) { - var c = exec(http("Browser posts wrong credentials") - .post("${login-form-uri}") - .headers(UI_HEADERS) - .formParam("username", "${username}") - .formParam("password", _ => Util.randomString(10)) - .formParam("login", "Log in") - .check(status.is(200), regex("action=\"([^\"]*)\"").find.transform(_.replaceAll("&", "&")).saveAs("login-form-uri"))) - .exitHereIfFailed - - // make sure to call the right version of thinkPause - one that takes chainBuilder as argument - // - because this is a nested chainBuilder - not the same as chainBuilder field - thinkPause(c) - } - this - } - - def browserPostsCorrectCredentials() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .exec(http("Browser posts correct credentials") - .post("${login-form-uri}") - .headers(UI_HEADERS) - .formParam("username", "${username}") - .formParam("password", "${password}") - .formParam("login", "Log in") - .check(status.is(302), header("Location").saveAs("login-redirect"))) - .exitHereIfFailed - this - } - - def browserOpensRegistrationPage() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .exec(http("Browser to Registration Endpoint") - .get("${keycloakServer}${registration-link}") - .headers(UI_HEADERS) - .check( - status.is(200), - regex("action=\"([^\"]*)\"").find.transform(_.replaceAll("&", "&")).saveAs("registration-form-uri")) - ) - .exitHereIfFailed - this - } - - def browserPostsRegistrationDetails() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .exec(http("Browser posts registration details") - .post("${registration-form-uri}") - .headers(UI_HEADERS) - .formParam("firstName", "${firstName}") - .formParam("lastName", "${lastName}") - .formParam("email", "${email}") - .formParam("username", "${username}") - .formParam("password", "${password}") - .formParam("password-confirm", "${password}") - .check(status.is(302), header("Location").saveAs("login-redirect"))) - .exitHereIfFailed - this - } - - def adapterExchangesCodeForTokens() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .exec(oauth("Adapter exchanges code for tokens") - .authorize("${login-redirect}", - session => List(new Cookie("OAuth_Token_Request_State", session("state").as[String], 0, null, null))) - .authServerUrl("${keycloakServer}") - .resource("${clientId}") - .clientCredentials("${secret}") - .realm("${realm}") - //.realmKey(Loader.realmRepresentation.getPublicKey) - ) - this - } - - def refreshTokenSeveralTimes() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .asLongAs(s => downCounterAboveZero(s, "refreshTokenCount")) { - // make sure to call newThinkPause rather than thinkPause - newThinkPause() - .exec(oauth("Adapter refreshes token").refresh()) - } - this - } - - def logoutChain() : ChainBuilder = { - exec(http("Browser logout") - .get(LOGOUT_ENDPOINT) - .headers(UI_HEADERS) - .queryParam("redirect_uri", "${appUrl}") - .check(status.is(302), header("Location").is("${appUrl}"))) - } - - def logout() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder.exec(logoutChain) - this - } - - def randomLogout() : OIDCScenarioBuilder = { - chainBuilder = chainBuilder - .randomSwitch( - // logout randomly based on logoutPct param - TestConfig.logoutPct -> exec(logoutChain) - ) - this - } - -} - diff --git a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/Admin.scala b/testsuite/performance/tests/src/test/scala/org/keycloak/performance/Admin.scala deleted file mode 100644 index e85222c057..0000000000 --- a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/Admin.scala +++ /dev/null @@ -1,114 +0,0 @@ -package org.keycloak.performance - -import io.gatling.core.Predef._ -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicInteger -import java.util.concurrent.TimeUnit -import java.util.concurrent.TimeUnit._ -import java.util.concurrent.TimeoutException -import scala.concurrent.duration._ -import java.util.concurrent.CyclicBarrier -import io.gatling.core.structure.ChainBuilder - -object Admin extends Admin { - - object Sync { // java.util.concurrent.CyclicBarrier doesn't work with Gatling because of the Akka actor model, need this custom solution - - val usersMax = adminUsers - val usersArrived = new AtomicInteger(0) - val latchOpen = new AtomicBoolean(false) - - def isLatchOpen = latchOpen.get - - def waitForPreviousLatchToCloseIfStillOpen = asLongAs ( s => latchOpen.get && !isGlobalStopRequested, "waitForLatchToCloseTimeout") ( - checkGlobalStopRequest - - .doIfOrElse ( s => (s("waitForLatchToCloseTimeout").as[Int] < 100)) ( // 100 * 100 millis = 10 seconds - exec { s => -// println("previous latch still open, waiting for its closure") - s - }.pause(100.millisecond) - ) ( - exec { s => - throw new IllegalStateException("Waiting for previous latch to close timed out. This shoulnd't happen.") - s - }.exitHereIfFailed - ) - ) - - def arriveAtLatchAndOpenIfLast(latchName:String) = exec { s => - usersArrived.incrementAndGet - if (usersArrived.get >= usersMax && !latchOpen.get) { - println("opening latch: "+latchName) - latchOpen.set(true) // last arriving opens the latch - } - s - } - - def waitForLatchToOpen(timeout:Integer) = asLongAs ( s => !latchOpen.get, "waitForLatchToOpenTimeout") ( - checkGlobalStopRequest - .doIfOrElse ( s => (s("waitForLatchToOpenTimeout").as[Int] < timeout)) ( - exec { s => -// println("waiting for latch to open. usersArrived: "+usersArrived.get +"/"+usersMax+ ", timeout: "+(timeout - s("waitForLatchToOpenTimeout").as[Int])) - s - }.pause(1.second) - ) ( - exec { s => - throw new TimeoutException("Waiting for others timed out. Missing users: " + (usersMax - usersArrived.get)) - s - }.exitHereIfFailed - ) - ) - - def leaveLatchAndCloseIfLast(latchName:String) = exec { s => - usersArrived.decrementAndGet - if (usersArrived.get <= 0 && latchOpen.get) { - println("closing latch: "+latchName) - latchOpen.set(false) // last leaving closes the latch - } - s.remove("waitForLatchToOpenTimeout") - s - } - - def waitForOthers(latchName:String, timeout:Integer) = exec ( - waitForPreviousLatchToCloseIfStillOpen, - arriveAtLatchAndOpenIfLast(latchName), - waitForLatchToOpen(timeout), - leaveLatchAndCloseIfLast(latchName) - ) - - def waitForOthers(latchName:String) : ChainBuilder = waitForOthers(latchName, 10) - - def waitForOthers : ChainBuilder = waitForOthers("") - - - - - val globalStopRequested = new AtomicBoolean(false) - def isGlobalStopRequested = { -// println("isGlobalStopRequested: "+globalStopRequested.get) - globalStopRequested.get - } - def checkGlobalStopRequest = exec { s => - if (isGlobalStopRequested) throw new RuntimeException("Global stop requested.") - s - }.exitHereIfFailed - - def requestGlobalStop : ChainBuilder = exec { s => - println("Requesting global stop.") - globalStopRequested.set(true) - s - }.exec(checkGlobalStopRequest) - - } - -} - -trait Admin extends OIDC { - import Admin._ - - val adminUsers = TestConfig.numOfWorkers - - val adminInjectionProfile = atOnceUsers(adminUsers) - -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminCLI.scala b/testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminCLI.scala deleted file mode 100644 index adf8de6c4c..0000000000 --- a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminCLI.scala +++ /dev/null @@ -1,91 +0,0 @@ -package org.keycloak.performance - -import java.time.ZonedDateTime -import java.util.concurrent.TimeUnit._ -import scala.collection.JavaConversions._ -import io.gatling.core.Predef._ -import io.gatling.http.Predef._ -import io.gatling.core.session._ -import io.gatling.core.structure.ChainBuilder -import org.keycloak.performance.iteration._ -import org.keycloak.performance.dataset._ -import org.keycloak.performance.dataset.idm._ -import org.keycloak.performance.dataset.idm.authorization._ - -object AdminCLI extends AdminCLI - -trait AdminCLI extends Admin { - - val adminCLIHttpConf = http - .disableFollowRedirect - .acceptHeader("application/json, text/plain, */*") - - object Auth { - - def init = exec(s => { - val serverUrl = TestConfig.serverUrisIterator.next - s.setAll( - "keycloakServer" -> serverUrl, - "username" -> TestConfig.authUser, - "password" -> TestConfig.authPassword, - "clientId" -> "admin-cli" - ) - }).exitHereIfFailed - - def login = exec( - http("Admin Login") - .post("${keycloakServer}/realms/master/protocol/openid-connect/token") - .headers(ACCEPT_ALL) - .formParam("grant_type", "password") - .formParam("username", "${username}") - .formParam("password", "${password}") - .formParam("client_id", "${clientId}") - .check(status.is(200), - jsonPath("$.access_token").saveAs("accessToken"), - jsonPath("$.refresh_token").saveAs("refreshToken"), - jsonPath("$.expires_in").saveAs("expiresIn"), - header("Date").saveAs("tokenTime"))) - .exitHereIfFailed - .exec{s => - s.set("accessTokenRefreshTime", ZonedDateTime.parse(s("tokenTime").as[String], DATE_FMT_RFC1123).toEpochSecond * 1000) - } - - def needTokenRefresh(session: Session): Boolean = { - val lastRefresh = session("accessTokenRefreshTime").as[Long] - - // 5 seconds before expiry is time to refresh - lastRefresh + session("expiresIn").as[String].toInt * 1000 - 5000 < System.currentTimeMillis() || - // or if refreshTokenPeriod is set force refresh even if not necessary - (TestConfig.refreshTokenPeriod > 0 && - lastRefresh + TestConfig.refreshTokenPeriod * 1000 < System.currentTimeMillis()) - } - - def refreshTokenIfExpired = doIf(s => needTokenRefresh(s)) { - exec{s => println("Access Token Expired. Refreshing.") - s} - .exec( - http("Refresh Token") - .post("${keycloakServer}/realms/master/protocol/openid-connect/token") - .headers(ACCEPT_ALL) - .formParam("grant_type", "refresh_token") - .formParam("refresh_token", "${refreshToken}") - .formParam("client_id", "admin-cli") - .check(status.is(200), - jsonPath("$.access_token").saveAs("accessToken"), - jsonPath("$.refresh_token").saveAs("refreshToken"), - jsonPath("$.expires_in").saveAs("expiresIn"), - header("Date").saveAs("tokenTime")) - ).exec{s => - s.set("accessTokenRefreshTime", ZonedDateTime.parse(s("tokenTime").as[String], DATE_FMT_RFC1123).toEpochSecond * 1000) - } - } - - def logout = exec (refreshTokenIfExpired).exec( - http("Admin Logout") - .get("${keycloakServer}/realms/master/protocol/openid-connect/logout") - .check(status.is(200)) - ) - - } - -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminConsole.scala b/testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminConsole.scala deleted file mode 100644 index 91599c45ca..0000000000 --- a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/AdminConsole.scala +++ /dev/null @@ -1,12 +0,0 @@ -package org.keycloak.performance - -object AdminConsole extends AdminConsole { - -} - -trait AdminConsole extends Admin { - import AdminConsole._ - - // TODO Existing tests from keycloak.AdminConsole* will be moved here. - -} diff --git a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/EmulatedOIDC.scala b/testsuite/performance/tests/src/test/scala/org/keycloak/performance/EmulatedOIDC.scala deleted file mode 100644 index 01fa8bf5c7..0000000000 --- a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/EmulatedOIDC.scala +++ /dev/null @@ -1,13 +0,0 @@ -package org.keycloak.performance - -object EmulatedOIDC extends EmulatedOIDC { - - - // TODO Existing OIDC tests from keycloak.OIDC* will be moved here. - -} - -trait EmulatedOIDC extends OIDC { - import EmulatedOIDC._ - -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/Keycloak.scala b/testsuite/performance/tests/src/test/scala/org/keycloak/performance/Keycloak.scala deleted file mode 100644 index 735bc23f79..0000000000 --- a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/Keycloak.scala +++ /dev/null @@ -1,17 +0,0 @@ -package org.keycloak.performance - -import java.time.format.DateTimeFormatter -import org.keycloak.performance.templates.DatasetTemplate - -trait Keycloak { - - val datasetTemplate = new DatasetTemplate() - datasetTemplate.validateConfiguration - val dataset = datasetTemplate.produce - - val DATE_FMT_RFC1123 = DateTimeFormatter.RFC_1123_DATE_TIME - - val ACCEPT_ALL = Map("Accept" -> "*/*") - val AUTHORIZATION = Map("Authorization" -> "Bearer ${accessToken}") - -} \ No newline at end of file diff --git a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/OIDC.scala b/testsuite/performance/tests/src/test/scala/org/keycloak/performance/OIDC.scala deleted file mode 100644 index 47b1ee9280..0000000000 --- a/testsuite/performance/tests/src/test/scala/org/keycloak/performance/OIDC.scala +++ /dev/null @@ -1,10 +0,0 @@ -package org.keycloak.performance - -object OIDC extends OIDC { - -} - -trait OIDC extends Keycloak { - import OIDC._ - -} \ No newline at end of file diff --git a/testsuite/pom.xml b/testsuite/pom.xml index 2d7d5459b8..b99cddf070 100755 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -62,13 +62,4 @@ utils - - - performance - - performance - - - -