0

I have a JMeter Test Plan to perform performance and load tests on a SAP Web Client. The Test plan contains 5 Thread Groups. In each Thread Groups i have a Transaction Controller that contains N Requests where they execute Login - Process - Logoff .

I need to be able to run the Test Plan with 20 users on infinite loop and then shutdown after 1 hour BUT perform the logoff of all the users that are still on the Web Client (Last request on each transaction controller).

As of this moment the shutdown simply stops the test on the active thread, whatever it is, without finishing the Transaction Controller.

Any ideas?

2 Answers2

0

This could be achieved by adding a While controller as a parent controller to the Transaction controllers. While controller should check the duration and exit when the duration is more than one hour.

enter image description here

Outside the While controlled add a Test Action Sampler and configure it to stop the current Thread.

enter image description here

Sample test plan with a solution is available @ GitHub

Janesh Kodikara
  • 1,670
  • 1
  • 12
  • 23
0

You can introduce a JVM Shutdown Hook to intercept JMeter shutdown and be able to finish the running tasks.

Example implementation:

  1. Add setUp Thread Group to your Test Plan
  2. Add JSR223 Sampler to the setUp Thread Group
  3. Put the following code into "Script" area:

    def myHook = new Thread({ ->
        try {
            println('' + new Date()  + '\tShutdown detected, waiting for 5 for logging out')
            Thread.sleep(5000)
            println('' + new Date()  + '\tExiting...')
        } catch (InterruptedException ignored) {
        }
    })
    Runtime.getRuntime().addShutdownHook(myHook)
    

That's it, the hook will be called when you send termination signal to JMeter and there you can put whatever logic you need:

enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133