-
-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add labels to the prometheus metrics (via #823)
- Loading branch information
1 parent
0da77c4
commit a52f238
Showing
3 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
allure-generator/src/test/java/io/qameta/allure/prometheus/PrometheusMetricLineTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.qameta.allure.prometheus; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Anton Tsyganov (jenkl) | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class PrometheusMetricLineTest { | ||
private static final String METRIC_NAME = "launch"; | ||
private static final String METRIC_KEY = "status passed"; | ||
private static final String METRIC_VALUE = "300"; | ||
|
||
private final String labels; | ||
private final String expectedMetric; | ||
|
||
public PrometheusMetricLineTest(String labels, String expectedMetric, String name) { | ||
this.labels = labels; | ||
this.expectedMetric = expectedMetric; | ||
} | ||
|
||
@Parameterized.Parameters(name = "prometheus metric {2}") | ||
public static String[][] data() { | ||
return new String[][] { | ||
{"evn=\"test\",suite=\"regression\"", "launch_status_passed{evn=\"test\",suite=\"regression\"} 300", | ||
"with labels"}, | ||
{null, "launch_status_passed 300", "without labels"} | ||
}; | ||
} | ||
|
||
@Test | ||
public void shouldReturnMetric() { | ||
PrometheusMetricLine prometheusMetric = new PrometheusMetricLine(METRIC_NAME, METRIC_KEY, METRIC_VALUE, labels); | ||
assertEquals(prometheusMetric.asString(), expectedMetric); | ||
} | ||
} |