def test_upgrade_charm_leader(self): self.is_leader.return_value = True self.is_unit_paused_set.return_value = False self.get_relation_ip.return_value = '10.10.10.10' self.leader_get.side_effect = [None, 'mypasswd', 'mypasswd'] def c(k): values = { 'wsrep_ready': 'on', 'wsrep_cluster_state_uuid': '1234-abcd' } return values[k] self.get_wsrep_value.side_effect = c hooks.upgrade() self.mark_seeded.assert_called_once() self.notify_bootstrapped.assert_called_with(cluster_uuid='1234-abcd') self.configure_sstuser.assert_called_once() self.leader_set.assert_has_calls([ mock.call(**{'leader-ip': '10.10.10.10'}), mock.call(**{'root-password': '******'}) ])
def test_upgrade_charm(self, mock_data_dir, mock_rids, mock_wsrep, mock_rset, mock_lset, mock_is_leader): mock_rids.return_value = ['cluster:22'] mock_is_leader.return_value = True self.is_leader.return_value = True self.is_unit_paused_set.return_value = False def c(k): values = { 'wsrep_ready': 'on', 'wsrep_cluster_state_uuid': '1234-abcd' } return values[k] self.get_wsrep_value.side_effect = c mock_wsrep.side_effect = c mock_data_dir.return_value = self.tmpdir hooks.upgrade() seeded_file = os.path.join(self.tmpdir, 'seeded') self.assertTrue(os.path.isfile(seeded_file), "%s is not file" % seeded_file) with open(seeded_file) as f: self.assertEqual(f.read(), 'done') mock_rset.assert_called_with(relation_id='cluster:22', **{'bootstrap-uuid': '1234-abcd'}) mock_lset.assert_called_with(**{'bootstrap-uuid': '1234-abcd'}) self.config_changed.assert_called_with()
def test_upgrade_charm_leader(self): self.is_leader.return_value = True self.is_unit_paused_set.return_value = False self.get_relation_ip.return_value = '10.10.10.10' self.leader_get.side_effect = [None, 'mypasswd', 'mypasswd'] def c(k): values = {'wsrep_ready': 'on', 'wsrep_cluster_state_uuid': '1234-abcd'} return values[k] self.get_wsrep_value.side_effect = c hooks.upgrade() self.mark_seeded.assert_called_once() self.notify_bootstrapped.assert_called_with(cluster_uuid='1234-abcd') self.configure_sstuser.assert_called_once() self.leader_set.assert_has_calls( [mock.call(**{'leader-ip': '10.10.10.10'}), mock.call(**{'root-password': '******'})])