Merge lp:~abentley/charmworld/remove-018-migration into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Aaron Bentley
Approved revision: 433
Merged at revision: 431
Proposed branch: lp:~abentley/charmworld/remove-018-migration
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 102 lines (+7/-76)
2 files modified
charmworld/migrations/versions/018_delete_all_bundles.py (+0/-18)
charmworld/migrations/versions/tests/test_migrations.py (+7/-58)
To merge this branch: bzr merge lp:~abentley/charmworld/remove-018-migration
Reviewer Review Type Date Requested Status
Juju Gui Bot continuous-integration Approve
Brad Crittenden (community) code Approve
Review via email: mp+192749@code.launchpad.net

Commit message

Remove 018 migration; before an exodus and already deployed to production.

Description of the change

Remove the 018 migration so that deployment is possible.

The 019 migration is an exodus, so no migrations are permitted before it. This currently blocks new deployments.

To post a comment you must log in.
432. By Aaron Bentley on 2013-10-25

Remove tests for 018.

433. By Aaron Bentley on 2013-10-25

Add test to ensure that migrations follow exodus rules.

Brad Crittenden (bac) :
review: Approve (code)
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'charmworld/migrations/versions/018_delete_all_bundles.py'
2--- charmworld/migrations/versions/018_delete_all_bundles.py 2013-09-05 21:36:14 +0000
3+++ charmworld/migrations/versions/018_delete_all_bundles.py 1970-01-01 00:00:00 +0000
4@@ -1,18 +0,0 @@
5-# Copyright 2013 Canonical Ltd. This software is licensed under the
6-# GNU Affero General Public License version 3 (see the file LICENSE).
7-
8-from charmworld.search import (
9- BUNDLE,
10- IndexMissing,
11- translate_error,
12-)
13-
14-
15-def upgrade(db, index_client):
16- db.bundles.remove({}, False)
17- try:
18- with translate_error():
19- index_client._client.delete_all(index_client.index_name, BUNDLE)
20- except IndexMissing:
21- # There is nothing to migrate.
22- pass
23
24=== modified file 'charmworld/migrations/versions/tests/test_migrations.py'
25--- charmworld/migrations/versions/tests/test_migrations.py 2013-10-24 17:24:43 +0000
26+++ charmworld/migrations/versions/tests/test_migrations.py 2013-10-25 23:11:01 +0000
27@@ -31,64 +31,6 @@
28 self.use_context(mock.patch.object(migrate, 'configure_logging'))
29
30
31-class TestMigration018(MigrationTestBase):
32-
33- def setUp(self):
34- super(TestMigration018, self).setUp()
35- self.use_index_client()
36- self.store_some_bundles()
37-
38- def store_some_bundles(self):
39- deployer_config = textwrap.dedent("""\
40- wordpress-stage:
41- series: precise
42- services:
43- blog:
44- charm: cs:precise/wordpress
45- constraints: mem=2
46- options:
47- tuning: optimized
48- engine: apache
49- """)
50- parsed = yaml.safe_load(deployer_config)
51- owner = 'owner'
52- bundle_name = 'wordpress-stage'
53- basket_name = 'wordpress-basket'
54- basket_rev = 3
55- basket_id = "%s/%d" % (basket_name, basket_rev)
56- self.search_id = Bundle.construct_id(
57- owner, basket_name, bundle_name)
58- store_bundles(
59- self.db.bundles, parsed, owner, basket_id,
60- None, None, None, None,
61- index_client=self.index_client)
62-
63- def test_bundles_are_removed_from_elastic_search(self):
64- assert self.index_client.get(self.search_id, BUNDLE), (
65- 'the test bundle is missing')
66- self.versions.run_migration(
67- self.db, self.index_client, '018_delete_all_bundles.py')
68- self.assertIsNone(self.index_client.get(self.search_id, BUNDLE))
69-
70- def test_bundles_are_removed_from_mongo(self):
71- assert self.index_client.get(self.search_id, BUNDLE), (
72- 'the test bundle is missing')
73- self.versions.run_migration(
74- self.db, self.index_client, '018_delete_all_bundles.py')
75- self.assertIsNone(self.db.bundles.find_one({}))
76-
77- def test_new_db_and_index_are_noop(self):
78- # The migration script survives MIssingIndex errors.
79- # New installs don't have ES indexes yet.
80- self.index_client.delete_index()
81- with self.assertRaises(IndexMissing):
82- self.index_client.get_status()
83- self.versions.run_migration(
84- self.db, self.index_client, '018_delete_all_bundles.py')
85- # Put the index back for the test case to handle.
86- self.index_client.create_index()
87-
88-
89 class TestMigration019(MigrationTestBase):
90
91 def setUp(self):
92@@ -166,3 +108,10 @@
93 self.versions.run_migration,
94 self.db, self.index_client,
95 '020_adds_type_field_to_existing_review_items.py')
96+
97+
98+class TestExodusRestrictions(MigrationTestBase):
99+
100+ def test_exodus_restrictions(self):
101+ """Ensure that deploy-from-scratch does not violate exodus rules."""
102+ self.versions._check_exodus(self.versions.list_pending(0))

Subscribers

People subscribed via source and target branches