| 1 |
#!/bin/bash |
| 2 |
# Copyright 2017 gRPC authors. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
|
| 16 |
# Creates a performance worker on GCE to be used on Kokoro. |
| 17 |
|
| 18 |
# IMPORTANT: Instructions for updating |
| 19 |
# If the VM configuration / installed software is updated, |
| 20 |
# - all existing performance worker VMs need to be updated to reflect the changes |
| 21 |
# - a new GCE image named "grpc-performance-kokoro-v1" needs to be created, |
| 22 |
# incrementing the version number. |
| 23 |
# - kokoro jobs need to be reconfigured to use the new image version |
| 24 |
|
| 25 |
set -ex |
| 26 |
|
| 27 |
cd "$(dirname "$0")" |
| 28 |
|
| 29 |
CLOUD_PROJECT=grpc-testing |
| 30 |
ZONE=us-central1-b # this zone allows 32core machines |
| 31 |
|
| 32 |
INSTANCE_NAME="${1:-grpc-kokoro-performance-server1}" |
| 33 |
MACHINE_TYPE=e2-standard-32 |
| 34 |
|
| 35 |
gcloud compute instances create "$INSTANCE_NAME" \ |
| 36 |
--project="$CLOUD_PROJECT" \ |
| 37 |
--zone "$ZONE" \ |
| 38 |
--machine-type $MACHINE_TYPE \ |
| 39 |
--image-project ubuntu-os-cloud \ |
| 40 |
--image-family ubuntu-1804-lts \ |
| 41 |
--boot-disk-size 300 \ |
| 42 |
--scopes https://www.googleapis.com/auth/bigquery \ |
| 43 |
--tags=allow-ssh |
| 44 |
|
| 45 |
echo 'Created GCE instance, waiting 60 seconds for it to come online.' |
| 46 |
sleep 60 |
| 47 |
|
| 48 |
gcloud compute copy-files \ |
| 49 |
--project="$CLOUD_PROJECT" \ |
| 50 |
--zone "$ZONE" \ |
| 51 |
kokoro_performance.pub linux_kokoro_performance_worker_init.sh "kbuilder@${INSTANCE_NAME}":~ |
| 52 |
|
| 53 |
gcloud compute ssh \ |
| 54 |
--project="$CLOUD_PROJECT" \ |
| 55 |
--zone "$ZONE" \ |
| 56 |
"kbuilder@${INSTANCE_NAME}" --command "./linux_kokoro_performance_worker_init.sh" |