Class LoadTest

java.lang.Object
at.jku.dke.etutor.task_app.test.LoadTest

public abstract class LoadTest extends Object
Application that can be used to run a load test on the task app.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final org.slf4j.Logger
    The logger.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    LoadTest(String url, String apiKey)
    Creates a new instance of the load test.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    createTask(long id, String body)
    Creates a task.
    protected final void
    createTaskGroup(long id, String body)
    Creates a task group.
    protected abstract void
    Creates the tasks for the load test.
    protected abstract SubmissionThread
    createThread(String name, String url, String apiKey, int initialSleep, int totalAmountOfRequests, int pauseBetweenRequestsInMs)
    Creates a new thread for the load test.
    protected final List<SubmissionThread>
    createThreads(int totalAmountOfRequests, int threadCount, double requestFactor, int maxInitialSleep, int maxPauseBetweenRequestsInMs)
    Creates the threads for the load test.
    protected final void
    deleteTaskGroup(long id)
    Creates a task group.
    protected abstract void
    Deletes the tasks created for the load test.
    void
    run(int totalAmountOfRequests, int threadCount, double requestFactor, int maxInitialSleep, int maxPauseBetweenRequestsInMs)
    Runs the load test.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      The logger.
  • Constructor Details

    • LoadTest

      protected LoadTest(String url, String apiKey)
      Creates a new instance of the load test.
      Parameters:
      url - The URL of the task app (without trailing slash!).
      apiKey - The api key to use for the requests.
  • Method Details

    • run

      public void run(int totalAmountOfRequests, int threadCount, double requestFactor, int maxInitialSleep, int maxPauseBetweenRequestsInMs)
      Runs the load test.
      Parameters:
      totalAmountOfRequests - The total amount of requests to submit.
      threadCount - The amount of threads to use.
      requestFactor - The factor to use for the calculation of the minimum and maximum amount of requests per thread (min = avg_amount_of_requests - (avg_amount_of_requests * factor)), (min = avg_amount_of_requests + (avg_amount_of_requests * factor)).
      maxInitialSleep - The maximum initial sleep time in ms. The initial sleep time will be a random number between 0 and maxInitialSleep.
      maxPauseBetweenRequestsInMs - The maximum pause between requests in ms. The pause between requests will be a random number between 100 and maxPauseBetweenRequestsInMs.
    • createThreads

      protected final List<SubmissionThread> createThreads(int totalAmountOfRequests, int threadCount, double requestFactor, int maxInitialSleep, int maxPauseBetweenRequestsInMs)
      Creates the threads for the load test.

      Randomly assigns the initial sleep time and the pause between requests as well as the total amount of requests. The sum of the amount of requests of all threads will be equal to the total amount of requests.

      Parameters:
      totalAmountOfRequests - The total amount of requests to submit.
      threadCount - The amount of threads to use.
      requestFactor - The factor to use for the calculation of the minimum and maximum amount of requests per thread (min = avg_amount_of_requests - (avg_amount_of_requests * factor)), (min = avg_amount_of_requests + (avg_amount_of_requests * factor)).
      maxInitialSleep - The maximum initial sleep time in ms. The initial sleep time will be a random number between 0 and maxInitialSleep.
      maxPauseBetweenRequestsInMs - The maximum pause between requests in ms. The pause between requests will be a random number between 100 and maxPauseBetweenRequestsInMs.
      Returns:
      The threads.
    • createThread

      protected abstract SubmissionThread createThread(String name, String url, String apiKey, int initialSleep, int totalAmountOfRequests, int pauseBetweenRequestsInMs)
      Creates a new thread for the load test.
      Parameters:
      name - The name of the thread. This is used for logging.
      url - The URL of the task app. This should not contain a trailing slash.
      apiKey - The API key to use for the requests.
      initialSleep - The initial sleep time in milliseconds.
      totalAmountOfRequests - The total amount of requests to submit.
      pauseBetweenRequestsInMs - The pause between requests in milliseconds.
      Returns:
      The thread.
    • createTasks

      protected abstract void createTasks()
      Creates the tasks for the load test.
    • deleteTasks

      protected abstract void deleteTasks()
      Deletes the tasks created for the load test.
    • createTaskGroup

      protected final void createTaskGroup(long id, String body)
      Creates a task group.
      Parameters:
      id - The id of the task group.
      body - The request body.
    • createTask

      protected final void createTask(long id, String body)
      Creates a task.
      Parameters:
      id - The id of the task.
      body - The request body.
    • deleteTaskGroup

      protected final void deleteTaskGroup(long id)
      Creates a task group.
      Parameters:
      id - The id of the task group.