2018-01-24 10:55:38 +02:00
|
|
|
#!groovy
|
2018-08-31 10:22:43 +02:00
|
|
|
|
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
|
|
|
|
|
2018-01-24 10:55:38 +02:00
|
|
|
import static org.junit.Assert.assertTrue
|
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 {
|
2018-02-28 14:11:09 +02:00
|
|
|
private JenkinsStepRule jsr = 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))
|
2018-02-28 14:11:09 +02:00
|
|
|
.around(jsr)
|
2018-01-24 10:55:38 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testDurationMeasurement() throws Exception {
|
|
|
|
def bodyExecuted = false
|
2018-06-06 11:19:19 +02:00
|
|
|
jsr.step.call(script: nullScript, measurementName: 'test') {
|
2018-01-24 10:55:38 +02:00
|
|
|
bodyExecuted = true
|
|
|
|
}
|
2018-06-06 11:19:19 +02:00
|
|
|
assertTrue(nullScript.commonPipelineEnvironment.getPipelineMeasurement('test') != null)
|
2018-01-24 10:55:38 +02:00
|
|
|
assertTrue(bodyExecuted)
|
|
|
|
assertJobStatusSuccess()
|
|
|
|
}
|
|
|
|
}
|