multithreadingjmetersingletonperformance-testingcrud

JMeter mechanism to negotiate a global variable assignment between threads from multiple different thread groups and pause them until a met condition


I am using JMeter and I have a situation in which I want to send a specific load of create update and delete operations against a target system under test.

I thought of separating the logical create, update and delete operations into 3 different Thread groups which should be running in parallel because I want to control their throughput individually.

However, in order to have a successful operation request, the system under test constrains me to use a unique global sequence number value (which it knows and expects in each request). The problem is that this global sequence number is owned (stored in the system db) and incremented by the system under test only after a successfully processed create/update/delete operation which can take a variable amount of time.

So, in order for JMeter me know what value it has to send next, it needs to wait for the success of a previously-sent operation (create/update/delete) which currently might be in processing and has not received a positive response yet.

I currently have a setUpThreadGroup in which I perform just one query on the system DB to get this unique global expected sequence number value and then pass it to a JMeter property so that I know from which id I need to start counting.

My problem is that I can't think of a way how the different spawned threads from different thread groups (1 create, 1 update, 1 delete) can "negotiate" the usage of a "currentGlobalId" value because once a value has been assigned to a thread and it requests an operation the other threads need to acknowledge that the value is in usage and not perform any request with the same sequenceID or an incremented sequenceID until operation success (because they will fail as long as the system does not increment the number on its side).

I need to implement a sort of lock-release synchronization mechanism so that when an Id is taken by a thread all other threads from all thread groups wait until a success condition is met and then based on their ThreadGroup defined throughput, race to get the next expected sequenceID and perform the request with it, but only one should and the others should wait.

Can anyone give me a nudge in the right direction about how/if I could achieve this in JMeter?


Solution

  • Well-behaved JMeter test should generate the same network footprint as the real user (or upstream system) using the system under test.

    If on each operation the client invokes somehow a database query to generate the sequence ID - you should be doing the same thing. The suitable test element is JDBC PreProcessor

    Alternatively you can use Inter-Thread Communication Plugin to share the value of the sequence ID between threads via FIFO queue