Skip to content

Commit

Permalink
Issue #20: Add keycloak performance test script
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbremer committed Dec 10, 2022
1 parent 5e8815d commit 98f386b
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ recover: 3
[master]
kvm_operating_system: Others
kvm_template: ucs-joined-master
kvm_ucsversion: 5.0-2+e479
kvm_ucsversion: 5.0-2
command1:
. utils.sh && basic_setup
. utils.sh && basic_setup_ucs_joined "[ENV:master_IP]"
Expand All @@ -31,7 +31,7 @@ command1:
command3:
. utils.sh && switch_to_test_app_center || :
echo "univention" > pwdfile
univention-app install keycloak=19.0.1-ucs5 --username=Administrator --pwdfile=/root/pwdfile --skip --noninteractive
univention-app install keycloak="[ENV:APPVERSION]" --username=Administrator --pwdfile=/root/pwdfile --skip --noninteractive
. utils.sh && assert_join
. utils.sh && install_ucs_test
command4:
Expand All @@ -49,7 +49,7 @@ files:
[backup]
kvm_operating_system: Others
kvm_template: ucs-joined-backup
kvm_ucsversion: 5.0-2+e479
kvm_ucsversion: 5.0-2
command1:
. utils.sh && basic_setup
. utils.sh && basic_setup_ucs_joined "[ENV:master_IP]"
Expand All @@ -61,7 +61,7 @@ command1:
command2:
. utils.sh && switch_to_test_app_center || :
echo "univention" > pwdfile
univention-app install keycloak=19.0.1-ucs5 --username=Administrator --pwdfile=/root/pwdfile --skip --noninteractive
univention-app install keycloak="[ENV:APPVERSION]" --username=Administrator --pwdfile=/root/pwdfile --skip --noninteractive
#univention-app install keycloak="16-test-julia"
. utils.sh && assert_join
. utils.sh && install_ucs_test
Expand Down
121 changes: 121 additions & 0 deletions test/scenarios/keycloak/keycloak_performance.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
[Global]

kvm_server: [ENV:KVM_BUILD_SERVER]
kvm_user: [ENV:KVM_USER]
kvm_dhcp: 1
kvm_interface: eth0
kvm_extra_label: ucs-[ENV:UCS_MINORRELEASE]-keycloak-performance
kvm_template: [ENV:KVM_TEMPLATE]
kvm_ucsversion: [ENV:KVM_UCSVERSION]
kvm_architecture: amd64
kvm_memory: 64GiB
kvm_vcpus: [ENV:KVM_CPUS]

# These settings can be overwritten by the instance
logfile: autotest-keycloak-backups.log

jenkins_description: Keycloak login performance test
# if command fails continue with command
recover: 3

[master]
kvm_template: ucs-joined-master
kvm_ucsversion: 5.0-2
kvm_architecture: amd64
kvm_operating_system: Others
kvm_cpus: 8
command1:
. utils.sh && basic_setup
. utils.sh && basic_setup_ucs_joined "[ENV:master_IP]"
command3:
. utils.sh && import_license
. utils.sh && add_tech_key_authorized_keys
. utils.sh && jenkins_updates
. utils.sh && switch_to_test_app_center
echo "univention" > pwdfile
univention-app install keycloak="[ENV:APPVERSION]" --username=Administrator --pwdfile=/root/pwdfile --skip --noninteractive
. utils.sh && run_join_scripts
. utils.sh && assert_join
ucr set umc/http/processes=8
ucr set umc/server/processes=8
service univention-management-console-server restart
service univention-management-console-web-server restart
command4:
ucr set umc/saml/idp-server='https://ucs-sso-ng.ucs.test/realms/ucs/protocol/saml/descriptor'
service slapd restart
. utils.sh && prepare_results
LOCAL utils/utils-local.sh fetch-results [SELF_IP] [SELF]
files:
~/ec2/scripts/activate-errata-test-scope.sh /root/
utils/utils.sh /root/
~/ec2/license/license.secret /etc/

[backup]
kvm_template: ucs-joined-backup
kvm_architecture: amd64
kvm_operating_system: Others
kvm_cpus: 8
kvm_ucsversion: 5.0-2
command1:
. utils.sh && basic_setup
. utils.sh && basic_setup_ucs_joined "[ENV:master_IP]"
. utils.sh && import_license
. utils.sh && jenkins_updates
. utils.sh && run_join_scripts
. utils.sh && assert_join
. utils.sh && assert_version "[ENV:TARGET_VERSION]"
command2:
. utils.sh && switch_to_test_app_center || :
echo "univention" > pwdfile
univention-app install keycloak="[ENV:APPVERSION]" --username=Administrator --pwdfile=/root/pwdfile --skip --noninteractive
. utils.sh && assert_join
. utils.sh && install_ucs_test
ucr set umc/http/processes=8
ucr set umc/server/processes=8
service univention-management-console-server restart
service univention-management-console-web-server restart
command4:
ucr set umc/saml/idp-server='https://ucs-sso-ng.ucs.test/realms/ucs/protocol/saml/descriptor'
service slapd restart
. utils.sh && prepare_results
LOCAL utils/utils-local.sh fetch-results [SELF_IP] [SELF]
files:
keycloaklocust.py /root/
~/ec2/scripts/activate-errata-test-scope.sh /root/
utils/utils.sh /root/
~/ec2/license/license.secret /etc/
~/ec2/spamassassin/1854818.tar.gz.sha256 /root/
~/ec2/spamassassin/1854818.tar.gz.asc /root/
~/ec2/spamassassin/1854818.tar.gz.sha512 /root/
~/ec2/spamassassin/1854818.tar.gz /root/

