Skip to content

Commit

Permalink
Merge pull request #71 from cdsap/default_metrics_values
Browse files Browse the repository at this point in the history
adding default values for metrics configurations
  • Loading branch information
cdsap authored Jul 25, 2019
2 parents 910ddb2 + 083b38f commit dfe2a80
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package com.cdsap.talaiot.configuration
* influxDbPublisher {
* dbName = "tracking"
* url = "url"
* taskMetricName = "tracking*
* taskMetricName = "tracking"
* buildMetricName = "buildMetric"
*
* }
*/
class InfluxDbPublisherConfiguration : PublisherConfiguration {
Expand All @@ -26,11 +28,11 @@ class InfluxDbPublisherConfiguration : PublisherConfiguration {
/**
* metric to identify the measurement in InfluxDb
*/
var taskMetricName: String = ""
var taskMetricName: String = "task"
/**
* metric name to identify the build measurements in InfluxDb
*/
var buildMetricName: String = ""
var buildMetricName: String = "build"
/**
* optional username for authentication
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,67 @@ class InfluxDbPublisherNotProperlyDefinedBuildTest : BehaviorSpec({
publishers {
influxDbPublisher {
dbName = "tracking"
taskMetricName = "tracking"
}
}
}
"""
)
val result = GradleRunner.create()
.withProjectDir(testProjectDir.getRoot())
.withArguments("assemble")
.withPluginClasspath()
.build()
then("logs displays the InfluxDbPublisher error") {
assert(result.output.contains("InfluxDbPublisher not executed. Configuration requires url, dbName, taskMetricName and buildMetricName"))
}
testProjectDir.delete()
}
`when`("Talaiot is included with InfluxDbPublisher and using default values for taskMetricName and buildMetricName") {
testProjectDir.create()
val buildFile = testProjectDir.newFile("build.gradle")
buildFile.appendText(
"""
plugins {
id 'java'
id 'talaiot'
}

talaiot{
publishers {
influxDbPublisher {
dbName = "tracking"
url = "http://url.influxdb"
}
}
}
"""
)
val result = GradleRunner.create()
.withProjectDir(testProjectDir.getRoot())
.withArguments("assemble")
.withPluginClasspath()
.build()
then("no error shown because using default values") {
assert(!result.output.contains("InfluxDbPublisher not executed. Configuration requires url, dbName, taskMetricName and buildMetricName"))
}
testProjectDir.delete()
}
`when`("Talaiot is included with InfluxDbPublisher and it's overridden default value for taskMetricName with empty value") {
testProjectDir.create()
val buildFile = testProjectDir.newFile("build.gradle")
buildFile.appendText(
"""
plugins {
id 'java'
id 'talaiot'
}

talaiot{
publishers {
influxDbPublisher {
dbName = "tracking"
url = "http://url.influxdb"
taskMetricName = ""
}
}
}
Expand Down

0 comments on commit dfe2a80

Please sign in to comment.