Add a http performance test script based on wrk
[iec.git] / src / use_cases / seba_on_arm / install / install.sh
1 #!/bin/bash -ex
2 # shellcheck disable=SC2016
3
4 #Modified from https://github.com/cachengo/seba_charts/blob/master/scripts/installSEBA.sh
5
6 basepath=$(cd "$(dirname "$0")"; pwd)
7 CORD_REPO=${CORD_REPO:-https://charts.opencord.org}
8 CORD_PLATFORM_VERSION=${CORD_PLATFORM_VERSION:-6.1.0}
9 SEBA_VERSION=${SEBA_VERSION:-1.0.0}
10 ATT_WORKFLOW_VERSION=${ATT_WORKFLOW_VERSION:-1.0.2}
11
12 CORD_CHART=${CORD_CHART:-${basepath}/../src_repo/seba_charts}
13
14 # TODO(alav): Make each step re-entrant
15
16 function wait_for {
17   # Execute in a subshell to prevent local variable override during recursion
18   (
19     local total_attempts=$1; shift
20     local cmdstr=$*
21     local sleep_time=2
22     echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}"
23     # shellcheck disable=SC2034
24     for attempt in $(seq "${total_attempts}"); do
25       echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}"
26       # shellcheck disable=SC2015
27       eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true
28       sleep "${sleep_time}"
29     done
30     echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}"
31     return 1
32   )
33 }
34
35 wait_for 10 'test $(kubectl get pods --all-namespaces | grep -ce "tiller.*Running") -eq 1'
36
37 # Add the CORD repository and update indexes
38
39 if [ "$(uname -m)" == "aarch64" ]; then
40   if [ ! -d ${CORD_CHART}/cord-platform ]; then
41     #git clone https://github.com/iecedge/seba_charts ${CORD_CHART}
42     cd ${basepath}/../src_repo && git submodule update --init seba_charts
43   fi
44 else
45   helm repo add cord "${CORD_REPO}"
46   helm repo update
47   CORD_CHART=cord
48 fi
49
50
51 # Install the CORD platform
52 helm install -n cord-platform ${CORD_CHART}/cord-platform --version="${CORD_PLATFORM_VERSION}"
53 # Wait until 3 etcd CRDs are present in Kubernetes
54 wait_for 300 'test $(kubectl get crd | grep -ice etcd) -eq 3'
55
56 # Install the SEBA profile
57 helm install -n seba --version "${SEBA_VERSION}" ${CORD_CHART}/seba
58 wait_for 1500 'test $(kubectl get pods | grep -vcE "(\s(.+)/\2.*Running|tosca-loader.*Completed)") -eq 1'
59
60 # Install the AT&T workflow
61 helm install -n att-workflow --version "${ATT_WORKFLOW_VERSION}" ${CORD_CHART}/att-workflow
62 wait_for 300 'test $(kubectl get pods | grep -vcE "(\s(.+)/\2.*Running|tosca-loader.*Completed)") -eq 1'