-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow taking more metrics than just the first one
- Loading branch information
1 parent
5297a67
commit 85b1e97
Showing
7 changed files
with
8,989 additions
and
13 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
75 changes: 75 additions & 0 deletions
75
theodolite/src/test/kotlin/rocks/theodolite/kubernetes/slo/PrometheusResponseTest.kt
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,75 @@ | ||
package rocks.theodolite.kubernetes.slo | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import org.junit.jupiter.api.Test | ||
|
||
import org.junit.jupiter.api.Assertions.* | ||
|
||
class PrometheusResponseTest { | ||
|
||
private val objectMapper = ObjectMapper() | ||
|
||
@Test | ||
fun testSingleTimeseriesListConvert() { | ||
val prometheusResponse = readSingleTimeseriesResponse() | ||
val resultsList = prometheusResponse.getResultAsList() | ||
assertEquals(126, resultsList.size) | ||
} | ||
|
||
@Test | ||
fun testSingleTimeseriesWithNoMillisListConvert() { | ||
val prometheusResponse = readSingleTimeseriesNoMillisResponse() | ||
val resultsList = prometheusResponse.getResultAsList() | ||
assertEquals(11, resultsList.size) | ||
} | ||
|
||
@Test | ||
fun testNoTimeseriesListConvert() { | ||
val prometheusResponse = readNoTimeseriesResponse() | ||
val resultsList = prometheusResponse.getResultAsList() | ||
assertEquals(0, resultsList.size) | ||
} | ||
|
||
@Test | ||
fun testMultiTimeseriesListConvertWithOnlyFirst() { | ||
val prometheusResponse = readMultiTimeseriesResponse() | ||
val resultsList = prometheusResponse.getResultAsList() | ||
assertEquals(17, resultsList.size) | ||
} | ||
|
||
@Test | ||
fun testMultiTimeseriesListConvertWithoutOnlyFirst() { | ||
val prometheusResponse = readMultiTimeseriesResponse() | ||
val resultsList = prometheusResponse.getResultAsList(onlyFirst = false) | ||
assertEquals(1700, resultsList.size) | ||
} | ||
|
||
private fun readMultiTimeseriesResponse(): PrometheusResponse { | ||
return objectMapper.readValue( | ||
javaClass.getResourceAsStream("/prometheus-response/multi-timeseries.json"), | ||
PrometheusResponse::class.java | ||
) | ||
} | ||
|
||
private fun readSingleTimeseriesResponse(): PrometheusResponse { | ||
return objectMapper.readValue( | ||
javaClass.getResourceAsStream("/prometheus-response/single-timeseries.json"), | ||
PrometheusResponse::class.java | ||
) | ||
} | ||
|
||
private fun readSingleTimeseriesNoMillisResponse(): PrometheusResponse { | ||
return objectMapper.readValue( | ||
javaClass.getResourceAsStream("/prometheus-response/single-timeseries-nomillis.json"), | ||
PrometheusResponse::class.java | ||
) | ||
} | ||
|
||
private fun readNoTimeseriesResponse(): PrometheusResponse { | ||
return objectMapper.readValue( | ||
javaClass.getResourceAsStream("/prometheus-response/empty-timeseries.json"), | ||
PrometheusResponse::class.java | ||
) | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
theodolite/src/test/resources/prometheus-response/empty-timeseries.json
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,8 @@ | ||
{ | ||
"status": "success", | ||
"data": { | ||
"resultType": "matrix", | ||
"result": [ | ||
] | ||
} | ||
} |
Oops, something went wrong.