Skip to content
Snippets Groups Projects
Commit 10c5a8e8 authored by Evili del Rio's avatar Evili del Rio
Browse files

Colorize output from test

parent 3287e9f6
Branches
Tags v1.4.0
No related merge requests found
Pipeline #4106 passed
......@@ -4,6 +4,13 @@
#
set -e
#
# Highlight results with colors
#
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
#
# Name of the Test Project
#
TEST_PROJECT=tinyp
......@@ -11,7 +18,7 @@ virtualenv .env
source .env/bin/activate
pip install --upgrade pip
#
# Basically we fire up a test project and check that healt_urls are working.
# Basically we fire up a test project and check that health_urls are working.
#
Django_Versions='3.2 2.2 1.11'
for django_version in ${Django_Versions}
......@@ -23,9 +30,9 @@ do
rm -fr ./${TEST_PROJECT} || echo "No project directory"
# Clean env
pip uninstall --verbose --yes $(pip freeze | awk -F '=' '{print $1}') || echo "WARNING: Could not clean Python environment"
pip uninstall --verbose --yes $(pip freeze | awk -F '=' '{print $1}') || echo -e "${YELLOW}WARNING: Could not clean Python environment${NC}"
pip install Django~=${django_version}
django-admin.py startproject --verbosity 2 ${TEST_PROJECT}
django-admin startproject --verbosity 2 ${TEST_PROJECT}
pip freeze > ${TEST_PROJECT}/requirements.txt
echo "Checking urls.py"
md5sum ${TEST_PROJECT}/${TEST_PROJECT}/urls.py
......@@ -48,7 +55,7 @@ do
echo -n "Getting container IP: "
TEST_PROJECT_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${TEST_PROJECT})
TEST_PROJECT_IP=${TEST_PROJECT_IP:-localhost}
echo "Container IP: ${TEST_PROJECT_IP}"
echo "${TEST_PROJECT_IP}"
echo "Getting logs from container:"
wait_container=1
MAX_WAIT_CONTAINER=${MAX_WAIT_CONTAINER:-59}
......@@ -68,14 +75,14 @@ do
set -e
if [[ "OK" != "${wait_container}" ]]
then
echo "WARNING: Container is not ready. Continuing..."
echo -e "${YELLOW}WARNING: Container is not ready. Continuing...${NC}"
docker logs --tail 10 ${TEST_PROJECT}
fi
echo "Getting test page.."
curl --output ${TEST_PROJECT}-${django_version}.html -f http://${TEST_PROJECT_IP}:5000/health_checks/
echo "Stopping and removing container"
docker stop ${TEST_PROJECT} || echo "WARNING: Container ${TEST_PROJECT} not stopped."
docker rm ${TEST_PROJECT} || echo "WARNING: Container ${TEST_PROJECT} not removed."
echo "OK with Django ${django_version}."
docker stop ${TEST_PROJECT} || echo -e "${YELLOW}WARNING: Container ${TEST_PROJECT} not stopped.${NC}"
docker rm ${TEST_PROJECT} || echo -e "${YELLOW}WARNING: Container ${TEST_PROJECT} not removed.${NC}"
echo -e "${GREEN}OK: Django ${django_version} successful.${NC}"
done
echo "OK with all Django versions: ${Django_Versions}"
echo -e "${GREEN}OK: Django versions ${Django_Versions} tested${NC}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment