Skip to content

Plugin extension points

JunHo Yoon edited this page Jul 25, 2019 · 2 revisions

The following describes the plugin structure in nGrinder. From 3.4, nGrinder uses the Plugin Framework for Java (PF4J) to customize nGrinder behavior without modifying nGrinder core code. nGrinder supports the following plugin extension points.

Extension Interface Extension Point Name(Plugin-Key) Description
OnLoginRunnable on-login loadUser is invoked whenever user info is required, Therefore if you like to allow not-yet-registered users to access ngrinder without explicit registration, you have to write the loadUser to load the user info from external user store procedure. Then this will invoke validateUser method to check the user provides the valid password for the given id. If you have the external server which is able to validate the user with the given id and password, you can use it for the user validation. Default plugin embedded in nGrinder can be found in here.
OnTestSamplingRunnable on-test-sampling This is a place to invoke external logic which should be executed whenever the sampling is started, is performed, and stopped. For example, If you have to monitor external servers using your own logic, you can use this extension point to retrieve them. sampling method should be very fast. we're expecting sampling method should be done within 2 ms. If it takes more time to finish this method, it can eventually ruin the performance test sampling. So we're highly recommend the plugin implementer to invoke another thread which retrieves the data in the startSampling method and fetch the already retrieved data from this thread in sampling method. You can find the sample implementation here
OnControllerLifeCycleRunnable on-start This is the plugin extension point to invoke your logic when the start and shutdown nGrinder controller.
OnPeriodicWorkingAgentCheckRunnable on-working-agent-check This is the plugin extension point to invoke your logic with the current agent status periodically. You can find the sample implementation here. This sample checks the current controllers whole agent's network usages and if it is over the designated traffics, stops all running test to block the network overflow.
OnTestLifeCycleRunnable on-test-start This is the plugin extension point to invoke your logic when the test is executed and stopped.
OnServletFilter on-servletfilter This is only one interface which ngrinder itself does not define. You should import as a servlet dependency in the plugin’s pom.xml to extend this interface.
<!-- Servlet -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>
The plugin will be located in the servlet filter chain. Therefore if you need to intercept the HTTPRequest or HTTPResponse to modify the WAS level behavior, you should implement this plugin. The sample implementation can be found here.
OnPreAuthServletFilter on-preauth-servletfilter This is the same extension point as on-servletfilter but it’s located before pre-auth by spring security is executed. The most common usage of this extension point is to allow SSO(such as SiteMinder) which is already processed by web servers like apache httpd. The sample implementation can be found here.
Clone this wiki locally