Make ovn-central network interface configurable
[multicloud/k8s.git] / kud / tests / _common_test.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright 2019 © Samsung Electronics Co., Ltd.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 set -o errexit
12 set -o nounset
13 set -o pipefail
14
15 # install_deps() - Install dependencies required for functional tests
16 function install_deps {
17     if ! $(jq --version &>/dev/null); then
18         function ubuntu_deps {
19             sudo apt-get install -y jq
20         }
21         install_packages "" ubuntu_deps ""
22     fi
23 }
24
25 # install_ovn_deps() - Install dependencies required for tests that require OVN
26 function install_ovn_deps {
27     if ! $(yq --version &>/dev/null); then
28         install_deps # jq needed as it's dependency of yq
29         sudo -E pip install yq
30     fi
31     if ! $(ovn-nbctl --version &>/dev/null); then
32         function ovn_ubuntu_deps {
33             sudo apt-get install -y apt-transport-https
34             echo "deb https://packages.wand.net.nz $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/wand.list
35             sudo curl https://packages.wand.net.nz/keyring.gpg -o /etc/apt/trusted.gpg.d/wand.gpg
36             sudo apt-get update
37             sudo apt install -y ovn-common
38         }
39         install_packages "" ovn_ubuntu_deps ""
40     fi
41 }
42
43 function install_packages {
44     local suse_packages=$1
45     local ubuntu_debian_packages=$2
46     local rhel_centos_packages=$3
47     source /etc/os-release || source /usr/lib/os-release
48     case ${ID,,} in
49         *suse)
50             ($suse_packages)
51         ;;
52         ubuntu|debian)
53             ($ubuntu_debian_packages)
54         ;;
55         rhel|centos|fedora)
56             ($rhel_centos_packages)
57         ;;
58     esac
59 }