Esempio n. 1
0
def testMultipleRequests(tdir_for_func):
    """
    Send multiple requests to the client
    """
    with TestNodeSet(count=7, tmpdir=tdir_for_func) as nodeSet:
        with Looper(nodeSet) as looper:
            for n in nodeSet:
                n.startKeySharing()

            ss0 = snapshotStats(*nodeSet)
            client = setupNodesAndClient(looper, nodeSet, tmpdir=tdir_for_func)
            ss1 = snapshotStats(*nodeSet)

            def x():
                requests = [sendRandomRequest(client) for _ in range(10)]
                for request in requests:
                    looper.run(eventually(
                        checkSufficientRepliesRecvd, client.inBox,
                        request.reqId, 3,
                        retryWait=1, timeout=3 * len(nodeSet)))
                ss2 = snapshotStats(*nodeSet)
                diff = statsDiff(ss2, ss1)

                # TODO verify the correct number of expected PROPAGATE, PRE-PREPARE, PREPARE, and COMMITs occurred
                pprint(ss2)
                print("----------------------------------------------")
                pprint(diff)

            profile_this(x)
Esempio n. 2
0
def testReqExecWhenReturnedByMaster(tdir_for_func):
    with TestNodeSet(count=4, tmpdir=tdir_for_func) as nodeSet:
        with Looper(nodeSet) as looper:
            for n in nodeSet:
                n.startKeySharing()
            client1 = setupNodesAndClient(looper, nodeSet, tmpdir=tdir_for_func)
            req = sendRandomRequest(client1)
            looper.run(eventually(checkSufficientRepliesRecvd, client1.inBox,
                                  req.reqId, 1,
                                  retryWait=1, timeout=15))
            for node in nodeSet:
                entries = node.spylog.getAll(
                    node.processOrdered.__name__)
                for entry in entries:
                    arg = entry.params['ordered']
                    result = entry.result
                    if arg.instId == node.masterInst:
                        assert result
                    else:
                        assert result is None