1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/test/groovy/DurationMeasureTest.groovy
Christopher Fenner e67b9cff23
influxWriteData: hold data in dedicated object (#624)
* add InfluxData object

* add InfluxData rule

* use InfluxData

* include jenkins_custom_data into InfluxData object

* correct typo

* add missing import

* fix condition for influx reporting

* add test class

* Update influxWriteData.groovy
2019-04-11 11:39:41 +02:00

45 lines
1.3 KiB
Groovy

#!groovy
import com.sap.piper.analytics.InfluxData
import org.junit.Rule
import org.junit.Test
import util.BasePiperTest
import static org.hamcrest.Matchers.hasKey
import static org.hamcrest.Matchers.is
import static org.hamcrest.Matchers.not
import static org.junit.Assert.assertThat
import org.junit.rules.RuleChain
import util.Rules
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
class DurationMeasureTest extends BasePiperTest {
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(stepRule)
@Test
void testDurationMeasurement() throws Exception {
def bodyExecuted = false
stepRule.step.durationMeasure(script: nullScript, measurementName: 'test') {
bodyExecuted = true
}
// doesnt work
//assertThat(InfluxData.getInstance().getFields(), hasEntry('pipeline_data', hasEntry('test', is(anything()))))
assertThat(InfluxData.getInstance().getFields(), hasKey('pipeline_data'))
assertThat(InfluxData.getInstance().getFields().pipeline_data, hasKey('test'))
assertThat(InfluxData.getInstance().getFields().pipeline_data.test, is(not(null)))
assertThat(bodyExecuted, is(true))
assertJobStatusSuccess()
}
}