Loadcoder can generate performance tests from recorded user interactions in a web browser. This means that you can browse your way through the scenario you want to simulate in the performance test, and then instruct Loadcoder to generate Java code containing network calls corresponding to the ones made from the browser. Pretty cool, right?
The recording is actually not done by Loadcoder, but rather the browser some other program that manages the network calls, like a proxy for instance. Many browsers and proxies has the ability to log the network interaction that is taking place, and then save this log to .har file. This har file is then read be Loadcoder that interprets the content and then generates a load test.
Follow the below description of each step in how to perform the recording and generation
This section describes how to record a user web browser scenario and save to a har file
Even though the har file format is specified, it is up to the browser vendors how they are implemented. This means that the har file will look different depending on what browser you use, ultimately affecting your generated Load test. The browsers below have been evaluated and recommended in descending order
The generation of a Loadcoder test is done by creating and using an instance of the class LoadcoderGeneratorBuilder.
Follow the below example to create a generator. Consult the Javadoc for details around the arguments.
import static com.loadcoder.statics.Statics.SECOND;
import java.util.Arrays;
import com.loadcoder.cluster.clients.influxdb.InfluxDBClient;
import com.loadcoder.network.LoadcoderGeneratorBuilder;
public class LoadcoderGenerator {
public static void main(String[] args) {
new LoadcoderGeneratorBuilder(
"/path/to/recording.har",
Arrays.asList("https://www.website.com", "https://another-site-to-loadtest.com"),
"javapackage.for.generated.code",
"src/test/java/javapackage/for/generated/code",
"src/test/resources/generated-resources"
)
.load(120 * SECOND, 3, 5)
.sendResultTo(InfluxDBClient.influxReporter("WebSiteTests", "ShortLoadTest"))
.checkResponseBodiesContaining(Arrays.asList("shoppingcart"))
.generate();
}
}
The generated test should not be taken as finished, ready to execute load test. The generated code will be running, but in order to have it exactly as you like, you will need to go through the generated code and make it complete
Below is a list of things to migth want to adjust. You find the Java classes in the directory you specified in the generator
Go through the list of transactions the verify that the correct transactions are there. Loadcoder has its own logic to select the transactions that you probably want to include based from the request URL. Remove transactions that you don't want. If you miss certain transaction you can simply copy another transaction and adjust it into how it should look like.
Loadcoder generates transaction names by trying to figure out the most essential parts of the URL, making some of them quite cryptic. It is a good idea to rename them to something more describing.
In some cases there can be dependencies between HTTP calls. For instance, some value in a HTTP reponse may be needed in the next HTTP request. Loadcoder have no support for generating this logic, so you have to manually fix this.
Even though an initial load level is created by the generator, additional adjustments may be needed. Modify the use of the LoadBuilder instance so that is meet your requirements of your load test.
In many cases you need to use some kind of test data for your load test. Consult the Loadcoder Core Documentation in how to manage test data in a best practise.