Testautomationguru already has released few detailed articles on creating real time results during Performance Testing. If you have not read them before, I would suggest you to check them out first.
The challenge here is, We have multiple systems in our architecture. Jenkins, JMeter-Load-Generators, InfluxDB, Grafana etc. When we run our performance test through Jenkins, we have our build history as shown here. It is little bit difficult for us to access the corresponding Grafana dashboard for the old Jenkins runs from the build history – We need to adjust the time in the Grafana based on the Jenkins build time to get the results.
In this short article, We are going to see how to provide a dynamic link to Grafana dashboard in Jenkins as part of the build. So that It is easy to access the performance test results from the build history.
import hudson.model.* //get current build def build = Thread.currentThread().executable // grafana url for aggregate dashboard - replace time stamp with %s def perfResult = "http://10.11.12.13:3000/dashboard/db/run-time-aggregate?from=%s&to=%s" def jmxMonitor = "http://10.11.12.13:3000/dashboard/db/jmx-monitor?from=%s&to=%s" // get build start and end time def start = build.getStartTimeInMillis(); def end = start + build.getExecutor().getElapsedTime(); // replace time perfResult = String.format(perfResult, start, end); jmxMonitor = String.format(jmxMonitor, start, end); //build the string to be added as description. def link = "<a href='%s'>%s</a><br/>"; def sb = new StringBuilder(); sb.append(String.format(link, perfResult, "Grafana Performance Result")) .append(String.format(link, jmxMonitor, "Grafana JMX Result")); // set build description build.setDescription(sb.toString());
Each Jenkins build has the corresponding URLs for Grafana Performance Test Results and JMX Results. We could even add the Kibana URL for the performance result log if you are collecting HTTP response as described in this article.
Happy Testing & Subscribe 🙂