Add kokoro AWS integration and corresponding test jobs. (#26349)

* milestone 1: static build instance, cmake

* on-demand vm per build, and use bazel

* PR cleanup

* pr cleanup: use builtin bazel wrapper

* pr: misc cleanup

* less verbose unzip

* small cleanup of shell scripts and config file

* using rsync for copying workspace is much faster

* simpler way to increase worker disk size

* simplify bazel build

* increase job timeout

* make max instance lifespan setting more obvious

* refactor the exitcode logic

* shutdown AWS instance once possible

* sudo shudown is required

* add useful AWS instance tags

* move aws integration scripts under AWS folder

* adjust scripts

* make sure ssh session closes even if stdout/stderr remains open

* add test scripts for multiple languages

* improvements to the run_remote_test script

* add cfg files for aws kokoro jobs

Co-authored-by: Alexander Midlash <amidlash@google.com>
pull/26363/head
Jan Tattermusch 4 years ago committed by GitHub
parent 1fb9e732cf
commit e065f22f27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      tools/internal_ci/linux/aws/grpc_aws_basictests_csharp.cfg
  2. 36
      tools/internal_ci/linux/aws/grpc_aws_basictests_php.cfg
  3. 36
      tools/internal_ci/linux/aws/grpc_aws_basictests_python.cfg
  4. 36
      tools/internal_ci/linux/aws/grpc_aws_basictests_ruby.cfg
  5. 36
      tools/internal_ci/linux/aws/grpc_aws_bazel_test_c_cpp.cfg
  6. 32
      tools/internal_ci/linux/aws/grpc_aws_experiment.cfg
  7. 29
      tools/internal_ci/linux/aws/grpc_aws_experiment_remote.sh
  8. 132
      tools/internal_ci/linux/aws/grpc_aws_run_remote_test.sh
  9. 29
      tools/internal_ci/linux/aws/grpc_bazel_test_c_cpp_aarch64.sh
  10. 42
      tools/internal_ci/linux/aws/grpc_run_basictests_csharp_aarch64.sh
  11. 33
      tools/internal_ci/linux/aws/grpc_run_basictests_php_aarch64.sh
  12. 39
      tools/internal_ci/linux/aws/grpc_run_basictests_python_aarch64.sh
  13. 33
      tools/internal_ci/linux/aws/grpc_run_basictests_ruby_aarch64.sh

@ -0,0 +1,36 @@
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/aws/grpc_aws_run_remote_test.sh"
timeout_mins: 90
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73836
keyname: "grpc_aws_ec2_credentials"
}
}
}
action {
define_artifacts {
regex: "**/*sponge_log.*"
}
}
env_vars {
key: "REMOTE_WORKLOAD_SCRIPT"
value: "tools/internal_ci/linux/aws/grpc_run_basictests_csharp_aarch64.sh"
}

@ -0,0 +1,36 @@
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/aws/grpc_aws_run_remote_test.sh"
timeout_mins: 90
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73836
keyname: "grpc_aws_ec2_credentials"
}
}
}
action {
define_artifacts {
regex: "**/*sponge_log.*"
}
}
env_vars {
key: "REMOTE_WORKLOAD_SCRIPT"
value: "tools/internal_ci/linux/aws/grpc_run_basictests_php_aarch64.sh"
}

@ -0,0 +1,36 @@
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/aws/grpc_aws_run_remote_test.sh"
timeout_mins: 90
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73836
keyname: "grpc_aws_ec2_credentials"
}
}
}
action {
define_artifacts {
regex: "**/*sponge_log.*"
}
}
env_vars {
key: "REMOTE_WORKLOAD_SCRIPT"
value: "tools/internal_ci/linux/aws/grpc_run_basictests_python_aarch64.sh"
}

@ -0,0 +1,36 @@
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/aws/grpc_aws_run_remote_test.sh"
timeout_mins: 90
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73836
keyname: "grpc_aws_ec2_credentials"
}
}
}
action {
define_artifacts {
regex: "**/*sponge_log.*"
}
}
env_vars {
key: "REMOTE_WORKLOAD_SCRIPT"
value: "tools/internal_ci/linux/aws/grpc_run_basictests_ruby_aarch64.sh"
}

