I am using the JMetter 5.1.1 to run load test against ASP.Net Core 2.2 with Identity framework. If I run the Login POST requests with many threads concurrently, it will result in AppIdentityDbContext optimistic concurrency exception when UserManager.UpdateSecurityStampAsync` is called. So, I need to send a POST login request only ONCE, extracts the Access Token from the response and use it for subsequent requests with many users/threads for the load test. How to achieve this objective?
If you really need to do this (see comment) you can do the login in a setup thread group that runs once. Extract the tokens (access and refresh or just access) with a JSON extractor, then copy them to properties with a JSR223Assertion with groovy:
def p = vars.get("accessToken");
props.put("accessTokenProperty", p);
Then in the other thread groups, use a JSR223PreProcessor for your first sampler that copies the properties to variables, i.e.:
def p = props.get("accessTokenProperty");
vars.put("accessToken", p);
You can then use the variable $accessToken as usual:
Bearer ${accessToken}