103
104
expect.extend(nutils.KILO_PACKAGES)
104
105
self.assertItemsEqual(pkg_list, expect)
107
@patch.object(nutils, 'git_install_requested')
108
def test_determine_packages_noplugin(self, git_requested):
109
git_requested.return_value = False
110
self.test_config.set('manage-neutron-plugin-legacy-mode', False)
111
pkg_list = nutils.determine_packages()
112
expect = deepcopy(nutils.BASE_PACKAGES)
113
expect.extend(['neutron-server'])
114
self.assertItemsEqual(pkg_list, expect)
106
116
def test_determine_ports(self):
107
117
port_list = nutils.determine_ports()
108
118
self.assertItemsEqual(port_list, [9696])
120
@patch.object(nutils, 'manage_plugin')
110
121
@patch('os.path.exists')
111
def test_resource_map(self, _path_exists):
122
def test_resource_map(self, _path_exists, _manage_plugin):
112
123
_path_exists.return_value = False
124
_manage_plugin.return_value = True
113
125
_map = nutils.resource_map()
114
126
confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT,
115
127
nutils.APACHE_CONF]
116
128
[self.assertIn(q_conf, _map.keys()) for q_conf in confs]
117
129
self.assertTrue(nutils.APACHE_24_CONF not in _map.keys())
131
@patch.object(nutils, 'manage_plugin')
119
132
@patch('os.path.exists')
120
def test_resource_map_apache24(self, _path_exists):
133
def test_resource_map_apache24(self, _path_exists, _manage_plugin):
121
134
_path_exists.return_value = True
135
_manage_plugin.return_value = True
122
136
_map = nutils.resource_map()
123
137
confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT,
124
138
nutils.APACHE_24_CONF]
125
139
[self.assertIn(q_conf, _map.keys()) for q_conf in confs]
126
140
self.assertTrue(nutils.APACHE_CONF not in _map.keys())
142
@patch.object(nutils, 'manage_plugin')
143
@patch('os.path.exists')
144
def test_resource_map_noplugin(self, _path_exists, _manage_plugin):
145
_path_exists.return_value = True
146
_manage_plugin.return_value = False
147
_map = nutils.resource_map()
148
found_sdn_ctxt = False
149
found_sdnconfig_ctxt = False
150
for ctxt in _map[nutils.NEUTRON_CONF]['contexts']:
151
if isinstance(ctxt, ncontext.NeutronApiSDNContext):
152
found_sdn_ctxt = True
153
for ctxt in _map[nutils.NEUTRON_DEFAULT]['contexts']:
154
if isinstance(ctxt, ncontext.NeutronApiSDNConfigFileContext):
155
found_sdnconfig_ctxt = True
156
self.assertTrue(found_sdn_ctxt and found_sdnconfig_ctxt)
128
158
@patch('os.path.exists')
129
159
def test_restart_map(self, mock_path_exists):
130
160
mock_path_exists.return_value = False
190
220
def test_do_openstack_upgrade_juno(self, git_requested,
191
221
stamp_neutron_db, migrate_neutron_db):
192
222
git_requested.return_value = False
223
self.is_elected_leader.return_value = True
193
224
self.config.side_effect = self.test_config.get
194
225
self.test_config.set('openstack-origin', 'cloud:trusty-juno')
195
226
self.os_release.return_value = 'icehouse'
256
288
stamp_neutron_db.assert_called_with('juno')
257
289
migrate_neutron_db.assert_called_with()
291
@patch.object(charmhelpers.contrib.openstack.utils,
292
'get_os_codename_install_source')
293
@patch.object(nutils, 'migrate_neutron_database')
294
@patch.object(nutils, 'stamp_neutron_database')
295
@patch.object(nutils, 'git_install_requested')
296
def test_do_openstack_upgrade_kilo_notleader(self, git_requested,
300
git_requested.return_value = False
301
self.is_elected_leader.return_value = False
302
self.os_release.return_value = 'juno'
303
self.config.side_effect = self.test_config.get
304
self.test_config.set('openstack-origin', 'cloud:trusty-kilo')
305
gsrc.return_value = 'kilo'
306
self.get_os_codename_install_source.return_value = 'kilo'
307
configs = MagicMock()
308
nutils.do_openstack_upgrade(configs)
309
self.os_release.assert_called_with('neutron-server')
310
self.log.assert_called()
311
self.configure_installation_source.assert_called_with(
314
self.apt_update.assert_called_with(fatal=True)
316
'--option', 'Dpkg::Options::=--force-confnew',
317
'--option', 'Dpkg::Options::=--force-confdef',
319
self.apt_upgrade.assert_called_with(options=dpkg_opts,
322
pkgs = nutils.determine_packages()
324
self.apt_install.assert_called_with(packages=pkgs,
327
configs.set_release.assert_called_with(openstack_release='kilo')
328
self.assertFalse(stamp_neutron_db.called)
329
self.assertFalse(migrate_neutron_db.called)
259
331
@patch.object(ncontext, 'IdentityServiceContext')
260
332
@patch('neutronclient.v2_0.client.Client')
261
333
def test_get_neutron_client(self, nclient, IdentityServiceContext):