Пример #1
0
def test_restart_on_inconsistency(looper, txnPoolNodeSet, tconf, tdir, monkeypatch):
    restarted = multiprocessing.Value('i', 0)

    def notify_restart():
        with restarted.get_lock():
            restarted.value = 1

    def transform(tool):
        nodeControlGeneralMonkeypatching(tool, monkeypatch, tdir, 'teststdout')
        monkeypatch.setattr(tool, '_restart', notify_restart)

    def check_restart(value):
        with restarted.get_lock():
            assert restarted.value == value

    nct = NodeControlToolExecutor(backup_dir=tdir, backup_target=tdir, transform=transform, config=tconf)
    try:
        # Trigger inconsistent 3PC state event
        txnPoolNodeSet[0].on_inconsistent_3pc_state()

        # Ensure we don't restart before timeout
        looper.runFor(0.8 * RESTART_TIMEOUT)
        check_restart(0)

        # Ensure we restart eventually
        looper.run(eventually(check_restart, 1, retryWait=1.0))
    finally:
        nct.stop()
Пример #2
0
def test_restart_on_inconsistency(looper, txnPoolNodeSet, tdir, monkeypatch):
    restarted = multiprocessing.Value('i', 0)

    def notify_restart():
        with restarted.get_lock():
            restarted.value = 1

    def transform(tool):
        nodeControlGeneralMonkeypatching(tool, monkeypatch, tdir, 'teststdout')
        monkeypatch.setattr(tool, '_restart', notify_restart)

    def check_restart():
        with restarted.get_lock():
            assert restarted.value == 1

    nct = NodeControlToolExecutor(backup_dir=tdir,
                                  backup_target=tdir,
                                  transform=transform)
    try:
        txnPoolNodeSet[0].on_inconsistent_3pc_state()
        looper.run(eventually(check_restart))
    finally:
        nct.stop()