66ba8ee2c0c5845bdbb48ce44c5ee20ceb92412c
[arvados-dev.git] / jenkins / test-arvados-multinode / script_test.multinode.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 WORKSPACE=${1}
7 ARVADOS_FORMULA_BRANCH=${2}
8 RELEASE=${3}
9 VERSION=${4}
10 GIT_COMMIT=${5}
11 BUILD_TAG=${6}
12
13 ### SCRIPT
14 _exit_handler() {
15   local rc="$?"
16   trap - EXIT
17   if [ "$rc" -ne 0 ]; then
18     echo "Error occurred ($rc) while running $0 at line $1 : $BASH_COMMAND"
19   fi
20   exit "$rc"
21 }
22
23 # trap '_exit_handler $LINENO' EXIT ERR
24
25 cd terraform || exit 1
26
27 NODE_A_EXT=$(terraform output -json public_ip | jq -r .[0])
28 NODE_B_EXT=$(terraform output -json public_ip | jq -r .[1])
29 NODE_A_INT=$(terraform output -json private_ip | jq -r .[0])
30 NODE_B_INT=$(terraform output -json private_ip | jq -r .[1])
31 CLUSTER_NAME=$(terraform output -json cluster_name | jq -r .)
32
33 echo "   + Waiting 10 seconds for nodes to be up"
34 sleep 10
35
36 cd $WORKSPACE/tools/salt-install || exit 1
37 mkdir ${GIT_COMMIT}
38
39 echo "== Preparing config files"
40 cp -vr ./config_examples/multi_host/aws ${GIT_COMMIT}/local_config_dir
41 ### FIXME!!!! The multi-host arvados' configuration requires a LOT of env-dependent changes
42 ### which are a bit hard to modify in a script.
43 ### Using a modified version of the single_host/single_hostname file
44 echo "== Copying a custom-made arvados pillar for this test case"
45 cp -v ./config_examples/multi_host/aws/pillars/arvados_development.sls ${GIT_COMMIT}/local_config_dir/pillars/arvados.sls
46
47 sed "s#cluster_fixme_or_this_wont_work#${CLUSTER_NAME}#g;
48      s#domain_fixme_or_this_wont_work#testing.arvados#g;
49      s#HOSTNAME_EXT=\"hostname_ext_fixme_or_this_wont_work\"#HOSTNAME_EXT=\"${CLUSTER_NAME}.testing.arvados\"#g;
50      s#IP_INT=\"ip_int_fixme_or_this_wont_work\"#IP_INT=\"127.0.0.1\"#g;
51      s#CLUSTER_INT_CIDR=10.0.0.0/16#CLUSTER_INT_CIDR=10.0.0.0/8#g;
52      s#CONTROLLER_INT_IP=.*#CONTROLLER_INT_IP=${NODE_A_INT}#g;
53      s#WEBSOCKET_INT_IP=.*#WEBSOCKET_INT_IP=${NODE_A_INT}#g;
54      s#KEEP_INT_IP=.*#KEEP_INT_IP=${NODE_A_INT}#g;
55      s#KEEPWEB_INT_IP=.*#KEEPWEB_INT_IP=${NODE_A_INT}#g;
56      s#KEEPSTORE0_INT_IP=.*#KEEPSTORE0_INT_IP=${NODE_A_INT}#g;
57      s#KEEPSTORE1_INT_IP=.*#KEEPSTORE1_INT_IP=${NODE_B_INT}#g;
58      s#WORKBENCH1_INT_IP=.*#WORKBENCH1_INT_IP=${NODE_A_INT}#g;
59      s#WORKBENCH2_INT_IP=.*#WORKBENCH2_INT_IP=${NODE_A_INT}#g;
60      s#WEBSHELL_INT_IP=.*#WEBSHELL_INT_IP=${NODE_A_INT}#g;
61      s#DATABASE_INT_IP=.*#DATABASE_INT_IP=${NODE_A_INT}#g;
62      s#SHELL_INT_IP=.*#SHELL_INT_IP=${NODE_B_INT}#g;
63      s#RELEASE=\"production\"#RELEASE=\"${RELEASE}\"#g;
64      s#SSL_MODE=\"lets-encrypt\"#SSL_MODE=\"bring-your-own\"#g;
65      s/# BRANCH=\"main\"/BRANCH=${ARVADOS_FORMULA_BRANCH}/g;
66      s/# VERSION=.*$/VERSION=\"${VERSION}\"/g" \
67      local.params.example.multiple_hosts > ${GIT_COMMIT}/debian11-local.params.example.multiple_hosts
68
69 cp -vr /usr/local/arvados-dev/jenkins/test-arvados-multinode/certs tests provision.sh ${GIT_COMMIT}
70
71 echo "== Setting up NODE_A with database,api,controller,keepstore,websocket,workbench2,keepbalance,keepproxy,workbench,dispatcher"
72
73 echo "   + Copying files to NODE_A"
74 scp -o "StrictHostKeyChecking=no" -r ${GIT_COMMIT}/* admin@${NODE_A_EXT}:
75
76 echo "   + Installing NODE_A"
77 ssh -o "StrictHostKeyChecking=no" admin@${NODE_A_EXT} sudo ./provision.sh \
78     --debug \
79     --roles database,api,controller,keepstore,websocket,workbench2,keepbalance,keepproxy,workbench \
80     --config debian11-local.params.example.multiple_hosts \
81     --development
82
83 echo "== Setting up NODE_B with keepstore,keepweb,webshell,shell"
84
85 echo "   + Copying files to NODE_B"
86 scp -o "StrictHostKeyChecking=no" -r ${GIT_COMMIT}/* admin@${NODE_B_EXT}:
87
88 echo "   + Installing NODE_B"
89 ssh -o "StrictHostKeyChecking=no" admin@${NODE_B_EXT} sudo ./provision.sh \
90     --debug \
91     --roles keepstore,keepweb,webshell,shell,dispatcher \
92     --config debian11-local.params.example.multiple_hosts \
93     --development \
94     --test