Example #1
0
def test_selector_with_a_dead_node():

    gossip = [GOOD_NODE._replace(is_alive=False)]

    selected = select(gossip)

    assert selected is None
Example #2
0
def test_selector_with_one_node():

    gossip = [GOOD_NODE]

    selected = select(gossip)

    assert selected == GOOD_NODE
Example #3
0
def test_selector_with_master_and_slave():
    gossip = [
        GOOD_NODE._replace(state=NodeState.Master),
        GOOD_NODE._replace(state=NodeState.Slave),
    ]

    selected = select(gossip)

    assert selected.state == NodeState.Master
Example #4
0
def test_selector_with_slave_and_clone():
    gossip = [
        GOOD_NODE._replace(state=NodeState.Clone),
        GOOD_NODE._replace(state=NodeState.Slave),
    ]

    selected = select(gossip)

    assert selected.state == NodeState.Slave
Example #5
0
def test_selector_with_nodes_in_bad_states():

    gossip = [
        GOOD_NODE._replace(state=s) for s in
        [NodeState.Manager, NodeState.Shutdown, NodeState.ShuttingDown]
    ]

    selected = select(gossip)

    assert selected is None
Example #6
0
def test_selector_with_nodes_in_all_states():
    gossip = [GOOD_NODE._replace(state=s) for s in NodeState]

    selected = select(gossip)

    assert selected.state == NodeState.Master
Example #7
0
def test_selector_with_empty_gossip():

    gossip = []
    selected = select(gossip)
    assert selected is None