[member]
kvm_template: ucs-joined-member
kvm_architecture: amd64
kvm_operating_system: Others
kvm_cpus: 8
kvm_ucsversion: 5.0-2
command1:
. utils.sh && basic_setup
. utils.sh && basic_setup_ucs_joined "[ENV:master_IP]"
. utils.sh && import_license
. utils.sh && jenkins_updates
. utils.sh && assert_join
. utils.sh && assert_version "[ENV:TARGET_VERSION]"
command2:
DEBIAN_FRONTEND=noninteractive apt-get -y install libffi-dev python3-pip
pip3 install locust bs4
. utils.sh && install_ucs_test
command4:
prlimit -n100000:100000 locust -t 20m -u 500 --spawn-rate 10 --host master.ucs.test --html keycloak.html --headless -f keycloaklocust.py || :
. utils.sh && prepare_results
LOCAL utils/utils-local.sh fetch-results [SELF_IP] [SELF]
files:
utils/keycloaklocust.py /root/
~/ec2/scripts/activate-errata-test-scope.sh /root/
utils/utils.sh /root/
~/ec2/license/license.secret /etc/
~/ec2/spamassassin/1854818.tar.gz.sha256 /root/
~/ec2/spamassassin/1854818.tar.gz.asc /root/
~/ec2/spamassassin/1854818.tar.gz.sha512 /root/
~/ec2/spamassassin/1854818.tar.gz /root/
68 changes: 68 additions & 0 deletions test/utils/keycloaklocust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python3

from html.parser import HTMLParser

import random
from bs4 import BeautifulSoup
import univention.testing.utils as utils
from locust import HttpUser, task, constant_throughput

html = HTMLParser()

account = utils.UCSTestDomainAdminCredentials()

WAIT_MIN = 1
WAIT_MAX = 1
hosts = ["https://master.ucs.test", "https://backup.ucs.test"]
#hosts = ["https://master.ucs.test"]
login_user = ["testuser" + str(i) for i in range(10000)]


def logout_at_idp(client, host):
logout = "/univention/logout"
uri = host + logout
with client.get(uri, name="/univention/logout/", allow_redirects=True, timeout=30, catch_response=True) as req3:
if not (200 <= req3.status_code <= 399):
return None


def login_at_idp_with_credentials(client, login_link):
data = {'username': 'Administrator', 'password': "univention"}
with client.post(login_link, name="/realms/ucs/login-actions/authenticate", allow_redirects=True, timeout=30, catch_response=True, data=data) as req2:
soup = BeautifulSoup(req2.content, features="lxml")
try:
saml_response = soup.find("input", {"name": "SAMLResponse"}).get("value")
except AttributeError:
print(soup)
return None
if not saml_response:
return None
if not (200 <= req2.status_code <= 399):
return None


def entry(client, host):
entry = "/univention/saml/"
uri = host + entry
try:
with client.get(uri, name="/univention/saml/", allow_redirects=True, timeout=30, catch_response=True) as req1:
if not (200 <= req1.status_code <= 399):
return None
if req1.content is None or len(req1.content) == 0:
return None
soup = BeautifulSoup(req1.content, features="lxml")
login_link = soup.find("form", {"id": "kc-form-login"}).get("action")
login_link = html.unescape(login_link)
login_at_idp_with_credentials(client, login_link)
finally:
#logout_at_idp(client, host)
client.cookies.clear()


class QuickstartUser(HttpUser):
wait_time = constant_throughput(0.1)

@task
def get_samlSession(self):
host = random.choice(hosts)
entry(self.client, host)
1 change: 1 addition & 0 deletions test/utils/utils-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fetch-results () { # <IP-ADDRESS> [TARGET-DIR]
'packages-under-test.log'
'test-reports'
'ucs-test.log'
'*.html'=
'/usr/share/ucs-test/*/selenium'
'/var/log/apache2/error.log'='apache2-error.log'
'/var/log/apache2/access.log'='apache2-access.log'
Expand Down

0 comments on commit 98f386b

Please sign in to comment.