Contribute to the DSpace Development Fund

The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

To test the performance of our services (Eprints, DSpace, ...) we recommend the open source load testing tool Locust - https://locust.io

Installation

Instructions according to https://docs.locust.io/en/stable/installation.html

  • Lokal (Win, Linux, Mac) vs. RHEL8 ServerSide; both installed and tested. Better RHEL8 for more pressure during load tests.

  • python 3.11

  • gcc-c++

  • pip3.11

  • Port 8089 (open in firewall)

locust install: [locust]$ pip3.11 install locust

Simple scenarios ("Hello World" mode)

Configuration

Simply pass through the URL entered at the start in the input form ("Number of Users", "Spawn rate", "Host") and test it - e.g. test  the homepage of your DS7 repo

[locust]$ vi locustfile.py

from locust import HttpUser, task

class HelloWorldUser(HttpUser):

@task def

   hello_world(self):

      self.client.get("/")


more on configs read https://docs.locust.io/en/stable/writing-a-locustfile.html#writing-a-locustfile


Start Locust

read Command Line Options

Attention: Standard http vs. https; Certs and Keys

[locust]$ locust --tls-cert /etc/pki/tls/certs/SERVERNAME/cert.pem --tls-key /etc/pki/tls/certs/SERVERNAME/privkey.pem
[2024-01-22 14:40:56,153] INFO/locust.main: Starting web interface at https://0.0.0.0:8089
[2024-01-22 14:40:56,166] INFO/locust.main: Starting Locust 2.20.1

UI

call Browser https://zizoradspace7trial.uzh.ch:8089/ and start loadtests. First easy with 1 user.
Screenshot 2024-01-30 at 10-37-32 Locust for locustfile.py.png
(Attention: use trailing slash)


See charts, failures, statistics and many more...

Screenshot 2024-01-30 at 10-39-05 Locust for locustfile.py.png

Real (warning) test scenarios (static & dynamic content)

  • Homepage

  • SubPage Communities

  • Search

  • Login Process incl. Token Autentication

and these scenarios according to the storybook in locustfile.py with

  • 1 user

  • 10 parallel users

  • nnn parallel users

Preliminary work / tests

Before the various authentication procedures for login, session handling (credentials, tokens, cookies, etc.) and workflow steps (dashboard, upload, metadata edit) are run through with try & error, it is advisable to test the individual work steps via the APIs beforehand using CURL.

For e.g. Before login ba POST method, receive TOKEN via GET. Read (insert Link)

Configuration (“complex” Mode)

    • vi locustfile.py

# Jens Witzel, Uni Zuerich 2024/01/30

import requests

from locust import HttpUser, task, between


class HelloWorldUser(HttpUser):

    @task

        def browse_homepage(self):

             self.client.get("/")


    @task

        def browse_cummunity(self):

             self.client.get("/communities/dc75f221-6ec0-4ff2-a72b-46d11444daa4")


         @task

         def search_items(self):

               needle = "test"

               self.client.get("/search?q={needle}") # Replace with the actual endpoint for searching items


       @task 

        def view_item_details(self): 

                item_id = "e0da84e0-0d71-41b6-9aee-17d7b29edca6" # Replace with the actual item ID

                self.client.get(f"/items/{item_id}") # Replace with the actual endpoint for viewing item details


class DSpaceUser(HttpUser):

           wait_time = between(1, 3) # Random wait time between 1 and 3 seconds

           @task def login(self): # get token

           getauthncookies = self.client.get("/server/api/authn", headers={})

          dscookies = dict(getauthncookies.cookies.get_dict()) 

           csrftoken = dscookies['DSPACE-XSRF-COOKIE']

           # post login with credentials and token

           response = self.client.post("https://SERVER/server/api/authn/login", {"user": USER, "password": PASSWORD}, headers={"X-XSRF-TOKEN":csrftoken}, cookies={"DSPACE-XSRF-COOKIE":csrftoken})

         if response.status_code == 200:

            print("Login successful")

        else:

           print(f"Login failed with status code: {response.status_code}")



Notes

  •     2 types of users (anonymous, registered user), login with token handling
  •     further, sequential storybook possible: login, workflow, upload, edit metadata, logout

Grafic Output (10 User)


Grafic Output (100 User)

Error rate increases as soon as system is overloaded









  • No labels