Merge "Update plots: Clean up k6 test suite"
[infra/cicd.git] / jjb / geode / apache-geode-slave / slave_setup.sh
1 #!/usr/bin/env bash
2 # Licensed to the Apache Software Foundation (ASF) under one
3 # or more contributor license agreements.  See the NOTICE file
4 # distributed with this work for additional information
5 # regarding copyright ownership.  The ASF licenses this file
6 # to you under the Apache License, Version 2.0 (the
7 # "License"); you may not use this file except in compliance
8 # with the License.  You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 set -o nounset
19 set -o errexit
20 set -o pipefail
21 set -o xtrace
22
23 # Global variables
24 DPKG_LOCK="/var/lib/dpkg/lock-frontend"
25 DOCKER_VERSION="5:20.10.20~3-0~ubuntu-bionic"
26 DOCKER_COMPOSE_URL="https://github.com/docker/compose/releases/download"
27 DOCKER_COMPOSE_VERSION="1.29.2"
28
29 # Wait for other apt process to finish by checking the dpkg lock file.
30 try=0
31 while sudo lsof ${DPKG_LOCK}  > /dev/null 2>&1 ; do
32   echo "DPKG file locked: ${DPKG_LOCK}."
33   echo "   Waiting for another pkg instalaltion process to finish ..."
34   sleep 10
35   if [[ ${try} -gt 60 ]] ; then
36     echo "ERROR: Max number of re-tries reached, exiting..."
37     exit 1
38   fi
39   try=$((try + 1))
40 done
41
42 sudo apt-get update
43 sudo apt-get install -y --no-install-recommends \
44   apt-transport-https \
45   lsb-release
46
47 curl -sSL https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
48 sudo add-apt-repository "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main"
49 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
50 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
51 sudo apt-get update
52 set +e && sudo apt-get purge -y google-cloud-sdk lxc-docker && set -e
53 sudo apt-get install -y --no-install-recommends \
54     aptitude \
55     ca-certificates \
56     cgroupfs-mount \
57     docker-ce=${DOCKER_VERSION} \
58     docker-ce-cli=${DOCKER_VERSION} \
59     git \
60     google-chrome-stable \
61     htop \
62     jq \
63     less \
64     lsof \
65     net-tools \
66     python3 \
67     python3-pip \
68     rsync \
69     tmux \
70     unzip \
71     vim
72
73 # Get correct docker-compose version required for geode-AcceptanceTest
74 sudo curl -L "${DOCKER_COMPOSE_URL}/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" \
75           -o /usr/local/bin/docker-compose
76 sudo chmod +x /usr/local/bin/docker-compose
77
78 # Increase number of Max threads that infra user (UserTasksMax) and systemd (DefaultTasksMax) can create.
79 # This is required for Geode UpgradeTest to avoid error:
80 # java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
81 # todo: This should be done during image creation
82 sudo sed -i 's/.*DefaultTasksMax=.*/DefaultTasksMax=infinity/g' /etc/systemd/system.conf
83 sudo sed -i 's/.*UserTasksMax=.*/UserTasksMax=infinity/g' /etc/systemd/logind.conf
84 sudo systemctl set-property user-$(id -u infra).slice TasksMax=infinity
85 sudo systemctl daemon-reload
86 sudo systemctl restart systemd-logind.service
87
88 sudo cp -R /etc/alternatives /etc/keep-alternatives
89 sudo apt-get update
90 sudo apt-get install -y --no-install-recommends \
91     openjdk-8-jdk \
92     openjdk-11-jdk \
93     openjdk-17-jdk
94 sudo rm -rf /etc/alternatives
95 sudo mv /etc/keep-alternatives /etc/alternatives
96
97 docker pull ${GEODE_DOCKER_IMAGE}
98 sudo curl -Lo /usr/local/bin/dunit-progress https://github.com/jdeppe-pivotal/progress-util/releases/download/0.2/progress.linux
99 sudo chmod +x /usr/local/bin/dunit-progress
100 wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip
101 sudo sudo rm -rf /opt/selenium/chromedriver
102 sudo unzip /tmp/chromedriver_linux64.zip -d /opt/selenium
103 rm /tmp/chromedriver_linux64.zip
104 sudo mv /opt/selenium/chromedriver /opt/selenium/chromedriver-${CHROME_DRIVER_VERSION}
105 sudo chmod 755 /opt/selenium/chromedriver-${CHROME_DRIVER_VERSION}
106 sudo ln -fs /opt/selenium/chromedriver-${CHROME_DRIVER_VERSION} /usr/bin/chromedriver
107
108 sudo apt-get clean
109 sudo rm -rf /var/lib/apt/lists/*