From ae5b9eddd00923e97ab9d3b402e75db39f0feb9a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jaime=20Caama=C3=B1o=20Ruiz?= Date: Fri, 27 Jul 2018 12:44:13 +0200 Subject: [PATCH] Use OVS 2.9.2 for fluorine sfc csit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I6575f785edd178fef1677b33b09f3018a5ff8e43 Signed-off-by: Jaime Caamaño Ruiz --- csit/libraries/SFC/SfcKeywords.robot | 7 +- .../Full_Deploy/010__sfc_full_deploy.robot | 2 +- csit/suites/sfc/Full_Deploy/Dockerfile | 5 +- .../sfc/Full_Deploy/setup-docker-image.sh | 141 +++++++++--------- 4 files changed, 82 insertions(+), 73 deletions(-) diff --git a/csit/libraries/SFC/SfcKeywords.robot b/csit/libraries/SFC/SfcKeywords.robot index 327a48d6ae..c40780155c 100644 --- a/csit/libraries/SFC/SfcKeywords.robot +++ b/csit/libraries/SFC/SfcKeywords.robot @@ -1,6 +1,7 @@ *** Settings *** Documentation Common Keywords for the SFC Test suites. Library Collections +Resource ../CompareStream.robot Resource ../Utils.robot *** Variables *** @@ -14,8 +15,10 @@ Get JSON Elements From URI Check Classifier Flows ${flowList} = DockerSfc.Get Flows In Docker Containers BuiltIn.log ${flowList} - BuiltIn.Should Contain ${flowList} *actions=pop_nsh* - BuiltIn.Should Contain ${flowList} *actions=push_nsh* + ${expected_nsh_pop}= Set_Variable_If_At_Most oxygen *actions=pop_nsh* *actions=decap(),decap(),* + ${expected_nsh_push}= Set_Variable_If_At_Most oxygen *actions=push_nsh* *actions=encap(nsh* + Collections.Should Contain Match ${flowList} ${expected_nsh_pop} + Collections.Should Contain Match ${flowList} ${expected_nsh_push} Check Service Function Types Added [Arguments] ${elements} diff --git a/csit/suites/sfc/Full_Deploy/010__sfc_full_deploy.robot b/csit/suites/sfc/Full_Deploy/010__sfc_full_deploy.robot index d39d7e835e..515a6f0e84 100644 --- a/csit/suites/sfc/Full_Deploy/010__sfc_full_deploy.robot +++ b/csit/suites/sfc/Full_Deploy/010__sfc_full_deploy.robot @@ -67,7 +67,7 @@ Init Suite SSHLibrary.Put File ${CURDIR}/docker-ovs.sh . mode=0755 SSHLibrary.Put File ${CURDIR}/Dockerfile . mode=0755 SSHLibrary.Put File ${CURDIR}/setup-docker-image.sh . mode=0755 - ${result} = SSHLibrary.Execute Command ./setup-docker-image.sh > >(tee myFile.log) 2> >(tee myFile.log) return_stderr=True return_stdout=True return_rc=True + ${result} = SSHLibrary.Execute Command ./setup-docker-image.sh ${ODL_STREAM} > >(tee myFile.log) 2> >(tee myFile.log) return_stderr=True return_stdout=True return_rc=True BuiltIn.log ${result} BuiltIn.Should be equal as integers ${result[2]} 0 BuiltIn.Set Suite Variable @{INTERFACE_NAMES} v-ovsnsn6g1 v-ovsnsn1g1 diff --git a/csit/suites/sfc/Full_Deploy/Dockerfile b/csit/suites/sfc/Full_Deploy/Dockerfile index 9e2dad4ec1..58f48bfff8 100644 --- a/csit/suites/sfc/Full_Deploy/Dockerfile +++ b/csit/suites/sfc/Full_Deploy/Dockerfile @@ -1,6 +1,8 @@ FROM socketplane/busybox:latest MAINTAINER The SocketPlane Team -ENV OVS openvswitch_2.6.1 +ARG OVS_VERSION + +ENV OVS openvswitch_${OVS_VERSION} # Configure supervisord RUN mkdir -p /var/log/supervisor/ @@ -28,6 +30,7 @@ RUN tar -xzvf ${OVS}.tgz &&\ rm -r openvswitch &&\ rm ${OVS}.tgz ADD configure-ovs.sh /usr/local/share/openvswitch/ +RUN mkdir -p /usr/local/var/run/openvswitch COPY libcrypto.so.10 /usr/lib COPY libssl.so.10 /usr/lib diff --git a/csit/suites/sfc/Full_Deploy/setup-docker-image.sh b/csit/suites/sfc/Full_Deploy/setup-docker-image.sh index eef3644551..58ab38b223 100755 --- a/csit/suites/sfc/Full_Deploy/setup-docker-image.sh +++ b/csit/suites/sfc/Full_Deploy/setup-docker-image.sh @@ -2,68 +2,78 @@ set -o xtrace set -o nounset #Do not allow for unset variables -#set -e #Exit script if a command fails - -WORK_DIR=`pwd` - -# bootstrap_centos -EL_VERSION=$(grep -oP '\d+\.\d+.\d+' /etc/centos-release) -K_VERSION=$(uname -r) -APT="sudo yum update -y centos-release" -$APT || (echo "Failed to update centos release info" && exit 1) - -APT="sudo yum install -y --enablerepo=C${EL_VERSION}-base --enablerepo=C${EL_VERSION}-updates kernel-devel-${K_VERSION} kernel-debug-devel-${K_VERSION} kernel-headers-${K_VERSION}" -$APT || (echo "Failed to install kernel devel packages" && exit 1) - -APT="sudo yum install -y git python-devel vim autoconf automake libtool systemd-units rpm-build openssl openssl-devel groff graphviz selinux-policy-devel python python-twisted-core python-zope-interface python-twisted-web PyQt4 python-six desktop-file-utils procps-ng wget" -$APT || (echo "Failed to install ovs requirement packages" && exit 1) - -cd $WORK_DIR -[ -e configure-ovs.sh ] || \ - wget https://raw.githubusercontent.com/socketplane/docker-ovs/master/configure-ovs.sh +set -e #Exit script if a command fails + +function build_ovs() { + K_VERSION=$(uname -r) + + if [[ "${OVS_VERSION}" != "2.6.1" && "${OVS_VERSION}" != "2.9.2" ]]; then + echo "Unsupported OVS version ${OVS_VERSION}" + exit 1 + fi + + echo "Building OVS ${OVS_VERSION}" + + # install running kernel devel packages + sudo yum -y install centos-release yum-utils @'Development Tools' rpm-build + REPO=$(repoquery --enablerepo=C* -i kernel-devel-${K_VERSION} | grep Repository | sed 's/Repo.*:[ \t]*//') + sudo yum -y --enablerepo=${REPO} install kernel-{devel,debug-devel,headers}-${K_VERSION} + + TMP=$(mktemp -d) + pushd ${TMP} + + git clone https://github.com/openvswitch/ovs.git + cd ovs + git checkout v${OVS_VERSION} + + if [[ "${OVS_VERSION}" == "2.6.1" ]]; then + echo "Will apply nsh patches for OVS version 2.6.1" + git clone https://github.com/yyang13/ovs_nsh_patches.git ../ovs_nsh_patches + git apply ../ovs_nsh_patches/v2.6.1_centos7/*.patch + fi + + sed -e 's/@VERSION@/0.0.1/' rhel/openvswitch-fedora.spec.in > /tmp/ovs.spec + sudo yum-builddep -y /tmp/ovs.spec + rm /tmp/ovs.spec + ./boot.sh + ./configure --with-linux=/lib/modules/${K_VERSION}/build --prefix=/usr/local --disable-libcapng + # dont use libcap, we wont have the proper libraries in the docker image + make rpm-fedora RPMBUILD_OPT="--without check --without libcapng" + # we dont need the kernel module (yet) + # make rpm-fedora-kmod RPMBUILD_OPT="-D 'kversion ${K_VERSION}'" + make DESTDIR=${TMP}/ovs_install/openvswitch_${OVS_VERSION} install + + popd + + # copy rpms and installation + mkdir -p ovs_package + find ${TMP}/ovs/rpm/rpmbuild/RPMS -name "*.rpm" | xargs -i cp {} ovs_package/ + tar cvzf ovs_package/openvswitch_${OVS_VERSION}.tgz -C ${TMP}/ovs_install . + + rm -rf ${TMP} +} + +ODL_STREAM=$1 + +# build ovs +[ "${ODL_STREAM}" == "oxygen" ] && OVS_VERSION="2.6.1" || OVS_VERSION="2.9.2" +build_ovs + +# install ovs +sudo yum -y install ovs_package/openvswitch-${OVS_VERSION}-*.rpm +# without libcapng, we have to run as root +sudo sed -i 's/^OVS_USER_ID/#OVS_USER_ID/' /etc/sysconfig/openvswitch +sudo systemctl enable openvswitch +sudo systemctl start openvswitch +sudo ovs-vsctl --retry -t 10 show + +# download supervisor to run OVS as a service inside the docker busybox image +wget https://raw.githubusercontent.com/socketplane/docker-ovs/master/configure-ovs.sh chmod a+x configure-ovs.sh -[ -e supervisord.conf ] || \ - wget https://raw.githubusercontent.com/socketplane/docker-ovs/master/supervisord.conf - -[ -e supervisor-stdout/supervisor-stdout-0.1.1.tar.gz ] || \ - wget https://pypi.python.org/packages/source/s/supervisor-stdout/supervisor-stdout-0.1.1.tar.gz --no-check-certificate - -[ -e ovs_nsh_patches ] || \ - git clone https://github.com/yyang13/ovs_nsh_patches.git -[ -e ovs ] || \ - git clone https://github.com/openvswitch/ovs.git - -cd ovs -git config user.email "yi.y.yang@intel.com" -git config user.name "Yi Yang" -git checkout -b v2.6.1 v2.6.1 -git am ../ovs_nsh_patches/v2.6.1/*.patch - -#compile ovs -./boot.sh -./configure --with-linux=/lib/modules/${K_VERSION}/build --prefix=/usr/local -make rpm-fedora RPMBUILD_OPT="--without check --without libcapng" -make DESTDIR=$WORK_DIR/ovs_install/openvswitch_2.6.1 install - -#copy rpms and installation -mkdir -p $WORK_DIR/ovs_package -find . -name "*.rpm"|xargs -I[] cp [] $WORK_DIR/ovs_package -tar cvzf $WORK_DIR/ovs_package/openvswitch_2.6.1.tgz -C $WORK_DIR/ovs_install . - -# install_ovs -cd $WORK_DIR/ovs_package -CMD='sudo yum list installed openvswitch' -if $CMD; then - echo "openvswitch already installed" -else - sudo yum --nogpgcheck -y install `find . -regex "\./openvswitch-[0-9,.,-].*"` -fi - -#start ovs -sudo /sbin/service openvswitch start - -#prepare libraries for docker image in busybox -cd $WORK_DIR +wget https://raw.githubusercontent.com/socketplane/docker-ovs/master/supervisord.conf +wget https://pypi.python.org/packages/source/s/supervisor-stdout/supervisor-stdout-0.1.1.tar.gz --no-check-certificate + +# busybox image is missing some libs, take them from the host cp /usr/lib64/libcrypto.so.10 . cp /usr/lib64/libssl.so.10 . cp /usr/lib64/libgssapi_krb5.so.2 . @@ -77,12 +87,5 @@ cp /usr/lib64/libpcre.so.1 . cp /usr/lib64/liblzma.so.5 . # build_ovs_docker -cd $WORK_DIR -sudo docker --version -if [ -z `sudo docker images | awk '/^ovs-docker / {print $1}'` ]; - then - sudo docker build -t ovs-docker . -fi - - +sudo docker build -t ovs-docker --build-arg OVS_VERSION=${OVS_VERSION} . -- 2.36.6