def test_check_cluster_memberships(self, mock_relation_ids,
                                    mock_subprocess,
                                    mock_relations_for_id,
                                    mock_forget_cluster_node):
     mock_relation_ids.return_value = [0]
     mock_subprocess.check_output.return_value = \
         RABBITMQCTL_CLUSTERSTATUS_RUNNING
     mock_relations_for_id.return_value = [
         {'clustered': 'juju-devel3-machine-14'},
         {'clustered': 'juju-devel3-machine-19'},
         {'dummy-entry': 'to validate behaviour on relations without '
                         'clustered key in dict'},
     ]
     rabbit_utils.check_cluster_memberships()
     mock_forget_cluster_node.assert_called_with(
         'rabbit@juju-devel3-machine-42')
示例#2
0
def update_status():
    log('Updating status.')

    # leader check for previously unsuccessful cluster departures
    #
    # This must be done here and not in the cluster-relation-departed hook.  At
    # the point in time the cluster-relation-departed hook is called we know
    # that a unit is departing.  We also know that RabbitMQ will not have
    # noticed its departure yet.  We cannot remove a node pre-emptively.
    #
    # In the normal case the departing node should remove itself from the
    # cluster in its stop hook.  We clean up the ones that for whatever reason
    # are unable to clean up after themselves successfully here.
    #
    # Have a look at the docstring of the stop() function for detailed
    # explanation.
    if is_leader():
        rabbit.check_cluster_memberships()
def update_status():
    log('Updating status.')

    # leader check for previously unsuccessful cluster departures
    #
    # This must be done here and not in the cluster-relation-departed hook.  At
    # the point in time the cluster-relation-departed hook is called we know
    # that a unit is departing.  We also know that RabbitMQ will not have
    # noticed its departure yet.  We cannot remove a node pre-emptively.
    #
    # In the normal case the departing node should remove itself from the
    # cluster in its stop hook.  We clean up the ones that for whatever reason
    # are unable to clean up after themselves successfully here.
    #
    # Have a look at the docstring of the stop() function for detailed
    # explanation.
    if is_leader() and not is_unit_paused_set():
        rabbit.check_cluster_memberships()
示例#4
0
 def test_check_cluster_memberships(self, mock_relation_ids,
                                    mock_subprocess, mock_relations_for_id,
                                    mock_forget_cluster_node):
     mock_relation_ids.return_value = [0]
     mock_subprocess.check_output.return_value = \
         RABBITMQCTL_CLUSTERSTATUS_RUNNING
     mock_relations_for_id.return_value = [
         {
             'clustered': 'juju-devel3-machine-14'
         },
         {
             'clustered': 'juju-devel3-machine-19'
         },
         {
             'dummy-entry':
             'to validate behaviour on relations without '
             'clustered key in dict'
         },
     ]
     rabbit_utils.check_cluster_memberships()
     mock_forget_cluster_node.assert_called_with(
         'rabbit@juju-devel3-machine-42')
 def test_check_cluster_memberships(self, mock_relation_ids,
                                    mock_subprocess, mock_relations_for_id,
                                    mock_cmp_pkgrevno):
     mock_relation_ids.return_value = [0]
     mock_subprocess.check_output.return_value = \
         RABBITMQCTL_CLUSTERSTATUS_RUNNING
     mock_cmp_pkgrevno.return_value = -1
     mock_relations_for_id.return_value = [
         {
             'clustered': 'juju-devel3-machine-14'
         },
         {
             'clustered': 'juju-devel3-machine-19'
         },
         {
             'dummy-entry':
             'to validate behaviour on relations without '
             'clustered key in dict'
         },
     ]
     self.assertEqual("rabbit@juju-devel3-machine-42",
                      rabbit_utils.check_cluster_memberships())