Exemple #1
0
def test_sync_log(clusters):
    leaders = find_leaders(clusters)
    assert leaders != []
    leader = leaders[0]
    append_logs(leader, ["test1", "test2", "test3"])
    time.sleep(3)
    logs = request_all_logs(clusters)
    for k in clusters:
        assert logs[k].logs == ["test1", "test2", "test3"]
Exemple #2
0
def test_1k_logs_sync(clusters):
    rand_logs = generate_random_logs(1000)
    leaders = find_leaders(clusters)
    assert len(leaders) == 1
    leader = leaders[0]
    append_logs(leader, rand_logs)
    time.sleep(10)
    logs = request_all_logs(clusters)
    for k in clusters:
        assert logs[k].logs == rand_logs
Exemple #3
0
def test_10k_logs_sync(clusters):
    rand_logs = generate_random_logs(10000)
    leaders = find_leaders(clusters)
    assert len(leaders) == 1
    leader = leaders[0]
    for i in range(10):
        append_logs(leader, rand_logs[i*1000:i*1000+1000])
        time.sleep(1)
    time.sleep(30)
    logs = request_all_logs(clusters)
    for k in clusters:
        assert logs[k].logs == rand_logs
Exemple #4
0
def test_sync_log_after_follower_kickoff(clusters):
    leaders = find_leaders(clusters)
    assert leaders != []
    leader = leaders[0]
    append_logs(leader, ["test1", "test2", "test3"])
    time.sleep(3)
    followers = find_followers(clusters)
    kicked_off_follower = followers[0]
    kick_off(kicked_off_follower)
    spawn_client_thread(kicked_off_follower)
    time.sleep(3)
    logs = request_all_logs(clusters)
    assert logs[leader].logs == ["test1", "test2", "test3"]
    for k in clusters:
        assert logs[k].logs == ["test1", "test2", "test3"]
Exemple #5
0
def test_sync_log_after_leader_kickoff(clusters):
    leaders = find_leaders(clusters)
    assert len(leaders) == 1
    leader = leaders[0]
    append_logs(leader, ["test1", "test2", "test3"])
    time.sleep(3)
    logs = request_all_logs(clusters)
    for k in clusters:
        assert logs[k].logs == ["test1", "test2", "test3"]
    kick_off(leader)
    spawn_client_thread(leader)
    time.sleep(3)
    leaders = find_leaders(clusters)
    assert len(leaders) == 1
    leader = leaders[0]
    logs = request_all_logs(clusters)
    assert logs[leader].logs == ["test1", "test2", "test3"]
    for k in clusters:
        assert logs[k].logs == ["test1", "test2", "test3"]
Exemple #6
0
def test_purge_log_after_leader_offline(clusters):
    leaders = find_leaders(clusters)
    assert len(leaders) == 1
    leader = leaders[0]
    append_logs(leader, ["test1", "test2", "test3"])
    time.sleep(1)
    offline(leader)
    time.sleep(3)
    append_logs(leader, ["test4", "test5", "test6"])
    time.sleep(1)
    leaders = find_leaders(clusters)
    assert len(leaders) == 2
    new_leader = leaders[0] if leaders[0] != leader else leaders[1]
    append_logs(new_leader, ["test7", "test8", "test9"])
    time.sleep(3)
    online(leader)
    time.sleep(3)
    logs = request_all_logs(clusters)
    assert logs[leader].logs == ["test1", "test2", "test3", "test7", "test8", "test9"]
    for k in clusters:
        assert logs[k].logs == ["test1", "test2", "test3", "test7", "test8", "test9"]