def test_error_if_long_message(cli, tconf, createAllNodes, validNodeNames, set_info_log_level): operation = '{{"Hello": "{}"}}'.format("T" * tconf.MSG_LEN_LIMIT) createClientAndConnect(cli, validNodeNames, "Alice") cli.enterCmd('client {} send {}'.format("Alice", operation)) assert "message is too large and cannot be split" in cli.lastCmdOutput
def test_error_if_long_message(cli, tconf, createAllNodes, validNodeNames, set_info_log_level): operation = '{{"Hello": "{}"}}'.format("T" * tconf.MSG_LEN_LIMIT) createClientAndConnect(cli, validNodeNames, "Alice") cli.enterCmd('client {} send {}'.format("Alice", operation)) assert "Message will be discarded due to InvalidMessageExceedingSizeException" in cli.lastCmdOutput
def testTransactions(cli, loadBankReqPlugin, createAllNodes, validNodeNames): nodeCount = len(validNodeNames) createClientAndConnect(cli, validNodeNames, "Alice") createClientAndConnect(cli, validNodeNames, "Bob") cli.enterCmd("client Alice credit 500 to Bob") cli.looper.run(eventually(checkReply, cli, nodeCount * 1, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Alice balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 2, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, len(validNodeNames), partial(checkBalance, 500), retryWait=1, timeout=5)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 3, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1500), retryWait=1, timeout=5)) cli.enterCmd("client Bob credit 10 to Alice") cli.looper.run(eventually(checkReply, cli, nodeCount * 4, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 5, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1490), retryWait=1, timeout=5)) cli.enterCmd("client Bob credit 100 to Alice") cli.looper.run(eventually(checkReply, cli, nodeCount * 6, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Alice balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 7, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 610), retryWait=1, timeout=10)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 8, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1390), retryWait=1, timeout=5)) createClientAndConnect(cli, validNodeNames, "Carol") cli.enterCmd("client Carol credit 50 to Bob") cli.looper.run(eventually(checkReply, cli, nodeCount * 9, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 10, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1440), retryWait=1, timeout=10)) cli.enterCmd("client Carol balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 11, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 950), retryWait=1, timeout=5))
def testTransactions(cli, loadBankReqPlugin, createAllNodes, validNodeNames): nodeCount = len(validNodeNames) createClientAndConnect(cli, validNodeNames, "Alice") createClientAndConnect(cli, validNodeNames, "Bob") cli.enterCmd("client Alice credit 500 to Bob") cli.looper.run(eventually(checkReply, cli, nodeCount * 1, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Alice balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 2, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, len(validNodeNames), partial(checkBalance, 500), retryWait=1, timeout=5)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 3, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1500), retryWait=1, timeout=5)) cli.enterCmd("client Bob credit 10 to Alice") cli.looper.run(eventually(checkReply, cli, nodeCount * 4, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 5, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1490), retryWait=1, timeout=5)) cli.enterCmd("client Bob credit 100 to Alice") cli.looper.run(eventually(checkReply, cli, nodeCount * 6, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Alice balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 7, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 610), retryWait=1, timeout=10)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 8, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1390), retryWait=1, timeout=5)) createClientAndConnect(cli, validNodeNames, "Carol") cli.enterCmd("client Carol credit 50 to Bob") cli.looper.run(eventually(checkReply, cli, nodeCount * 9, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client Bob balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 10, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 1440), retryWait=1, timeout=10)) cli.enterCmd("client Carol balance") cli.looper.run(eventually(checkReply, cli, nodeCount * 11, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 950), retryWait=1, timeout=5))
def testTransactions(cli, loadBankReqPlugin, createAllNodes, validNodeNames): nodeCount = len(validNodeNames) createClientAndConnect(cli, validNodeNames, "Alice") createClientAndConnect(cli, validNodeNames, "Bob") timeout = waits.expectedTransactionExecutionTime(nodeCount) cli.enterCmd("client Alice credit 500 to Bob") waitRequestSuccess(cli, nodeCount, customTimeout=timeout) cli.enterCmd("client Alice balance") waitRequestSuccess(cli, nodeCount * 2, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 500, customTimeout=timeout) cli.enterCmd("client Bob balance") waitRequestSuccess(cli, nodeCount * 3, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 1500, customTimeout=timeout) cli.enterCmd("client Bob credit 10 to Alice") waitRequestSuccess(cli, nodeCount * 4, customTimeout=timeout) cli.enterCmd("client Bob balance") waitRequestSuccess(cli, nodeCount * 5, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 1490, customTimeout=timeout) cli.enterCmd("client Bob credit 100 to Alice") waitRequestSuccess(cli, nodeCount * 6, customTimeout=timeout) cli.enterCmd("client Alice balance") waitRequestSuccess(cli, nodeCount * 7, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 610, customTimeout=timeout) cli.enterCmd("client Bob balance") waitRequestSuccess(cli, nodeCount * 8, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 1390, customTimeout=timeout) createClientAndConnect(cli, validNodeNames, "Carol") cli.enterCmd("client Carol credit 50 to Bob") waitRequestSuccess(cli, nodeCount * 9, customTimeout=timeout) cli.enterCmd("client Bob balance") waitRequestSuccess(cli, nodeCount * 10, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 1440, customTimeout=timeout) cli.enterCmd("client Carol balance") waitRequestSuccess(cli, nodeCount * 11, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 950, customTimeout=timeout)
def testTransactions(cli, loadAuctionReqPlugin, createAllNodes, validNodeNames): nodeCount = len(validNodeNames) auctionId = str(uuid4()) names = ["Jason", "John", "Les", "Timothy", "Tyler"] for name in names: createClientAndConnect(cli, validNodeNames, name) jason, tyler, les, john, timothy = names cli.enterCmd("client {} start auction {}".format(jason, auctionId)) cli.looper.run( eventually(checkReply, cli, nodeCount * 1, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 20 on {}".format(tyler, auctionId)) cli.looper.run( eventually(checkReply, cli, nodeCount * 2, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(tyler)) cli.looper.run( eventually(checkReply, cli, nodeCount * 3, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount, partial(checkBalance, 980), retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 40 on {}".format(les, auctionId)) cli.looper.run( eventually(checkReply, cli, nodeCount * 4, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(tyler)) cli.looper.run( eventually(checkReply, cli, nodeCount * 5, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 1, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run( eventually(checkReply, cli, nodeCount * 6, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount, partial(checkBalance, 960), retryWait=1, timeout=5)) # This bid would fail so `success` would be false and thus success count # wont increase cli.enterCmd("client {} place bid 30 on {}".format(john, auctionId)) cli.looper.run( eventually(checkReply, cli, nodeCount * 6, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(john)) cli.looper.run( eventually(checkReply, cli, nodeCount * 7, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 2, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run( eventually(checkReply, cli, nodeCount * 8, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 2, partial(checkBalance, 960), retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 200 on {}".format(timothy, auctionId)) cli.looper.run( eventually(checkReply, cli, nodeCount * 9, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(timothy)) cli.looper.run( eventually(checkReply, cli, nodeCount * 10, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount, partial(checkBalance, 800), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run( eventually(checkReply, cli, nodeCount * 11, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 3, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} end auction {}".format(jason, auctionId)) cli.looper.run( eventually(checkReply, cli, nodeCount * 12, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 300 on {}".format(john, auctionId)) cli.looper.run( eventually(checkReply, cli, nodeCount * 12, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(john)) cli.looper.run( eventually(checkReply, cli, nodeCount * 13, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 4, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(tyler)) cli.looper.run( eventually(checkReply, cli, nodeCount * 14, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 5, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(john)) cli.looper.run( eventually(checkReply, cli, nodeCount * 15, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 6, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run( eventually(checkReply, cli, nodeCount * 16, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 7, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(timothy)) cli.looper.run( eventually(checkReply, cli, nodeCount * 17, checkSuccess, retryWait=1, timeout=5)) cli.looper.run( eventually(checkReply, cli, nodeCount * 2, partial(checkBalance, 800), retryWait=1, timeout=5))
def testTransactions(cli, loadAuctionReqPlugin, createAllNodes, validNodeNames): nodeCount = len(validNodeNames) auctionId = str(uuid4()) names = ["Jason", "John", "Les", "Timothy", "Tyler"] for name in names: createClientAndConnect(cli, validNodeNames, name) jason, tyler, les, john, timothy = names cli.enterCmd("client {} start auction {}".format(jason, auctionId)) cli.looper.run(eventually(checkReply, cli, nodeCount * 1, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 20 on {}".format(tyler, auctionId)) cli.looper.run(eventually(checkReply, cli, nodeCount * 2, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(tyler)) cli.looper.run(eventually(checkReply, cli, nodeCount * 3, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 980), retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 40 on {}".format(les, auctionId)) cli.looper.run(eventually(checkReply, cli, nodeCount * 4, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(tyler)) cli.looper.run(eventually(checkReply, cli, nodeCount * 5, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 1, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run(eventually(checkReply, cli, nodeCount * 6, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 960), retryWait=1, timeout=5)) # This bid would fail so `success` would be false and thus success count # wont increase cli.enterCmd("client {} place bid 30 on {}".format(john, auctionId)) cli.looper.run(eventually(checkReply, cli, nodeCount * 6, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(john)) cli.looper.run(eventually(checkReply, cli, nodeCount * 7, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 2, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run(eventually(checkReply, cli, nodeCount * 8, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 2, partial(checkBalance, 960), retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 200 on {}".format(timothy, auctionId)) cli.looper.run(eventually(checkReply, cli, nodeCount * 9, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(timothy)) cli.looper.run(eventually(checkReply, cli, nodeCount * 10, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount, partial(checkBalance, 800), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run(eventually(checkReply, cli, nodeCount * 11, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 3, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} end auction {}".format(jason, auctionId)) cli.looper.run(eventually(checkReply, cli, nodeCount * 12, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} place bid 300 on {}".format(john, auctionId)) cli.looper.run(eventually(checkReply, cli, nodeCount * 12, checkSuccess, retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(john)) cli.looper.run(eventually(checkReply, cli, nodeCount * 13, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 4, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(tyler)) cli.looper.run(eventually(checkReply, cli, nodeCount * 14, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 5, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(john)) cli.looper.run(eventually(checkReply, cli, nodeCount * 15, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 6, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(les)) cli.looper.run(eventually(checkReply, cli, nodeCount * 16, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 7, partial(checkBalance, 1000), retryWait=1, timeout=5)) cli.enterCmd("client {} balance".format(timothy)) cli.looper.run(eventually(checkReply, cli, nodeCount * 17, checkSuccess, retryWait=1, timeout=5)) cli.looper.run(eventually(checkReply, cli, nodeCount * 2, partial(checkBalance, 800), retryWait=1, timeout=5))
def testTransactions(cli, loadAuctionReqPlugin, createAllNodes, validNodeNames): nodeCount = len(validNodeNames) auctionId = str(uuid4()) names = ["Jason", "John", "Les", "Timothy", "Tyler"] for name in names: createClientAndConnect(cli, validNodeNames, name) jason, tyler, les, john, timothy = names timeout = waits.expectedTransactionExecutionTime(nodeCount) cli.enterCmd("client {} start auction {}".format(jason, auctionId)) waitRequestSuccess(cli, nodeCount * 1, customTimeout=timeout) cli.enterCmd("client {} place bid 20 on {}".format(tyler, auctionId)) waitRequestSuccess(cli, nodeCount * 2, customTimeout=timeout) cli.enterCmd("client {} balance".format(tyler)) waitRequestSuccess(cli, nodeCount * 3, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 980, customTimeout=timeout) cli.enterCmd("client {} place bid 40 on {}".format(les, auctionId)) waitRequestSuccess(cli, nodeCount * 4, customTimeout=timeout) cli.enterCmd("client {} balance".format(tyler)) waitRequestSuccess(cli, nodeCount * 5, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 1000, customTimeout=timeout) cli.enterCmd("client {} balance".format(les)) waitRequestSuccess(cli, nodeCount * 6, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 960, customTimeout=timeout) # This bid would fail so `success` would be false and thus success count # wont increase cli.enterCmd("client {} place bid 30 on {}".format(john, auctionId)) waitRequestSuccess(cli, nodeCount * 6, customTimeout=timeout) cli.enterCmd("client {} balance".format(john)) waitRequestSuccess(cli, nodeCount * 7, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 2, 1000, customTimeout=timeout) cli.enterCmd("client {} balance".format(les)) waitRequestSuccess(cli, nodeCount * 8, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 2, 960, customTimeout=timeout) cli.enterCmd("client {} place bid 200 on {}".format(timothy, auctionId)) waitRequestSuccess(cli, nodeCount * 9, customTimeout=timeout) cli.enterCmd("client {} balance".format(timothy)) waitRequestSuccess(cli, nodeCount * 10, customTimeout=timeout) waitBalanceChange(cli, nodeCount, 800, customTimeout=timeout) cli.enterCmd("client {} balance".format(les)) waitRequestSuccess(cli, nodeCount * 11, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 3, 1000, customTimeout=timeout) cli.enterCmd("client {} end auction {}".format(jason, auctionId)) waitRequestSuccess(cli, nodeCount * 12, customTimeout=timeout) cli.enterCmd("client {} place bid 300 on {}".format(john, auctionId)) waitRequestSuccess(cli, nodeCount * 12, customTimeout=timeout) cli.enterCmd("client {} balance".format(john)) waitRequestSuccess(cli, nodeCount * 13, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 4, 1000, customTimeout=timeout) cli.enterCmd("client {} balance".format(tyler)) waitRequestSuccess(cli, nodeCount * 14, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 5, 1000, customTimeout=timeout) cli.enterCmd("client {} balance".format(john)) waitRequestSuccess(cli, nodeCount * 15, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 6, 1000, customTimeout=timeout) cli.enterCmd("client {} balance".format(les)) waitRequestSuccess(cli, nodeCount * 16, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 7, 1000, customTimeout=timeout) cli.enterCmd("client {} balance".format(timothy)) waitRequestSuccess(cli, nodeCount * 17, customTimeout=timeout) waitBalanceChange(cli, nodeCount * 2, 800, customTimeout=timeout)