Comments (5)
I join the question. For each request in each iteration, a new request must be created.
My code:
[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
}
}
});
}
from jmeter-dotnet-dsl.
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 .
from jmeter-dotnet-dsl.
Tnx for fast reply, this is my code:
.............
using Bogus;
[Fact]
public async Task LoadTest()
{
// Arrange
var requestDto = Create_CreateCompanyRequestBogus();
var request = JsonSerializer.Serialize(requestDto);
// Act
var stats = TestPlan(
ThreadGroup(2, 5,
HttpSampler("https://tst-api.purpleunity.dev/company-and-contact/api/companies")
.Post(request, new MediaTypeHeaderValue(MediaTypeNames.Application.Json))
.Header("Authorization", AuthToken)
),
JtlWriter("jtls")
).Run();
stats.Overall.SampleTimePercentile99.Should().BeLessThan(TimeSpan.FromSeconds(5));
}
private CreateCompanyRequest Create_CreateCompanyRequestBogus()
{
var faker = new Faker<CreateCompanyRequest>()
.CustomInstantiator(f =>
new CreateCompanyRequest(
IdentityId: Guid.NewGuid().ToString().OrNull(f, 0.2f),
Name: f.Company.CompanyName(),
VatNumber: f.Random.Replace("??#########").OrNull(f, 0.2f),
Iban: f.Random.Replace("??######################").OrNull(f, 0.2f),
Bic: f.Finance.Bic().OrNull(f, 0.2f),
ChamberOfCommerceNumber : f.Random.Replace("??-???-########").OrNull(f, 0.2f),
ExternalId: Guid.NewGuid().ToString().OrNull(f, 0.2f),
IsBuyerEvaluated: f.Random.Bool().OrNull(f, 0.2f),
Remarks: f.Lorem.Sentences(1).OrNull(f, 0.2f),
AddressLine: f.Address.StreetAddress().OrNull(f, 0.2f),
Zipcode: f.Address.ZipCode().OrNull(f, 0.2f),
City: f.Address.City().OrNull(f, 0.2f),
Region: f.Address.State().OrNull(f, 0.2f),
CountryCode: f.Address.CountryCode().OrNull(f, 0.2f),
Phone: f.Phone.PhoneNumber().OrNull(f, 0.2f),
Mobile: f.Phone.PhoneNumber().OrNull(f, 0.2f),
Fax: f.Phone.PhoneNumber().OrNull(f, 0.2f),
Email: f.Internet.Email().OrNull(f, 0.2f),
WebsiteUrl: new Uri(f.Internet.Url()),
DefaultContact: null,
UseTheSameAddressForPostal: f.Random.Bool().OrNull(f, 0.2f),
PostalAddressLine: f.Address.StreetAddress().OrNull(f, 0.2f),
PostalZipCode: f.Address.ZipCode().OrNull(f, 0.2f),
PostalCity: f.Address.City().OrNull(f, 0.2f),
PostalRegion: f.Address.State().OrNull(f, 0.2f),
PostalCountry: f.Address.CountryCode().OrNull(f, 0.2f)
)
);
return faker.Generate();
}
from jmeter-dotnet-dsl.
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!
from jmeter-dotnet-dsl.
We just released 0.4 which includes CsvDataSet
and Jsr223PreProcessor
.
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
from jmeter-dotnet-dsl.
Related Issues (18)
- Setting name for HttpSampler is not working HOT 2
- `Perc99` lower than `Perc95` and `Perc90` HOT 2
- Connect to WebSocket/SignalR HOT 2
- Add possibility to run HttpSampler to execute a fixed number of times. HOT 2
- Getting System.InvalidOperationException when running test plan - .Net Framework Library HOT 4
- Add A Support for Post Request with FormParams JMeter DSL Dotnet HOT 1
- Incorporate functionality to verify the expected response. HOT 2
- threadPause support? HOT 2
- Error when trying to execute a simple test using a CSV file and Azure Load Testing HOT 2
- Backend Listener HOT 1
- How to detect Java_Home is correct set? HOT 4
- Missing allow quoted data in DslCsvDataSet HOT 4
- Threadgroup missing Loopcount in configuration HOT 1
- Assertion missing Average option HOT 8
- Perfmon Plugin & Updation of JMeter Properties in jmeter dsl dotnet HOT 6
- Please add the ability to generate HTML reports from the execution of test plans. HOT 1
- ERROR org.apache.jmeter.util.JMeterUtils - Could not find resources for 'ru_RU'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmeter-dotnet-dsl.