Merge lp:~corey.bryant/charms/precise/nova-cloud-controller/migration-tests into lp:~openstack-charmers/charms/precise/nova-cloud-controller/icehouse

Proposed by Corey Bryant
Status: Merged
Merged at revision: 113
Proposed branch: lp:~corey.bryant/charms/precise/nova-cloud-controller/migration-tests
Merge into: lp:~openstack-charmers/charms/precise/nova-cloud-controller/icehouse
Diff against target: 132 lines (+100/-1)
1 file modified
unit_tests/test_nova_cc_utils.py (+100/-1)
To merge this branch: bzr merge lp:~corey.bryant/charms/precise/nova-cloud-controller/migration-tests
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+214969@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unit_tests/test_nova_cc_utils.py'
2--- unit_tests/test_nova_cc_utils.py 2014-03-31 11:56:09 +0000
3+++ unit_tests/test_nova_cc_utils.py 2014-04-09 15:14:19 +0000
4@@ -13,17 +13,29 @@
5 hookenv.config = _conf
6
7 TO_PATCH = [
8+ 'apt_update',
9+ 'apt_upgrade',
10+ 'apt_install',
11 'config',
12+ 'configure_installation_source',
13+ 'disable_policy_rcd',
14+ 'eligible_leader',
15+ 'enable_policy_rcd',
16+ 'get_os_codename_install_source',
17 'log',
18+ 'ml2_migration',
19 'network_manager',
20+ 'neutron_db_manage',
21 'neutron_plugin',
22 'neutron_plugin_attribute',
23 'os_release',
24+ 'register_configs',
25 'relation_ids',
26 'remote_unit',
27 '_save_script_rc',
28 'service_stop',
29- 'service_start'
30+ 'service_start',
31+ 'services'
32 ]
33
34 SCRIPTRC_ENV_VARS = {
35@@ -105,6 +117,12 @@
36 }
37
38
39+DPKG_OPTS = [
40+ '--option', 'Dpkg::Options::=--force-confnew',
41+ '--option', 'Dpkg::Options::=--force-confdef',
42+]
43+
44+
45 def fake_plugin_attribute(plugin, attr, net_manager):
46 if plugin in PLUGIN_ATTRIBUTES:
47 try:
48@@ -458,3 +476,84 @@
49 _known_hosts.assert_called_with(None)
50 utils.remove_known_host('test', 'bar')
51 _known_hosts.assert_called_with('bar')
52+
53+
54+ @patch('subprocess.check_output')
55+ def test_migrate_database(self, check_output):
56+ "Migrate database with nova-manage"
57+ utils.migrate_database()
58+ check_output.assert_called_with(['nova-manage', 'db', 'sync'])
59+
60+
61+ @patch.object(utils, 'get_step_upgrade_source')
62+ @patch.object(utils, 'migrate_database')
63+ @patch.object(utils, 'determine_packages')
64+ def test_upgrade_grizzly_icehouse(self, determine_packages,
65+ migrate_database,
66+ get_step_upgrade_source):
67+ "Simulate a call to do_openstack_upgrade() for grizzly->icehouse"
68+ get_step_upgrade_source.return_value = 'cloud:precise-havana'
69+ self.os_release.side_effect = ['grizzly', 'havana']
70+ self.get_os_codename_install_source.side_effect = ['havana', 'icehouse']
71+ self.eligible_leader.return_value = True
72+ utils.do_openstack_upgrade()
73+ expected = [call(['stamp', 'grizzly']), call(['upgrade', 'head']),
74+ call(['upgrade', 'head'])]
75+ self.assertEquals(utils.neutron_db_manage.call_args_list, expected)
76+ self.apt_update.assert_called_with(fatal=True)
77+ self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
78+ dist=True)
79+ self.apt_install.assert_called_with(determine_packages(), fatal=True)
80+ expected = [call(release='havana'), call(release='icehouse')]
81+ self.assertEquals(utils.register_configs.call_args_list, expected)
82+ self.assertEquals(utils.ml2_migration.call_count, 1)
83+ self.assertTrue(migrate_database.call_count, 2)
84+
85+
86+ @patch.object(utils, 'get_step_upgrade_source')
87+ @patch.object(utils, 'migrate_database')
88+ @patch.object(utils, 'determine_packages')
89+ def test_upgrade_havana_icehouse(self, determine_packages,
90+ migrate_database,
91+ get_step_upgrade_source):
92+ "Simulate a call to do_openstack_upgrade() for havana->icehouse"
93+ get_step_upgrade_source.return_value = None
94+ self.os_release.return_value = 'havana'
95+ self.get_os_codename_install_source.return_value = 'icehouse'
96+ self.eligible_leader.return_value = True
97+ utils.do_openstack_upgrade()
98+ utils.neutron_db_manage.assert_called_with(['upgrade', 'head'])
99+ self.apt_update.assert_called_with(fatal=True)
100+ self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
101+ dist=True)
102+ self.apt_install.assert_called_with(determine_packages(), fatal=True)
103+ utils.register_configs.assert_called_with(release='icehouse')
104+ self.assertEquals(utils.ml2_migration.call_count, 1)
105+ self.assertTrue(migrate_database.call_count, 1)
106+
107+
108+ @patch.object(utils, '_do_openstack_upgrade')
109+ def test_ugrade_grizzly_icehouse_source(self, _do_openstack_upgrade):
110+ "Verify get_step_upgrade_source() for grizzly->icehouse"
111+ self.config.side_effect = None
112+ self.config.return_value = 'cloud:precise-icehouse'
113+ with patch_open() as (_open, _file):
114+ _file.read = MagicMock()
115+ _file.readline.return_value = "deb url precise-updates/grizzly main"
116+ utils.do_openstack_upgrade()
117+ expected = [call('cloud:precise-havana'),
118+ call('cloud:precise-icehouse')]
119+ self.assertEquals(_do_openstack_upgrade.call_args_list, expected)
120+
121+
122+ @patch.object(utils, '_do_openstack_upgrade')
123+ def test_ugrade_havana_icehouse_source(self, _do_openstack_upgrade):
124+ "Verify get_step_upgrade_source() for havana->icehouse"
125+ self.config.side_effect = None
126+ self.config.return_value = 'cloud:precise-icehouse'
127+ with patch_open() as (_open, _file):
128+ _file.read = MagicMock()
129+ _file.readline.return_value = "deb url precise-updates/havana main"
130+ utils.do_openstack_upgrade()
131+ expected = [call('cloud:precise-icehouse')]
132+ self.assertEquals(_do_openstack_upgrade.call_args_list, expected)

Subscribers

People subscribed via source and target branches

to all changes: