blob: 78cdd31f0b0f2949906f4628a140f62c89b6f6a5 [file] [log] [blame]
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -07001#!/bin/bash
Craig Tiller6169d5f2016-03-31 07:46:18 -07002# Copyright 2015, Google Inc.
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -07003# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met:
8#
9# * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above
12# copyright notice, this list of conditions and the following disclaimer
13# in the documentation and/or other materials provided with the
14# distribution.
15# * Neither the name of Google Inc. nor the names of its
16# contributors may be used to endorse or promote products derived from
17# this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31# Initializes a fresh GCE VM to become a jenkins linux performance worker.
32# You shouldn't run this script on your own,
33# use create_linux_performance_worker.sh instead.
34
35set -ex
36
37sudo apt-get update
38
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070039# Install Java 8 JDK (to build gRPC Java)
40sudo apt-get install -y openjdk-8-jdk
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070041sudo apt-get install -y unzip lsof
42
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070043sudo apt-get install -y \
44 autoconf \
45 autotools-dev \
46 build-essential \
47 bzip2 \
48 ccache \
49 curl \
50 gcc \
51 gcc-multilib \
52 git \
53 gyp \
54 lcov \
55 libc6 \
56 libc6-dbg \
57 libc6-dev \
Matt Kwong6ae91752017-04-26 19:03:18 -070058 libcurl4-openssl-dev \
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070059 libgtest-dev \
Matt Kwong6ae91752017-04-26 19:03:18 -070060 libreadline-dev \
61 libssl-dev \
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070062 libtool \
63 make \
64 strace \
65 pypy \
66 python-dev \
67 python-pip \
68 python-setuptools \
69 python-yaml \
Ken Payson1efb6012016-06-08 13:06:44 -070070 python3-dev \
71 python3-pip \
72 python3-setuptools \
73 python3-yaml \
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070074 telnet \
75 unzip \
76 wget \
Matt Kwong6ae91752017-04-26 19:03:18 -070077 zip \
78 zlib1g-dev
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070079
80# perftools
81sudo apt-get install -y google-perftools libgoogle-perftools-dev
82
Jan Tattermusch11280192016-05-06 13:28:46 -070083# netperf
84sudo apt-get install -y netperf
85
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -070086# C++ dependencies
87sudo apt-get install -y libgflags-dev libgtest-dev libc++-dev clang
88
89# Python dependencies
90sudo pip install tabulate
Jan Tattermusch962c3872016-04-21 10:09:06 -070091sudo pip install google-api-python-client
Jan Tattermuschab0a7272016-10-15 21:12:41 +020092sudo pip install virtualenv
93
Matt Kwong6ae91752017-04-26 19:03:18 -070094# Building gRPC Python depends on python3.4 being installed, but python3.4
95# is not available on Ubuntu 16.10, so install from source
96curl -O https://www.python.org/ftp/python/3.4.6/Python-3.4.6.tgz
97tar xzvf Python-3.4.6.tgz
98cd Python-3.4.6
99./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,--rpath=/usr/local/lib"
100sudo make altinstall
101cd ..
102rm Python-3.4.6.tgz
Jan Tattermusch962c3872016-04-21 10:09:06 -0700103
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700104curl -O https://bootstrap.pypa.io/get-pip.py
105sudo pypy get-pip.py
106sudo pypy -m pip install tabulate
Jan Tattermusch962c3872016-04-21 10:09:06 -0700107sudo pip install google-api-python-client
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700108
Jan Tattermuschb19b62c2016-03-31 17:18:54 -0700109# Node dependencies (nvm has to be installed under user jenkins)
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700110touch .profile
111curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
Jan Tattermusch15d29792016-05-09 23:27:05 -0700112source ~/.nvm/nvm.sh
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700113nvm install 0.12 && npm config set cache /tmp/npm-cache
murgatroid99957fe8d2016-05-02 15:03:55 -0700114nvm install 4 && npm config set cache /tmp/npm-cache
115nvm install 5 && npm config set cache /tmp/npm-cache
116nvm alias default 4
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700117
Jan Tattermusch8e258d32016-10-14 14:04:44 +0200118# C# mono dependencies (http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives)
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700119sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
120echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
121sudo apt-get update
122sudo apt-get install -y mono-devel nuget
123
Jan Tattermusch8e258d32016-10-14 14:04:44 +0200124# C# .NET Core dependencies (https://www.microsoft.com/net/core#ubuntu)
Matt Kwong6ae91752017-04-26 19:03:18 -0700125sudo 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 +0200126sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
127sudo apt-get update
Matt Kwong6ae91752017-04-26 19:03:18 -0700128sudo apt-get install -y dotnet-dev-1.0.0-preview2.1-003155
Jan Tattermusch17ce30e2017-04-05 18:10:50 +0200129sudo apt-get install -y dotnet-dev-1.0.1
Alexander Polcyne4959282016-08-15 12:20:00 -0700130
Jan Tattermuscha30fc5d2016-03-25 14:00:23 -0700131# Ruby dependencies
Matt Kwong6ae91752017-04-26 19:03:18 -0700132git clone https://github.com/rbenv/rbenv.git ~/.rbenv
133export PATH="$HOME/.rbenv/bin:$PATH"
134eval "$(rbenv init -)"
135
136git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
137export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
138
139rbenv install 2.4.0
140rbenv global 2.4.0
141ruby -v
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700142
Jan Tattermusch962c3872016-04-21 10:09:06 -0700143# Install bundler (prerequisite for gRPC Ruby)
Jan Tattermusch962c3872016-04-21 10:09:06 -0700144gem install bundler
145
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700146# Java dependencies - nothing as we already have Java JDK 8
Jan Tattermusch03b44ab2016-05-10 09:20:59 -0700147
148# Go dependencies
Alexander Polcync4fb2e72016-10-07 11:00:45 -0700149# Currently, the golang package available via apt-get doesn't have the latest go.
Alexander Polcyn46b9be72016-10-12 14:33:13 -0700150# Significant performance improvements with grpc-go have been observed after
151# upgrading from go 1.5 to a later version, so a later go version is preferred.
Alexander Polcync4fb2e72016-10-07 11:00:45 -0700152# Following go install instructions from https://golang.org/doc/install
Alexander Polcyn08ad5652017-02-27 13:45:15 -0800153GO_VERSION=1.8
Alexander Polcync4fb2e72016-10-07 11:00:45 -0700154OS=linux
155ARCH=amd64
156curl -O https://storage.googleapis.com/golang/go${GO_VERSION}.${OS}-${ARCH}.tar.gz
157sudo tar -C /usr/local -xzf go$GO_VERSION.$OS-$ARCH.tar.gz
158# Put go on the PATH, keep the usual installation dir
159sudo ln -s /usr/local/go/bin/go /usr/bin/go
160rm go$GO_VERSION.$OS-$ARCH.tar.gz
Alexander Polcyn9f08d112016-10-24 12:25:02 -0700161
162# Install perf, to profile benchmarks. (need to get the right linux-tools-<> for kernel version)
163sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r`
164# see http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar
165echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
166# see http://stackoverflow.com/questions/21284906/perf-couldnt-record-kernel-reference-relocation-symbol
167echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
168
169# qps workers under perf appear to need a lot of mmap pages under certain scenarios and perf args in
170# order to not lose perf events or time out
171echo 4096 | sudo tee /proc/sys/kernel/perf_event_mlock_kb
172
173# Fetch scripts to generate flame graphs from perf data collected
174# on benchmarks
175git clone -v https://github.com/brendangregg/FlameGraph ~/FlameGraph
176
Alexander Polcynd88168b2017-03-28 14:13:37 -0700177# Install scipy and numpy for benchmarking scripts
Matt Kwong6ae91752017-04-26 19:03:18 -0700178sudo apt-get install -y python-scipy python-numpy
Matt Kwong654c3672017-04-11 14:31:39 -0700179
180# Add pubkey of jenkins@grpc-jenkins-master to authorized keys of jenkins@
181# This needs to happen as the last step to prevent Jenkins master from connecting
182# to a machine that hasn't been properly setup yet.
183cat jenkins_master.pub | sudo tee --append ~jenkins/.ssh/authorized_keys
184
185# Restart for VM to pick up kernel update
186echo 'Successfully initialized the linux worker, going for reboot in 10 seconds'
187sleep 10
188sudo reboot