Commit 9d5b03c3 authored by Elian Kraja's avatar Elian Kraja Committed by Michele Carignani
Browse files

Adding dockerized validation test

parent 96898064
#!/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)"
./scripts/build-container.sh
./scripts/run-container.sh "${run_dir}"
exit $?
#!/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 --force-rm -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
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 \
&& apt install openssh-server -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
ADD . /home/etsi/dev/robot
RUN pip3 install robotframework
RUN DEBIAN_FRONTEND=noninteractive \
&& cd /home/etsi/dev/robot \
&& pip3 install -r requirements.txt \
&& chmod +x /home/etsi/dev/robot/scripts/* \
&& git clone https://github.com/etsi-cti-admin/robotframework-mockserver \
&& cd robotframework-mockserver \
&& patch -p1 < ../extensions/mockserverlibrary.patch \
&& python3 -m pip install -e .
CMD tail -f /dev/null
#!/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
#!/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
#!/bin/bash
# Copyright ETSI 2019
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt
#set -e
#set -vx
docker run stf583-rf-validation:latest "/bin/bash" \
-c "cd /home/etsi/dev/robot \
&& sh scripts/validate.sh "
# That's all Floks
exit $?
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment