forked from IBM/dbb-zappbuild
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fullBuild.groovy
83 lines (69 loc) · 3.19 KB
/
fullBuild.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript
import groovy.transform.*
import com.ibm.dbb.*
import com.ibm.dbb.build.*
@Field BuildProperties props = BuildProperties.getInstance()
@Field def testUtils = loadScript(new File("../utils/testUtilities.groovy"))
println "\n**************************************************************"
println "** Executing test script ${this.class.getName()}.groovy"
println "**************************************************************"
// Get the DBB_HOME location
def dbbHome = EnvVars.getHome()
if (props.verbose) println "** DBB_HOME = ${dbbHome}"
// Create full build command
def fullBuildCommand = []
fullBuildCommand << "${dbbHome}/bin/groovyz"
fullBuildCommand << "${props.zAppBuildDir}/build.groovy"
fullBuildCommand << "--workspace ${props.workspace}"
fullBuildCommand << "--application ${props.app}"
fullBuildCommand << (props.outDir ? "--outDir ${props.outDir}" : "--outDir ${props.zAppBuildDir}/out")
fullBuildCommand << "--hlq ${props.hlq}"
fullBuildCommand << "--logEncoding UTF-8"
fullBuildCommand << (props.url ? "--url ${props.url}" : "")
fullBuildCommand << (props.id ? "--id ${props.id}" : "")
fullBuildCommand << (props.pw ? "--pw ${props.pw}" : "")
fullBuildCommand << (props.pwFile ? "--pwFile ${props.pwFile}" : "")
fullBuildCommand << (props.verbose ? "--verbose" : "")
fullBuildCommand << (props.propFiles ? "--propFiles ${props.propFiles}" : "")
fullBuildCommand << "--fullBuild"
// Run full build
println "** Executing ${fullBuildCommand.join(" ")}"
def process = ['bash', '-c', fullBuildCommand.join(" ")].execute()
def outputStream = new StringBuffer();
process.waitForProcessOutput(outputStream, System.err)
//Validate build results
println "** Validating full build results"
def expectedFilesBuiltList = props.fullBuild_expectedFilesBuilt.split(',')
@Field def assertionList = []
try {
// Validate clean build
assert outputStream.contains("Build State : CLEAN") : "*! FULL BUILD FAILED\nOUTPUT STREAM:\n$outputStream\n"
// Validate expected number of files built
def numFullFiles = expectedFilesBuiltList.size()
assert outputStream.contains("Total files processed : ${numFullFiles}") : "*! TOTAL FILES PROCESSED ARE NOT EQUAL TO ${numFullFiles}\nOUTPUT STREAM:\n$outputStream\n"
// Validate expected built files in output stream
assert expectedFilesBuiltList.count{ i-> outputStream.contains(i) } == expectedFilesBuiltList.size() : "*! FILES PROCESSED IN THE FULL BUILD DOES NOT CONTAIN THE LIST OF FILES PASSED ${expectedFilesBuiltList}\nOUTPUT STREAM:\n$outputStream\n"
println "**"
println "** FULL BUILD TEST : PASSED **"
println "**"
}
catch(AssertionError e) {
def result = e.getMessage()
assertionList << result;
props.testsSucceeded = 'false'
}
finally {
// report failures
if (assertionList.size()>0) {
println "\n***"
println "**START OF FAILED FULL BUILD TEST RESULTS**\n"
println "*FAILED FULL BUILD RESULTS*\n" + assertionList
println "\n**END OF FAILED FULL BUILD **"
println "***"
}
testUtils.cleanUpDatasets(props.fullBuild_datasetsToCleanUp)
}
// script end
//*************************************************************
// Method Definitions
//*************************************************************