This repository was archived by the owner on Mar 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstart
More file actions
executable file
·169 lines (146 loc) · 5.02 KB
/
start
File metadata and controls
executable file
·169 lines (146 loc) · 5.02 KB
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
#! /usr/bin/env bash
set -e
set -o pipefail
# the versions of software that tests will use
SOROBAN_EXAMPLES_GIT_HASH="main"
SOROBAN_EXAMPLES_REPO_URL="https://github.com/stellar/soroban-examples.git"
DEBUG_MODE=false
# the target network under test
# defaults to local quickstart network settings
TARGET_NETWORK_PASSPHRASE="Standalone Network ; February 2017"
TARGET_NETWORK_SECRET_KEY="SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L"
TARGET_NETWORK_PUBLIC_KEY="GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"
TARGET_NETWORK_RPC_URL="http://host.docker.internal:8000/rpc"
# example filter for all combos of one scenario outline: ^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$
# each row in example data for a scenario outline is postfixed with '#01', '#02', example:
# TestDappDevelop/DApp developer compiles, deploys and invokes a contract#01
TEST_FILTER=""
VERBOSE_OUTPUT=false
CANCELLED=false
# the relative path to runtime directory on image that feature files will be found at
# these files are aggregated into this directory by Dockerfile
FEATURE_PATH=.
function print_screen_output() {
echo "$1"
}
print_screen_output "Starting system test ..."
trap printout SIGINT
printout() {
echo "Cancelling and exit."
exit 1
}
trap finish EXIT
function finish {
CANCELLED=true
if [ "$DEBUG_MODE" = "true" ]; then
print_screen_output "** DEBUG MODE Enabled **"
read -p 'Debug mode, you can shell into the container now, hit enter to let container stop: '
fi
}
function main() {
process_args "$@"
if [ -z "$TARGET_NETWORK_RPC_URL" ]; then
echo "Invalid, TargetNetworkRPCUrl must be set" >&2
exit 1
fi
stellar_rpc_status
print_screen_output " RUST_TOOLCHAIN_VERSION=$(rustc --version 2>/dev/null || echo"n/a" )"
print_screen_output " SOROBAN_CLI_CRATE_VERSION=$(soroban version 2>/dev/null || echo "n/a" )"
print_screen_output " SOROBAN_EXAMPLES_GIT_HASH=$SOROBAN_EXAMPLES_GIT_HASH"
print_screen_output " SOROBAN_EXAMPLES_REPO_URL=$SOROBAN_EXAMPLES_REPO_URL"
print_screen_output " TARGET_NETWORK_PASSPHRASE=$TARGET_NETWORK_PASSPHRASE"
print_screen_output " TARGET_NETWORK_SECRET_KEY=$TARGET_NETWORK_SECRET_KEY"
print_screen_output " TARGET_NETWORK_PUBLIC_KEY=$TARGET_NETWORK_PUBLIC_KEY"
print_screen_output " TARGET_NETWORK_RPC_URL=$TARGET_NETWORK_RPC_URL"
print_screen_output " TEST_FILTER=${TEST_FILTER}"
print_screen_output "Tests can now begin ..."
cd /home/tester/bin
export SorobanExamplesGitHash=${SOROBAN_EXAMPLES_GIT_HASH}
export SorobanExamplesRepoURL=${SOROBAN_EXAMPLES_REPO_URL}
export TargetNetworkPassPhrase="${TARGET_NETWORK_PASSPHRASE}"
export TargetNetworkSecretKey=${TARGET_NETWORK_SECRET_KEY}
export TargetNetworkPublicKey=${TARGET_NETWORK_PUBLIC_KEY}
export TargetNetworkRPCURL=${TARGET_NETWORK_RPC_URL}
export VerboseOutput=${VERBOSE_OUTPUT}
export FeaturePath=${FEATURE_PATH}
for file in ./*;
do
if [ "$CANCELLED" = "true" ]; then
break
fi
if [[ "$file" =~ ^.*\.bin$ ]]; then
# these bin files were compiled from go feature tests in the Dockerfile during image build
print_screen_output "Running test binary ${file} ... "
${file} -test.v ${TEST_FILTER}
fi
done
}
function process_args() {
while [[ -n "$1" ]]; do
ARG="$1"
shift
case "${ARG}" in
--DebugMode)
DEBUG_MODE="$1"
shift
;;
--SorobanExamplesGitHash)
SOROBAN_EXAMPLES_GIT_HASH="$1"
shift
;;
--SorobanExamplesRepoURL)
SOROBAN_EXAMPLES_REPO_URL="$1"
shift
;;
--TestFilter)
TEST_FILTER="-test.run ""$1"""
shift
;;
--VerboseOutput)
VERBOSE_OUTPUT="$1"
shift
;;
--TargetNetworkPassphrase)
TARGET_NETWORK_PASSPHRASE="$1"
shift
;;
--TargetNetworkTestAccountSecret)
TARGET_NETWORK_SECRET_KEY="$1"
shift
;;
--TargetNetworkTestAccountPublic)
TARGET_NETWORK_PUBLIC_KEY="$1"
shift
;;
--TargetNetworkRPCURL)
TARGET_NETWORK_RPC_URL="$1"
shift
;;
*)
esac
done
}
function stellar_rpc_status () {
print_screen_output "waiting for soroban rpc to report ready state..."
COUNTER=1
while ! $(curl --silent --location --request POST "$TARGET_NETWORK_RPC_URL" \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"id": 10235,
"method": "getHealth"
}' | jq --exit-status '.result.status == "healthy"' 2>/dev/null | grep -o true || echo false );
do
if [ $(expr $COUNTER % 12) -eq 0 ]; then
print_screen_output "waited $(expr $COUNTER / 12) minutes for Stellar RPC to report ready state..."
fi
COUNTER=$[$COUNTER +1]
if [ $COUNTER -gt 180 ]; then
echo "Waited longer than 15 minutes for Stellar RPC, cancelling and exit."
exit 1
fi
sleep 5
done
print_screen_output "Stellar RPC reported ready status, the service can be used by tools/cli now ..."
}
main "$@"