-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgcs_test.sh
executable file
·140 lines (112 loc) · 4.95 KB
/
gcs_test.sh
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
137
138
139
140
#!/bin/bash
set -eo pipefail
source .github/workflows/script/helper.sh
if [ -z "${GCS_ACCESS_KEY}" ]; then
echo "GCS_ACCESS_KEY is not set. Exiting..."
exit 1
fi
if [ -z "${GCS_SECRET_KEY}" ]; then
echo "GCS_SECRET_KEY is not set. Exiting..."
exit 1
fi
if [ -z "${BUCKET_NAME}" ]; then
streamBucket="solo-ci-test-streams"
else
streamBucket=${BUCKET_NAME}
fi
if [ -z "${BACKUP_BUCKET_NAME}" ]; then
streamBackupBucket="solo-ci-backups"
else
streamBackupBucket=${BACKUP_BUCKET_NAME}
fi
if [ -z "${STORAGE_TYPE}" ]; then
storageType="minio_only"
else
storageType=${STORAGE_TYPE}
fi
if [ -z "${PREFIX}" ]; then
echo "PREFIX is not set"
else
echo "Using PREFIX: ${PREFIX}"
if [ "${storageType}" == "aws_only" ]; then
STORAGE_OPTIONS=(
"--aws-endpoint" "https://storage.googleapis.com"
"--aws-write-access-key" "${GCS_ACCESS_KEY}"
"--aws-write-secrets" "${GCS_SECRET_KEY}"
"--aws-bucket" "${streamBucket}"
"--aws-bucket-prefix" "${PREFIX}"
"--backupWriteSecrets" "${GCS_SECRET_KEY}"
"--backupWriteAccessKey" "${GCS_ACCESS_KEY}"
"--backupEndpoint" "storage.googleapis.com"
"--backupRegion" "us-central1"
"--backup-bucket" "${streamBackupBucket}"
)
elif [ "${storageType}" == "gcs_only" ]; then
STORAGE_OPTIONS=(
"--gcs-endpoint" "https://storage.googleapis.com"
"--gcs-write-access-key" "${GCS_ACCESS_KEY}"
"--gcs-write-secrets" "${GCS_SECRET_KEY}"
"--gcs-bucket" "${streamBucket}"
"--gcs-bucket-prefix" "${PREFIX}"
"--backupWriteSecrets" "${GCS_SECRET_KEY}"
"--backupWriteAccessKey" "${GCS_ACCESS_KEY}"
"--backupEndpoint" "storage.googleapis.com"
"--backupRegion" "us-central1"
"--backup-bucket" "${streamBackupBucket}"
)
fi
if [ "${storageType}" == "aws_only" ] || [ "${storageType}" == "gcs_only" ]; then
MIRROR_STORAGE_OPTIONS=(
"--storage-endpoint" "https://storage.googleapis.com"
"--storage-read-access-key" "${GCS_ACCESS_KEY}"
"--storage-read-secrets" "${GCS_SECRET_KEY}"
"--storage-bucket" "${streamBucket}"
"--storage-bucket-prefix" "${PREFIX}"
)
fi
fi
echo "STORAGE_OPTIONS: " "${STORAGE_OPTIONS[@]}"
echo "MIRROR_STORAGE_OPTIONS: " "${MIRROR_STORAGE_OPTIONS[@]}"
echo "Using bucket name: ${streamBucket}"
echo "Test storage type: ${storageType}"
SOLO_CLUSTER_NAME=solo-e2e
SOLO_NAMESPACE=solo-e2e
SOLO_CLUSTER_SETUP_NAMESPACE=solo-setup
SOLO_DEPLOYMENT=solo-e2e
kind delete cluster -n "${SOLO_CLUSTER_NAME}"
kind create cluster -n "${SOLO_CLUSTER_NAME}"
npm run solo-test -- init
npm run solo-test -- cluster-ref setup \
-s "${SOLO_CLUSTER_SETUP_NAMESPACE}"
npm run solo-test -- cluster-ref connect --cluster-ref kind-${SOLO_CLUSTER_NAME} --context kind-${SOLO_CLUSTER_NAME} --email [email protected]
npm run solo-test -- deployment create -n "${SOLO_NAMESPACE}" --deployment "${SOLO_DEPLOYMENT}"
npm run solo-test -- deployment add-cluster --deployment "${SOLO_DEPLOYMENT}" --cluster-ref kind-${SOLO_CLUSTER_NAME} --num-consensus-nodes 1
npm run solo-test -- node keys --gossip-keys --tls-keys -i node1 --deployment "${SOLO_DEPLOYMENT}"
npm run solo-test -- network deploy --deployment "${SOLO_DEPLOYMENT}" -i node1 \
--storage-type "${storageType}" \
"${STORAGE_OPTIONS[@]}"
npm run solo-test -- node setup -i node1 --deployment "${SOLO_DEPLOYMENT}"
npm run solo-test -- node start -i node1 --deployment "${SOLO_DEPLOYMENT}"
npm run solo-test -- mirror-node deploy --deployment "${SOLO_DEPLOYMENT}" --cluster-ref kind-${SOLO_CLUSTER_NAME} \
--storage-type "${storageType}" \
"${MIRROR_STORAGE_OPTIONS[@]}" \
npm run solo-test -- explorer deploy -s "${SOLO_CLUSTER_SETUP_NAMESPACE}" --deployment "${SOLO_DEPLOYMENT}" --cluster-ref kind-${SOLO_CLUSTER_NAME}
kubectl port-forward -n "${SOLO_NAMESPACE}" svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 &
explorer_svc="$(kubectl get svc -l app.kubernetes.io/component=hedera-explorer -n ${SOLO_NAMESPACE} --output json | jq -r '.items[].metadata.name')"
kubectl port-forward -n "${SOLO_NAMESPACE}" svc/"${explorer_svc}" 8080:80 > /dev/null 2>&1 &
cd ..; create_test_account ; cd -
node examples/create-topic.js
npm run solo-test -- node stop -i node1 --deployment "${SOLO_DEPLOYMENT}"
if [ "${storageType}" == "aws_only" ] || [ "${storageType}" == "gcs_only" ]; then
echo "Waiting for backup uploader to run"
# manually call script "backup.sh" from container backup-uploader since it only runs every 5 minutes
kubectl exec network-node1-0 -c backup-uploader -n solo-e2e -- /app/backup.sh
echo "Retrieve logs and check if it include the error message"
# example : {"level":"error","msg":"Updated modification time ......}
kubectl logs network-node1-0 -c backup-uploader -n solo-e2e > backup-uploader.log
if grep -q \""error\"" backup-uploader.log; then
echo "Backup uploader logs contain error message"
exit 1
fi
fi
npm run solo-test -- network destroy --deployment "${SOLO_DEPLOYMENT}" --force -q