File add-docker-integration-testing.diff of Package cobbler
diff --git a/.travis.yml b/.travis.yml
index 2f0693675..55929601c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,32 +1,23 @@
-language: python
-python:
- - "3.6"
+dist: xenial
+language: generic
+sudo: required
+services:
+ - docker
branches:
- only:
- - master
+ only:
+ - master
addons:
apt:
- packages:
- - python3-pip
- - apache2
- - apache2-dev
- - acl
- - libapache2-mod-wsgi-py3
- - ipmitool
- - rsync
- - fence-agents
- - genders
- # mkisofs is not available on ubuntu
- - genisoimage
-install:
- # Disable venv and use root for installation.
- - deactivate
- - sudo pip3 install --upgrade pip
- - sudo pip3 install --upgrade --force-reinstall setuptools
- - sudo pip3 install -r requirements-test.txt --ignore-installed six
- - sudo python3 setup.py build
- - sudo python3 setup.py install
+ packages:
+ - python3
+ - python3-pip
before_script:
- - pyflakes *.py cobbler/*.py cobbler/modules/*.py cobbler/web/*.py cobbler/web/templatetags/*.py bin/cobbler* bin/*.py web/cobbler.wsgi
- - pycodestyle -r --ignore E501,E402,E722 *.py cobbler/*.py cobbler/modules/*.py cobbler/web/*.py cobbler/web/templatetags/*.py bin/cobbler* bin/*.py web/cobbler.wsgi
-script: pytest
+ - pip3 install pyflakes pycodestyle
+ - pyflakes *.py cobbler/*.py cobbler/modules/*.py cobbler/web/*.py cobbler/web/templatetags/*.py bin/cobbler* bin/*.py web/cobbler.wsgi
+ - pycodestyle -r --ignore E501,E402,E722 *.py cobbler/*.py cobbler/modules/*.py cobbler/web/*.py cobbler/web/templatetags/*.py bin/cobbler* bin/*.py web/cobbler.wsgi
+script:
+ - docker build -t cobbler .
+ - docker run -d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name cobbler cobbler
+ - sleep 30
+ - docker logs cobbler
+ - docker exec -u 0 -it cobbler bash -c pytest
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..6dd1b0c52
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,15 @@
+# WARNING! This is not in any way production ready. It is just for testing!
+
+FROM opensuse/leap:15
+
+ENV container docker
+
+WORKDIR /test_dir
+COPY . /test_dir
+
+VOLUME [ "/sys/fs/cgroup" ]
+
+RUN tests/setup-test-docker.sh
+
+# Set this as an entrypoint
+CMD ["/usr/lib/systemd/systemd", "--system"]
diff --git a/setup.py b/setup.py
index 06e2d1991..51c5306c7 100644
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,7 @@
import time
import logging
import glob as _glob
+import distro
from builtins import str
from setuptools import setup
@@ -507,17 +508,6 @@ def run(self):
self._copy(os.path.join(etcpath, 'rsync.template'), self.statepath)
-def parse_os_release():
- out = {}
- osreleasepath = "/etc/os-release"
- if os.path.exists(osreleasepath):
- with open(osreleasepath, 'r') as os_release:
- out.update(
- [[it.strip('"\n') for it in line.split('=', 1)] for line in [line for line in os_release if not line.startswith('#') and '=' in line]]
- )
- return out
-
-
def requires(filename):
"""Returns a list of all pip requirements
Source of this function: https://github.com/tomschr/leo/blob/develop/setup.py
@@ -553,11 +543,9 @@ def requires(filename):
logpath = "/var/log/"
statepath = "/tmp/cobbler_settings/devinstall"
httpd_service = "httpd.service"
- os_release = parse_os_release()
- suse_release = (
- os.path.exists("/etc/SuSE-release") or os_release.get('ID_LIKE', '').lower() == 'suse'
- )
-
+ os_release = distro.linux_distribution()[0].lower().strip()
+ suse_release = ("suse" in os_release)
+
if suse_release:
webconfig = "/etc/apache2/conf.d"
webroot = "/srv/www/"
@@ -636,10 +624,10 @@ def requires(filename):
("%s" % webconfig, ["build/config/apache/cobbler_web.conf"]),
("%s" % initpath, ["build/config/service/cobblerd"]),
("%s" % docpath, glob("build/docs/man/*.1.gz")),
- ("%s/templates" % libpath, glob("autoinstall_templates/*")),
- ("%s/templates/install_profiles" % libpath, glob("autoinstall_templates/install_profiles/*")),
- ("%s/snippets" % libpath, glob("autoinstall_snippets/*", recursive=True)),
- ("%s/scripts" % libpath, glob("autoinstall_scripts/*")),
+ ("%stemplates" % libpath, glob("autoinstall_templates/*")),
+ ("%stemplates/install_profiles" % libpath, glob("autoinstall_templates/install_profiles/*")),
+ ("%ssnippets" % libpath, glob("autoinstall_snippets/*", recursive=True)),
+ ("%sscripts" % libpath, glob("autoinstall_scripts/*")),
("%s" % libpath, ["config/cobbler/distro_signatures.json"]),
("share/cobbler/web", glob("web/*.*")),
("%s" % webcontent, glob("web/static/*")),
diff --git a/tests/setup-test-docker.sh b/tests/setup-test-docker.sh
new file mode 100755
index 000000000..688cab5f4
--- /dev/null
+++ b/tests/setup-test-docker.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/bash
+
+# SystemD stuff (needs insserv additionally)
+zypper -n install systemd insserv; zypper clean
+cd /usr/lib/systemd/system/sysinit.target.wants/
+for i in *; do
+ [[ ${i} == systemd-tmpfiles-setup.service ]] || rm -f ${i};
+done
+rm -f /usr/lib/systemd/system/multi-user.target.wants/*
+rm -f /etc/systemd/system/*.wants/*
+rm -f /usr/lib/systemd/system/local-fs.target.wants/*
+rm -f /usr/lib/systemd/system/sockets.target.wants/*udev*
+rm -f /usr/lib/systemd/system/sockets.target.wants/*initctl*
+rm -f /usr/lib/systemd/system/basic.target.wants/*
+rm -f /usr/lib/systemd/system/anaconda.target.wants/*
+
+cd /test_dir
+
+# Packages for running cobbler
+zypper -n update
+zypper -n in python3 python3-devel python3-pip apache2 apache2-devel acl apache2-mod_wsgi-python3 ipmitool rsync fence-agents genders mkisofs python3-ldap tftp
+# Packages for building & installing cobbler from source
+zypper -n in make gzip
+
+# Install and upgrade all dependecys
+pip3 install --upgrade pip
+pip3 install -r requirements-test.txt
+
+# Install cobbler
+make install
+cp /etc/cobbler/cobblerd.service /usr/lib/systemd/system/cobblerd.service
+cp /etc/cobbler/cobbler.conf /etc/apache2/conf.d/
+
+# Enable the services
+systemctl enable cobblerd apache2 tftp
+a2enmod version
+a2enmod proxy
+a2enmod proxy_http
\ No newline at end of file