yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00409
lp:~benji/charms/oneiric/buildbot-master/tests-with-config-up-front into lp:~yellow/charms/oneiric/buildbot-master/trunk
Benji York has proposed merging lp:~benji/charms/oneiric/buildbot-master/tests-with-config-up-front into lp:~yellow/charms/oneiric/buildbot-master/trunk.
Requested reviews:
Launchpad Yellow Squad (yellow)
For more details, see:
https://code.launchpad.net/~benji/charms/oneiric/buildbot-master/tests-with-config-up-front/+merge/92377
This branch adds tests for the configure-things-up-front scenario.
All the configuration options for the buildbot-master should be covered
now except for config-user and config-private-key, both of which I
/think/ can go away.
Tests pass:
% python hooks/tests.py
..............
----------------------------------------------------------------------
Ran 14 tests in 0.047s
% RESOLVE_TEST_CHARMS=1 tests/buildbot-master.test; beep
...
----------------------------------------------------------------------
Ran 3 tests in 119.182s
--
https://code.launchpad.net/~benji/charms/oneiric/buildbot-master/tests-with-config-up-front/+merge/92377
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~benji/charms/oneiric/buildbot-master/tests-with-config-up-front into lp:~yellow/charms/oneiric/buildbot-master/trunk.
=== modified file 'tests/buildbot-master.test'
--- tests/buildbot-master.test 2012-02-08 22:01:59 +0000
+++ tests/buildbot-master.test 2012-02-09 21:57:17 +0000
@@ -7,15 +7,32 @@
encode_file,
run,
unit_info,
+ wait_for_page_contents,
wait_for_unit,
)
-import base64
import os.path
+import tempfile
import unittest
-import urllib2
+import yaml
juju = command('juju')
+def make_charm_config_file(charm_config):
+ charm_config_file = tempfile.NamedTemporaryFile()
+ charm_config_file.write(yaml.dump(charm_config))
+ charm_config_file.flush()
+ return charm_config_file
+
+
+def deploy(charm_config):
+ charm_config_file = make_charm_config_file(charm_config)
+ juju('deploy', 'buildbot-master', '--config='+charm_config_file.name)
+ wait_for_unit('buildbot-master')
+ addr = unit_info('buildbot-master', 'public-address')
+ url = 'http://{}:8010'.format(addr)
+ wait_for_page_contents(url, 'Welcome to the Buildbot')
+
+
class TestCharm(unittest.TestCase):
def tearDown(self):
@@ -30,18 +47,35 @@
self.assertEqual(unit_info('buildbot-master', 'state'), 'started')
def test_port_opened(self):
- juju('deploy', 'buildbot-master')
- juju('set', 'buildbot-master', 'extra-packages=git')
- config_path = os.path.join(os.path.dirname(__file__), 'test.cfg')
- config = encode_file(config_path)
- juju('set', 'buildbot-master', 'config-file='+config)
- wait_for_unit('buildbot-master')
- addr = unit_info('buildbot-master', 'public-address')
- try:
- page = urllib2.urlopen('http://{}:8010'.format(addr)).read()
- except urllib2.URLError:
- self.fail('could not fetch buildbot master status page')
- self.assertIn('Welcome to the Buildbot', page)
+ # Deploying a buildbot master should result in it opening a port and
+ # serving its status via HTTP.
+ bb_config_path = os.path.join(os.path.dirname(__file__), 'test.cfg')
+ charm_config = {
+ 'buildbot-master': {
+ 'extra-packages': 'git',
+ 'installdir': '/tmp/buildbot',
+ 'config-file': encode_file(bb_config_path),
+ }}
+ deploy(charm_config)
+
+ def test_lpbuildbot(self):
+ # Deploying a Launchpad-specific buildbot master does a good job of
+ # exercising the configuration parameters. For example, the
+ # configuration in this test adds a repositroy (lucid main universe),
+ # installs a non-default buildbot package, and fetches the buildbot
+ # configuration from bzr.
+ charm_config = {
+ 'buildbot-master': {
+ 'buildbot-pkg': 'buildbot/lucid',
+ 'config-transport': 'bzr',
+ 'config-url':
+ 'http://bazaar.launchpad.net/~launchpad/lpbuildbot/public',
+ 'extra-repository':
+ 'deb http://us.archive.ubuntu.com/ubuntu/'
+ ' lucid main universe',
+ 'installdir': '/var/lib/buildbot/masters/lpbuildbot',
+ }}
+ deploy(charm_config)
if __name__ == '__main__':
Follow ups