Validate the JDBC request with a user defined variable

Viewed 161

I am new to JMeter,

In my test I am creating a JDBC Connection to oracle DB and running a query which fetching me the count of records, which I want to validate must be equal to the SAMPLE-NUMBER (which is a defined variable in the user defined variable).

SELECT COUNT(*) FROM event_log WHERE audit_context_key LIKE '288017ec-0dcf-4fd5-9565-e8ad15e65cd2' AND event_desc = 'Success'

Response Body:

COUNT(*)
2

UserDefined Variable

2 Answers

You can do this, defined the variable name in JDBC request,

for example, TOTALCOUNT and add a JSR223 Assertion with the following code,

1.upto(vars.get('TOTALCOUNT_#') as int, {
    if (vars.get('TOTALCOUNT_' + it) == '${__groovy(vars.get('SAMPLE-NUMBER'),)}') {
        AssertionResult.setFailure(false);
    }
})

Response Assertion can do the trick for you:

  1. In the JDBC Request define "Variable Names", i.e. ACTUAL_COUNT

    enter image description here

  2. Once done you can compare the ACTUAL_COUNT variable value with the SAMPLE-NUMBER variable like:

    enter image description here

Related