diff --git a/.jenkins.sh b/.jenkins.sh new file mode 100644 index 0000000000000000000000000000000000000000..3bad4e68f952186871fbe544cc7ac1c9422b8668 --- /dev/null +++ b/.jenkins.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Copyright ETSI 2018 +# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt + +#set -vx +#set -e + +cd "$(dirname "$0")" + +run_dir="$(pwd)" + +bash ./scripts/build-container.sh +bash ./scripts/run-container.sh "${run_dir}" + +ret=$? +echo "Final validation result: $ret" +exit $ret diff --git a/SOL005/NSDManagement-API/NSDManagementKeywords.robot b/SOL005/NSDManagement-API/NSDManagementKeywords.robot index 43b142f98832e64bd8f1ae5c6608f38c4c6e8480..1c65fa8712bb31922aa33944e9654684a1acc37e 100644 --- a/SOL005/NSDManagement-API/NSDManagementKeywords.robot +++ b/SOL005/NSDManagement-API/NSDManagementKeywords.robot @@ -1027,7 +1027,7 @@ Create Sessions Pass Execution If ${NFVO_CHECKS_NOTIF_ENDPOINT} == 0 MockServer not started as NFVO is not checking the notification endpoint Start Process java -jar ${MOCK_SERVER_JAR} -serverPort ${callback_port} alias=mockInstance Wait For Process handle=mockInstance timeout=5s on_timeout=continue - Create Mock Session ${callback_uri} + Create Mock Session ${callback_uri}:${callback_port} Check Notification Endpoint diff --git a/SOL005/NSDManagement-API/environment/variables.txt b/SOL005/NSDManagement-API/environment/variables.txt index 9f9d5956c6cffa1e8a2c3a69786c08f568e96493..4833412eabdd9dff36bc745c5fe337bee0366a6c 100644 --- a/SOL005/NSDManagement-API/environment/variables.txt +++ b/SOL005/NSDManagement-API/environment/variables.txt @@ -17,7 +17,7 @@ ${NFVO_AUTH_USAGE} 1 ${MOCK_SERVER_JAR} ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar ${callback_port} 9091 -${callback_uri} http://172.22.1.7:${callback_port} +${callback_uri} http://172.22.1.7 ${callback_endpoint} /nsd/subscriptions ${callback_endpoint_error} /subs_404 ${callback_endpoint_fwd} /endpoint/check diff --git a/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot b/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot index 155df9a50683973fd0d3f15d00820c78b955a01e..1cc9d359db8bea6f28b851283960f9cffbc5522a 100644 --- a/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot +++ b/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot @@ -783,7 +783,7 @@ Create Sessions Pass Execution If ${NFVO_CHECKS_NOTIF_ENDPOINT} == 0 MockServer not started as NFVO is not checking the notification endpoint Start Process java -jar ${MOCK_SERVER_JAR} -serverPort ${callback_port} alias=mockInstance Wait For Process handle=mockInstance timeout=5s on_timeout=continue - Create Mock Session ${callback_uri} + Create Mock Session ${callback_uri}:${callback_port} Check Notification Endpoint diff --git a/SOL005/NSPerformanceManagement-API/environment/variables.txt b/SOL005/NSPerformanceManagement-API/environment/variables.txt index 64de1566ed183475beac88efd2a969031e80397f..c1236069e9a00142f06cd128d183135fbde19cb8 100644 --- a/SOL005/NSPerformanceManagement-API/environment/variables.txt +++ b/SOL005/NSPerformanceManagement-API/environment/variables.txt @@ -18,7 +18,7 @@ ${MOCK_SERVER_JAR} ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies. ${testOptionalMethods} 0 ${callback_port} 9091 -${callback_uri} http://172.22.1.7:${callback_port} +${callback_uri} http://172.22.1.7 ${callback_endpoint} /nspm/subscriptions ${callback_endpoint_error} /subs_404 ${sleep_interval} 20s diff --git a/scripts/build-container.sh b/scripts/build-container.sh new file mode 100644 index 0000000000000000000000000000000000000000..f5c825ad9b06585a6b1aff2191c5df9ef18a3f7b --- /dev/null +++ b/scripts/build-container.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright ETSI 2019 +# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt + +#set -e +set -vx + +DOCKER_FILE=./scripts/docker/Dockerfile +if [ -f ${DOCKER_FILE} ] +then + #check and build stf583-rf-validation image + DOCKER_ID=`docker ps -a | grep -e stf583-rf-validation | awk '{ print $1 }'` +# if [ ! -z "${DOCKER_ID}" ] +# then +# docker rm --force stf583-rf-validation +# fi + docker build --tag stf583-rf-validation -f ${DOCKER_FILE} . + if [ "$?" != "0" ] + then + echo "Docker build failed: $?" + exit -1 + fi +# docker image ls -a +# docker inspect stf583-rf-validation:latest +# if [ "$?" != "0" ] +# then +# echo "Docker inspect failed: $?" +# exit -2 +# fi +#else +# exit -3 +fi + +# That's all Floks +exit 0 + diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9f753df87329ee5f9811c52fab79cee8e0018b36 --- /dev/null +++ b/scripts/docker/Dockerfile @@ -0,0 +1,58 @@ +FROM ubuntu:16.04 + +MAINTAINER ETSI STF 583 + +LABEL description="SFT583 Robot Framework Docker Image" + +ENV TERM=xterm +ENV HOSTNAME docker-robot-STF583 + +ARG ssh_prv_key + +RUN DEBIAN_FRONTEND=noninteractive apt update \ + && apt install python3 git -y \ + && apt install python3-pip -y \ + && DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y \ + && DEBIAN_FRONTEND=noninteractive apt-get autoclean \ + && rm -rf /var/lib/apt/lists/* + +RUN echo "docker-robot-STF583" > /etc/hostname \ + && echo "root:etsi" | chpasswd + +RUN useradd --create-home --shell /bin/bash --user-group etsi --groups sudo \ + && echo "etsi:etsi" | chpasswd \ + && adduser etsi sudo \ + && echo "etsi ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +RUN DEBIAN_FRONTEND=noninteractive \ + && mkdir -p /home/etsi/dev/robot \ + && cd /home/etsi/dev/robot + +#RUN pip3 install robotframework + +ADD requirements.txt /home/etsi/dev/robot/ +ADD extensions /home/etsi/dev/robot/extensions + +RUN ls /home/etsi/dev/robot + + +RUN DEBIAN_FRONTED=noninteractive \ + cd /home/etsi/dev/ \ + mkdir -p build \ + && git clone https://forge.etsi.org/rep/forge-tools/robot2doc.git \ + && cd robot2doc \ + && pip3 install -r requirements.txt \ + && python3 -m pip install -e . + +RUN DEBIAN_FRONTEND=noninteractive \ + && cd /home/etsi/dev/robot \ + && pip3 install -r requirements.txt + + +ADD . /home/etsi/dev/robot + +RUN chmod +x /home/etsi/dev/robot/scripts/* + +CMD tail -f /dev/null + + diff --git a/scripts/launch-validation.sh b/scripts/launch-validation.sh new file mode 100644 index 0000000000000000000000000000000000000000..59030577655abb1e4a05e0e092b7b8af5cd105ba --- /dev/null +++ b/scripts/launch-validation.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "Starting check on ROBOT CODE" + +for FILE in $(find . -name "*.robot"); do + echo "Syntax check on ${FILE}" + robot --dryrun -d /tmp ${FILE} +done diff --git a/scripts/run-all.bash b/scripts/run-all.bash new file mode 100644 index 0000000000000000000000000000000000000000..793febd18ebca7b55f1eecc2fbaf294f19c3dee9 --- /dev/null +++ b/scripts/run-all.bash @@ -0,0 +1,38 @@ +#!/bin/bash + +## Launch robot tests validator + +mkdir logs + +/bin/bash scripts/launch-validation.sh > logs/robot_stdout.log 2> logs/robot_stderr.log + +## Filter failed Keywords +grep -r10n "| FAIL |" logs/robot_stdout.log | grep -v "Output:" | grep -v "Log:" | grep -v "Report:" > logs/failures.log +rm -f logs/robot_stdout.log + + +## Filter Errors on code +grep -rn " ERROR " logs/robot_stderr.log | grep -v "File has no tests or tasks" > logs/errors.log +rm -f logs/robot_stderr.log + + +ERRORS=`awk 'END{print NR}' logs/errors.log logs/failures.log` +if [ "${ERRORS}" -eq 0 ]; then + rm -f logs/errors.log + rm -f logs/failures.log +fi + + +if [ -f logs/errors.log ]; then + cat logs/errors.log +fi + +if [ -f logs/failures.log ]; then + cat logs/failures.log +fi + +if [ -f logs/erros.log ] || [ -f logs.failures.log ]; then + echo "Errors are found. Job failed" + exit 1 +fi + diff --git a/scripts/run-container.sh b/scripts/run-container.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0ea09699ff44dd9ef5ee6e29b2564683f7a7099 --- /dev/null +++ b/scripts/run-container.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Copyright ETSI 2019 +# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt + +#set -e +#set -vx + +mkdir -p build + +docker run -v "$(pwd)/build:/home/etsi/dev/build" stf583-rf-validation:latest "bash" \ + -c "/home/etsi/dev/robot/scripts/validate.sh" + +ret=$? + +exit $ret + diff --git a/scripts/validate.sh b/scripts/validate.sh new file mode 100644 index 0000000000000000000000000000000000000000..ae06e2ea0e0d328935f8d4de143093ff075d95c1 --- /dev/null +++ b/scripts/validate.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Validate syntax and keywords existance in each Robot file + +cd /home/etsi/dev/robot/ + +res=0 +for i in */*/*.robot ; do + if [[ "$i" != *"Keywords.robot"* && "$i" != *"Keyword.robot"* ]] ; then + echo "++++ Dryrun file $i" + msg=$(robot --dryrun --output NONE --report NONE --log NONE $i 2>&1) + if [ $? != 0 ] ; then + echo "++++ Issues found in file $i" + echo "$msg" + res=1 + fi + fi +done + +cd /home/etsi/dev/robot2doc/robot2doc + +mkdir -p /home/etsi/dev/build + +python3 create_sols.py ../../robot 'local' ../../build +res2=$? + +exit $res && $res2