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
=== modified file 'unit_tests/test_nova_cc_utils.py'
--- unit_tests/test_nova_cc_utils.py 2014-03-31 11:56:09 +0000
+++ unit_tests/test_nova_cc_utils.py 2014-04-09 15:14:19 +0000
@@ -13,17 +13,29 @@
13hookenv.config = _conf13hookenv.config = _conf
1414
15TO_PATCH = [15TO_PATCH = [
16 'apt_update',
17 'apt_upgrade',
18 'apt_install',
16 'config',19 'config',
20 'configure_installation_source',
21 'disable_policy_rcd',
22 'eligible_leader',
23 'enable_policy_rcd',
24 'get_os_codename_install_source',
17 'log',25 'log',
26 'ml2_migration',
18 'network_manager',27 'network_manager',
28 'neutron_db_manage',
19 'neutron_plugin',29 'neutron_plugin',
20 'neutron_plugin_attribute',30 'neutron_plugin_attribute',
21 'os_release',31 'os_release',
32 'register_configs',
22 'relation_ids',33 'relation_ids',
23 'remote_unit',34 'remote_unit',
24 '_save_script_rc',35 '_save_script_rc',
25 'service_stop',36 'service_stop',
26 'service_start'37 'service_start',
38 'services'
27]39]
2840
29SCRIPTRC_ENV_VARS = {41SCRIPTRC_ENV_VARS = {
@@ -105,6 +117,12 @@
105}117}
106118
107119
120DPKG_OPTS = [
121 '--option', 'Dpkg::Options::=--force-confnew',
122 '--option', 'Dpkg::Options::=--force-confdef',
123]
124
125
108def fake_plugin_attribute(plugin, attr, net_manager):126def fake_plugin_attribute(plugin, attr, net_manager):
109 if plugin in PLUGIN_ATTRIBUTES:127 if plugin in PLUGIN_ATTRIBUTES:
110 try:128 try:
@@ -458,3 +476,84 @@
458 _known_hosts.assert_called_with(None)476 _known_hosts.assert_called_with(None)
459 utils.remove_known_host('test', 'bar')477 utils.remove_known_host('test', 'bar')
460 _known_hosts.assert_called_with('bar')478 _known_hosts.assert_called_with('bar')
479
480
481 @patch('subprocess.check_output')
482 def test_migrate_database(self, check_output):
483 "Migrate database with nova-manage"
484 utils.migrate_database()
485 check_output.assert_called_with(['nova-manage', 'db', 'sync'])
486
487
488 @patch.object(utils, 'get_step_upgrade_source')
489 @patch.object(utils, 'migrate_database')
490 @patch.object(utils, 'determine_packages')
491 def test_upgrade_grizzly_icehouse(self, determine_packages,
492 migrate_database,
493 get_step_upgrade_source):
494 "Simulate a call to do_openstack_upgrade() for grizzly->icehouse"
495 get_step_upgrade_source.return_value = 'cloud:precise-havana'
496 self.os_release.side_effect = ['grizzly', 'havana']
497 self.get_os_codename_install_source.side_effect = ['havana', 'icehouse']
498 self.eligible_leader.return_value = True
499 utils.do_openstack_upgrade()
500 expected = [call(['stamp', 'grizzly']), call(['upgrade', 'head']),
501 call(['upgrade', 'head'])]
502 self.assertEquals(utils.neutron_db_manage.call_args_list, expected)
503 self.apt_update.assert_called_with(fatal=True)
504 self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
505 dist=True)
506 self.apt_install.assert_called_with(determine_packages(), fatal=True)
507 expected = [call(release='havana'), call(release='icehouse')]
508 self.assertEquals(utils.register_configs.call_args_list, expected)
509 self.assertEquals(utils.ml2_migration.call_count, 1)
510 self.assertTrue(migrate_database.call_count, 2)
511
512
513 @patch.object(utils, 'get_step_upgrade_source')
514 @patch.object(utils, 'migrate_database')
515 @patch.object(utils, 'determine_packages')
516 def test_upgrade_havana_icehouse(self, determine_packages,
517 migrate_database,
518 get_step_upgrade_source):
519 "Simulate a call to do_openstack_upgrade() for havana->icehouse"
520 get_step_upgrade_source.return_value = None
521 self.os_release.return_value = 'havana'
522 self.get_os_codename_install_source.return_value = 'icehouse'
523 self.eligible_leader.return_value = True
524 utils.do_openstack_upgrade()
525 utils.neutron_db_manage.assert_called_with(['upgrade', 'head'])
526 self.apt_update.assert_called_with(fatal=True)
527 self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
528 dist=True)
529 self.apt_install.assert_called_with(determine_packages(), fatal=True)
530 utils.register_configs.assert_called_with(release='icehouse')
531 self.assertEquals(utils.ml2_migration.call_count, 1)
532 self.assertTrue(migrate_database.call_count, 1)
533
534
535 @patch.object(utils, '_do_openstack_upgrade')
536 def test_ugrade_grizzly_icehouse_source(self, _do_openstack_upgrade):
537 "Verify get_step_upgrade_source() for grizzly->icehouse"
538 self.config.side_effect = None
539 self.config.return_value = 'cloud:precise-icehouse'
540 with patch_open() as (_open, _file):
541 _file.read = MagicMock()
542 _file.readline.return_value = "deb url precise-updates/grizzly main"
543 utils.do_openstack_upgrade()
544 expected = [call('cloud:precise-havana'),
545 call('cloud:precise-icehouse')]
546 self.assertEquals(_do_openstack_upgrade.call_args_list, expected)
547
548
549 @patch.object(utils, '_do_openstack_upgrade')
550 def test_ugrade_havana_icehouse_source(self, _do_openstack_upgrade):
551 "Verify get_step_upgrade_source() for havana->icehouse"
552 self.config.side_effect = None
553 self.config.return_value = 'cloud:precise-icehouse'
554 with patch_open() as (_open, _file):
555 _file.read = MagicMock()
556 _file.readline.return_value = "deb url precise-updates/havana main"
557 utils.do_openstack_upgrade()
558 expected = [call('cloud:precise-icehouse')]
559 self.assertEquals(_do_openstack_upgrade.call_args_list, expected)

Subscribers

People subscribed via source and target branches

to all changes: