Gatling user injection for 50 total users in 1 hour adding 10 users per 5 minutes - testing

I need to setup a Gatling Test with a total of 50 concurrent users, but I have a problem because there is no choice to get it.
I use rampUsers(10) over (60 minutes) but it gets only 10 concurrent users.
Using constantUsersPerSec(users) during (60 minutes) is too stressful.
Is there any suggestion?
Thanks.

This could be done as follow:
val scn = scenario("Test").during(1 hours) {
exec(http("test").get("/"))
}
setUp(scn.inject(splitUsers(50) into atOnceUsers(10) separatedBy(5 minutes))
.protocols(httpConf))
see http://gatling.io/docs/2.0.3/general/simulation_setup.html:
splitUsers(nbUsers) into(injectionStep) separatedBy(duration): Repeatedly execute the defined injection step separated by a pause of the given duration until reaching nbUsers, the total number of users to inject.

Related

how to get the average response time for a request using Jmeter testing tool

I am trying Jmeter for load and performance test, so I created the thread group and below is the output of aggregate report.
The first column Avg request t/s, i have calculated using the formula
((Average/Total Requests)/1000)
but it does not seems good, as I am loggin request time in my code, almost every request is taking minimum 2-4 seconds.
I tried with MEdian/1000 but again, i am in doubt.
what is the corerct way to get the average time for a request?
Avg request t/s
Total Requests
Average
MEdian
Min
Max
Error %
ThroughPut request per time unit
Recieved KB
Sent KB
0.07454
100
7454
6663
2464
19313
0
3/sec
2.062251152
1.074506499
1.11322
100
111322
107240
4400
222042
0
26.3/min
0.1408915377
0.1271878015
1.19035
100
119035
117718
0.03
26.3/min
0.1309013211
0.1279624502
1.21287
100
121287
119198
0
0.4136384882
0.135725129
0.1211831508
1.11943
100
111943
111582
5257
220004
0
0.4359482965
0.1507086884
0.1264420352
1.14289
100
114289
114215
4543
223947
0
0.4369846313
0.1497867242
0.1288763268
0.23614
150
35421
26731
4759
114162
0
0.9494271789
0.3600282257
0.1842358496
Don't you have the ThroughPut request per time unit column already? What else do you need to "calculate"?
As per Aggregate Report documentation
Throughput - the Throughput is measured in requests per second/minute/hour. The time unit is chosen so that the displayed rate is at least 1.0. When the throughput is saved to a CSV file, it is expressed in requests/second, i.e. 30.0 requests/minute is saved as 0.5.
So if you click Save Table Data button:
you will get the average transactions per second in the CSV file
It is also possible to generate the CSV file with the calculated aggregate values using JMeter Plugins Command Line Tool as
JMeterPluginsCMD.bat --generate-csv aggregate-report.csv --input-jtl /path/to/your/results.jtl --plugin-type AggregateReport

Moment Formatting in minutes for over 60 minutes

