Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(811)

Side by Side Diff: charmworld/migrations/versions/tests/test_migrations.py

Issue 90300043: Fix 026 exodus.
Patch Set: Created 10 years, 12 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « charmworld/migrations/versions/026_convert_comma_constraints.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2012, 2013 Canonical Ltd. This software is licensed under the 1 # Copyright 2012, 2013 Canonical Ltd. This software is licensed under the
2 # GNU Affero General Public License version 3 (see the file LICENSE). 2 # GNU Affero General Public License version 3 (see the file LICENSE).
3 3
4 from charmworld.models import ( 4 from charmworld.models import (
5 CharmSource, 5 CharmSource,
6 ) 6 )
7 from charmworld.testing import ( 7 from charmworld.testing import (
8 factory, 8 factory,
9 MongoTestBase, 9 MongoTestBase,
10 ) 10 )
(...skipping 28 matching lines...) Expand all
39 exodus_update = self.versions.get_exodus( 39 exodus_update = self.versions.get_exodus(
40 self.exodus) 40 self.exodus)
41 target = self.versions.get_pending_source(source, self.version) 41 target = self.versions.get_pending_source(source, self.version)
42 target_db = target.collection.database 42 target_db = target.collection.database
43 services = dict( 43 services = dict(
44 svc1=dict(constraints='cpu-cores=4,mem=2G,arch=i686'), 44 svc1=dict(constraints='cpu-cores=4,mem=2G,arch=i686'),
45 svc2=dict(constraints='cpu-cores=44 arch=i386 mem=9G'), 45 svc2=dict(constraints='cpu-cores=44 arch=i386 mem=9G'),
46 ) 46 )
47 self.assertEqual(0, source_db.bundles.count()) 47 self.assertEqual(0, source_db.bundles.count())
48 self.assertEqual(0, target_db.bundles.count()) 48 self.assertEqual(0, target_db.bundles.count())
49 bundle, bundle_data = factory.make_bundle( 49 _, bundle_data = factory.make_bundle(source_db, services=services)
50 source_db, services=services) 50 # Add in 'inherits' property to exercise its deletion.
51 bundle_data['data']['inherits'] = 'super-charm'
52 source_db.bundles.save(bundle_data)
51 self.assertEqual(1, source_db.bundles.count()) 53 self.assertEqual(1, source_db.bundles.count())
52 self.assertEqual(1, target_db.bundles.count()) 54 self.assertEqual(1, target_db.bundles.count())
53 55
54 # Run the exodus. 56 # Run the exodus.
55 exodus_update(source, target, self.version) 57 exodus_update(source, target, self.version)
56 # Ensure there is still just the one bundle. 58 # Ensure there is still just the one bundle.
57 self.assertEqual(1, target_db.bundles.count()) 59 self.assertEqual(1, target_db.bundles.count())
58 converted = target_db.bundles.find_one() 60 converted = target_db.bundles.find_one()
59 services = converted['data']['services'] 61 services = converted['data']['services']
60 # Constraints are now space-separated and sorted. 62 # Constraints are now space-separated and sorted.
61 self.assertEqual(services['svc1']['constraints'], 63 self.assertEqual(services['svc1']['constraints'],
62 'arch=i686 cpu-cores=4 mem=2G') 64 'arch=i686 cpu-cores=4 mem=2G')
63 self.assertEqual(services['svc2']['constraints'], 65 self.assertEqual(services['svc2']['constraints'],
64 'arch=i386 cpu-cores=44 mem=9G') 66 'arch=i386 cpu-cores=44 mem=9G')
65 67
66 68
67 class TestExodusRestrictions(MigrationTestBase): 69 class TestExodusRestrictions(MigrationTestBase):
68 70
69 def test_exodus_restrictions(self): 71 def test_exodus_restrictions(self):
70 """Ensure that deploy-from-scratch does not violate exodus rules.""" 72 """Ensure that deploy-from-scratch does not violate exodus rules."""
71 self.versions._check_exodus(self.versions.list_pending(0)) 73 self.versions._check_exodus(self.versions.list_pending(0))
OLDNEW
« no previous file with comments | « charmworld/migrations/versions/026_convert_comma_constraints.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b