-
Notifications
You must be signed in to change notification settings - Fork 603
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·136 lines (127 loc) · 5.03 KB
/
bootstrap.sh
File metadata and controls
executable file
·136 lines (127 loc) · 5.03 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
#!/usr/bin/env bash
source $(git rev-parse --show-toplevel)/ci3/source_bootstrap
cmd=${1:-}
hash=$(hash_str $(cache_content_hash .rebuild_patterns) $(../yarn-project/bootstrap.sh hash))
flock scripts/logs/install_deps.lock scripts/install_deps.sh >&2
function network_shaping {
namespace="$1"
chaos_values="$2"
if ! kubectl get service chaos-daemon -n chaos-mesh &>/dev/null; then
echo "Please set up chaos-mesh first. You can do this by running spartan/bootstrap.sh chaos-mesh"
exit 1
fi
echo "Deploying Aztec Chaos Scenarios..."
if ! helm upgrade --install aztec-chaos-scenarios aztec-chaos-scenarios \
--namespace chaos-mesh \
--values "aztec-chaos-scenarios/values/$chaos_values" \
--set global.targetNamespace="$namespace" \
--wait \
--timeout=5m; then
echo "Error: failed to deploy Aztec Chaos Scenarios!"
return 1
fi
echo "Aztec Chaos Scenarios applied successfully"
return 0
}
function gke {
# For GKE access
if ! command -v gcloud &> /dev/null; then
if [ -f /etc/os-release ] && grep -qi "Ubuntu" /etc/os-release; then
sudo apt update
sudo apt install -y apt-transport-https ca-certificates gnupg curl
sudo rm -f /usr/share/keyrings/cloud.google.gpg && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt install -y google-cloud-cli
sudo apt install google-cloud-cli-gke-gcloud-auth-plugin
echo "Now you can run 'gcloud init'. Exiting with 1 as this is a necessary step."
else
echo "gcloud not found. This is needed for GKE kubernetes usage." >&2
echo "If needed, install glcoud and do 'gcloud components install gke-gcloud-auth-plugin', then 'gcloud init'" >&2
fi
exit 1
fi
}
function test_cmds {
echo "$hash ./spartan/bootstrap.sh test-local"
if [ "$(arch)" == "arm64" ]; then
# Currently maddiaa/eth2-testnet-genesis is not published for arm64. Skip KIND tests.
return
fi
# Note: commands that start with 'timeout ...' override the default timeout.
# TODO figure out why these take long sometimes.
echo "$hash timeout -v 20m ./spartan/bootstrap.sh test-kind-smoke"
if [ "$CI_FULL" -eq 1 ]; then
echo "$hash timeout -v 20m ./spartan/bootstrap.sh test-kind-transfer"
echo "$hash timeout -v 30m ./spartan/bootstrap.sh test-kind-4epochs"
echo "$hash timeout -v 30m ./spartan/bootstrap.sh test-kind-transfer-blob-with-sink"
fi
}
function test {
echo_header "spartan test"
test_cmds | filter_test_cmds | parallelise
}
case "$cmd" in
"")
# do nothing but the install_deps.sh above
;;
"kind")
if ! kubectl config get-clusters | grep -q "^kind-kind$" || ! docker ps | grep -q "kind-control-plane"; then
# Sometimes, kubectl does not have our kind context yet kind registers it as existing
# Ensure our context exists in kubectl
# As well if kind-control-plane has been killed, just recreate the cluster
flock scripts/logs/kind-boot.lock bash -c "kind delete cluster; kind create cluster"
fi
kubectl config use-context kind-kind >/dev/null || true
docker update --restart=no kind-control-plane >/dev/null || true
;;
"chaos-mesh")
chaos-mesh/install.sh
;;
"metrics-kind")
metrics/install-kind.sh
;;
"metrics-prod")
metrics/install-prod.sh
;;
"network-shaping")
shift
namespace="$1"
chaos_values="$2"
if network_shaping "$namespace" "$chaos_values"; then
exit
fi
# If we are unable to apply network shaping, as we cannot change existing chaos configurations, then delete existing configurations and try again
echo "Deleting existing network chaos experiments..."
kubectl delete networkchaos --all --all-namespaces
network_shaping "$namespace" "$chaos_values"
;;
"hash")
echo $hash
;;
test|test_cmds|gke)
$cmd
;;
"test-kind-smoke")
NAMESPACE=smoke FRESH_INSTALL=${FRESH_INSTALL:-true} INSTALL_METRICS=false ./scripts/test_kind.sh src/spartan/smoke.test.ts ci-smoke.yaml
;;
"test-kind-4epochs")
NAMESPACE=4epochs FRESH_INSTALL=${FRESH_INSTALL:-true} INSTALL_METRICS=false ./scripts/test_kind.sh src/spartan/4epochs.test.ts ci.yaml
;;
"test-kind-transfer")
NAMESPACE=transfer FRESH_INSTALL=${FRESH_INSTALL:-true} INSTALL_METRICS=false ./scripts/test_kind.sh src/spartan/transfer.test.ts ci.yaml
;;
"test-kind-transfer-blob-with-sink")
OVERRIDES="blobSink.enabled=true" ./bootstrap.sh test-kind-transfer
;;
"test-kind-chaos-prover")
chaos-mesh/install.sh
OVERRIDES="proverAgent.testDelayMs=1000" NAMESPACE=chaos-prover FRESH_INSTALL=${FRESH_INSTALL:-true} INSTALL_METRICS=true ./scripts/test_kind.sh src/spartan/prover-node.test.ts ci.yaml
;;
"test-local")
# Isolate network stack in docker.
docker_isolate ../scripts/run_native_testnet.sh -i -val 3
;;
*)
echo "Unknown command: $cmd"
exit 1
esac