Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...

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

...

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}")



...

  •     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)

Image Modified

Grafic Output (100 User)

Error rate increases as soon as system is overloaded