-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I need to create POST requests with different body each one #3
Comments
Hello, thank you for bringing this into attention! We can easily add the jsr223PreProcessor to the dotnet library with support for specifying code in groovy. Providing support for using c# code and dotnet libraries is not that simple though. Can you provide an example code of what you would like the DSL to support or how would your think you could express in code what you need? One alternative for generated and distinct data might also be implementing the csvDataSet element in dotnet library (easy to do as well) so you can generate in dotnet/c# code a CSV with whatever content you may like (and using whatever library you desire) and then just use the proper variables in the HTTP Post request. In any case, I would like to understand a little better what would be the ideal scenario for your use case and then provide a good approximation to it . |
Tnx for fast reply, this is my code:
|
I join the question. For each request in each iteration, a new request must be created. [Test]
public void RegisterTest()
{
var stats =
TestPlan(
ThreadGroup(5, 2,
HttpSampler("http://localhost/register/")
.Post(GetRegRequest(), new MediaTypeHeaderValue("application/json")
))).Run();
Assert.That(stats.Overall.SampleTimePercentile99, Is.LessThan(TimeSpan.FromSeconds(2)));
}
//Random random = new Random();
private SecureRandom random = new SecureRandom();
public string GetCardCode()
{
var getCard = random.Next(0, cardsCount - 1);
logger.Debug(getCard);
var cardCode = cards.Skip(getCard).Take(1).FirstOrDefault()?.CardCode;
logger.Debug(cardCode);
while (cardCode == null)
{
cardCode = cards.Skip(random.Next(0, cardsCount - 1)).Take(1).FirstOrDefault()?.CardCode;
}
return cardCode;
}
public string GetRegRequest()
{
var license = cashes.ToList().ElementAt(random.Next(0, cashCount - 1));
Guid accessTokenGuid = license.AccessTokenGuid;
var cardCode = GetCardCode();
return JsonConvert.SerializeObject(new RegisterRequestDto
{
LicenseGuid = license.LicenseGuid,
AccessTokenGuid = accessTokenGuid,
CardCode = cardCode,
CardRegisterDateTime = DateTime.Now,
RegisterDetailDtos = new List<RegisterDetailDto>
{
new RegisterDetailDto
{
PositionId="1",
ProductCode="12345",
Quantity=1,
TotalPrice=100
}
}
});
} |
Great, thank you! The information you two provide is very helpful and we have some ideas that we would like to implement to support these scenarios. It is great to see the community interest in this feature. If some other have similar interests please let us know! |
We just released 0.4 which includes None of these are optimal solutions for your use cases, but you can use them in the meantime as workarounds or approximations while we come up with some better solution. Regards |
Hello
I have a big model (generating using Bogus lib - it has unique email, id etc) - I want to run Post Requests to create a lot of entities. Are there any ways to implement this?
I'v found you advised to use PreProcessor here - abstracta/jmeter-java-dsl#7 - but there is no PreProcessor class in dotnet dsl.
Tnanks!
The text was updated successfully, but these errors were encountered: