Merge lp:~stub/charms/precise/postgresql/test-upgrade-charm into lp:charms/postgresql

Proposed by Stuart Bishop
Status: Merged
Merge reported by: Marco Ceppi
Merged at revision: not available
Proposed branch: lp:~stub/charms/precise/postgresql/test-upgrade-charm
Merge into: lp:charms/postgresql
Prerequisite: lp:~stub/charms/precise/postgresql/wal-e
Diff against target: 77 lines (+28/-2)
2 files modified
hooks/hooks.py (+4/-0)
test.py (+24/-2)
To merge this branch: bzr merge lp:~stub/charms/precise/postgresql/test-upgrade-charm
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Needs Fixing
charmers Pending
Review via email: mp+229914@code.launchpad.net

Description of the change

I've been trying to track down a weird state I've seen. This test failed to find it, since it passes, but it is a useful test to keep. It simply confirms that 'juju upgrade-charm' keeps the existing database intact. It doesn't test upgrades from old versions of the charm, which will be mojo jobs.

To post a comment you must log in.
156. By Stuart Bishop

Merged wal-e into test-upgrade-charm.

157. By Stuart Bishop

Merged wal-e into test-upgrade-charm.

158. By Stuart Bishop

Merged wal-e into test-upgrade-charm.

159. By Stuart Bishop

Merged wal-e into test-upgrade-charm.

160. By Stuart Bishop

Merged wal-e into test-upgrade-charm.

Revision history for this message
Whit Morriss (whitmo) wrote :
Revision history for this message
Review Queue (review-queue) wrote :

This items has failed automated testing! Results available here http://reports.vapour.ws/charm-tests/charm-bundle-test-1037-results

review: Needs Fixing (automated testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2014-08-27 12:56:34 +0000
3+++ hooks/hooks.py 2014-08-27 12:56:34 +0000
4@@ -145,6 +145,7 @@
5 for relid in hookenv.relation_ids('replication'):
6 hookenv.relation_set(relid, replication_state)
7
8+ log('saving local state', DEBUG)
9 self.save()
10
11
12@@ -1125,11 +1126,13 @@
13 config_data = hookenv.config()
14 update_repos_and_packages()
15 if not 'state' in local_state:
16+ log('state not in {}'.format(local_state.keys()), DEBUG)
17 # Fresh installation. Because this function is invoked by both
18 # the install hook and the upgrade-charm hook, we need to guard
19 # any non-idempotent setup. We should probably fix this; it
20 # seems rather fragile.
21 local_state.setdefault('state', 'standalone')
22+ log(repr(local_state.keys()), DEBUG)
23
24 # Drop the cluster created when the postgresql package was
25 # installed, and rebuild it with the requested locale and encoding.
26@@ -1149,6 +1152,7 @@
27 'allocated port {!r} != {!r}'.format(
28 get_service_port(), config_data['listen_port']))
29 local_state['port'] = get_service_port()
30+ log('publishing state', DEBUG)
31 local_state.publish()
32
33 postgresql_backups_dir = (
34
35=== modified file 'test.py'
36--- test.py 2014-08-27 12:56:34 +0000
37+++ test.py 2014-08-27 12:56:34 +0000
38@@ -302,8 +302,9 @@
39 if postgres_unit in full_rel_info[rel_name][rel_id]:
40 rel_info = full_rel_info[rel_name][rel_id][postgres_unit]
41 break
42- assert rel_info is not None, 'Unable to find pg rel info {!r}'.format(
43- full_rel_info[rel_name])
44+ assert rel_info is not None, (
45+ 'Unable to find pg rel info {} {!r}'.format(
46+ postgres_unit, full_rel_info[rel_name]))
47
48 if dbname is None:
49 dbname = rel_info['database']
50@@ -864,6 +865,27 @@
51 'rsyslog' not in status['services'], 'rsyslog failed to die')
52 self.wait_until_ready(pg_units)
53
54+ def test_upgrade_charm(self):
55+ self.juju.deploy(
56+ TEST_CHARM, 'postgresql', num_units=2, config=self.pg_config)
57+ self.juju.deploy(PSQL_CHARM, 'psql')
58+ self.juju.do(['add-relation', 'postgresql:db', 'psql:db'])
59+ pg_units = ['postgresql/0', 'postgresql/1']
60+ self.wait_until_ready(pg_units)
61+
62+ # Create something
63+ self.sql("CREATE TABLE Foo AS SELECT TRUE", 'master')
64+
65+ # Kick off the upgrade-charm hook
66+ self.juju.do(['upgrade-charm', 'postgresql'])
67+ self.wait_until_ready(pg_units)
68+
69+ # Ensure that our data has perservered.
70+ master_data = self.sql('SELECT * FROM Foo', 'master')[0][0]
71+ self.assertTrue(master_data)
72+ standby_data = self.sql('SELECT * FROM Foo', 'hot standby')[0][0]
73+ self.assertTrue(standby_data)
74+
75
76 class PG91Tests(
77 PostgreSQLCharmBaseTestCase,

Subscribers

People subscribed via source and target branches