@@ -57,6 +57,7 @@ class Tester {
57
57
String testSearchDir = ' ../../..'
58
58
String sdExt = ' .dsd.json'
59
59
String optionPrefix = ' arg.'
60
+ String metricsFile = ' output_metrics.txt'
60
61
String outputBasePath = System . getProperty(' user.dir' ) + ' /tmp/PipelineTester'
61
62
String outputRegex = ' -o (\\ S+)'
62
63
String infoPrompt = ' ->'
@@ -549,7 +550,7 @@ class Tester {
549
550
def paramsBlock = section. value[' params' ]
550
551
def seeBlock = section. value[' see' ]
551
552
def createsBlock = section. value[' creates' ]
552
- def doesNotCreateBlock = section. value[' does_not_create ' ]
553
+ def metricsBlock = section. value[' metrics ' ]
553
554
554
555
// Enforce conditions on block combinations...
555
556
if (command != null && paramsBlock != null ) {
@@ -696,6 +697,38 @@ class Tester {
696
697
697
698
}
698
699
700
+ // Has the user specified any metrics?
701
+ // These are located in the `output_metrics.txt` file.
702
+ if (validated && metricsBlock != null ) {
703
+ // A metrics file must exist.
704
+ Properties properties = new Properties ()
705
+ String metricsPath = testOutputPath. toString() + File . separator + metricsFile
706
+ File propertiesFile = new File (metricsPath)
707
+ if (propertiesFile. exists()) {
708
+ propertiesFile. withInputStream {
709
+ properties. load(it)
710
+ }
711
+ metricsBlock. each { metric ->
712
+ String fileProperty = properties. " $metric . key "
713
+ if (fileProperty == null ) {
714
+ // The Metric is not in the file!
715
+ err(" Metric for '$metric . key ' is not in the metrics file" )
716
+ validated = false
717
+ } else {
718
+ def finder = (fileProperty =~ / ${metric.value}/ )
719
+ if (finder. count == 0 ) {
720
+ err(" Expected value for metric '$metric . key ' ($metric . value )" +
721
+ " does not match file value ($fileProperty )" )
722
+ validated = false
723
+ }
724
+ }
725
+ }
726
+ } else {
727
+ err(" Expected metrics but there was no metrics file ($metricsFile )" )
728
+ validated = false
729
+ }
730
+ }
731
+
699
732
} else {
700
733
err(" Pipeline exitValue=$exitValue . <stderr> follows..." )
701
734
}
0 commit comments