|
| 1 | +#! /usr/bin/env bash |
| 2 | +set -e |
| 3 | +set -o pipefail |
| 4 | + |
| 5 | +# the versions of software that tests will use |
| 6 | +SOROBAN_EXAMPLES_GIT_HASH="main" |
| 7 | +SOROBAN_EXAMPLES_REPO_URL="https://github.com/stellar/soroban-examples.git" |
| 8 | +DEBUG_MODE= |
| 9 | + |
| 10 | +# the target network under test |
| 11 | +# TODO: support other networks |
| 12 | +TARGET_NETWORK_PASSPHRASE="Standalone Network ; February 2017" |
| 13 | +TARGET_NETWORK_SECRET_KEY="SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L" |
| 14 | +TARGET_NETWORK_PUBLIC_KEY="GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI" |
| 15 | +TARGET_NETWORK_RPC_URL="http://localhost:8000/soroban/rpc" |
| 16 | +QUICKSTART_LOG_FILE=/var/log/system-test-quickstart.log |
| 17 | +LOCAL_CORE=false |
| 18 | +ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=--enable-soroban-diagnostic-events |
| 19 | + |
| 20 | +# example filter for all combos of one scenario outline: ^TestDappDevelop$/^DApp developer compiles, deploys and invokes a contract.*$ |
| 21 | +# each row in example data for a scenario outline is postfixed with '#01', '#02', example: |
| 22 | +# TestDappDevelop/DApp developer compiles, deploys and invokes a contract#01 |
| 23 | +TEST_FILTER="" |
| 24 | +VERBOSE_OUTPUT=false |
| 25 | +CANCELLED=false |
| 26 | +# the relative path to runtime directory on image that feature files will be found at |
| 27 | +# these files are aggregated into this directory by Dockerfile |
| 28 | +FEATURE_PATH=. |
| 29 | + |
| 30 | +function print_screen_output() { |
| 31 | + echo "$1" |
| 32 | +} |
| 33 | + |
| 34 | +print_screen_output "Starting system test ..." |
| 35 | + |
| 36 | +trap printout SIGINT |
| 37 | +printout() { |
| 38 | + echo "Cancelling and exit." |
| 39 | + exit 1 |
| 40 | +} |
| 41 | + |
| 42 | +function main() { |
| 43 | + process_args "$@" |
| 44 | + |
| 45 | + if [ ! -z "$TARGET_NETWORK_RPC_URL" ] && [ ! -z "$TARGET_NETWORK" ]; then |
| 46 | + echo "Invalid TargetNetwork config, must set TargetNetwork or TargetNetworkRPCURL, aborting test ..." >&2 |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + |
| 50 | + stellar_rpc_status |
| 51 | + |
| 52 | + print_screen_output " RUST_TOOLCHAIN_VERSION=$(rustc --version 2>/dev/null || echo"n/a" )" |
| 53 | + print_screen_output " SOROBAN_CLI_CRATE_VERSION=$(soroban version 2>/dev/null || echo "n/a" )" |
| 54 | + print_screen_output " SOROBAN_EXAMPLES_GIT_HASH=$SOROBAN_EXAMPLES_GIT_HASH" |
| 55 | + print_screen_output " SOROBAN_EXAMPLES_REPO_URL=$SOROBAN_EXAMPLES_REPO_URL" |
| 56 | + print_screen_output " TARGET_NETWORK_PASSPHRASE=$TARGET_NETWORK_PASSPHRASE" |
| 57 | + print_screen_output " TARGET_NETWORK_SECRET_KEY=$TARGET_NETWORK_SECRET_KEY" |
| 58 | + print_screen_output " TARGET_NETWORK_PUBLIC_KEY=$TARGET_NETWORK_PUBLIC_KEY" |
| 59 | + print_screen_output " TARGET_NETWORK_RPC_URL=$TARGET_NETWORK_RPC_URL" |
| 60 | + print_screen_output " TEST_FILTER=${TEST_FILTER}" |
| 61 | + print_screen_output "Tests can now begin ..." |
| 62 | + |
| 63 | + cd ./bin |
| 64 | + |
| 65 | + export SorobanExamplesGitHash=${SOROBAN_EXAMPLES_GIT_HASH} |
| 66 | + export SorobanExamplesRepoURL=${SOROBAN_EXAMPLES_REPO_URL} |
| 67 | + export TargetNetworkPassPhrase="${TARGET_NETWORK_PASSPHRASE}" |
| 68 | + export TargetNetworkSecretKey=${TARGET_NETWORK_SECRET_KEY} |
| 69 | + export TargetNetworkPublicKey=${TARGET_NETWORK_PUBLIC_KEY} |
| 70 | + export TargetNetworkRPCURL=${TARGET_NETWORK_RPC_URL} |
| 71 | + export VerboseOutput=${VERBOSE_OUTPUT} |
| 72 | + export LocalCore=${LOCAL_CORE} |
| 73 | + export FeaturePath=${FEATURE_PATH} |
| 74 | + |
| 75 | + for file in ./*; |
| 76 | + do |
| 77 | + if [ "$CANCELLED" = "true" ]; then |
| 78 | + break |
| 79 | + fi |
| 80 | + |
| 81 | + if [[ "$file" =~ ^.*\.bin$ ]]; then |
| 82 | + # these bin files were compiled from go feature tests in the Dockerfile during image build |
| 83 | + print_screen_output "Running test binary ${file} ... " |
| 84 | + ${file} -test.v ${TEST_FILTER} |
| 85 | + fi |
| 86 | + done |
| 87 | +} |
| 88 | + |
| 89 | +function process_args() { |
| 90 | + while [[ -n "$1" ]]; do |
| 91 | + ARG="$1" |
| 92 | + shift |
| 93 | + |
| 94 | + case "${ARG}" in |
| 95 | + --DebugMode) |
| 96 | + DEBUG_MODE="$1" |
| 97 | + shift |
| 98 | + ;; |
| 99 | + --SorobanExamplesGitHash) |
| 100 | + SOROBAN_EXAMPLES_GIT_HASH="$1" |
| 101 | + shift |
| 102 | + ;; |
| 103 | + --SorobanExamplesRepoURL) |
| 104 | + SOROBAN_EXAMPLES_REPO_URL="$1" |
| 105 | + shift |
| 106 | + ;; |
| 107 | + --TestFilter) |
| 108 | + TEST_FILTER="-test.run ""$1""" |
| 109 | + shift |
| 110 | + ;; |
| 111 | + --VerboseOutput) |
| 112 | + VERBOSE_OUTPUT="$1" |
| 113 | + shift |
| 114 | + ;; |
| 115 | + --TargetNetwork) |
| 116 | + TARGET_NETWORK="$1" |
| 117 | + shift |
| 118 | + ;; |
| 119 | + --TargetNetworkPassphrase) |
| 120 | + TARGET_NETWORK_PASSPHRASE="$1" |
| 121 | + shift |
| 122 | + ;; |
| 123 | + --TargetNetworkTestAccountSecret) |
| 124 | + TARGET_NETWORK_SECRET_KEY="$1" |
| 125 | + shift |
| 126 | + ;; |
| 127 | + --TargetNetworkTestAccountPublic) |
| 128 | + TARGET_NETWORK_PUBLIC_KEY="$1" |
| 129 | + shift |
| 130 | + ;; |
| 131 | + --TargetNetworkRPCURL) |
| 132 | + TARGET_NETWORK_RPC_URL="$1" |
| 133 | + shift |
| 134 | + ;; |
| 135 | + *) |
| 136 | + esac |
| 137 | + done |
| 138 | +} |
| 139 | + |
| 140 | +function stellar_rpc_status () { |
| 141 | + print_screen_output "waiting for soroban rpc to report ready state..." |
| 142 | + COUNTER=1 |
| 143 | + while ! $(curl --silent --location --request POST "$TARGET_NETWORK_RPC_URL" \ |
| 144 | + --header 'Content-Type: application/json' \ |
| 145 | + --data-raw '{ |
| 146 | + "jsonrpc": "2.0", |
| 147 | + "id": 10235, |
| 148 | + "method": "getHealth" |
| 149 | + |
| 150 | + }' | jq --exit-status '.result.status == "healthy"' 2>/dev/null | grep -o true || echo false ); |
| 151 | + do |
| 152 | + if [ $(expr $COUNTER % 12) -eq 0 ]; then |
| 153 | + print_screen_output "waited $(expr $COUNTER / 12) minutes for Stellar RPC to report ready state..." |
| 154 | + fi |
| 155 | + COUNTER=$[$COUNTER +1] |
| 156 | + |
| 157 | + if [ $COUNTER -gt 900 ]; then |
| 158 | + echo "Waited longer than 15 minutes for Stellar RPC, cancelling and exit." |
| 159 | + exit 1 |
| 160 | + fi |
| 161 | + |
| 162 | + sleep 5 |
| 163 | + done |
| 164 | + print_screen_output "Stellar RPC reported ready status, the service can be used by tools/cli now ..." |
| 165 | +} |
| 166 | + |
| 167 | +main "$@" |
0 commit comments