22406: Install arvados-server on test nodes during build
[arvados-dev.git] / jenkins / packer-images / jenkins-image-arvados-tests.sh
1 #!/bin/bash
2
3 # Copyright (C) The Arvados Authors. All rights reserved.
4 #
5 # SPDX-License-Identifier: Apache-2.0
6
7 set -eo pipefail
8
9 # Install the dependencies for arvados-server
10 sudo su -c "DEBIAN_FRONTEND=noninteractive apt-get install -y libpam0g-dev wget build-essential"
11
12 # Docker installed earlier by jenkins-image-with-docker.sh
13
14 # Check out a local copy of the arvados repo so we can use it to install the dependencies
15 cd /usr/src
16 sudo git clone arvados.git
17
18 if [[ "$GIT_HASH" != "" ]]; then
19   echo "GIT_HASH is set to $GIT_HASH, checking out that revision..."
20   (cd arvados && sudo git checkout $GIT_HASH)
21 fi
22
23 # Install the correct version of Go
24 GO_VERSION=`grep 'const goversion =' /usr/src/arvados/lib/install/deps.go |awk -F'"' '{print $2}'`
25 cd /usr/src
26 sudo wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
27 sudo tar xzf go${GO_VERSION}.linux-amd64.tar.gz
28 sudo ln -s /usr/src/go/bin/go /usr/local/bin/go-${GO_VERSION}
29 sudo ln -s /usr/src/go/bin/gofmt /usr/local/bin/gofmt-${GO_VERSION}
30 sudo ln -s /usr/local/bin/go-${GO_VERSION} /usr/local/bin/go
31 sudo ln -s /usr/local/bin/gofmt-${GO_VERSION} /usr/local/bin/gofmt
32
33 # Preseed our dependencies
34 cd arvados
35 sudo go mod download
36 builddir="$(mktemp --directory --tmpdir arvados-server.XXXXXX)"
37 trap 'sudo rm -rf "$builddir"' EXIT ERR INT TERM QUIT
38 sudo go build -o "$builddir" ./cmd/arvados-server
39 # Install arvados-server on $PATH so that RailsAPI install commands can find it.
40 # Remove it afterwards since run-tests.sh should build and use its own copy.
41 sudo install "$builddir/arvados-server" /usr/local/bin/
42 trap 'sudo rm -rf "$builddir" /usr/local/bin/arvados-server' EXIT ERR INT TERM QUIT
43 sudo arvados-server install -type test
44
45 # FUSE must be configured with the 'user_allow_other' option enabled for Crunch to set up Keep mounts that are readable by containers.
46 # This is used in our test suite.
47 echo user_allow_other | sudo tee -a /etc/fuse.conf
48
49 # inotify.max_user_watches set earlier by jenkins-image-with-docker.sh
50
51 # Our Jenkins jobs use this directory to store the temporary files for the tests
52 mkdir /home/jenkins/tmp
53
54 # Preseed the run-tests.sh cache. This is a little bit silly (a lot of this
55 # stuff was already done by the call to `./cmd/arvados-server install -type
56 # test` above, but they do not share a cache.
57 sudo chown jenkins:jenkins /home/jenkins -R
58 sudo chown jenkins:jenkins /usr/src/arvados -R
59 sudo -u jenkins ./build/run-tests.sh WORKSPACE=/usr/src/arvados --temp /home/jenkins/tmp --only install
60
61 # arvados-dev cloned earlier by jenkins-image-with-docker.sh