10
wait_for_page_contents,
17
18
juju = command('juju')
20
def make_charm_config_file(charm_config):
21
charm_config_file = tempfile.NamedTemporaryFile()
22
charm_config_file.write(yaml.dump(charm_config))
23
charm_config_file.flush()
24
# The NamedTemporaryFile instance is returned instead of just the name
25
# because we want to take advantage of garbage collection-triggered
26
# deletion of the temp file when it goes out of scope in the caller.
27
return charm_config_file
30
def deploy(charm_config):
31
charm_config_file = make_charm_config_file(charm_config)
32
juju('deploy', 'buildbot-master', '--config='+charm_config_file.name)
33
wait_for_unit('buildbot-master')
34
addr = unit_info('buildbot-master', 'public-address')
35
url = 'http://{}:8010'.format(addr)
36
wait_for_page_contents(url, 'Welcome to the Buildbot')
19
39
class TestCharm(unittest.TestCase):
21
41
def tearDown(self):
30
50
self.assertEqual(unit_info('buildbot-master', 'state'), 'started')
32
52
def test_port_opened(self):
33
juju('deploy', 'buildbot-master')
34
juju('set', 'buildbot-master', 'extra-packages=git')
35
config_path = os.path.join(os.path.dirname(__file__), 'test.cfg')
36
config = encode_file(config_path)
37
juju('set', 'buildbot-master', 'config-file='+config)
38
wait_for_unit('buildbot-master')
39
addr = unit_info('buildbot-master', 'public-address')
41
page = urllib2.urlopen('http://{}:8010'.format(addr)).read()
42
except urllib2.URLError:
43
self.fail('could not fetch buildbot master status page')
44
self.assertIn('Welcome to the Buildbot', page)
53
# Deploying a buildbot master should result in it opening a port and
54
# serving its status via HTTP.
55
bb_config_path = os.path.join(os.path.dirname(__file__), 'test.cfg')
58
'extra-packages': 'git',
59
'installdir': '/tmp/buildbot',
60
'config-file': encode_file(bb_config_path),
64
def test_lpbuildbot(self):
65
# Deploying a Launchpad-specific buildbot master does a good job of
66
# exercising the configuration parameters. For example, the
67
# configuration in this test adds a repositroy (lucid main universe),
68
# installs a non-default buildbot package, and fetches the buildbot
69
# configuration from bzr.
72
'buildbot-pkg': 'buildbot/lucid',
73
'config-transport': 'bzr',
75
'http://bazaar.launchpad.net/~launchpad/lpbuildbot/public',
77
'deb http://us.archive.ubuntu.com/ubuntu/'
78
' lucid main universe',
79
'installdir': '/var/lib/buildbot/masters/lpbuildbot',
47
84
if __name__ == '__main__':