3 # Copyright (C) 2015 SUSE LINUX GmbH
4 # Copyright (C) 2015 <contact@redhat.com>
6 # Author: Owen Synge <osynge@suse.com>
7 # Author: Loic Dachary <loic@dachary.org>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU Library Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU Library Public License for more details.
24 from ceph_detect_init import main
26 logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
31 name = 'ceph-detect-init-' + os
32 shutil.rmtree(name, ignore_errors=True)
34 docker build -t {name} --file integration/{os}.dockerfile .
35 toplevel=$(git rev-parse --show-toplevel)
37 cat > {name}/try.sh <<EOF
40 pip install -r requirements.txt
41 python setup.py install
42 ceph-detect-init > {name}/init
45 docker run -v $toplevel:$toplevel -w $(pwd) --user $(id -u) {name} bash -x {name}/try.sh
48 subprocess.check_call(script, shell=True)
49 init = open(name + '/init').read().strip()
54 class TestCephDetectInit(testtools.TestCase):
56 def test_alpine_3_4(self):
57 self.assertEqual('openrc', run('alpine-3.4'))
59 def test_centos_6(self):
60 self.assertEqual('sysvinit', run('centos-6'))
62 def test_centos_7(self):
63 self.assertEqual('sysvinit', run('centos-7'))
65 def test_ubuntu_12_04(self):
66 self.assertEqual('upstart', run('ubuntu-12.04'))
68 def test_ubuntu_14_04(self):
69 self.assertEqual('upstart', run('ubuntu-14.04'))
71 def test_ubuntu_15_04(self):
72 self.assertEqual('upstart', run('ubuntu-15.04'))
74 def test_debian_squeeze(self):
75 self.assertEqual('sysvinit', run('debian-squeeze'))
77 def test_debian_wheezy(self):
78 self.assertEqual('sysvinit', run('debian-wheezy'))
80 def test_debian_jessie(self):
81 self.assertEqual('sysvinit', run('debian-jessie'))
83 def test_debian_sid(self):
84 self.assertEqual('sysvinit', run('debian-sid'))
86 def test_fedora_21(self):
87 self.assertEqual('sysvinit', run('fedora-21'))
89 def test_opensuse_13_1(self):
90 self.assertEqual('systemd', run('opensuse-13.1'))
92 def test_opensuse_13_2(self):
93 self.assertEqual('systemd', run('opensuse-13.2'))
96 # compile-command: "cd .. ; .tox/py27/bin/py.test integration/test_main.py"