Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab22865
commit f5f76e3
Showing
9 changed files
with
89 additions
and
4 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
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
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
64 changes: 64 additions & 0 deletions
64
ontrack-acceptance/src/test/groovy/net/nemerosa/ontrack/acceptance/ACCInfluxDBRunInfo.groovy
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,64 @@ | ||
package net.nemerosa.ontrack.acceptance | ||
|
||
import org.influxdb.InfluxDBFactory | ||
import org.influxdb.annotation.Column | ||
import org.influxdb.annotation.Measurement | ||
import org.influxdb.dto.Query | ||
import org.influxdb.impl.InfluxDBResultMapper | ||
import org.junit.Test | ||
|
||
import static net.nemerosa.ontrack.test.TestUtils.uid | ||
|
||
class ACCInfluxDBRunInfo extends AcceptanceTestClient { | ||
|
||
@Test | ||
void 'Run info is exported to InfluxDB'() { | ||
def p = uid("P") | ||
ontrack.project(p) { | ||
branch("1.0") { | ||
build("1.0.0") { | ||
runInfo = [ | ||
runTime: 120 | ||
] | ||
} | ||
} | ||
} | ||
// Checks the time has been written in InfluxDB | ||
def influxDB = InfluxDBFactory.connect( | ||
configRule.config.influxdbUri | ||
) | ||
def result = influxDB.query( | ||
new Query( | ||
"SELECT * " + | ||
"FROM ontrack_value_run_info_build_time_seconds " + | ||
"WHERE project = '${p}' " + | ||
"AND branch = '1.0'", | ||
"ontrack" | ||
) | ||
) | ||
def resultMapper = new InfluxDBResultMapper() | ||
def measurements = resultMapper.toPOJO( | ||
result, | ||
RunInfoMeasurement | ||
) | ||
assert !measurements.empty | ||
def measurement = measurements.first() | ||
assert measurement.value == 120 | ||
assert measurement.project == p | ||
assert measurement.branch == "1.0" | ||
assert measurement.name == "1.0.0" | ||
} | ||
|
||
@Measurement(name = "ontrack_value_run_info_build_time_seconds") | ||
static class RunInfoMeasurement { | ||
@Column(name = "value") | ||
int value | ||
@Column(name = "project") | ||
String project | ||
@Column(name = "branch") | ||
String branch | ||
@Column(name = "name") | ||
String name | ||
} | ||
|
||
} |
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
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