forked from hyperledger-archives/indy-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.ci
883 lines (745 loc) · 32.6 KB
/
Jenkinsfile.ci
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
#!groovy
Ubuntu16 = "Ubuntu 16.04"
Ubuntu18 = "Ubuntu 18.04"
RedHat = "RedHat"
libindyBuildFinished = [(Ubuntu16): false, (Ubuntu18): false, (RedHat): false]
libvcxBuildFinished = [(Ubuntu16): false, (Ubuntu18): false, (RedHat): false]
testing()
def testing() {
stage('Static Analysis') {
staticValidation()
}
stage('Testing') {
parallel([
'ubuntu-test' : { ubuntuTesting() },
'android-test': { androidTesting() },
'macos-test' : { macosTesting() },
'ios-test' : { iosTesting() },
'centos-test' : { centosTesting() },
'windows-test': { windowsTesting() }
])
}
}
def staticValidation() {
parallel([
'libindy' : { runValdiationRust('libindy') },
'libnullpay': { runValdiationRust('libnullpay') },
'libvcx' : { runValdiationRust('vcx/libvcx') },
'cli' : { runValdiationRust('cli') }
])
}
def runValdiationRust(dir) {
node('ubuntu') {
try {
cleanWs()
checkout scm
def testEnv
if (dir == 'vcx/libvcx') {
testEnv = dockerBuild("static-validation-libvcx", "vcx/ci/ubuntu.dockerfile .")
} else {
testEnv = dockerBuild("static-validation-libindy", "libindy/ci/ubuntu.dockerfile libindy/ci")
}
testEnv.inside {
//FIXME waiting on IS-823
//sh "cargo clippy --manifest-path ${dir}/Cargo.toml"
sh "cargo clippy --manifest-path ${dir}/Cargo.toml -- -W clippy::style -W clippy::correctness -W clippy::complexity -W clippy::perf"
}
} finally {
cleanWs()
}
}
}
def windowsTesting() {
node('win2016') {
stage('Windows Test') {
def ws_path = "workspace/${env.JOB_NAME}".replace(' ', '_')
ws(ws_path) {
cleanWs()
try {
echo "Windows Test: Checkout scm"
checkout scm
echo "Windows Test: Run Indy pool"
bat "docker -H $INDY_SDK_SERVER_IP build --build-arg pool_ip=$INDY_SDK_SERVER_IP -f ci/indy-pool.dockerfile -t indy_pool ci"
bat "docker -H $INDY_SDK_SERVER_IP run -d --network host --name indy_pool -p 9701-9708:9701-9708 indy_pool"
setupRust()
dir('libindy') {
echo "Windows Test: Download prebuilt dependencies"
bat 'wget -O prebuilt.zip "https://repo.sovrin.org/windows/libindy/deps/indy-sdk-deps.zip"'
bat 'unzip prebuilt.zip -d prebuilt'
echo "Windows Libindy Test: Build"
withEnv([
"INDY_PREBUILT_DEPS_DIR=$WORKSPACE\\libindy\\prebuilt",
"INDY_CRYPTO_PREBUILT_DEPS_DIR=$WORKSPACE\\libindy\\prebuilt",
"MILAGRO_DIR=$WORKSPACE\\libindy\\prebuilt",
"LIBZMQ_PREFIX=$WORKSPACE\\libindy\\prebuilt",
"SODIUM_LIB_DIR=$WORKSPACE\\libindy\\prebuilt",
"OPENSSL_DIR=$WORKSPACE\\libindy\\prebuilt",
"PATH=$WORKSPACE\\libindy\\prebuilt\\lib;$PATH",
"RUST_BACKTRACE=1"
]) {
bat "cargo build --features fatal_warnings"
bat 'cargo test --no-run --features only_high_cases'
echo "Windows Libindy before Test: Deleting %TEMP\\indy_client"
bat "DEL /S /Q /F %TEMP%\\indy_client"
bat "DEL /S /Q /F %UserProfile%\\.indy_client"
echo "Windows Libindy Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=indy::=debug,zmq=trace",
"TEST_POOL_IP=$INDY_SDK_SERVER_IP"
]) {
bat 'cargo test --features only_high_cases'
}
echo "Windows Libindy after Test: Deleting %TEMP\\indy_client"
bat "DEL /S /Q /F %TEMP%\\indy_client"
bat "DEL /S /Q /F %UserProfile%\\.indy_client"
}
}
dir('libnullpay') {
echo "Windows Libnullpay Test: Build"
withEnv([
"RUST_BACKTRACE=1"
]) {
bat "cargo build --features fatal_warnings"
bat "cargo test --no-run"
echo "Windows Libnullpay Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=indy::=debug,zmq=trace",
"TEST_POOL_IP=$INDY_SDK_SERVER_IP",
"PATH=$WORKSPACE\\libindy\\target\\debug;$PATH",
]) {
bat "cargo test"
}
}
}
bat "PowerShell.exe \"Copy-Item $WORKSPACE/libnullpay/target/debug/nullpay.dll -Destination $WORKSPACE/cli\""
dir('cli') {
bat "PowerShell.exe \"&{(Get-Content -Path docker_pool_transactions_genesis -Raw) -replace '10\\.0\\.0\\.2','$INDY_SDK_SERVER_IP'} | Set-Content -Path docker_pool_transactions_genesis\""
def featuresArgs = ''
// def featuresArgs = '--features "nullpay_plugin"' // disabled because of IS-1109
echo "Windows Indy Cli Test: Build"
withEnv([
"RUST_BACKTRACE=1"
]) {
bat "cargo test $featuresArgs --no-run"
echo "Windows Indy Cli Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=indy::=debug,zmq=trace",
"TEST_POOL_IP=$INDY_SDK_SERVER_IP"
]) {
bat "cargo test $featuresArgs"
}
}
}
bat "PowerShell.exe \"Copy-Item $WORKSPACE/libnullpay/target/debug/nullpay.dll -Destination $WORKSPACE/vcx/libvcx\""
dir('vcx/libvcx') {
echo "Windows Libvcx Test: Build"
withEnv([
"OPENSSL_DIR=$WORKSPACE\\libindy\\prebuilt",
"RUST_BACKTRACE=1"
]) {
bat "cargo build --features fatal_warnings"
bat "cargo test --no-run"
echo "Windows Libvcx Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=vcx=debug,indy::=debug",
"PATH=$WORKSPACE\\libindy\\target\\debug;$PATH",
]) {
bat "cargo test"
}
}
}
//TODO wrappers testing
} finally {
try {
echo "Windows Libindy after Test: Deleting %TEMP\\indy_client"
bat "DEL /S /Q /F %TEMP%\\indy_client"
bat "DEL /S /Q /F %UserProfile%\\.indy_client"
} catch (ignore) {
}
try {
bat "docker -H $INDY_SDK_SERVER_IP stop indy_pool"
} catch (ignore) {
}
try {
bat "docker -H $INDY_SDK_SERVER_IP rm indy_pool"
} catch (ignore) {
}
cleanWs()
}
}
cleanWs()
}
}
}
def macosTesting() {
node('macos') {
cleanWs()
stage('MacOS Test') {
def pool_name = "indy_pool"
try {
echo "MacOS Test: Checkout scm"
checkout scm
setupRust()
setupBrewPackages()
macosRunPool(pool_name)
macosCleanIndyDir()
macosModuleBuildingAndTest('libindy', "--features only_high_cases")
sh "cp libindy/target/debug/libindy.dylib libnullpay"
sh "cp libindy/target/debug/libindy.dylib vcx/libvcx"
sh "cp libindy/target/debug/libindy.dylib cli"
macosModuleBuildingAndTest('libnullpay')
sh "cp libnullpay/target/debug/libnullpay.dylib vcx/libvcx"
macosModuleBuildingAndTest('vcx/libvcx')
sh "sed -i'.original' -e 's/10.0.0.2/127.0.0.1/g' cli/docker_pool_transactions_genesis"
macosModuleBuildingAndTest('cli')
//TODO wrappers testing
} finally {
macosStopPool(pool_name)
macosCleanIndyDir()
step([$class: 'WsCleanup'])
}
}
}
}
def macosCleanIndyDir() {
sh "rm -rf ~/.indy_client || true"
}
def macosModuleBuildingAndTest(library, testFeatures = "") {
dir(library) {
echo "MacOS ${library} Testing: Build"
sh "LIBRARY_PATH=./ cargo build --features fatal_warnings"
echo "MacOS ${library} Testing: Run Tests"
sh "LIBRARY_PATH=./ cargo test --no-run ${testFeatures}"
sh "LIBRARY_PATH=./ RUST_TEST_THREADS=1 cargo test ${testFeatures}"
}
}
def androidTesting() {
env_name = "android_on_linux"
network_name = "pool_network"
linuxModuleTesting("ci/android.dockerfile ci", env_name, network_name, this.&linuxAndroidOnEmulatorTesting, "android", "android", ["libindy": 'ci/ubuntu.dockerfile ci'])
}
def iosTesting() {
def setupRustIOS = {
sh "rustup target add x86_64-apple-ios"
}
def cleanSimulators = {
sh '''
xcrun simctl list devices | grep 'IndySDK' | awk '{print $4}' | sed -n 's/(\\(.*\\))/\\1/p'
xcrun simctl list devices | grep 'IndySDK' | awk '{print $4}' | sed -n 's/(\\(.*\\))/\\1/p' | xargs xcrun simctl delete
'''
}
def createSimulators = {
sh '''
xcrun simctl create "iPhone X IndySDK" "iPhone X" "11.2"
'''
}
node('macos') {
cleanWs()
stage('iOS Test') {
def pool_name = "indy_pool"
try {
echo "iOS Test: Checkout scm"
checkout scm
echo "iOS Test: setup rust, brew and simulators"
setupRust()
setupRustIOS()
setupBrewPackages()
cleanSimulators()
createSimulators()
withEnv([
"BUNDLE_PATH=$HOME/.gem.indy_sdk"
]) {
dir('wrappers/ios') {
echo "iOS Test: Installing ruby, bundler and gems"
sh '''
rbenv install -s $(cat .ruby-version)
gem install bundler
bundler install
bundler list
'''
}
dir('wrappers/ios/libindy-pod') {
echo "iOS Test: Installing dependencies (pods)"
sh "bundler exec pod install --repo-update"
}
echo "iOS Test: Running pool"
macosRunPool(pool_name)
sh 'chmod -R 777 ci'
echo "iOS Test: build libindy pod"
sh "ci/ios-build.sh libindy x86_64-apple-ios"
// FIXME replace this hack (manually rewrite installed pod)
sh "rm -f wrappers/ios/libindy-pod/Pods/libindy/*.[ah]"
sh "cp libindy/out_pod/*.[ah] wrappers/ios/libindy-pod/Pods/libindy"
// FIXME restore Xcode testing
// dir('wrappers/ios/libindy-pod') {
// echo "iOS Test: Testing"
// sh "xcodebuild test -workspace Indy.xcworkspace -scheme Indy-demo -destination 'platform=iOS Simulator,name=iPhone X IndySDK,OS=11.2'"
// }
}
} finally {
try {
cleanSimulators()
} catch (ignore) {
}
macosStopPool(pool_name)
step([$class: 'WsCleanup'])
}
}
}
}
def ubuntuTesting() {
stage('Ubuntu Test') {
parallel([
"ubuntu:16.04": {
linuxTesting("ci/ubuntu.dockerfile ci", Ubuntu16, "pool_network", false)
},
"ubuntu:18.04": {
linuxTesting("ci/ubuntu18.dockerfile ci", Ubuntu18, "pool_network", true)
}
])
}
}
def centosTesting() {
stage('RedHat Test') {
linuxTesting("ci/centos.dockerfile ci", "RedHat", "pool_network", false)
}
}
def linuxTesting(file, env_name, network_name, full_testing) {
parallel([
failFast : true,
"${env_name} Test: build and test libindy": {
node('ubuntu') {
cleanWs()
linuxLibindyBuild(file, env_name, network_name, full_testing)
}
},
"${env_name} Test: test other components" : {
waitUntil {
libindyBuildFinished[env_name]
}
def jobs = [
"${env_name}-cli-test": {
linuxModuleTesting(file, env_name, network_name, this.&linuxCLITesting)
},
"${env_name}-vcx-test": {
vcxTesting(file, env_name, network_name, full_testing)
}
]
if (full_testing) {
jobs["${env_name}wrappers-test"] = {
linuxModuleTesting(file, env_name, network_name, this.&linuxIndyWrappersTesting)
}
jobs["${env_name}-cloud-agent-test"] = {
linuxModuleTesting(file, env_name, network_name, this.&linuxCloudAgentTesting)
}
}
parallel(jobs)
},
])
}
def vcxTesting(file, env_name, network_name, full_testing) {
parallel([
failFast : true,
"${env_name} Test: build and test libvcx" : {
node('ubuntu') {
cleanWs()
linuxVcxBuild(file, env_name, network_name)
}
},
"${env_name} Test: test other vcx components": {
if (full_testing) {
waitUntil {
libvcxBuildFinished[env_name]
}
linuxModuleTesting(file, env_name, network_name, this.&linuxVcxWrappersTesting)
}
},
])
}
def linuxLibindyBuild(file, env_name, network_name, full_testing) {
def poolInst
try {
echo "${env_name} Test: Checkout csm"
checkout scm
poolInst = openPool(env_name, network_name)
def testEnv = buildTestEnv(file, env_name)
testEnv.inside {
echo "${env_name} Libindy Test: Build"
sh '''
cd libindy
cargo build --features "fatal_warnings sodium_static"
'''
}
sh "cp libindy/target/debug/libindy.so wrappers/java/lib"
sh "cp libindy/target/debug/libindy.so wrappers/python"
sh "cp libindy/target/debug/libindy.so wrappers/nodejs"
sh "cp libindy/target/debug/libindy.so wrappers/rust"
sh "cp libindy/target/debug/libindy.so cli"
sh "cp libindy/target/debug/libindy.so libnullpay"
sh "cp libindy/target/debug/libindy.so vcx/libvcx"
sh "cp libindy/target/debug/libindy.so vcx/wrappers/node"
sh "cp libindy/target/debug/libindy.so vcx/wrappers/java"
sh "cp libindy/target/debug/libindy.so vcx/wrappers/python3"
sh "cp libindy/target/debug/libindy.so vcx/dummy-cloud-agent"
testEnv.inside {
echo "${env_name} Libnullpay Test: Build"
sh '''
cd libnullpay
LIBRARY_PATH=./ cargo build --features fatal_warnings
'''
}
sh "cp libnullpay/target/debug/libnullpay.so cli"
sh "cp libnullpay/target/debug/libnullpay.so vcx/libvcx"
sh "cp libnullpay/target/debug/libnullpay.so vcx/wrappers/node"
sh "cp libnullpay/target/debug/libnullpay.so vcx/wrappers/java"
sh "cp libnullpay/target/debug/libnullpay.so vcx/wrappers/python3"
stash includes: 'wrappers/java/lib/libindy.so', name: "LibindyJavaSO${env_name}"
stash includes: 'wrappers/python/libindy.so', name: "LibindyPythonSO${env_name}"
stash includes: 'wrappers/nodejs/libindy.so', name: "LibindyNodejsSO${env_name}"
stash includes: 'wrappers/rust/libindy.so', name: "LibindyRustSO${env_name}"
stash includes: 'cli/libindy.so', name: "LibindyCliSO${env_name}"
stash includes: 'cli/libnullpay.so', name: "LibnullpayCliSO${env_name}"
stash includes: 'vcx/libvcx/libindy.so,vcx/libvcx/libnullpay.so', name: "VCXLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/wrappers/node/libindy.so,vcx/wrappers/node/libnullpay.so', name: "VcxNodeLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/wrappers/java/libindy.so,vcx/wrappers/java/libnullpay.so', name: "VcxJavaLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/wrappers/python3/libindy.so,vcx/wrappers/python3/libnullpay.so', name: "VcxPythonLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/dummy-cloud-agent/libindy.so', name: "LibindyCloudAgentSO${env_name}"
libindyBuildFinished[env_name] = true
testEnv.inside("--network=${network_name}") {
echo "${env_name} Libindy Test: Test Libindy submodules"
for (component in ["libindy/indy-api-types", "libindy/indy-utils", "libindy/indy-wallet"]) {
testLibindyComponent(component)
}
echo "${env_name} Libindy Test: Test"
def features_args = full_testing ? "--features sodium_static" : "--features \"sodium_static only_high_cases\""
sh """
cd libindy
RUST_BACKTRACE=1 cargo test --no-run ${features_args}
RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test ${features_args}
"""
}
echo "${env_name} Libnullpay Test: Test"
testEnv.inside("--network=${network_name}") {
sh '''
cd libnullpay
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --no-run
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test
'''
}
}
finally {
closePool(env_name, network_name, poolInst)
}
}
def testLibindyComponent(directory) {
sh """
cd ${directory}
RUST_BACKTRACE=1 cargo test --no-run
RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test
"""
}
def linuxVcxBuild(file, env_name, network_name) {
def poolInst
try {
echo "${env_name} Test: Checkout csm"
checkout scm
poolInst = openPool(env_name, network_name)
def testEnv = buildTestEnv(file, env_name)
unstash name: "VCXLibindyAndLibnullpaySO${env_name}"
echo "${env_name} Libvcx Test: Build"
testEnv.inside {
sh '''
cd vcx/libvcx
LIBRARY_PATH=./ cargo build --features fatal_warnings
'''
}
sh "cp vcx/libvcx/target/debug/libvcx.so vcx/wrappers/node"
sh "cp vcx/libvcx/target/debug/libvcx.so vcx/wrappers/java"
sh "cp vcx/libvcx/target/debug/libvcx.so vcx/wrappers/python3"
stash includes: 'vcx/wrappers/node/libvcx.so', name: "VcxNodeLibvcxSO${env_name}"
stash includes: 'vcx/wrappers/java/libvcx.so', name: "VcxJavaLibvcxSO${env_name}"
stash includes: 'vcx/wrappers/python3/libvcx.so', name: "VcxPythonLibvcxSO${env_name}"
libvcxBuildFinished[env_name] = true
sh "cp vcx/libvcx/libindy.so vcx/dummy-cloud-agent"
testEnv.inside("--network=${network_name}") {
sh '''
cd vcx/dummy-cloud-agent
sed -i 's/\\("protocol_type": "\\)2.0/\\11.0/' config/sample-config.json
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy=info cargo build
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy=info cargo run config/sample-config.json &
'''
echo "${env_name} Libvcx Test: Run tests"
sh '''
cd vcx/libvcx
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=vcx=debug,indy=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --features "pool_tests agency"
'''
}
testEnv.inside("--network=${network_name}") {
sh '''
cd vcx/dummy-cloud-agent
sed -i 's/\\("protocol_type": "\\)1.0/\\12.0/' config/sample-config.json
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy=info cargo run config/sample-config.json &
'''
echo "${env_name} Libvcx Test: Run vcx demo test for protocol version 2.0"
// TODO in Rust 1.39.0 there was a problem with test name before "--". Temporary put test name after it.
sh '''
cd vcx/libvcx
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=vcx=debug,indy=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --features "pool_tests agency_v2" -- tests::test_real_proof_for_protocol_type_v2 --exact
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=vcx=debug,indy=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --features "pool_tests aries" -- v3::test::aries_demo --exact
'''
}
}
finally {
closePool(env_name, network_name, poolInst)
}
}
def linuxModuleTesting(file, env_name, network_name, module_tester) {
linuxModuleTesting(file, env_name, network_name, module_tester, "ubuntu")
}
def linuxModuleTesting(file, env_name, network_name, module_tester, node_label, image_name="libindy", prebuilt_images = [:]) {
node(node_label) {
cleanWs()
def poolInst
try {
echo "${env_name} Test: Checkout csm"
checkout scm
poolInst = openPool(env_name, network_name)
def testEnv = buildTestEnv(file, env_name, image_name, prebuilt_images)
module_tester(env_name, network_name, testEnv)
} finally {
closePool(env_name, network_name, poolInst)
}
}
}
def linuxAndroidOnEmulatorTesting(env_name, network_name, testEnv) {
sh 'chmod -R 777 libindy/ci/*.sh'
sh 'chmod -R 777 libindy/*.sh'
def emu_arch = "x86"
testEnv.inside("--network=${network_name}") {
for (directory in ["libindy", "libnullpay", "vcx/libvcx"]) {
echo "${env_name} ${directory} Test: Test on ${emu_arch} emulator"
sh "cd ${directory} && ./android.test.sh ${emu_arch}"
}
}
}
def linuxIndyWrappersTesting(env_name, network_name, testEnv) {
linuxJavaTesting(env_name, network_name, testEnv)
linuxPythonTesting(env_name, network_name, testEnv)
linuxNodejsTesting(env_name, network_name, testEnv)
linuxRustTesting(env_name, network_name, testEnv)
}
def linuxVcxWrappersTesting(env_name, network_name, testEnv) {
linuxVcxNodejsTesting(env_name, network_name, testEnv)
linuxVcxJavaTesting(env_name, network_name, testEnv)
linuxVcxPythonTesting(env_name, network_name, testEnv)
}
def linuxJavaTesting(env_name, network_name, testEnv) {
unstash name: "LibindyJavaSO${env_name}"
dir('wrappers/java') {
testEnv.inside("--network=${network_name}") {
echo "${env_name} Libindy Test: Test java wrapper"
sh "TEST_POOL_IP=10.0.0.2 mvn clean test"
}
}
}
def linuxPythonTesting(env_name, network_name, testEnv) {
unstash name: "LibindyPythonSO${env_name}"
dir('wrappers/python') {
testEnv.inside("--network=${network_name}") {
echo "${env_name} Libindy Test: Test python wrapper"
sh '''
python3 -m pip install --user -e .[test]
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} TEST_POOL_IP=10.0.0.2 python3 -m pytest
'''
}
}
}
def linuxNodejsTesting(env_name, network_name, testEnv) {
unstash name: "LibindyNodejsSO${env_name}"
testEnv.inside("--network=${network_name}") {
echo "${env_name} Libindy Test: Test nodejs wrapper"
sh '''
cd wrappers/nodejs
npm run prepare
npm install
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_LOG=indy::=debug TEST_POOL_IP=10.0.0.2 npm test
'''
}
}
def linuxVcxNodejsTesting(env_name, network_name, testEnv) {
unstash name: "VcxNodeLibvcxSO${env_name}"
unstash name: "VcxNodeLibindyAndLibnullpaySO${env_name}"
testEnv.inside("--network=${network_name}") {
echo "${env_name} Vcx Test: Test nodejs wrapper"
sh '''
cd vcx/wrappers/node/
npm i
npm run compile
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} LIBVCX_PATH=./ npm test
'''
}
}
def linuxVcxJavaTesting(env_name, network_name, testEnv) {
unstash name: "VcxJavaLibvcxSO${env_name}"
unstash name: "VcxJavaLibindyAndLibnullpaySO${env_name}"
dir('vcx/wrappers/java') {
echo "${env_name} Vcx Test: Test java wrapper"
testEnv.inside("--network=${network_name}") {
sh 'LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} ./gradlew --no-daemon test'
}
}
}
def linuxVcxPythonTesting(env_name, network_name, testEnv) {
unstash name: "VcxPythonLibvcxSO${env_name}"
unstash name: "VcxPythonLibindyAndLibnullpaySO${env_name}"
dir('vcx/wrappers/python3') {
testEnv.inside("--network=${network_name}") {
echo "${env_name} Vcx Test: Test python wrapper"
sh '''
python3 -m pip install --user pytest==3.6.4 pytest-asyncio==0.10.0
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} python3 -m pytest -s
'''
}
}
}
def linuxCLITesting(env_name, network_name, testEnv) {
unstash name: "LibindyCliSO${env_name}"
unstash name: "LibnullpayCliSO${env_name}"
echo "${env_name} Indy Cli Test: tests"
testEnv.inside("--network=${network_name}") {
sh '''
cd cli
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo build --features fatal_warnings
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --features "nullpay_plugin" --no-run
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --features "nullpay_plugin"
'''
}
}
def linuxRustTesting(env_name, network_name, testEnv) {
unstash name: "LibindyRustSO${env_name}"
dir('wrappers/rust') {
testEnv.inside("--network=${network_name}") {
echo "${env_name} Indy Rust wrapper Test: Build"
sh 'LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --no-run'
echo "${env_name} Indy Rust wrupper Test: Run tests"
sh 'LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test'
}
}
}
def linuxCloudAgentTesting(env_name, network_name, testEnv) {
unstash name: "LibindyCloudAgentSO${env_name}"
echo "${env_name} Cloud Agent Test: tests"
testEnv.inside {
sh '''
cd vcx/dummy-cloud-agent
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --no-run
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::=debug RUST_TEST_THREADS=1 cargo test
'''
}
}
def getBuildPoolVerOptions(pool_type, plenum_ver, anoncreds_ver, node_ver) {
if (pool_type != null && plenum_ver != null && anoncreds_ver != null && node_ver != null) {
return "--build-arg=indy_stream=${pool_type} --build-arg indy_plenum_ver=${plenum_ver} --build-arg indy_anoncreds_ver=${anoncreds_ver} --build-arg indy_node_ver=${node_ver}"
} else {
return ""
}
}
def getUserUid() {
return sh(returnStdout: true, script: 'id -u').trim()
}
def buildTestEnv(file, env_name, name="libindy", prebuilt_images=[:]) {
dir('libindy') {
echo "${env_name} Build test environment"
for (entry in mapToList(prebuilt_images)) {
dockerBuild(entry[0], entry[1])
}
return dockerBuild(name, file)
}
}
def dockerBuild(name, file = 'ci/ubuntu.dockerfile ci', customParams = '') {
return docker.build("$name-test", "--build-arg uid=${getUserUid()} ${customParams} -f $file")
}
def macosRunPool(pool_name) {
sh "docker rm -f ${pool_name} || true"
sh "docker build -f ci/indy-pool.dockerfile -t ${pool_name} ci"
sh "docker run -d --name ${pool_name} -p 9701-9708:9701-9708 ${pool_name}"
}
def macosStopPool(pool_name) {
try {
sh "docker stop ${pool_name}"
} catch (ignore) {
}
try {
sh "docker rm ${pool_name}"
} catch (ignore) {
}
}
def dockerClean(env_name, network_name) {
try {
try {
sh returnStatus: true, script: "docker ps --format '{{.ID}}' --filter network=${network_name} | xargs docker rm -f"
} catch (error) {
echo "${env_name} Test: error while force clean-up network ${network_name} - ${error}"
}
try {
echo "${env_name} Test: remove pool network ${network_name}"
sh returnStatus: true, script: "docker network rm ${network_name}"
} catch (error) {
echo "${env_name} Test: error while delete ${network_name} - ${error}"
}
}
finally {
sh "docker container prune -f"
sh "docker network prune -f"
}
}
def openPool(env_name, network_name, pool_type = null, pool_ver = null, plenum_ver = null, anoncreds_ver = null, node_ver = null) {
echo "${env_name} Test: Clean docker"
dockerClean(env_name, network_name)
echo "${env_name} Test: Create docker network (${network_name}) for nodes pool and test image"
sh "docker network create --subnet=10.0.0.0/8 ${network_name}"
echo "${env_name} Test: Build docker image for nodes pool ver. ${pool_ver}"
echo "${env_name} Test: Building nodes pool for versions: plenum ${plenum_ver}, anoncreds ${anoncreds_ver}, node ${node_ver}"
verOptions = getBuildPoolVerOptions(pool_type, plenum_ver, anoncreds_ver, node_ver)
def poolEnv = dockerBuild("indy_pool_${pool_ver}", 'ci/indy-pool.dockerfile ci', "--build-arg pool_ip=10.0.0.2 ${verOptions}")
echo "${env_name} Test: Run nodes pool"
return poolEnv.run("--ip=\"10.0.0.2\" --network=${network_name}")
}
def closePool(env_name, network_name, poolInst) {
echo "${env_name} Test: Cleanup"
try {
echo "${env_name} Test: stop pool"
poolInst.stop()
} catch (error) {
echo "${env_name} Tests: error while stop pool ${error}"
}
finally {
dockerClean(env_name, network_name)
}
step([$class: 'WsCleanup'])
}
def shell(command) {
if (isUnix()) {
sh command
} else {
bat command
}
}
def setupRust() {
shell("rustup default 1.46.0")
}
def setupBrewPackages() {
sh "brew switch libsodium 1.0.12"
sh "brew switch openssl 1.0.2q"
sh "brew switch zeromq 4.2.3"
}
@NonCPS
List<List<?>> mapToList(Map map) {
return map.collect { it ->
[it.key, it.value]
}
}