5
5
# Use of this software is governed by the CockroachDB Software License
6
6
# included in the /LICENSE file.
7
7
8
-
9
8
set -exuo pipefail
10
9
11
10
export ROACHPROD_DISABLED_PROVIDERS=aws,azure,ibm
12
11
export ROACHPROD_DISABLE_UPDATE_CHECK=true
13
- export ROACHPROD_GCE_DEFAULT_SERVICE_ACCOUNT=$GOOGLE_SERVICE_ACCOUNT
14
- export ROACHPROD_GCE_DEFAULT_PROJECT=cockroach-ephemeral
15
12
16
- # build the binaries - roachprod, roachtest and drtprod
13
+ export ROACHPROD_GCE_DEFAULT_SERVICE_ACCOUNT=${GOOGLE_SERVICE_ACCOUNT:- teamcity-pua@ cockroach-ephemeral.iam.gserviceaccount.com}
14
+ export ROACHPROD_GCE_DEFAULT_PROJECT=${GOOGLE_PROJECT:- cockroach-ephemeral}
15
+
16
+ export ROACHPROD_DNS=${ROACHPROD_DNS:- roachprod.crdb.io}
17
+ export ROACHPROD_GCE_DNS_ZONE=${ROACHPROD_GCE_DNS_ZONE:- roachprod}
18
+ export ROACHPROD_GCE_DNS_DOMAIN=${ROACHPROD_GCE_DNS_DOMAIN:- roachprod.crdb.io}
19
+
20
+ # generate the ssh key if it doesn't exist.
21
+ if [[ ! -f ~ /.ssh/id_rsa.pub ]]; then
22
+ ssh-keygen -q -C " teamcity-pua-bazel $( date) " -N " " -f ~ /.ssh/id_rsa
23
+ fi
24
+
25
+ # set up google credentials.
26
+ if [[ " $GOOGLE_APPLICATION_CREDENTIALS_CONTENT " ]]; then
27
+ echo " $GOOGLE_APPLICATION_CREDENTIALS_CONTENT " > creds.json
28
+ gcloud auth activate-service-account --key-file=creds.json
29
+
30
+ # Set GOOGLE_APPLICATION_CREDENTIALS so that gcp go libraries can find it.
31
+ export GOOGLE_APPLICATION_CREDENTIALS=" $( pwd) /creds.json"
32
+ else
33
+ echo ' warning: $GOOGLE_APPLICATION_CREDENTIALS_CONTENT not set' >&2
34
+ exit 1
35
+ fi
36
+
37
+ # build the binaries: roachprod, roachtest, and drtprod.
17
38
build () {
18
39
config=" crosslinux"
19
- # Prepare the bin/ and lib / directories.
20
- mkdir -p bin
21
- chmod o+rwx bin
40
+ # prepare the bin/ and artifacts / directories.
41
+ mkdir -p bin artifacts
42
+ chmod o+rwx bin artifacts
22
43
23
- # Array of arguments to be passed to bazel for the component.
44
+ # array of arguments to be passed to bazel for the component.
24
45
bazel_args=()
25
46
26
- # Array of build artifacts. Each item has format "src:dest"; src is relative to
47
+ # array of build artifacts. each item has format "src:dest"; src is relative to
27
48
# the bazel-bin directory, dst is relative to cwd.
28
49
artifacts=()
29
50
30
51
bazel_args+=(//pkg/cmd/roachtest)
31
52
artifacts+=(" pkg/cmd/roachtest/roachtest_/roachtest:bin/roachtest" )
53
+ artifacts+=(" pkg/cmd/roachtest/roachtest_/roachtest:artifacts/roachtest" )
32
54
33
55
bazel_args+=(//pkg/cmd/roachprod)
34
56
artifacts+=(" pkg/cmd/roachprod/roachprod_/roachprod:bin/roachprod" )
57
+ artifacts+=(" pkg/cmd/roachprod/roachprod_/roachprod:artifacts/roachprod" )
35
58
36
59
bazel_args+=(//pkg/cmd/drtprod)
37
60
artifacts+=(" pkg/cmd/drtprod/drtprod_/drtprod:bin/drtprod" )
61
+ artifacts+=(" pkg/cmd/drtprod/drtprod_/drtprod:artifacts/drtprod" )
38
62
39
63
bazel build --config $config -c opt " ${bazel_args[@]} "
40
64
BAZEL_BIN=$( bazel info bazel-bin --config $config -c opt)
@@ -46,25 +70,65 @@ build() {
46
70
chmod a+w " $dst "
47
71
done
48
72
49
- # add bin to path
73
+ # add bin to path.
50
74
export PATH=$PATH :$( pwd) /bin
51
75
}
52
76
53
- # Set up Google credentials. Note that we need this for all clouds since we upload
54
- # perf artifacts to Google Storage at the end.
55
- if [[ " $GOOGLE_APPLICATION_CREDENTIALS_CONTENT " ]]; then
56
- echo " $GOOGLE_APPLICATION_CREDENTIALS_CONTENT " > creds.json
57
- gcloud auth activate-service-account --key-file=creds.json
77
+ # run the build function.
78
+ build
58
79
59
- # Set GOOGLE_APPLICATION_CREDENTIALS so that gcp go libraries can find it.
60
- export GOOGLE_APPLICATION_CREDENTIALS=" $( pwd) /creds.json"
80
+ log_file=" artifacts/pua.log"
81
+ export config=${PUA_CONFIG:- " single_region" }
82
+ if [[ " $config " == " single_region" ]]; then
83
+ CLUSTER=drt-pua-9
84
+ WORKLOAD=workload-pua-9
85
+ ZONE_NODE=7-9
86
+ config_file=" pkg/cmd/drtprod/configs/drt_pua_9.yaml"
87
+ elif [[ " $config " == " multi_region" ]]; then
88
+ CLUSTER=drt-pua-15
89
+ WORKLOAD=workload-pua-15
90
+ ZONE_NODE=3-4
91
+ config_file=" pkg/cmd/drtprod/configs/drt_pua_15.yaml"
61
92
else
62
- echo ' warning: GOOGLE_EPHEMERAL_CREDENTIALS not set ' >&2
93
+ echo " Error: Invalid PUA_CONFIG value: ' $config '. Must be 'single_region' or 'multi_region'. " >&2
63
94
exit 1
64
95
fi
65
96
66
- # Run the build function
67
- build
68
- #
69
- roachprod list
70
- # drtprod list
97
+ # execute the pua benchmark test.
98
+ drtprod execute ${config_file} | tee -a " ${log_file} "
99
+
100
+ # the pua dashboard uses a json file to show the benchmark results.
101
+ # we will generate the json file from the datadog metrics.
102
+ # download metric converter from gcs bucket pua-backup-us-east1.
103
+ mkdir -p datadog-metric-converter
104
+ gsutil -m cp -r gs://pua-backup-us-east1/datadog-metric-converter/** datadog-metric-converter/
105
+
106
+ # install pip for python3.8.
107
+ curl -sS https://bootstrap.pypa.io/pip/3.8/get-pip.py -o get-pip.py
108
+ python3 get-pip.py
109
+
110
+ # install the requirements for the metric converter.
111
+ python3 -m pip install -r datadog-metric-converter/requirements.txt
112
+
113
+ # get the start and end time of the benchmark.
114
+ epoch_start_time=$( grep " \[Phase-1: Baseline Performance\]" ${log_file} | grep " Starting" | awk -F' [][]' ' {print $4}' )
115
+ epoch_start_time=$(( epoch_start_time - 240 ))
116
+ epoch_end_time=$(( $(date +% s) - 120 ))
117
+ host=$( hostname)
118
+
119
+ # generate the benchmark.json file
120
+ python3 datadog-metric-converter/convert-datadog-metric.py --start-time=${epoch_start_time} --end-time=${epoch_end_time} \
121
+ --cluster-name ${CLUSTER} --workload-name ${WORKLOAD} \
122
+ --monitor-host ${host} --zone-node ${ZONE_NODE}
123
+
124
+
125
+ # delete the binaries - roachprod, roachtest and drtprod,
126
+ # as we don't need them to be uploaded to TeamCity artifacts
127
+ rm -f artifacts/roachprod artifacts/roachtest artifacts/drtprod
128
+ cp benchmark.json " artifacts/benchmark.json"
129
+
130
+ rm -rf datadog-metric-converter
131
+
132
+ # destroy the clusters.
133
+ drtprod destroy ${CLUSTER}
134
+ drtprod destroy ${WORKLOAD}
0 commit comments