@ -0,0 +1,36 @@
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/aws/grpc_aws_run_remote_test.sh"
timeout_mins: 90
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73836
keyname: "grpc_aws_ec2_credentials"
}
}
}
action {
define_artifacts {
regex: "**/*sponge_log.*"
}
}
env_vars {
key: "REMOTE_WORKLOAD_SCRIPT"
value: "tools/internal_ci/linux/aws/grpc_bazel_test_c_cpp_aarch64.sh"
}

@ -0,0 +1,32 @@
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/aws/grpc_aws_run_remote_test.sh"
timeout_mins: 90
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73836
keyname: "grpc_aws_ec2_credentials"
}
}
}
action {
define_artifacts {
regex: "**/*sponge_log.*"
}
}

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
#install ubuntu pre-requisites
sudo apt update
sudo apt install -y build-essential autoconf libtool pkg-config cmake python python-pip clang
sudo pip install six
cd grpc
# without port server running, many tests will fail
python tools/run_tests/start_port_server.py
# build with bazel
tools/bazel build --config=opt //test/...

@ -0,0 +1,132 @@
#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# WARNING: this script has been reviewed by the security team, so
# any changes need to be made with great care.
# Contact @jtattermusch or @amidlash if in doubt.
# This script is responsible for remotely running tests on an ARM instance.
# At the start, it provisions a new AWS ARM64 instance and then uses
# it to execute a test script (and cleans up afterwards).
# It should return a status code useful to the kokoro infrastructure.
# TODO(jtattermusch): make the script safe to run under "set -ex"
set -e
if [ -z "$KOKORO_KEYSTORE_DIR" ]; then
echo "KOKORO_KEYSTORE_DIR is unset. This must be run from kokoro"
exit 1
fi
AWS_CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73836_grpc_aws_ec2_credentials
# Setup aws cli
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install
aws --version
# authenticate with aws cli
mkdir ~/.aws/
echo "[default]" >> ~/.aws/config
ln -s $AWS_CREDENTIALS ~/.aws/credentials
# setup instance
sudo apt update && sudo apt install -y jq
# ubuntu 18.04 lts(arm64)
# https://aws.amazon.com/amazon-linux-ami/
AWS_MACHINE_IMAGE=ami-026141f3d5c6d2d0c
AWS_INSTANCE_TYPE=t4g.xlarge
AWS_SECURITY_GROUP=sg-021240e886feba750
# Max allowed lifespan of the AWS instance. After this period of time, the instance will
# self-terminate (delete itself). This is very important to ensure that there will
# be no orphaned AWS instances if the initiating kokoro job fails / gets cancelled etc.
AWS_INSTANCE_MAX_LIFESPAN_MINS=120
# increase the size of the root volume so that builds don't run out of disk space
AWS_STORAGE_SIZE_GB=75
AWS_DEVICE_MAPPING="DeviceName='/dev/sda1',Ebs={VolumeSize=${AWS_STORAGE_SIZE_GB}}"
AWS_INSTANCE_TAGS="ResourceType='instance',Tags=[{Key='kokoro_job_name',Value='${KOKORO_JOB_NAME}'},{Key='kokoro_build_number',Value='${KOKORO_BUILD_NUMBER}'},{Key='kokoro_aws_integration',Value='true'}]"
ssh-keygen -N '' -t rsa -b 4096 -f ~/.ssh/temp_client_key
ssh-keygen -N '' -t ecdsa -b 256 -f ~/.ssh/temp_server_key
SERVER_PRIVATE_KEY=$(cat ~/.ssh/temp_server_key | sed 's/\(.*\)/ \1/')
SERVER_PUBLIC_KEY=$(cat ~/.ssh/temp_server_key.pub | awk '{print $1 " " $2 " root@localhost"}')
SERVER_HOST_KEY_ENTRY=$(cat ~/.ssh/temp_server_key.pub | awk '{print $1 " " $2}')
CLIENT_PUBLIC_KEY=$(cat ~/.ssh/temp_client_key.pub)
echo '#cloud-config' > userdata
echo 'ssh_authorized_keys:' >> userdata
echo " - $CLIENT_PUBLIC_KEY" >> userdata
echo 'ssh_keys:' >> userdata
echo ' ecdsa_private: |' >> userdata
echo "$SERVER_PRIVATE_KEY" >> userdata
echo " ecdsa_public: $SERVER_PUBLIC_KEY" >> userdata
echo '' >> userdata
echo 'runcmd:' >> userdata
echo " - sleep ${AWS_INSTANCE_MAX_LIFESPAN_MINS}m" >> userdata
echo ' - shutdown' >> userdata
ID=$(aws ec2 run-instances --image-id $AWS_MACHINE_IMAGE --instance-initiated-shutdown-behavior=terminate \
--instance-type $AWS_INSTANCE_TYPE \
--security-group-ids $AWS_SECURITY_GROUP \
--user-data file://userdata \
--block-device-mapping "$AWS_DEVICE_MAPPING" \
--tag-specifications "$AWS_INSTANCE_TAGS" \
--region us-east-2 | jq .Instances[0].InstanceId | sed 's/"//g')
echo "instance-id=$ID"
echo "Waiting 1m for instance ip..."
sleep 1m
IP=$(aws ec2 describe-instances \
--instance-id=$ID \
--region us-east-2 | jq .Reservations[0].Instances[0].NetworkInterfaces[0].Association.PublicIp | sed 's/"//g')
SERVER_HOST_KEY_ENTRY="$IP $SERVER_HOST_KEY_ENTRY"
echo $SERVER_HOST_KEY_ENTRY >> ~/.ssh/known_hosts
echo "Waiting 2m for instance to initialize..."
sleep 2m
echo "Copying workspace to remote instance..."
# use rsync over ssh since it's much faster than scp
time rsync -e "ssh -i ~/.ssh/temp_client_key" -a github/grpc ubuntu@$IP:~/workspace
echo "Beginning CI workload..."
# filename of the test script to execute remotely, relative to gRPC repository root
# use a default value if the env variable is not set
REMOTE_WORKLOAD_SCRIPT=${REMOTE_WORKLOAD_SCRIPT:-tools/internal_ci/linux/aws/grpc_aws_experiment_remote.sh}
# run remote workload script in the background, with redirected stdout and stderr
# to avoid problems with ssh session not closing after the remote script finishes
# but stdout and stderr are still open because the remote has spawned subprocesses
# that keep stdout and stderr open.
# * PID of the process that executes the remote script will be stored in aws_build.pid
# * stderr and stdout will be streamed to aws_build.log
# * once done, the exitcode of the remote script will be in aws_build.exitcode
REMOTE_WORKLOAD_COMMAND="nohup bash -c '(bash grpc/${REMOTE_WORKLOAD_SCRIPT}; echo \$? >/tmp/aws_build.exitcode) >>/tmp/aws_build.log 2>&1' >/dev/null 2>&1 & echo \$! >/tmp/aws_build.pid"
# the tail command simply streams the contents of aws_build.log as they become available
# and stops when the remote workload exits (determined based on the PID)
SSH_COMMAND='uname -a; rm -f /tmp/aws_build.log /tmp/aws_build.exitcode /tmp/aws_build.pid; touch /tmp/aws_build.log; cd ~/workspace; '"${REMOTE_WORKLOAD_COMMAND};"' tail -f /tmp/aws_build.log --pid $(cat /tmp/aws_build.pid); exit $(cat /tmp/aws_build.exitcode)'
REMOTE_SCRIPT_EXITCODE=0
time ssh -i ~/.ssh/temp_client_key ubuntu@$IP "${SSH_COMMAND}" || REMOTE_SCRIPT_EXITCODE=$?
# Regardless of the remote script's result (success or failure), initiate shutdown of AWS instance a minute from now.
# The small delay is useful to make sure the ssh session doesn't hang up on us if shutdown happens too quickly.
echo "Shutting down instance $ID."
ssh -i ~/.ssh/temp_client_key ubuntu@$IP "sudo shutdown +1" || echo "WARNING: Failed to initiate AWS instance shutdown."
# Match exitcode
echo "Exiting with exitcode $REMOTE_SCRIPT_EXITCODE based on remote script output."
exit $REMOTE_SCRIPT_EXITCODE

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
# install pre-requisites for gRPC C core build
sudo apt update
sudo apt install -y build-essential autoconf libtool pkg-config cmake python python-pip clang
sudo pip install six
cd grpc
# tests require port server to be running
python tools/run_tests/start_port_server.py
# test gRPC C/C++ with bazel
tools/bazel test --config=opt --test_output=errors --test_tag_filters=-no_linux --build_tag_filters=-no_linux --flaky_test_attempts=1 --runs_per_test=1 //test/...

