Passing parameters to JDBC connection in Jmeter - jmeter

I have a problem trying to setup a JDBC connection in Jmeter. What I need to do is getting a username from a first database, called A, and use that username as a connection parameter in a second JDBC connection, so I can connect to database B.
I read that the JDBC connection is loaded immediately, before any JDBC request. So I cannot pass usernames as parameters to it. How could I achieve this?
I am using the latest version of Jmeter (5.4.1).

One of the options is getting the username in the setUp Thread Group, converting it into a JMeter Property using __setProperty() function and reading the username in the normal Thread Group using __P() function
Alternative approach would be switching from JDBC Request sampler to JSR223 Sampler and instantiate the connection (or connection pool) yourself. See Working with a relational database chapter of Groovy documentation for more details.

Related

How to use existing websocket connection to another websocket request in jmeter?

How to use existing websocket connection to another websocket request in jmeter?
When I tried to use existing connect then as result it show me an error "Sampler configured for using existing connection, but there is no connection" . Please refer attached screenshot.
enter image description here
enter image description here
It looks like you're using 2 different WebSocket Samplers implementations:
JMeter-WebSocketSampler
and JMeter WebSocket Samplers
Your WebSocket Single Write Sampler:
Doesn't know anything about the connection established by the WebSocket Sampler
The WebSocket Sampler closes the connection after receiving the response
So if you want to continue with the WebSocket Single Write Sampler you need to:
Use WebSocket Open Connection sampler to establish the connection:
In the WebSocket Single Write Sampler tick use existing connection box
More information: JMeter WebSocket Samplers - A Practical Guide
If you want to continue with the WebSocket Sampler - tick Streaming connection box:
and remove the WebSocket Single Write Sampler and friends from the Test Plan

In jmeter, how can I keep a websocket connection for later use

I just have a load test in JMeter, in the test, the client will send several requests in few seconds. But I find a problem when the client makes a new request, the JMeter will close the former connection and create a new connection, I just want to reuse the former connection to send a request to the WebSocket server.enter image description here
Just tick use existing connection box in your WebSocket Samplers and the connection established by the WebSocket Open Connection sampler will be re-used
I believe the connection doesn't survive Thread Group iterations (it's basically re-established when Open Connection sampler is executed 2nd time, if you need to repeat the request more than once - either go for Loop Controller or put the Open Connection sampler under the Once Only Controller
More information: JMeter WebSocket Samplers - A Practical Guide

JMeter - I need to open and keep multiple websocket connections at the same time to be able to use them in parallel in JMeter

I am using JMeter to test our websockets server API and now I have the following issue. I need to open and keep multiple WS at the same time to be able to use them in parallel.
JMeter WebSocket Samplers plugin provides possibility:
To open a WebSocket connection via WebSocket Open Connection sampler
And then you can re-use the connection in the following Samplers which will be doing the real work: read, write
When you don't need the connection anymore you can use WebSocket Close sampler
The connections are established "per thread" (virtual user) so provide necessary amount of concurrent threads in the Thread Group and make sure to specify enough loops or the desired duration of the test
More information: JMeter WebSocket Samplers - A Practical Guide

How to connect multiple MQTT clients to single iothub via JMeter

I am trying to establish connection of multiple MQTT clients to single azure server via JMeter.
Note: all client ID's & all username's are different but sharing the common password(SAS)
client ID-1 connection snapshot:
clinet ID-2 connection snapshot:
and it goes on..
Now the problem is when I run the in thread, first client only get connect :
& the other clients connections are throwing the error:
Anyhelp would be grealy appreciated. Thanks.
JMeter executes Samplers upside down by each virtual user so you don't need to duplicate this Gateway Connect sampler, just define 2 threads (virtual users) in the Thread Group and each thread (virtual user) will execute Gateway Connect sampler and establish its own connection with the broker.
The credentials can be parameterized using i.e. CSV Data Set Config so each virtual user would connect with its own username/password combination
More information: Testing the MQTT Messaging Broker for IoT - A Guide

REST Service load test using Jmeter

I have a REST service written in Spring Boot which have only GET and POST methods. The GET/POST method retrieve/post data from/to cassandra cluster.
I tried testing the REST service with 100 users running concurrently.
My jmeter configurations are:
When I run this test, for the first few request it gives errors and half request is successful.
Here is the result table
Then I checked the reason of error in the Result tree and found this response data:
{"timestamp":1474278650822,"status":500,"error":"Internal Server Error","exception":"com.datastax.driver.core.exceptions.NoHostAvailableException","message":"org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried)","path":"/post"}
I couldn't figure out why it failed to connect to cassandra cluster for the first few requests.
I am new to cassandra, REST service and jmeter. Can anyone point out what mistake I am making.
NOTE: I have tested my REST Service using Postman, and it functions well, both GET and POST request.
With this configuration you're hitting the service at once with 100 requests.
Each request will get a request thread, therefore I assume your service has a thread-pool with at least 100 connection threads.
Each request thread tries to obtain a connection to the DB from the DB Connection pool. If 50% of your requests fail, I'd guess, your DB Connection Pool size set to 50. In case your DB connection pool can handle 100 connections, check the connection settings of your Cassandra DB, maybe that one is limited to 50.
There is few more to add with the answer of #Gerald. The number of threadpool limitation in the DB might not be the only culprit, the other possibilities are the max thread connections set in the server level as well. If you have the access to the server log of the api your trying to test, you can get exactly at what point it breaks and fix it with help of developers

Resources