-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcti
executable file
·116 lines (104 loc) · 3.18 KB
/
cti
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
#!/bin/bash
# Copyright (c) The Libra Core Contributors
# SPDX-License-Identifier: Apache-2.0
set -e
set -o pipefail
TAG=""
PR=""
WORKSPACE="cluster-test-ci"
ENV="env"
REPORT=""
MARKER=$USER
DEPLOY=yes
while (( "$#" )); do
case "$1" in
-R|--report)
REPORT=$2
shift 2
;;
-p|--pr)
PR=$2
shift 2
;;
-M|--master)
TAG=master
shift 1
;;
--marker)
MARKER=$2
shift 2
;;
-T|--tag)
TAG=$2
shift 2
;;
-D|--no-deploy)
DEPLOY=no
shift 1
;;
-W|--workspace)
WORKSPACE=$2
shift 2
;;
-E|--env)
ENV="$ENV $2"
shift 2
;;
-c|--container|-i|--image|--deploy)
echo "$1 command is not allowed in cti"
exit 1
;;
*) # end argument parsing
break
;;
esac
done
if [ -z "$PR" ] && [ -z "$TAG" ]
then
echo "No PR or tag specified"
echo "Usage:"
echo "cti [--pr <PR>|--master|--tag <TAG>] [--workspace <WORKSPACE>] [-E <env>] <cluster test arguments>"
echo
echo "--pr <PR>: Build image from pull request #<PR>"
echo "-M|--master: Use latest image available in CI"
echo "-T|--tag <TAG>: Use image with tag TAG"
echo "-W|--workspace <WORKSPACE>: Use custom workplace <WORKSPACE>"
echo "-E|--env <ENV>: Set environment variable, ex. -E RUST_LOG=debug. Can be repeated, e.g. -E A=B -E C=D"
echo "-R|--report file.json: Generate json report into file.json"
echo "--marker <MARKER>: Marker to identify purpose of this run. Must be set by automatic invocations like CI"
echo "--D|--no-deploy: Do not deploy new version of validator"
echo
echo "To see cluster test runner arguments run cti --master"
echo
echo "Examples:"
echo "cti --pr <PR> --run bench # Run benchmark"
echo "cti --master --emit-tx # Submit transactions until Ctrl+C pressed"
exit 1
fi
JUMPHOST=${JUMPHOST:-ssh.${WORKSPACE}.aws.hlw3truzy4ls.com}
ssh $JUMPHOST echo "ssh ok" >/dev/null || (echo "Failed to ssh to jump host $JUMPHOST. Try renew corp canal cert with cc-certs"; exit 1)
if [ -z "$TAG" ]; then
aws codebuild list-projects >/dev/null || (echo "Failed to access codebuild, try awsmfa?"; exit 1)
./docker/build-aws.sh --build-all --version pull/$PR
TAG=dev_${USER}_pull_${PR}
echo "**TIP Use cti -T $TAG <...> to restart this run with same tag without rebuilding it"
fi
OUTPUT_TEE=$(mktemp)
echo "**********"
echo "Copy of this output: $OUTPUT_TEE"
echo "Dashboard: http://prometheus.${WORKSPACE}.aws.hlw3truzy4ls.com:9091/"
echo "Logs:"
echo " * ssh ssh.${WORKSPACE}.aws.hlw3truzy4ls.com"
echo " * ssh-peer"
echo " * tail -f /data/libra/libra.log"
echo "**********"
if [ "$DEPLOY" == "yes" ]
then
DEPLOY_CMD="--deploy $TAG"
else
DEPLOY_CMD=""
fi
ssh -t $JUMPHOST ssh -i /libra_rsa [email protected].${WORKSPACE}.aws.hlw3truzy4ls.com $ENV CTI_MARKER=$MARKER REMOTE_USER=$MARKER ct -c cluster-test-ci --image "853397791086.dkr.ecr.us-west-2.amazonaws.com/libra_cluster_test:$TAG" $DEPLOY_CMD $* | tee $OUTPUT_TEE
if [ ! -z "$REPORT" ]; then
cat $OUTPUT_TEE | awk '/====json-report-begin===/{f=1;next} /====json-report-end===/{f=0} f' > $REPORT
fi