Tcp sampler end of line byte value in Jmeter - jmeter

I have TCP server which will be sending dynamic responses i.e. approve or decline or hold. Now I am trying to load test it using jmeters TCP sampler. In this case how can I give dynamic EOL byte value in TCP sampler. If response is approve or decline it should be byte value of character e and if the response is hold it should be the byte value of d. How can i give dynamic EOL byte value.

If this is really what you're looking for you can define EOL byte value in form of a JMeter Variable like ${EOL} and amend this variable value according to your test scenario.
However I strongly doubt that TCP server you're testing changes EOL byte value depending on the request status, I would rather expect that it provides different response which you can verify using Response Assertion
Also be aware that you can amend response status via tcp.status.prefix and tcp.status.suffix JMeter properties so you can use them in order to amend Response Code so you will be able to see how many requests had response code e and how many had d once your test finishes.

Related

Append length in iso8583 using jmeter

I am using ISO8583 Sampler in JMeter for Sending ISO Messages, I need to append the length in in hex of the total message divide by 2 at the beginning. I have read the documentation and i cannot find anything.
Git: https://github.com/tilln/jmeter-iso8583
Question is, why do you need to manually perform that?
I believe you just need to select the proper channel in the connection configuration.
Depending on what you mean by "in hex" maybe HEXChannel which sends four ASCII bytes with the hex character or NACChannel which will send 2 bytes with the length, some people incorrectly call that hex when they are actually just 2 raw bytes.
Take a look at JSR223 PreProcessor, if you add it as a child of the ISO8583 Sampler you will be able to access the underlying class functions using sampler shorthand, in your case it will be ISO8583Sampler, take a look at available methods, i.e. getRequest() will give you an instance of ISOMsg and you can get/set the neccessary header/fields/whatever.

JMeter ignore specific types of responses in all Receive samplers (Websocket)

Is there a way for all Receive samplers to ignore specific responses in JMeter and wait for the one that we are interested?
To be more precise, we have created a jmx file that contains a large flow like a user would create on the browser. Each request sent is followed by a response, so we use a request handler followed by the corresponding receive handler for each call. And everything seems to work fine.
But there are cases that another kind of response may arrive, which is not the one we expect in our flow, but it is triggered by another independent mechanism. You can think of it like notifications sent to the user that is doing the flow and are independent of the flow itself, but theu are received in the channel (for us inside the websocket connection).
So we are trying to find a way to ignore a specific set of responses that may come while we are running the tests.
We firstly tried to add a While Controller in each receive sampler that checks if the content is of the desired type and if not loops again. But this solution has 3 disadvantages :
we have to add the sampler for the specific receive twice - one before the while element and one inside the element because we have to first extract the received data and while does not execute its contents before doing the while condition check
we have so many pairs of send-receive in our jmeter test script , that we have to add so many while controllers inside the script
since the received message may not be of the type we expect but another one that we want to ignore, then we cannot add a Response Assertion because it will fail if the notification arrives, so we have to verify the content indirect -> in the condition of the while loop
We use apache-jmeter-5.3.
So we are wondering if we could do another kind of configuration in order to avoid all these while loops.
It may be irrelevant to the solution, but we use websocket through "WebSocket Samplers by Peter Doornbosch".
Thanks
You don't have to, just amend your While Controller's condition to accept undefined variable as well
Sounds like a potential use case for using Module Controller to avoid code duplication
If you're getting the response you don't expect you can change the response body using JSR223 PostProcessor to the one you expect, example code
if (!prev.getResponseDataAsString().contains('foo')) {
prev.setResponseData('foo', 'UTF-8')
}

Possible to access TCP packet details with a go HTTP client?

I have a need to be able to validate TOS/DSCP marks on response data from a set of HTTP servers. Would it be possible, given a list of target URLs to test, if there is a way in go to generate the HTTP request, and then be able to examine the response's TCP packet details in order to obtain the TOS value?
My assumption at this point is that it may require creating a socket, and then dynamically generating a TCP packet that contains the HTTP request payload. I've been searching around to see if there were any libraries that would aid in this task, but haven't found anything specific yet.
Note: a simple TCP connection will not provide enough data - the target servers in question will alter TOS/DSCP marks dynamically based on the HTTP server name (so essentially, a single physical server will respond with different TOS marks depending on the vHost requested), so it is important to be able to verify the TOS on actual HTTP response packets, and not something simple like a ping. The TOS values in the TCP 3-way handshake cannot be trusted either - it must be a packet containing the HTTP data.
I did end up solving this problem using gopacket/pcap and net/http.
In a nutshell, what I ended up doing is writing a function that creates a channel, and then calls a goroutine that does the actual packet capture and parsing. The goroutine passes the captured TOS value back to the channel, and then the original function does the http request, and then reads the channel to get the TOS result. Still a bit of a work-in-progress, but so far, this solution seems to be working fairly well.

Jmeter Websocket: Wait for all frames in a response

I am using the Jmeter WebSocket Sampler. I have successfully connected to the websocket, and can send a text request. It is a chat bot, and I will be validating it's response.
However, I have observed in Fiddler, the websocket responds to the text request with a short confirmation response before the chat bot's response.
for example, the first response is {"ok":true, "replyto":1151810327491, "type":"ack"} where replyto is a message ID. I don't really need this information.
Only then is the real response sent (as I observed in Fiddler), the one I would actually like to read and put Assertions on.
I have tried Websocket request-response Sampler, Websocket Single Write Sampler (followed by a Single Read Sampler), and I have tried the general Websocket Sampler.
TL;DR: The websocket responses come in "frames", each having a JSON response, my samplers are closing right after the first frame.
If the server is sending frames you are not interested in, there are two possible solutions.
If you know in advance which frame you want to discard (e.g. the first that is received after sending a message), you can simply use a Single Read Sampler to read the message you want to discard and have a second Single Read Sampler read the "real" message.
If the sequence of messages is not that easy to predict, you can use a Frame Filter to discard the messages for you, so they don't show up in the (Read) Sampler. For example, configure a Text Frame Filter with condition "starts with text" and use the string '{"ok":true, "replyto":' as match value, this will discard all frames that start with that string. If this doesn't work because the message you are interested in start with the same string, you can create more complex conditions, even with regular expressions.

Getting the HTTP Request from a TIBCO BW Process

I have a TIBCO BW process which starts with the 'HTTP Receiver' Activity.
I'd like to obtain (via a custom Java Code activity) the size of the original HTTP request.
(The purpose is to collect statistics, measure response times, request/response sizes etc.)
I'd like to measure the data in bytes and not in characters, is it possible to get the request
as a byte array, ServletInputStream or something similar?
I don't think you can get the original request from Java code - simply because you cannot access the HTTPServletRequest object of the HTTP Receiver from a Java activity. If you'd like to access the raw request data, you may write a proxy servlet and access BusinessWorks via this proxy servlet.
If your task is only to get stats on the request size, there is a simpler solution. You can use the "Content-length" header parameter for this reason (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
The Content-Length entity-header field indicates the size of the entity-body,
in decimal number of OCTETs, sent to the recipient
Content-length is an output parameter of the HTTP receiver. You may need to add the length of "RequestURI", "PostData" and "Header" parameters as they are not part of the entity body.
Update: PostData is part of entity-body, therefore its size is included in Content-length

Resources