logger test and fix debian/install

This commit is contained in:
Denis Zheleztsov 2016-11-14 14:57:17 +03:00
parent 1fdefce3dc
commit c62a38eb7f
5 changed files with 64 additions and 2 deletions

View File

@ -11,6 +11,8 @@ services:
before_install:
- docker pull ubuntu:xenial
- cd build && ./build.sh surok_image
- ./build.sh alpine
- ./build.sh centos
script:
- ./runtests.sh

View File

@ -5,7 +5,7 @@ set -e
. functions.sh
function usage() {
echo "$0 <clean|build_package|surok_image|alpine>"
echo "$0 <clean|build_package|surok_image|alpine|centos>"
}
case $1 in
@ -18,5 +18,6 @@ case $1 in
surok_image) build_surok_base rebuild ;;
surok_image_no_rebuild) build_surok_base ;;
alpine) build_alpine ;;
centos) build_centos ;;
*) usage ;;
esac

View File

@ -93,3 +93,35 @@ ENTRYPOINT cd /opt/surok && python3 surok.py -c /etc/surok/conf/surok.json
EOF
docker build -t surok_alpine -f Dockerfile.alpine .
}
function build_centos() {
copy_surok
cat > Dockerfile.centos <<EOF
FROM centos:latest
MAINTAINER Denis Zheleztsov <difrex.punk@gmail.com>
RUN yum -y install epel-release
RUN yum -y install python34
# Install pip
RUN cd /tmp && curl -O https://bootstrap.pypa.io/get-pip.py
RUN cd /tmp && python3.4 get-pip.py
# Install surok
COPY surok /opt/surok
RUN mkdir /etc/surok
RUN ln -s /opt/surok/conf /etc/surok/conf
RUN ln -s /opt/surok/conf.d /etc/surok/conf.d
RUN ln -s /opt/surok/templates /etc/surok/templates
# Install surok depends
RUN cd /opt/surok && pip3 install -r requriments.txt
# Cleanup
RUN yum clean all
ENTRYPOINT cd /opt/surok && python3 surok.py -c /etc/surok/conf/surok.json
EOF
docker build -t surok_centos -f Dockerfile.centos .
}

View File

@ -1,11 +1,11 @@
import unittest
import json
import os
import re
class TestLoadConfig(unittest.TestCase):
def test_main_conf(self):
# Load base configurations
surok_conf = '/etc/surok/conf/surok.json'
@ -17,6 +17,32 @@ class TestLoadConfig(unittest.TestCase):
self.assertIn('confd', conf)
self.assertTrue(os.path.isdir(conf['confd']))
self.assertIn('domain', conf)
self.assertIn('wait_time', conf)
self.assertIn('lock_dir', conf)
self.assertTrue(os.path.isdir(conf['lock_dir']))
class TestLogger(unittest.TestCase):
def test_info(self):
from surok.logger import make_message
m = make_message
self.assertIn('INFO', m({'level': 'info', 'raw': 'log message'}))
def test_warning(self):
from surok.logger import make_message
m = make_message
self.assertIn('WARNING', m({'level': 'warning', 'raw': 'log message'}))
def test_error(self):
from surok.logger import make_message
m = make_message
self.assertIn('ERROR', m({'level': 'error', 'raw': 'log message'}))
def test_info(self):
from surok.logger import make_message
m = make_message
self.assertIn('DEBUG', m({'level': 'debug', 'raw': 'log message'}))
if __name__ == '__main__':

1
debian/install vendored
View File

@ -1,6 +1,7 @@
conf/surok.json etc/surok/conf
surok/templates.py opt/surok/surok
surok/system.py opt/surok/surok
surok/logger.py opt/surok/surok
surok/__init__.py opt/surok/surok
surok/discovery.py opt/surok/surok
surok.py opt/surok