I am working on an app that tracks a users activity over time. When the user completes the activity I'd like to show the total time in minutes. Currently when the user passes 60 mins it resets the minute counter.
If a user is active for 1hr:2min I'd like it to show as 62 minutes. Is this possible? Currently it rolls over to 2 mins. This is what I have and it works great for under 60 minutes. I appreciate the feedback.
export const formatWalkTimeInMinutes = (walkSeconds) => {
return moment().hour(0).minute(0).second(walkSeconds).format('m');
};
'''
You can use
return moment.duration(walkSeconds, "seconds").asMinutes()

advanced user simulation using Gatling [duplicate]

This question already has an answer here:
#karate How to pass parameter to a feature file in gatling simulation class?
(1 answer)
Closed 1 year ago.
I am trying to simulate a user scenario over an api using Gatling. I am a newbie to scala and gatling and would like to simulate a load scenario such that:
it starts with 0 users,
increase a load of 5 users in 10 seconds,
holds the user load for the next 10 seconds,
increase 5 more users over the next 10 seconds,
holds the user load for the next 10 seconds,
ramp down users from 10 to 0 over the next 10 seconds.
I am using karate feature files to define the api specifications.
Thanks for the help.
It should be possible by referring to the Karate docs and then the Gatling docs:
setUp(
create.inject(
rampUsers(5) during (10 seconds),
nothingFor(10 seconds),
rampUsers(5) during (10 seconds),
nothingFor(10 seconds),
rampUsers(0) during(10 seconds)
).protocols(protocol)
)

How to speed up selenium tests on AWS device farm?

I'm using Python for testing on AWS device farm. It seems that starting a selenium takes very very long. This is the code I use:
from time import time
from boto3 import client
from selenium import webdriver
def main():
start = time()
device_farm_client = client("devicefarm", region_name='us-west-2')
test_grid_url_response = device_farm_client.create_test_grid_url(
expiresInSeconds=666,
projectArn="arn:aws:devicefarm:us-west-2:..."
)
driver = webdriver.Remote(
command_executor=test_grid_url_response['url'],
desired_capabilities=webdriver.DesiredCapabilities.CHROME,
)
driver.get('https://api.ipify.org')
print(f"Your IP is: {driver.find_element_by_tag_name('pre').text}")
driver.quit()
print(f"took: {time() - start:.2f}")
if __name__ == '__main__':
main()
Output:
Your IP is: 100.10.10.111
took: 99.89s
Using existing selenium-hub infrastructure the IP is obtained in less than 2 seconds!
Is there any way how to reduce the time radically?
To reduce the overall execution time for complete test suite execution take advantage of the 50 concurrent sessions given you by default at no cost. Check this link. For eg:
Lets assume following details
one test Suite has 200 Selenium test cases
each test case takes around 10 seconds to execute
One AWS Device Farm Selenium Session takes around 60 seconds to start
then I will divide my 200 test cases into 50 concurrent sessions by running concurrent batches of 4 test cases per session.
Total Execution Time = (60 seconds to start each session + 10 seconds to start all 50 concurrent sessions with rate of 5 sessions per second + 4*10 seconds to execute the test cases in each session) = 60+10+40 = 110 seconds to finish complete test suite execution
WHEREAS
If you are existing selenium-hub infrastructure and lets say following details are assumed
200 Selenium test cases to execute
2 seconds to start a session
assume at max you can run 10 concurrent sessions
Total Execution Time = 2 seconds to start each session + 20*10 seconds to execute the test cases in each session = 200+2 = 202 seconds to finish complete test suite execution

How to use assertions for multiple scenario in gatling?

Right Now I am trying to do performance testing of all my api's.I already created one feature file having different scenarios(every scenario having different tag).Now I want to do use assertions on mean ResponseTime with different scenarios different assertions.
val Performance1 = scenario("Performance1").exec(karateFeature("classpath:mock/Testing1.feature#Performance"))
val Performance2 = scenario("Performance2").exec(karateFeature("classpath:mock/Testing2.feature#v3ContentMeta"))
val v4SearchTest = scenario("SearchTest").
group("SearchTesting") { exec(karateFeature("classpath:mock/Testing1.feature#Performance"))
}
setUp(
(Performance1.inject(rampUsers(10) over (5 seconds)).protocols(protocol)),
Performance2.inject(rampUsers(10) over (5 seconds)).protocols(protocol)
).assertions(details("SearchTesting").responseTime.mean.lte(680))```
You can add Gatling assertions as Global asserts. This will perfectly work with Karate Gatling. This is a sample scenario which we tried
setUp(
firstScenario.inject(
nothingFor(5 seconds), // Pause for a given duration
atOnceUsers(10), //Inject 10 Users at once
constantUsersPerSec(10) during (20 seconds), // Induce 10 requests on every second and continues this process for 30 seconds
rampUsers(10) over (10 seconds) // Linear Ramp up of the user
).protocols(protocol),
secondScenario.inject(
nothingFor(10 seconds), // Pause for a given duration
atOnceUsers(20), // Inject 10 Users at once
constantUsersPerSec(10) during (10 seconds), // Induce 10 requests on every second and continues this process for 40 seconds
).protocols(protocol),
thirdScenario.inject(
nothingFor(15 seconds), // Pause for a given duration
rampUsers(20) over (1 minute) // Linear Ramp up of the user
).protocols(protocol),
fourthScenario.inject(
nothingFor(20 seconds), // Pause for a given duration
constantUsersPerSec(10) during (20 seconds), // Induce 10 requests on every second and continues this process for 20 seconds
).protocols(protocol)
).assertions(
global.responseTime.max.between(100, 5000),
global.failedRequests.percent.is(0),
global.successfulRequests.percent.gt(90)
).maxDuration(10 minutes) // Configuring the maximum duration of your simulation. It is useful when we need to bound the duration the simulation when we can’t predict it.
The global asserts will be displayed as a separate section in the Gatling reports. This is a useful feature of Karate Gatling. Test specific failures will also get displayed in the report of Karate Gatling. For example, if this is your scenario
Scenario: My First Sample Scenario
Given url endpointUrl
And header karate-name = 'Feature 1_Scenario3'
When method get
Then status 200
And if the status code is not responded as 200, this also gets recorded in the Karate Gatling reports.
Asserts in Gatling: https://gatling.io/docs/current/general/assertions/#scope