8
class BundleTest(unittest.TestCase):
9
""" Create a class for testing the charm in the unit test framework. """
12
""" Set up an amulet deployment using the bundle. """
13
d = amulet.Deployment(series='trusty')
14
d.add('apache2', os.path.join(os.path.dirname(__file__), os.pardir))
17
cls.unit = d.sentry.unit['apache2/0']
18
output, code = cls.unit.run('curl localhost')
20
def assert_mpm(self, mpm):
21
cmd = (". /etc/apache2/envvars && apache2 -V 2>/dev/null "
22
"| grep MPM | awk -F: '{print $2}' | xargs")
23
self.d.configure('apache2', {'mpm_type': mpm})
25
# the above doesn't seem to work
27
# enable default web site so we can check for a valid config
28
output, code = self.unit.run(
29
'a2ensite 000-default.conf && service apache2 reload')
31
# enable default web site so we can check for a valid config
32
output, code = self.unit.run(cmd)
33
self.assertEqual(code, 0)
34
self.assertIn(mpm, output)
35
output, code = self.unit.run('curl localhost')
37
raise Exception(output)
38
self.assertEqual(code, 0)
40
def test_mpm_worker(self):
41
self.assert_mpm('worker')
43
def test_mpm_prefork(self):
44
self.assert_mpm('prefork')
46
def test_mpm_event(self):
47
self.assert_mpm('event')
50
if __name__ == '__main__':