From: Felipe Vicens Date: Wed, 24 Jun 2020 13:55:57 +0000 (+0200) Subject: Adding the repository to CI/CD pipeline X-Git-Tag: release-v9.0-start~57 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F9148%2F8;p=osm%2Ftests.git Adding the repository to CI/CD pipeline Change-Id: I9acb3bde5872939c4435fe438717e10db3776743 Signed-off-by: Felipe Vicens --- diff --git a/Dockerfile b/Dockerfile index 51f4c53..65c2c78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -# Copyright 2020 ETSI -# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -13,35 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM ubuntu:18.04 - -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git software-properties-common \ - make python3 debhelper python3-setuptools python3-pip apt-utils ssh iputils-ping libcurl4-openssl-dev libssl-dev \ - python3-openstackclient -RUN add-apt-repository -y ppa:rmescandon/yq && apt update && apt install yq -y -RUN python3 -m pip install haikunator requests robotframework robotframework-seleniumlibrary robotframework-requests robotframework-jsonlibrary \ - robotframework-sshlibrary charm-tools git+https://osm.etsi.org/gerrit/osm/IM.git git+https://osm.etsi.org/gerrit/osm/osmclient.git -WORKDIR /robot-systest -RUN git clone https://osm.etsi.org/gitlab/vnf-onboarding/osm-packages.git --recurse-submodules /robot-systest/osm-packages -COPY robot-systest /robot-systest -COPY charm.sh /usr/sbin/charm - -# Folder where Robot tests are stored -ENV ROBOT_DEVOPS_FOLDER=/robot-systest - -# Folder to save alternative DUT environments (optional) -ENV ENVIRONMENTS_FOLDER=environments - -# Folder where all required packages are stored -ENV PACKAGES_FOLDER=/robot-systest/osm-packages - -# Folder where test results should be exported -ENV ROBOT_REPORT_FOLDER=/robot-systest/results +# This Dockerfile is intented for devops and deb package generation +# +# Use Dockerfile.local for running osm/NBI in a docker container from source +# Use Dockerfile.fromdeb for running osm/NBI in a docker container from last stable package -# Kubeconfig file -ENV K8S_CREDENTIALS=/root/.kube/config -ENV LC_ALL=C.UTF-8 -ENV LANG=C.UTF-8 +FROM ubuntu:16.04 -ENTRYPOINT [ "/robot-systest/run_test.sh"] +RUN apt-get update && apt-get -y install git make libcurl4-gnutls-dev \ + libgnutls-dev debhelper apt-utils dh-make diff --git a/README.md b/README.md index cd81fd2..51a7ec5 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ It is possible to run the tests directly from the repository or using a docker c 1. Docker container creation: ```bash -docker build -t osmtests . +docker build -f docker/Dockerfile -t osmtests . ``` Options: diff --git a/build-debpkg.sh b/build-debpkg.sh new file mode 100755 index 0000000..e4e83b3 --- /dev/null +++ b/build-debpkg.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# Copyright 2020 ETSI +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +PKG_DIRECTORIES="robot-systest" +PKG_FILES="CONTRIBUTING.md LICENSE README.md charm.sh" +MDG_NAME=tests +DEB_INSTALL=debian/osm-${MDG_NAME}.install +export DEBEMAIL="gerardo.garciadeblas@telefonica.com" +export DEBFULLNAME="Gerardo Garcia" + +PKG_VERSION=$(git describe --match "v*" --tags --abbrev=0) +PKG_VERSION_PREFIX=$(echo $PKG_VERSION | sed -e 's/v//g') +PKG_VERSION_POST=$(git rev-list $PKG_VERSION..HEAD | wc -l) +PKG_VERSION_HASH=$(git describe --match "v*" --tags | awk '{print $3}' FS=-) +if [ "$PKG_VERSION_POST" -eq 0 ]; then + PKG_DIR="deb_dist/osm-${MDG_NAME}-${PKG_VERSION_PREFIX}" +else + PKG_DIR="deb_dist/osm-${MDG_NAME}-$PKG_VERSION_PREFIX.post${PKG_VERSION_POST}+${PKG_VERSION_HASH}" +fi + +rm -rf $PKG_DIR +rm -f *.orig.tar.xz +rm -f *.deb +rm -f $DEB_INSTALL +mkdir -p $PKG_DIR + +for dir in $PKG_DIRECTORIES; do + ln -s $PWD/$dir $PKG_DIR/. + echo "$dir/* usr/share/osm-$MDG_NAME/$dir" >> $DEB_INSTALL +done +for f in $PKG_FILES; do + cp $f $PKG_DIR/. + echo "$f usr/share/osm-$MDG_NAME" >> $DEB_INSTALL +done +cp -R debian $PKG_DIR/. + +pushd $PKG_DIR +dh_make -y --indep --createorig --a -c apache +dpkg-buildpackage -uc -us -tc -rfakeroot +popd diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..daa9f1a --- /dev/null +++ b/debian/control @@ -0,0 +1,29 @@ +## +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact with: OSM_TECH@list.etsi.org +## +Source: osm-tests +Section: devel +Priority: optional +Maintainer: Gerardo Garcia +Build-Depends: debhelper (>=9) +Standards-Version: 3.9.6 +Homepage: http://osm.etsi.org + +Package: osm-tests +Architecture: all +Depends: ${misc:Depends} +Description: Open Source MANO Next Generation UI based on Angular + diff --git a/devops-stages/stage-archive.sh b/devops-stages/stage-archive.sh index 013953f..56a1c5c 100755 --- a/devops-stages/stage-archive.sh +++ b/devops-stages/stage-archive.sh @@ -12,4 +12,15 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +MDG=tests + +rm -rf pool +rm -rf dists +mkdir -p pool/$MDG +mv deb_dist/*.deb pool/$MDG/ + +mkdir -p dists/unstable/$MDG/binary-amd64/ +apt-ftparchive packages pool/$MDG > dists/unstable/$MDG/binary-amd64/Packages +gzip -9fk dists/unstable/$MDG/binary-amd64/Packages + echo "ARCHIVE" diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh index b58d1f3..23e921b 100755 --- a/devops-stages/stage-build.sh +++ b/devops-stages/stage-build.sh @@ -12,4 +12,5 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +./build-debpkg.sh echo "BUILD" diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index 337cf59..c5ca053 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -11,4 +11,5 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +# python3 -m rflint testsuites echo "TEST" diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..2ae03c9 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,56 @@ +# Copyright 2020 ETSI +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Author: Felipe Vicens (felipe.vicens@atos.net) ATOS + +FROM ubuntu:18.04 + +# Installing robot dependencies +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git software-properties-common \ + make python3 debhelper python3-setuptools python3-pip apt-utils ssh iputils-ping libcurl4-openssl-dev libssl-dev \ + python3-openstackclient + +RUN add-apt-repository -y ppa:rmescandon/yq && apt update && apt install yq -y + +RUN python3 -m pip install haikunator requests robotframework robotframework-seleniumlibrary robotframework-requests robotframework-jsonlibrary \ + robotframework-sshlibrary charm-tools git+https://osm.etsi.org/gerrit/osm/IM.git git+https://osm.etsi.org/gerrit/osm/osmclient.git + +# Preparing working environment +WORKDIR /robot-systest +RUN git clone https://osm.etsi.org/gitlab/vnf-onboarding/osm-packages.git --recurse-submodules /robot-systest/osm-packages + +# Copy robot folder and charm.sh +COPY robot-systest /robot-systest +COPY charm.sh /usr/sbin/charm + +# Folder where Robot tests are stored +ENV ROBOT_DEVOPS_FOLDER=/robot-systest + +# Folder to save alternative DUT environments (optional) +ENV ENVIRONMENTS_FOLDER=environments + +# Folder where all required packages are stored +ENV PACKAGES_FOLDER=/robot-systest/osm-packages + +# Folder where test results should be exported +ENV ROBOT_REPORT_FOLDER=/robot-systest/results + +# Kubeconfig file +ENV K8S_CREDENTIALS=/root/.kube/config + +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +ENTRYPOINT [ "/robot-systest/run_test.sh"]