From bc83f936c1b369fc6291898ec88b6c6c17b2aa5d Mon Sep 17 00:00:00 2001 From: Samuli Silvius Date: Thu, 23 May 2019 12:50:57 +0300 Subject: Install jq as an dependency for yq Before using yq binary we need to install also its dependency jq. This commit is fixing jq installation in case it was required as dependency for yq. Also refactored a bit dependency installations of tests. Issue-ID: MULTICLOUD-617 Change-Id: I0ea1143befa1cff809c231422b5cfb14fba1de4e Signed-off-by: Samuli Silvius --- kud/tests/_common_test.sh | 50 +++++++++++++++++++++++++++++++-------- kud/tests/_functions.sh | 23 ------------------ kud/tests/integration_vcFW.sh | 1 + kud/tests/ovn4nfv.sh | 1 + kud/tests/ovn_provider_nw_test.sh | 1 + 5 files changed, 43 insertions(+), 33 deletions(-) diff --git a/kud/tests/_common_test.sh b/kud/tests/_common_test.sh index be22db9a..1c6af678 100755 --- a/kud/tests/_common_test.sh +++ b/kud/tests/_common_test.sh @@ -15,15 +15,45 @@ set -o pipefail # install_deps() - Install dependencies required for functional tests function install_deps { if ! $(jq --version &>/dev/null); then - source /etc/os-release || source /usr/lib/os-release - case ${ID,,} in - *suse) - ;; - ubuntu|debian) - sudo apt-get install -y jq - ;; - rhel|centos|fedora) - ;; - esac + function ubuntu_deps { + sudo apt-get install -y jq + } + install_packages "" ubuntu_deps "" fi } + +# install_ovn_deps() - Install dependencies required for tests that require OVN +function install_ovn_deps { + if ! $(yq --version &>/dev/null); then + install_deps # jq needed as it's dependency of yq + sudo -E pip install yq + fi + if ! $(ovn-nbctl --version &>/dev/null); then + function ovn_ubuntu_deps { + sudo apt-get install -y apt-transport-https + echo "deb https://packages.wand.net.nz $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/wand.list + sudo curl https://packages.wand.net.nz/keyring.gpg -o /etc/apt/trusted.gpg.d/wand.gpg + sudo apt-get update + sudo apt install -y ovn-common + } + install_packages "" ovn_ubuntu_deps "" + fi +} + +function install_packages { + local suse_packages=$1 + local ubuntu_debian_packages=$2 + local rhel_centos_packages=$3 + source /etc/os-release || source /usr/lib/os-release + case ${ID,,} in + *suse) + ($suse_packages) + ;; + ubuntu|debian) + ($ubuntu_debian_packages) + ;; + rhel|centos|fedora) + ($rhel_centos_packages) + ;; + esac +} diff --git a/kud/tests/_functions.sh b/kud/tests/_functions.sh index 5efb56fe..542443d6 100755 --- a/kud/tests/_functions.sh +++ b/kud/tests/_functions.sh @@ -31,29 +31,6 @@ function _get_ovn_central_address { echo "$(echo ${ansible_ifconfig#*>>} | tr '\n' ':')6641" } -# install_ovn_deps() - Install dependencies required for tests that require OVN -function install_ovn_deps { - if ! $(yq --version &>/dev/null); then - sudo -E pip install yq - fi - if ! $(ovn-nbctl --version &>/dev/null); then - source /etc/os-release || source /usr/lib/os-release - case ${ID,,} in - *suse) - ;; - ubuntu|debian) - sudo apt-get install -y apt-transport-https - echo "deb https://packages.wand.net.nz $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/wand.list - sudo curl https://packages.wand.net.nz/keyring.gpg -o /etc/apt/trusted.gpg.d/wand.gpg - sudo apt-get update - sudo apt install -y ovn-common - ;; - rhel|centos|fedora) - ;; - esac - fi -} - # init_network() - This function creates the OVN resouces required by the test function init_network { local fname=$1 diff --git a/kud/tests/integration_vcFW.sh b/kud/tests/integration_vcFW.sh index 0c6d0689..a4035207 100755 --- a/kud/tests/integration_vcFW.sh +++ b/kud/tests/integration_vcFW.sh @@ -13,6 +13,7 @@ set -o nounset set -o pipefail source _common.sh +source _common_test.sh source _functions.sh csar_id=aa443e7e-c8ba-11e8-8877-525400b164ff diff --git a/kud/tests/ovn4nfv.sh b/kud/tests/ovn4nfv.sh index de8631f4..6be6aae8 100755 --- a/kud/tests/ovn4nfv.sh +++ b/kud/tests/ovn4nfv.sh @@ -12,6 +12,7 @@ set -o nounset set -o pipefail source _common.sh +source _common_test.sh source _functions.sh csar_id=a1c5b53e-d7ab-11e8-85b7-525400e8c29a diff --git a/kud/tests/ovn_provider_nw_test.sh b/kud/tests/ovn_provider_nw_test.sh index 9b32d904..b2a8642c 100644 --- a/kud/tests/ovn_provider_nw_test.sh +++ b/kud/tests/ovn_provider_nw_test.sh @@ -13,6 +13,7 @@ set -o nounset set -o pipefail source _common.sh +source _common_test.sh source _functions.sh # populate_CSAR_ovn4nfv() - Create content used for OVN4NFV functional test -- cgit 1.2.3-korg