-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #20: Add keycloak performance test script
- Loading branch information
Showing
4 changed files
with
194 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters