I am exploring Grafana with influxdb for Selenium Test Reports and was successful into sending metrics to Influx > Grafana but my dashboard yield separate reports against each build execution. One has to manually select report from the dropdown to visualize build specific report.
LIKE:
Is there’s any way to generate reports grouped together as Build 1, Build 2 and so on with PASS/FAIL/SKIP count in a tabular way. Click on each Build report will open new dashboard highlighting all the test cases within that report.
Sample Report:
I have tried below set of queries but nothing yielded positive result.
from(bucket: "sel")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "test_execution")
|> filter(fn: (r) => r["MARKER"] == "Edge_Management")
|> filter(fn: (r) => r["_field"] == "NAME")
|> filter(fn: (r) => r["BUILD_NUMBER"] == "1")
|> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS")
|> group(columns: ["MARKER"])
|> yield()
from(bucket: "sel")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "test_execution")
|> filter(fn: (r) => r["MARKER"] == "Edge_Management")
|> filter(fn: (r) => r["_field"] == "DURATION")
|> filter(fn: (r) => r["BUILD_NUMBER"] == "1")
|> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS")
|> group(columns: ["MARKER"])
|> count(column: "STATUS")
|> yield()
from(bucket: "sel")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "test_execution")
|> filter(fn: (r) => r["MARKER"] == "Edge_Management")
|> filter(fn: (r) => r["_field"] == "NAME")
|> filter(fn: (r) => r["BUILD_NUMBER"] == "1")
|> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS" )
|> count()
|> group(columns: ["MARKER"])
|> yield(name: "MARKER")
from(bucket: "sel")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "test_execution")
|> filter(fn: (r) => r["_field"] == "NAME")
|> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS")
|> count()
|> group(columns: ["MARKER","BUILD_NUMBER"])
|> yield()
Below are my selenium code:
private void sendTestMethodStatus(ITestResult iTestResult, String status) {
Point point = Point.measurement("test_execution")
.addTag("BUILD_NUMBER", "3")
.addField("NAME", iTestResult.getName())
.addTag("STATUS", status)
.addTag("MARKER", "Edge_Management")
.addField("DURATION", (iTestResult.getEndMillis() - iTestResult.getStartMillis()))
.time(System.currentTimeMillis(), WritePrecision.MS);
InfluxListener.send(point);
public static void send(final Point point) {
InfluxDBClient influxDBClient = InfluxDBClientFactory.create("http://localhost:8086", token, org, bucket);
WriteApiBlocking writeApi = influxDBClient.getWriteApiBlocking();
writeApi.writePoint(point);
}
Grafana Version: 9.0.0 InfluxDB Version: 2.3.0