forked from R3Conclave/conclave-core-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-conclave-init.sh
executable file
·89 lines (65 loc) · 3.2 KB
/
test-conclave-init.sh
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
#!/usr/bin/env bash
set -eou pipefail
# This script requires a local build of the SDK at build/repo, which can be produced by running
# ./gradlew publishAllPublicationsToBuildRepository.
echo
echo Testing Conclave Init
echo
pushd build
conclaveInitJar=$(find repo/com/r3/conclave/conclave-init/ -name 'conclave-init-*jar' -not -name 'conclave-init-*javadoc.jar' -not -name 'conclave-init-*-sources.jar')
echo Create Java project
"$JAVA_HOME"/bin/java -jar "$conclaveInitJar" \
--enclave-class-name "MegaEnclave" \
--package "com.megacorp" \
--target "mega-project" \
pushd mega-project
echo Run Java project unit tests
# As a user-facing tool, Conclave Init will produce a project which will download all the Conclave dependencies from
# Maven Central. However, for testing against a particular build of the SDK, we need to tell the generated project to
# use our local repo containing the SDK under test.
# Gradle takes into consideration the order in which the repositories are listed. Because we are applying changes to gradle files using the sed,
# the repos will appear in reverse order in the file.
# Please ensure that the url conclave-maven always appears after the repo to ensure that Gradle first looks at the local repo before searching in Artifactory.
sed -i "s/repositories {/repositories {\nmaven { url = 'https:\/\/software.r3.com\/artifactory\/conclave-maven' }/" build.gradle
sed -i "s/repositories {/repositories {\nmaven { url = '..\/..\/repo' }/" build.gradle
sed -i "s/repositories {/repositories {\nmaven { url = '..\/repo' }/" settings.gradle
./gradlew test
echo Run Java project host and client
# NOTE: this command is only run in mock mode, so that the signer can be provided below.
./gradlew :host:run & _PID=$!
sleep 5
./gradlew :client:run \
--args="'S:0000000000000000000000000000000000000000000000000000000000000000 PROD:1 SEC:INSECURE'"
# kill the host
kill -9 $_PID
sleep 10
popd
echo Create Kotlin project
"$JAVA_HOME"/bin/java -jar $conclaveInitJar \
--enclave-class-name "MegaEnclave" \
--package "com.megacorp" \
--target "mega-kotlin-project" \
--language kotlin \
pushd mega-kotlin-project
echo Run Kotlin project unit tests
# Gradle takes into consideration the order in which the repositories are listed. Because we are applying changes to gradle files using the sed,
# the repos will appear in reverse order in the file.
# Please ensure that the url conclave-maven always appears after the repo to ensure that Gradle first looks at the local repo before searching in Artifactory.
sed -i "s/repositories {/repositories {\nmaven { url = 'https:\/\/software.r3.com\/artifactory\/conclave-maven' }/" build.gradle
sed -i "s/repositories {/repositories {\nmaven { url = '..\/..\/repo' }/" build.gradle
sed -i "s/repositories {/repositories {\nmaven { url = '..\/repo' }/" settings.gradle
./gradlew test
echo Run Kotlin project host and client
# NOTE: this command is only run in mock mode, so that the signer can be provided below.
./gradlew :host:run & _PID=$!
sleep 5
./gradlew :client:run \
--args="'S:0000000000000000000000000000000000000000000000000000000000000000 PROD:1 SEC:INSECURE'"
# kill the host
kill -9 $_PID
sleep 10
popd
# clean up
rm -r mega-project
rm -r mega-kotlin-project
popd