blob: 8d900f1d16a369257e6c151574c534c6de206297 [file] [log] [blame]
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -07001#!/bin/bash
Jan Tattermusch7897ae92017-06-07 22:57:36 +02002# Copyright 2015 gRPC authors.
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -07003#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02004# 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
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -07007#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02008# http://www.apache.org/licenses/LICENSE-2.0
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -07009#
Jan Tattermusch7897ae92017-06-07 22:57:36 +020010# 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.
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070015
16# Initializes a fresh GCE VM to become a jenkins linux performance worker.
17# You shouldn't run this script on your own,
18# use create_linux_performance_worker.sh instead.
19
20set -ex
21
22sudo apt-get update
23
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070024# Install Java 8 JDK (to build gRPC Java)
25sudo apt-get install -y openjdk-8-jdk
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070026sudo apt-get install -y unzip lsof
27
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070028sudo apt-get install -y \
29 autoconf \
30 autotools-dev \
31 build-essential \
32 bzip2 \
33 ccache \
34 curl \
35 gcc \
36 gcc-multilib \
37 git \
38 gyp \
39 lcov \
40 libc6 \
41 libc6-dbg \
42 libc6-dev \
Matt Kwong6ae91752017-04-26 19:03:18 -070043 libcurl4-openssl-dev \
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070044 libgtest-dev \
Matt Kwong6ae91752017-04-26 19:03:18 -070045 libreadline-dev \
46 libssl-dev \
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070047 libtool \
48 make \
49 strace \
50 pypy \
51 python-dev \
52 python-pip \
53 python-setuptools \
54 python-yaml \
Ken Payson1efb6012016-06-08 13:06:44 -070055 python3-dev \
56 python3-pip \
57 python3-setuptools \
58 python3-yaml \
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070059 telnet \
60 unzip \
61 wget \
Matt Kwong6ae91752017-04-26 19:03:18 -070062 zip \
63 zlib1g-dev
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070064
65# perftools
66sudo apt-get install -y google-perftools libgoogle-perftools-dev
67
Jan Tattermusch11280192016-05-06 13:28:46 -070068# netperf
69sudo apt-get install -y netperf
70
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070071# C++ dependencies
72sudo apt-get install -y libgflags-dev libgtest-dev libc++-dev clang
73
74# Python dependencies
Nathaniel Manista8bba3bf2017-06-26 16:33:25 +000075sudo pip install --upgrade pip==9.0.1
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070076sudo pip install tabulate
Jan Tattermusch962c3872016-04-21 10:09:06 -070077sudo pip install google-api-python-client
Jan Tattermuschab0a7272016-10-15 21:12:41 +020078sudo pip install virtualenv
79
Matt Kwong6ae91752017-04-26 19:03:18 -070080# Building gRPC Python depends on python3.4 being installed, but python3.4
81# is not available on Ubuntu 16.10, so install from source
82curl -O https://www.python.org/ftp/python/3.4.6/Python-3.4.6.tgz
83tar xzvf Python-3.4.6.tgz
84cd Python-3.4.6
85./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,--rpath=/usr/local/lib"
86sudo make altinstall
87cd ..
88rm Python-3.4.6.tgz
Jan Tattermusch962c3872016-04-21 10:09:06 -070089
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070090curl -O https://bootstrap.pypa.io/get-pip.py
91sudo pypy get-pip.py
92sudo pypy -m pip install tabulate
Jan Tattermusch962c3872016-04-21 10:09:06 -070093sudo pip install google-api-python-client
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070094
Jan Tattermuschb19b62c2016-03-31 17:18:54 -070095# Node dependencies (nvm has to be installed under user jenkins)
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070096touch .profile
97curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
Jan Tattermusch15d29792016-05-09 23:27:05 -070098source ~/.nvm/nvm.sh
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070099nvm install 0.12 && npm config set cache /tmp/npm-cache
murgatroid99957fe8d2016-05-02 15:03:55 -0700100nvm install 4 && npm config set cache /tmp/npm-cache
101nvm install 5 && npm config set cache /tmp/npm-cache
102nvm alias default 4
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700103
Jan Tattermusch8e258d32016-10-14 14:04:44 +0200104# C# mono dependencies (http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives)
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700105sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
106echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
107sudo apt-get update
108sudo apt-get install -y mono-devel nuget
109
Jan Tattermusch8e258d32016-10-14 14:04:44 +0200110# C# .NET Core dependencies (https://www.microsoft.com/net/core#ubuntu)
Matt Kwong6ae91752017-04-26 19:03:18 -0700111sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ yakkety main" > /etc/apt/sources.list.d/dotnetdev.list'
Jan Tattermusch8e258d32016-10-14 14:04:44 +0200112sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
113sudo apt-get update
Matt Kwong6ae91752017-04-26 19:03:18 -0700114sudo apt-get install -y dotnet-dev-1.0.0-preview2.1-003155
Jan Tattermusch17ce30e2017-04-05 18:10:50 +0200115sudo apt-get install -y dotnet-dev-1.0.1
Alexander Polcyne4959282016-08-15 12:20:00 -0700116
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700117# Ruby dependencies
Matt Kwong6ae91752017-04-26 19:03:18 -0700118git clone https://github.com/rbenv/rbenv.git ~/.rbenv
119export PATH="$HOME/.rbenv/bin:$PATH"
120eval "$(rbenv init -)"
121
122git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
123export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
124
125rbenv install 2.4.0
126rbenv global 2.4.0
127ruby -v
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700128
Jan Tattermusch962c3872016-04-21 10:09:06 -0700129# Install bundler (prerequisite for gRPC Ruby)
Jan Tattermusch962c3872016-04-21 10:09:06 -0700130gem install bundler
131
Zhouyihai Ding4917b082017-09-21 12:52:50 -0700132# PHP dependencies
133sudo apt-get install -y php php-dev phpunit php-pear unzip zlib1g-dev
134curl -sS https://getcomposer.org/installer | php
135sudo mv composer.phar /usr/local/bin/composer
136
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700137# Java dependencies - nothing as we already have Java JDK 8
Jan Tattermusch03b44ab2016-05-10 09:20:59 -0700138
139# Go dependencies
Alexander Polcync4fb2e72016-10-07 11:00:45 -0700140# Currently, the golang package available via apt-get doesn't have the latest go.
Alexander Polcyn46b9be72016-10-12 14:33:13 -0700141# Significant performance improvements with grpc-go have been observed after
142# upgrading from go 1.5 to a later version, so a later go version is preferred.
Alexander Polcync4fb2e72016-10-07 11:00:45 -0700143# Following go install instructions from https://golang.org/doc/install
Alexander Polcyn08ad5652017-02-27 13:45:15 -0800144GO_VERSION=1.8
Alexander Polcync4fb2e72016-10-07 11:00:45 -0700145OS=linux
146ARCH=amd64
147curl -O https://storage.googleapis.com/golang/go${GO_VERSION}.${OS}-${ARCH}.tar.gz
148sudo tar -C /usr/local -xzf go$GO_VERSION.$OS-$ARCH.tar.gz
149# Put go on the PATH, keep the usual installation dir
150sudo ln -s /usr/local/go/bin/go /usr/bin/go
151rm go$GO_VERSION.$OS-$ARCH.tar.gz
Alexander Polcyn9f08d112016-10-24 12:25:02 -0700152
153# Install perf, to profile benchmarks. (need to get the right linux-tools-<> for kernel version)
154sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r`
155# see http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar
156echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
157# see http://stackoverflow.com/questions/21284906/perf-couldnt-record-kernel-reference-relocation-symbol
158echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
159
160# qps workers under perf appear to need a lot of mmap pages under certain scenarios and perf args in
161# order to not lose perf events or time out
162echo 4096 | sudo tee /proc/sys/kernel/perf_event_mlock_kb
163
164# Fetch scripts to generate flame graphs from perf data collected
165# on benchmarks
166git clone -v https://github.com/brendangregg/FlameGraph ~/FlameGraph
167
Alexander Polcynd88168b2017-03-28 14:13:37 -0700168# Install scipy and numpy for benchmarking scripts
Matt Kwong6ae91752017-04-26 19:03:18 -0700169sudo apt-get install -y python-scipy python-numpy
Matt Kwong654c3672017-04-11 14:31:39 -0700170
171# Add pubkey of jenkins@grpc-jenkins-master to authorized keys of jenkins@
172# This needs to happen as the last step to prevent Jenkins master from connecting
173# to a machine that hasn't been properly setup yet.
174cat jenkins_master.pub | sudo tee --append ~jenkins/.ssh/authorized_keys
175
176# Restart for VM to pick up kernel update
177echo 'Successfully initialized the linux worker, going for reboot in 10 seconds'
178sleep 10
179sudo reboot