From f70a11c09144730f7f88a4223e1026fa2a877c25 Mon Sep 17 00:00:00 2001 From: Elian Kraja Date: Tue, 19 Jan 2021 15:52:02 +0100 Subject: [PATCH 1/3] Fix on mockserver configuration --- SOL005/NSDManagement-API/NSDManagementKeywords.robot | 2 +- SOL005/NSDManagement-API/environment/variables.txt | 2 +- .../NSPerformanceManagementKeywords.robot | 2 +- SOL005/NSPerformanceManagement-API/environment/variables.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SOL005/NSDManagement-API/NSDManagementKeywords.robot b/SOL005/NSDManagement-API/NSDManagementKeywords.robot index 43b142f98..1c65fa871 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 9f9d5956c..4833412ea 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 155df9a50..1cc9d359d 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 64de1566e..c1236069e 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 -- GitLab From fd9be2bba6b791c20b2147ac655784d2fa491a11 Mon Sep 17 00:00:00 2001 From: Elian Kraja Date: Tue, 19 Jan 2021 15:55:11 +0100 Subject: [PATCH 2/3] Adding validation script --- .jenkins.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .jenkins.sh diff --git a/.jenkins.sh b/.jenkins.sh new file mode 100644 index 000000000..3bad4e68f --- /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 -- GitLab From a052a7d4466714613a1a0e623da4b13831b491af Mon Sep 17 00:00:00 2001 From: Elian Kraja Date: Tue, 19 Jan 2021 15:59:40 +0100 Subject: [PATCH 3/3] Adding scripts for builder --- scripts/build-container.sh | 36 ++++++++++++++++++++++ scripts/docker/Dockerfile | 58 ++++++++++++++++++++++++++++++++++++ scripts/launch-validation.sh | 8 +++++ scripts/run-all.bash | 38 +++++++++++++++++++++++ scripts/run-container.sh | 16 ++++++++++ scripts/validate.sh | 27 +++++++++++++++++ 6 files changed, 183 insertions(+) create mode 100644 scripts/build-container.sh create mode 100644 scripts/docker/Dockerfile create mode 100644 scripts/launch-validation.sh create mode 100644 scripts/run-all.bash create mode 100644 scripts/run-container.sh create mode 100644 scripts/validate.sh diff --git a/scripts/build-container.sh b/scripts/build-container.sh new file mode 100644 index 000000000..f5c825ad9 --- /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 000000000..9f753df87 --- /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 000000000..590305776 --- /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 000000000..793febd18 --- /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 000000000..c0ea09699 --- /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 000000000..ae06e2ea0 --- /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 -- GitLab