@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
# install pre-requisites for gRPC C core build
sudo apt update
sudo apt install -y build-essential autoconf libtool pkg-config cmake python python-pip clang
sudo pip install six
# install gRPC C# pre-requisites
curl -sSL -o dotnet-install.sh https://dot.net/v1/dotnet-install.sh
chmod u+x dotnet-install.sh
./dotnet-install.sh --channel 2.1 # needed for the netcoreapp2.1 targets
./dotnet-install.sh --channel 5.0
export PATH="$HOME/.dotnet:$PATH"
# Disable some unwanted dotnet options
export NUGET_XMLDOC_MODE=skip
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
export DOTNET_CLI_TELEMETRY_OPTOUT=true
dotnet --list-sdks
cd grpc
git submodule update --init
# build and test C#
tools/run_tests/run_tests.py -l csharp -c opt --compiler coreclr -t -x run_tests/csharp_linux_aarch64_opt_native/sponge_log.xml --report_suite_name csharp_linux_aarch64_opt_native --report_multi_target

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
# install pre-requisites for gRPC C core build
sudo apt update
sudo apt install -y build-essential autoconf libtool pkg-config cmake python python-pip clang
sudo pip install six
# install gRPC Ruby pre-requisites
sudo apt install -y php7.2-cli php7.2-dev
sudo apt install -y composer phpunit
sudo apt install -y php-bcmath # required by protobuf PHP, is it really needed for gRPC?
cd grpc
git submodule update --init
# build and test php
tools/run_tests/run_tests.py -l php7 -c opt -t -x run_tests/php7_linux_aarch64_opt_native/sponge_log.xml --report_suite_name php7_linux_aarch64_opt_native --report_multi_target

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
# install pre-requisites for gRPC C core build
sudo apt update
sudo apt install -y build-essential autoconf libtool pkg-config cmake python python-pip clang
sudo pip install six
# install python3.6 and pip
sudo apt install -y python3 python3-pip
python3 --version
cd grpc
git submodule update --init
# build and test python (currently we only test with python3.6, but that's ok since our aarch64 testing resources are limited)
tools/run_tests/run_tests.py -l python --compiler python3.6 -c opt --iomgr_platform native -t -x run_tests/python_linux_opt_native/sponge_log.xml --report_suite_name python_linux_opt_native --report_multi_target || FAILED=true
tools/run_tests/run_tests.py -l python --compiler python3.6 -c opt --iomgr_platform asyncio -t -x run_tests/python_linux_opt_gevent/sponge_log.xml --report_suite_name python_linux_opt_asyncio --report_multi_target || FAILED=true
tools/run_tests/run_tests.py -l python --compiler python3.6 -c opt --iomgr_platform gevent -t -x run_tests/python_linux_opt_gevent/sponge_log.xml --report_suite_name python_linux_opt_gevent --report_multi_target || FAILED=true
if [ "$FAILED" != "" ]
then
exit 1
fi

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
# install pre-requisites for gRPC C core build
sudo apt update
sudo apt install -y build-essential autoconf libtool pkg-config cmake python python-pip clang
sudo pip install six
# install gRPC Ruby pre-requisites
sudo apt install -y ruby ruby-dev
sudo gem install bundler
ruby --version
cd grpc
git submodule update --init
# build and test ruby
tools/run_tests/run_tests.py -l ruby -c opt -t -x run_tests/ruby_linux_aarch64_opt_native/sponge_log.xml --report_suite_name ruby_linux_aarch64_opt_native --report_multi_target
Loading…
Cancel
Save