forked from hyperledger/indy-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.cd
174 lines (147 loc) · 5.86 KB
/
Jenkinsfile.cd
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!groovy
@Library('SovrinHelpers') _
def name = 'indy-node'
def nodeTestUbuntu = {
try {
echo 'Ubuntu Test: Checkout csm'
checkout scm
echo 'Ubuntu Test: Build docker image'
def testEnv = dockerHelpers.build(name)
testEnv.inside('--network host') {
echo 'Ubuntu Test: Install dependencies'
testHelpers.install()
echo 'Ubuntu Test: Test'
testHelpers.testRunner([resFile: "test-result-node.${NODE_NAME}.txt", testDir: 'indy_node'])
//testHelpers.testJUnit(resFile: "test-result-node.${NODE_NAME}.xml")
}
}
finally {
echo 'Ubuntu Test: Cleanup'
step([$class: 'WsCleanup'])
}
}
def commonTestUbuntu = {
try {
echo 'Ubuntu Test: Checkout csm'
checkout scm
echo 'Ubuntu Test: Build docker image'
def testEnv = dockerHelpers.build(name)
testEnv.inside {
echo 'Ubuntu Test: Install dependencies'
testHelpers.install()
echo 'Ubuntu Test: Test'
testHelpers.testJUnit([resFile: "test-result-common.${NODE_NAME}.xml", testDir: 'indy_common'])
}
}
finally {
echo 'Ubuntu Test: Cleanup'
step([$class: 'WsCleanup'])
}
}
def buildDebUbuntu = { repoName, releaseVersion, sourcePath ->
def volumeName = "$name-deb-u1604"
if (env.BRANCH_NAME != '' && env.BRANCH_NAME != 'master') {
volumeName = "${volumeName}.${BRANCH_NAME}"
}
if (sh(script: "docker volume ls -q | grep -q '^$volumeName\$'", returnStatus: true) == 0) {
sh "docker volume rm $volumeName"
}
dir('build-scripts/ubuntu-1604') {
sh "./build-$name-docker.sh \"$sourcePath\" $releaseVersion $volumeName"
sh "./build-3rd-parties-docker.sh $volumeName"
}
return "$volumeName"
}
def systemTests = { component ->
node("ubuntu") {
try {
dir("environment/docker/pool"){
stage("Prepare pool") {
sh '''sed -i 's/\\(RUN pip3 install python3-indy\\)/& pytest/g' core.ubuntu.dockerfile'''
sh """sed -i 's/repo.sovrin.org\\/deb xenial master/repo.sovrin.org\\/deb xenial $component/g' core.ubuntu.dockerfile"""
sh '''sed -i 's/sdk\\/deb xenial master/sdk\\/deb xenial stable/g' core.ubuntu.dockerfile'''
}
stage("Run pool") {
sh script: '''./pool_start.sh 25'''
echo "Running nodes: "
pool_nodes = sh(script: 'docker ps', returnStdout: true)
echo pool_nodes
}
stage("Prepare client") {
sh script: '''sed -i 's/\\(docker exec -it\\)/#&/g' client_start.sh'''
}
stage("Run client") {
sh script: '''./client_for_pool_start.sh'''
}
} //end dir
stage("Prepare System Tests") {
testHelpers.getSystemTests(targetDir: './system_tests')
}
stage("Copy tests and genesis to the client") {
sh '''docker cp ./system_tests/system indyclient:/home/indy'''
sh '''docker cp node1:/var/lib/indy/sandbox/pool_transactions_genesis ./docker_genesis'''
sh '''docker cp ./docker_genesis indyclient:/home/indy/system/docker_genesis'''
}
stage("Run tests") {
try {
dir("environment/docker/pool"){
sh '''docker exec -t --user indy indyclient bash -c "cd /home/indy/system && pytest --junit-xml=./reports/system_tests_ledger_report.xml test_ledger.py" '''
}
}
catch (Exception exc) {
continue
}
}
stage("Prepare reports") {
sh '''mkdir -p system_tests/reports'''
dir("system_tests/reports"){
sh '''docker cp indyclient:/home/indy/system/reports/system_tests_ledger_report.xml ./'''
}
}
stage("Upload reports") {
dir("system_tests/reports"){
archiveArtifacts artifacts: '*.xml', onlyIfSuccessful: true
junit healthScaleFactor: 0.0, keepLongStdio: true, testResults: '*.xml'
}
}
}
catch (Exception exc) {
echo "Catch the exception ${exc.getMessage()}"
echo "Stack trace:"
echo "{exc.getStackTrace()}"
}
finally {
sh '''docker stop $(docker ps -a -q)'''
sh '''docker network rm pool-network'''
}
}
}
options = new TestAndPublishOptions()
// FIXME: Remove after tests
options.skips([
StagesEnum.IS_TESTED,
StagesEnum.STATIC_CODE_VALIDATION,
StagesEnum.TEST,
StagesEnum.AUTOMERGE,
StagesEnum.GET_RELEASE_VERSION,
StagesEnum.PYPI_RELEASE,
StagesEnum.PACK_RELEASE,
StagesEnum.PACK_RELEASE_COPY,
StagesEnum.GITHUB_RELEASE,
StagesEnum.QA_NOTIF,
StagesEnum.QA_APPROVAL,
StagesEnum.PRODUCT_NOTIF,
StagesEnum.PRODUCT_APPROVAL,
StagesEnum.TGB_NOTIF,
StagesEnum.TGB_APPROVAL,
StagesEnum.PACK_RELEASE_ST,
StagesEnum.PACK_RELEASE_COPY_ST,
StagesEnum.GITHUB_RELEASE_ST,
StagesEnum.POOL_UPDATE_NOTIF,
StagesEnum.BUILD_RESULT_NOTIF,
])
options.enable([StagesEnum.PACK_RELEASE_COPY, StagesEnum.PACK_RELEASE_COPY_ST])
options.setCopyWithDeps(true)
options.setSystemTestsCb(systemTests)
options.setPrContexts([env.INDY_GITHUB_PR_REQUIRED_CONTEXT ?: "ci/hyperledger-jenkins/pr-merge"])
testAndPublish(name, [ubuntu: [node: nodeTestUbuntu, common: commonTestUbuntu]], true, options, [ubuntu: buildDebUbuntu])