nGrinder supports the process rampup as a default feature. If a user want to increase the loads step by steps, User can set a number of process and how to increase them at the ramp-up panel in the test configuration page.
It’s the process ramp-up. If you like to 10 steps in ramp-up, you should set the process count at least 10. If you want more, you should set the process count more.
However, the processes take a lot of resources to be invoked. 100 processes in a agent is not realistic. It will cause the agent machine out of memory error.
Let’s assume that you want to know from which TPS level the system starts to be satuated.
You can use the thread level ramp up for this case. All you need is to add following code in your script.
# -*- coding:utf-8 -*-
# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP.
#
# This script is auto generated by ngrinder.
#
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest
from net.grinder.plugin.http import HTTPPluginControl
from HTTPClient import NVPair
control = HTTPPluginControl.getConnectionDefaults()
control.setTimeout(30000)
test1 = Test(1, "Test1")
request1 = HTTPRequest();
test1.record(request1)
class TestRunner:
def initialSleep( self ):
sleepTime = grinder.threadNumber * 1000 # 1 seconds per thread
grinder.sleep(sleepTime, 0)
def __call__( self ):
if grinder.runNumber == 0: self.initialSleep()
grinder.statistics.delayReports=True
result = request1.GET("http://www.google.com")
if result.getText().find("Google") != -1 :
grinder.statistics.forLastTest.success = 1
else :
grinder.statistics.forLastTest.success = 0 /**
* A simple example using the HTTP plugin that shows the retrieval of a
* single page via HTTP.
*
* This script is auto generated by ngrinder.
*
* @author ${userName}
*/
@RunWith(GrinderRunner)
class Test1 {
public static GTest test;
public static HTTPRequest request;
@BeforeProcess
public static void beforeClass() {
test = new GTest(1, "aa000000");
request = new HTTPRequest();
test.record(request);
grinder.logger.info("before process.");
}
@BeforeThread
public void beforeThread() {
grinder.statistics.delayReports=true;
grinder.logger.info("before thread.");
}
public void initialSleep() {
grinder.sleep(grinder.threadNumber * 1000, 0)
}
@Test
public void test(){
if (grinder.runNumber == 0) {
initialSleep()
}
HTTPResponse result = request.GET("http://www.google.com");
if (result.statusCode == 301 || result.statusCode == 302) {
grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode);
} else {
assertThat(result.statusCode, is(200));
}
}