53
62
call(_pkgs, fatal=True),
56
def test_config_changed(self):
57
self._call_hook('config-changed')
58
self.assertTrue(self.CONFIGS.write_all.called)
65
@patch.object(hooks, 'git_install_requested')
66
def test_install_hook_git(self, git_requested):
67
git_requested.return_value = True
68
_pkgs = ['foo', 'bar']
69
self.determine_packages.return_value = _pkgs
70
openstack_origin_git = {
72
{'name': 'requirements',
73
'repository': 'git://git.openstack.org/openstack/requirements', # noqa
74
'branch': 'stable/juno'},
76
'repository': 'git://git.openstack.org/openstack/neutron',
77
'branch': 'stable/juno'}
79
'directory': '/mnt/openstack-git',
81
projects_yaml = yaml.dump(openstack_origin_git)
82
self.test_config.set('openstack-origin-git', projects_yaml)
83
self._call_hook('install')
84
self.apt_update.assert_called_with()
85
self.assertTrue(self.determine_packages)
86
self.git_install.assert_called_with(projects_yaml)
88
@patch.object(hooks, 'git_install_requested')
89
def test_config_changed(self, git_requested):
90
git_requested.return_value = False
91
self.relation_ids.return_value = ['relid']
92
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
93
self._call_hook('config-changed')
94
self.assertTrue(self.CONFIGS.write_all.called)
95
self.assertTrue(_zmq_joined.called_with('relid'))
96
self.configure_ovs.assert_called_with()
98
@patch.object(hooks, 'git_install_requested')
99
@patch.object(hooks, 'config_value_changed')
100
def test_config_changed_git(self, config_val_changed, git_requested):
101
git_requested.return_value = True
102
self.relation_ids.return_value = ['relid']
103
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
104
openstack_origin_git = {
106
{'name': 'requirements',
108
'git://git.openstack.org/openstack/requirements',
109
'branch': 'stable/juno'},
111
'repository': 'git://git.openstack.org/openstack/neutron',
112
'branch': 'stable/juno'}
114
'directory': '/mnt/openstack-git',
116
projects_yaml = yaml.dump(openstack_origin_git)
117
self.test_config.set('openstack-origin-git', projects_yaml)
118
self._call_hook('config-changed')
119
self.git_install.assert_called_with(projects_yaml)
120
self.assertTrue(self.CONFIGS.write_all.called)
121
self.assertTrue(_zmq_joined.called_with('relid'))
122
self.configure_ovs.assert_called_with()
124
@patch.object(hooks, 'git_install_requested')
125
def test_config_changed_dvr(self, git_requested):
126
git_requested.return_value = False
127
self.determine_dvr_packages.return_value = ['dvr']
128
self._call_hook('config-changed')
129
self.apt_update.assert_called_with()
130
self.assertTrue(self.CONFIGS.write_all.called)
131
self.apt_install.assert_has_calls([
132
call(['dvr'], fatal=True),
134
self.configure_ovs.assert_called_with()
136
@patch.object(hooks, 'neutron_plugin_joined')
137
def test_neutron_plugin_api(self, _plugin_joined):
138
self.relation_ids.return_value = ['rid']
139
self._call_hook('neutron-plugin-api-relation-changed')
140
self.configure_ovs.assert_called_with()
141
self.assertTrue(self.CONFIGS.write_all.called)
142
_plugin_joined.assert_called_with(relation_id='rid')
144
@patch.object(hooks, 'git_install_requested')
145
def test_neutron_plugin_joined(self, git_requested):
146
git_requested.return_value = False
147
self.get_shared_secret.return_value = 'secret'
148
self._call_hook('neutron-plugin-relation-joined')
150
'metadata-shared-secret': 'secret',
152
self.relation_set.assert_called_with(
60
157
def test_amqp_joined(self):
61
158
self._call_hook('amqp-relation-joined')