github.com/letsencrypt/trillian@v1.1.2-0.20180615153820-ae375a99d36a/integration/mapreplay.sh (about) 1 #!/bin/bash 2 set -e 3 INTEGRATION_DIR="$( cd "$( dirname "$0" )" && pwd )" 4 . "${INTEGRATION_DIR}"/functions.sh 5 6 MAP_JOURNAL=${1} 7 if [[ ! -f "${MAP_JOURNAL}" ]]; then 8 echo "First argument should be map journal file" 9 exit 1 10 fi 11 12 echo "Building mapreplay" 13 go build github.com/google/trillian/testonly/hammer/mapreplay 14 15 declare -a OLD_MAP_ARRAY 16 OLD_MAP_IDS=$(./mapreplay --logtostderr -v 2 --replay_from ${MAP_JOURNAL} 2>&1 >/dev/null | grep "map_id:" | sed 's/.*map_id:\([0-9]\+\).*/\1/' | sort | uniq) 17 for mapid in "${OLD_MAP_IDS}"; do 18 OLD_MAP_ARRAY+=(${mapid}) 19 done 20 MAP_COUNT=${#OLD_MAP_ARRAY[@]} 21 echo "Observed map IDs in ${MAP_JOURNAL}: ${OLD_MAP_IDS}" 22 23 map_prep_test 1 24 TO_KILL+=(${RPC_SERVER_PIDS[@]}) 25 26 echo "Provisioning ${MAP_COUNT} map(s)" 27 map_provision "${RPC_SERVER_1}" ${MAP_COUNT} 28 echo "Provisioned ${MAP_COUNT} map(s): ${MAP_IDS}" 29 30 declare -a MAP_ARRAY 31 for mapid in $(echo ${MAP_IDS} | sed 's/,/ / '); do 32 MAP_ARRAY+=(${mapid}) 33 done 34 35 # Map from original map IDs to the newly provisioned ones. 36 MAPMAP="" 37 for ((i=0; i < MAP_COUNT; i++)); do 38 if [[ $i -eq 0 ]]; then 39 MAPMAP="${OLD_MAP_ARRAY[$i]}:${MAP_ARRAY[$i]}" 40 else 41 MAPMAP="${MAPMAP},${OLD_MAP_ARRAY[$i]}:${MAP_ARRAY[$i]}" 42 fi 43 done 44 echo "Mapping map/tree IDs ${MAPMAP}" 45 46 echo "Replaying requests from ${MAP_JOURNAL}" 47 set +e 48 ./mapreplay --map_ids=${MAPMAP} --rpc_server=${RPC_SERVER_1} --logtostderr -v 1 --replay_from "${MAP_JOURNAL}" 49 RESULT=$? 50 set -e 51 52 map_stop_test 53 TO_KILL=() 54 55 exit $RESULT