• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2015 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# 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
24# Install Java 8 JDK (to build gRPC Java)
25sudo apt-get install -y openjdk-8-jdk
26sudo apt-get install -y unzip lsof
27
28sudo 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 \
43  libcurl4-openssl-dev \
44  libgtest-dev \
45  libreadline-dev \
46  libssl-dev \
47  libtool \
48  make \
49  strace \
50  pypy \
51  python-dev \
52  python-pip \
53  python-setuptools \
54  python-yaml \
55  python3-dev \
56  python3-pip \
57  python3-setuptools \
58  python3-yaml \
59  telnet \
60  unzip \
61  wget \
62  zip \
63  zlib1g-dev
64
65# perftools
66sudo apt-get install -y google-perftools libgoogle-perftools-dev
67
68# netperf
69sudo apt-get install -y netperf
70
71# C++ dependencies
72sudo apt-get install -y libgflags-dev libgtest-dev libc++-dev clang
73
74# Python dependencies
75sudo pip install --upgrade pip==10.0.1
76sudo pip install tabulate
77sudo pip install google-api-python-client
78sudo pip install virtualenv
79
80# 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
84(
85cd Python-3.4.6 || exit
86./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,--rpath=/usr/local/lib"
87sudo make altinstall
88)
89rm Python-3.4.6.tgz
90
91curl -O https://bootstrap.pypa.io/get-pip.py
92sudo pypy get-pip.py
93sudo pypy -m pip install tabulate
94sudo pip install google-api-python-client
95
96# Node dependencies (nvm has to be installed under user jenkins)
97touch .profile
98curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
99# silence shellcheck warning as it cannot follow the `source` path statically:
100# shellcheck disable=SC1090
101source ~/.nvm/nvm.sh
102nvm install 0.12 && npm config set cache /tmp/npm-cache
103nvm install 4 && npm config set cache /tmp/npm-cache
104nvm install 5 && npm config set cache /tmp/npm-cache
105nvm alias default 4
106
107# C# mono dependencies (http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives)
108sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
109echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
110sudo apt-get update
111sudo apt-get install -y mono-devel nuget
112
113# C# .NET Core dependencies (https://www.microsoft.com/net/core#ubuntu)
114sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ yakkety main" > /etc/apt/sources.list.d/dotnetdev.list'
115sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
116sudo apt-get update
117sudo apt-get install -y dotnet-dev-1.0.0-preview2.1-003155
118sudo apt-get install -y dotnet-dev-1.0.1
119
120# Ruby dependencies
121git clone https://github.com/rbenv/rbenv.git ~/.rbenv
122export PATH="$HOME/.rbenv/bin:$PATH"
123eval "$(rbenv init -)"
124
125git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
126export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
127
128rbenv install 2.4.0
129rbenv global 2.4.0
130ruby -v
131
132# Install bundler (prerequisite for gRPC Ruby)
133gem install bundler
134
135# PHP dependencies
136sudo apt-get install -y php php-dev phpunit php-pear unzip zlib1g-dev
137curl -sS https://getcomposer.org/installer | php
138sudo mv composer.phar /usr/local/bin/composer
139
140# Java dependencies - nothing as we already have Java JDK 8
141
142# Go dependencies
143# Currently, the golang package available via apt-get doesn't have the latest go.
144# Significant performance improvements with grpc-go have been observed after
145# upgrading from go 1.5 to a later version, so a later go version is preferred.
146# Following go install instructions from https://golang.org/doc/install
147GO_VERSION=1.8
148OS=linux
149ARCH=amd64
150curl -O https://storage.googleapis.com/golang/go${GO_VERSION}.${OS}-${ARCH}.tar.gz
151sudo tar -C /usr/local -xzf go$GO_VERSION.$OS-$ARCH.tar.gz
152# Put go on the PATH, keep the usual installation dir
153sudo ln -s /usr/local/go/bin/go /usr/bin/go
154rm go$GO_VERSION.$OS-$ARCH.tar.gz
155
156# Install perf, to profile benchmarks. (need to get the right linux-tools-<> for kernel version)
157sudo apt-get install -y linux-tools-common linux-tools-generic "linux-tools-$(uname -r)"
158# see http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar
159echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
160# see http://stackoverflow.com/questions/21284906/perf-couldnt-record-kernel-reference-relocation-symbol
161echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
162
163# qps workers under perf appear to need a lot of mmap pages under certain scenarios and perf args in
164# order to not lose perf events or time out
165echo 4096 | sudo tee /proc/sys/kernel/perf_event_mlock_kb
166
167# Fetch scripts to generate flame graphs from perf data collected
168# on benchmarks
169git clone -v https://github.com/brendangregg/FlameGraph ~/FlameGraph
170
171# Install scipy and numpy for benchmarking scripts
172sudo apt-get install -y python-scipy python-numpy
173
174# Add pubkey of jenkins@grpc-jenkins-master to authorized keys of jenkins@
175# This needs to happen as the last step to prevent Jenkins master from connecting
176# to a machine that hasn't been properly setup yet.
177# silence false-positive shellcheck warning ("< redirect does not affect sudo")
178# shellcheck disable=SC2024
179sudo tee --append ~jenkins/.ssh/authorized_keys < jenkins_master.pub
180
181# Restart for VM to pick up kernel update
182echo 'Successfully initialized the linux worker, going for reboot in 10 seconds'
183sleep 10
184sudo reboot
185