1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-06-02 23:17:33 +02:00
sap-jenkins-library/test/groovy/DurationMeasureTest.groovy

45 lines
1.3 KiB
Groovy
Raw Normal View History

#!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
2018-02-28 13:11:09 +01:00
import util.JenkinsStepRule
class DurationMeasureTest extends BasePiperTest {
2019-01-22 09:25:42 +01:00
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@Rule
2018-02-28 13:11:09 +01:00
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
2019-01-22 09:25:42 +01:00
.around(stepRule)
@Test
void testDurationMeasurement() throws Exception {
def bodyExecuted = false
2019-01-22 09:25:42 +01:00
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()
}
}