My test works in Jmeter but not in Azure Load Testing - jmeter

I've defined a test on Jmeter which works correctly on Jmeter on my pc, but it doesn't work when I run it Azure Load Testing.
My test is very simple: it performs a POST request towards Azure AD (https://login.microsoftonline.com/TenantID/oauth2/token?api-version=1.0) with a body like the following one in order to retrieve a token:
"grant_type" = "client_credentials";
"resource" = "$resource";
"client_id" = "$APPID";
"client_secret" = "$ClientSecret"
JMeter parameters for the POST call
When I perform the call from my PC, it works and I'm then able to use the token to perform some other calls (not relevant here).
When I perform this single call on Azure Load Testing with my jmx file, the calls fails with a 400 (Bad request), as if my request was malformed.
When I download the results of the test, I get the following csv:
timeStamp elapsed label responseCode responseMessage threadName dataType success failureMessage bytes sentBytes grpThreads allThreads URL Latency IdleTime Connect
1.67602E+12 147 Get token 400 Bad Request 172.18.19.5-Setup Authentication 1-1 text FALSE 925 1119 1 1 https://login.microsoft.com/*tenantID*/oauth2/v2.0/token 144 0 107
where tenantID reflects the actual tenant ID.
In order to troubleshoot it, I've tried to replace the values of the tenand id with the values of client id, scope and secret and they show up correctly in the log file when I execute the test.
Also, in my AAD logs I don't see my login attempts, probably because of the 400 - Bad request code, as if my request was somehow malformed, so it doesn't get logged.
I've no idea how I could troubleshoot this further (e.g. can I somehow trace the parameters of the POST call Azure Load Testing is doing?). Any suggestions?
thanks for your help,
Marco

Related

Bybit API (ErrCode: 10002)

Just trying to interact with the API, but I am getting a specific error when trying the simplest tasks such as getting the balance.
Example Code
import API_Login as apiLogin
from pybit.usdt_perpetual import HTTP
apiKey = apiLogin.api_key
apisecret = apiLogin.api_secret
session = HTTP(
endpoint="https://api.bybit.com",
api_key= apiKey,
api_secret= apisecret)
session.get_wallet_balance(coin="USDT")
The error I receive:
2022-09-26 15:31:49 - pybit._http_manager - ERROR - invalid request, please check your timestamp and recv_window param.
req_timestamp: 1664231507914 server_timestamp: 1664231504913 recv_window: 5000 (ErrCode: 10002). Added 2.5 seconds to recv_window. 2 retries remain.
Error code 10002 is defined: Request not authorized - an API key is required and should be included in all requests.
But I know my API information is valid.
Figured out that my system clock was not synced properly. Hit the Sync Now button and it works perfectly.

JMeter - Execute HTTP Request until Response Headers matches

I'm new with JMeter and I'm working with a script for checking the cache, the scenario was to:
do a GET request
verify that it has been cached
do a DELETE request
verify that the cache has been deleted
However since there are three instances in the environment I'm working on my script is having intermittent failures because of the different x-internal-service-host being returned.
My test results looks like this:
do a GET request (x-internal-service-host returned is
c3c8021a51a9:8080 - PASS)
verify that it has been cached
(x-internal-service-host returned is 4eb7ac9d4a76:8080 - FAILED
because the call made was for c3c8021a51a9:8080)
do a DELETE
request (x-internal-service-host returned
is c3c8021a51a9:8080 - PASS)
verify that the cache has been deleted
(request x-internal-service-host returned is c3c8021a51a9:8080 -
FAILED because the delete was made for 4eb7ac9d4a76:8080)
I'm thinking of extracting the Response Header x-internal-service-host in step 1 but I'm not sure how to proceed once extracted, is it possible to send a GET request until the Response Header extracted matches the Response Header result for steps 2 to 4 or is there a better way to do this?

Getting 401 Unauthorized error when threads in JMeter increase

I am running a JMeter script, where I get the Access Token which I use it for my HTTP Request Samplers (By using Bearer ${AccessToken} in Header Manager of each Request). My HTTP Requests are being categorized into multiple Simple Controllers.
There are 70 HTTP GET Requests and ONE Thread takes around 20 seconds to execute them all.
Now when my no. of threads increase, say 3 onwards, then I start getting 401 Errors
({
"statusCode": 401,
"error": "Unauthorized",
"message": "Bad token",
"attributes": {
"error": "Bad token"
}
})
for a few requests. But eventually 401 errors start getting high as no. of Threads increase, keeping Ramp Up time low. for eg: for 5 Requests Ramp Up time = 30 sec.
JMeter Script snapshot
I have checked, my Access Token call always return a different token which is used per new THREAD. so not sure where the issue is :(
So far I have not used any think times, maybe that is one of the issue, but not sure.
By looking at your http get response , The issue is caused most likely due to incorrect value of AccessToken.
Make sure you are passing correct AccessToken to get response.
IF you have a recorded script log, check where this access token originating from and make sure your regular expression extractor is extracting it correctly.
For more information on extracting variables and reusing it in the script you can read this article.

Jmeter keeps failing

I have a simple web application that checks the price of books. The web application is called books. I am using Jmeter to test some performance aspects about my application. I have created a thread group in which I have a simple controller in which I have a sampler Http request. I have the following tree in Jmeter
Thread Group
Simple Controller
Get Books
In the get books I pass in the following values in the parameter(price) and the value is 40
When I run the tests I get this error message
Thread Name: Thread Group 1-1
Sample Start: 1970-01-01 10:00:00 EST
Load time: 0
Latency: 0
Size in bytes: 1098
Headers size in bytes: 0
Body size in bytes: 1098
Sample Count: 1
Error Count: 1
Response code: Non HTTP response code: java.lang.IllegalArgumentException
Response message: Non HTTP response message: protocol = http host = null
Response headers:
HTTPSampleResult fields:
ContentType:
DataEncoding: null
Not sure what I am doing wrong. The tomcat server is running the application works fine. I am really new to Jmeter so not that good with it.
Check Server name, port number, method and path are correct. Do not add http:// in server name.
If the method is GET, try to access the url through browser and check response is same.
Check if all the request headers are handled.

jmeter response code 204 and can't get content

I am doing a websocket stress test through jmeter2.9.
When I send a request and response with a "light" json. the result is ok.
But when the response json contains a base64 png(about 360kb) . jmeter return code 204 No content (probably timeout).
Is my jmeter need some config here, or something else wrong.
If someone know something about this please teach me.
complete info:
Thread Name: threadgroup 1-1
Sample Start: 2013-07-17 15:36:06 CST
Load time: 20000
Latency: 0
Size in bytes: 0
Headers size in bytes: 0
Body size in bytes: 0
Sample Count: 1
Error Count: 1
Response code: 204
Response message: No content (probably timeout).
Response headers:
SampleResult fields:
ContentType:
DataEncoding:
Check if you are using Cache manager, there seems to be a (bug) in Jmeter that sets the response code to HTTP Code '204' ("No Response") while, there is no outgoing request, the information is retrieved from the Cache, try disabling cache manager and lets see if you can reproduce it then.
This could be because of the unhandled exception, response being larger than the maximum message size specified in the plugin code, etc. The exception which you see will be thrown if no response has been received from the server after predefined timeout.
Here is another WebSocket plugin for JMeter which might work for you
Link: https://github.com/maciejzaleski/JMeter
Features:
Supports HTTS/HTTPS (ws/wss) version of the WebSocket protocol
Option to ignore SSL certificate errors
Streaming allows for a single connection to remain open for the duration of the test
Response has to match predefined regular expression
Response timeout
Response message back log (build the Sampler response from multiple server messages)
Connection could be closed if server sends a mesage matching predefined regular expression

Resources