File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ export COCKROACH_USER=root
6
+
7
+ A=" $USER -a"
8
+ B=" $USER -b"
9
+
10
+
11
+ if [ " $# " -lt 1 ]; then
12
+ cat << EOF
13
+ usage: $0 <command>
14
+ EOF
15
+ exit 0
16
+ fi
17
+
18
+
19
+ case $1 in
20
+ " setup" )
21
+ shift
22
+ $0 create " $@ "
23
+ $0 go
24
+ ;;
25
+
26
+ " create" )
27
+ shift
28
+ roachprod create $A \
29
+ --clouds gce --gce-machine-type n2-standard-16 --nodes 4 --username " $USER " --local-ssd=false --gce-pd-volume-size 1000 --lifetime 24h " $@ "
30
+ roachprod create $B \
31
+ --clouds gce --gce-machine-type n2-standard-16 --nodes 4 --username " $USER " --local-ssd=false --gce-pd-volume-size 1000 --lifetime 24h " $@ "
32
+ $0 stage cockroach
33
+ $0 stage workload
34
+ ;;
35
+
36
+ " init" )
37
+ $0 start
38
+ roachprod sql --cluster=system $B :1 -- -e " CREATE EXTERNAL CONNECTION IF NOT EXISTS a AS $( roachprod pgurl --cluster=system $A :1) "
39
+ roachprod sql --cluster=system $A :1 -- -e " CREATE VIRTUAL CLUSTER main;"
40
+ roachprod sql --cluster=system $B :1 -- -e " CREATE VIRTUAL CLUSTER main FROM REPLICATION OF main ON 'external://a' WITH READ VIRTUAL CLUSTER;"
41
+ roachprod sql --cluster=system $A :1 -- -e " ALTER VIRTUAL CLUSTER main START SERVICE SHARED;"
42
+ roachprod sql --cluster=system $A :1 -- -e " SET CLUSTER SETTING server.controller.default_target_cluster = 'main';"
43
+ roachprod sql --cluster=system $B :1 -- -e " SET CLUSTER SETTING server.controller.default_target_cluster = 'main';"
44
+ ;;
45
+ * )
46
+ cmd=" ${1} "
47
+ shift
48
+
49
+ # We're going to run the same command against A and B, but note that we have
50
+ # set -e above which normally would cause the first to stop the script if it
51
+ # exited non-zero. So we capture the result in an `||` so we keep going to
52
+ # the second one, then if we're still running, exit with the first's result.
53
+ ret=0
54
+
55
+ echo " ${A} :"
56
+ roachprod " ${cmd} " $A " $@ " || ret=$?
57
+ echo " ${B} :"
58
+ roachprod " ${cmd} " $B " $@ "
59
+ exit $ret
60
+ ;;
61
+ esac
You can’t perform that action at this time.
0 commit comments