2019-04-11 11:39:41 +02:00
|
|
|
import com.sap.piper.analytics.InfluxData
|
|
|
|
|
2018-01-24 10:55:38 +02:00
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
2018-06-06 11:19:19 +02:00
|
|
|
import util.BasePiperTest
|
|
|
|
|
2019-04-11 11:39:41 +02:00
|
|
|
import static org.hamcrest.Matchers.hasKey
|
|
|
|
import static org.hamcrest.Matchers.is
|
|
|
|
import static org.hamcrest.Matchers.not
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertThat
|
2018-01-26 15:55:15 +02:00
|
|
|
import org.junit.rules.RuleChain
|
|
|
|
|
|
|
|
import util.Rules
|
2018-08-31 10:22:43 +02:00
|
|
|
import util.JenkinsReadYamlRule
|
2018-02-28 14:11:09 +02:00
|
|
|
import util.JenkinsStepRule
|
2018-01-24 10:55:38 +02:00
|
|
|
|
2018-08-31 10:22:43 +02:00
|
|
|
|
2018-06-06 11:19:19 +02:00
|
|
|
class DurationMeasureTest extends BasePiperTest {
|
2019-01-22 10:25:42 +02:00
|
|
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
2018-01-24 10:55:38 +02:00
|
|
|
|
|
|
|
@Rule
|
2018-02-28 14:11:09 +02:00
|
|
|
public RuleChain rules = Rules
|
|
|
|
.getCommonRules(this)
|
2018-08-31 10:22:43 +02:00
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2019-01-22 10:25:42 +02:00
|
|
|
.around(stepRule)
|
2018-01-24 10:55:38 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testDurationMeasurement() throws Exception {
|
|
|
|
def bodyExecuted = false
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.durationMeasure(script: nullScript, measurementName: 'test') {
|
2018-01-24 10:55:38 +02:00
|
|
|
bodyExecuted = true
|
|
|
|
}
|
2019-04-11 11:39:41 +02:00
|
|
|
// 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))
|
2018-01-24 10:55:38 +02:00
|
|
|
assertJobStatusSuccess()
|
|
|
|
}
|
|
|
|
}
|