class TestLinksysParser(unittest.TestCase): def setUp(self): self.parser = LinksysParser() self.helper = TestHelper() def test_parse_time(self): now = datetime.now() dt = self.parser.parse_time("12:10:42") self.assertEqual(now.year, dt.year) self.assertEqual(now.month, dt.month) self.assertEqual(now.day, dt.day) self.assertEqual(12, dt.hour) self.assertEqual(10, dt.minute) self.assertEqual(42, dt.second) def test_parse_dhcp_clients(self): clients = self.parser.parse_dhcp_clients(self.helper.dhcp_response()) # Make sure we got all the records self.assertEqual(10, len(clients)) # Spot check a single record to ensure all the fields are correct client = clients[0] self.assertEqual('LAN', client['interface']) self.assertEqual('zelda', client['hostname']) self.assertEqual('192.168.1.107', client['ip_address']) self.assertEqual('01:35:10', client['lease_expires']) self.assertEqual('00:15:af:e6:6b:da', client['mac_address']) def test_parse_mac_blacklist(self): mac_addrs = self.parser.parse_mac_blacklist(self.helper.mac_response()) self.assertEqual(3, len(mac_addrs)) self.assertEqual('22:22:22:22:22:22', mac_addrs[0]) self.assertEqual('00:33:33:33:33:33', mac_addrs[1]) self.assertEqual('00:44:44:44:44:44', mac_addrs[2])
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("Test.ice") import Ice import TestI import AllTests class Collocated(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint()) adapter = communicator.createObjectAdapter("TestAdapter") adapter.add(TestI.MyDerivedClassI(), Ice.stringToIdentity("test")) # adapter.activate() // Don't activate OA to ensure collocation is used. AllTests.allTests(self, communicator, True)
import time ############################################################### # prod_preactivation_test # --dump-error-details <Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout> # --keep-logs <Don't delete var/lib/node_* folders upon test completion> ############################################################### Print = Utils.Print errorExit = Utils.errorExit cmdError = Utils.cmdError from core_symbol import CORE_SYMBOL args = TestHelper.parse_args({ "--host", "--port", "--defproducera_prvt_key", "--defproducerb_prvt_key", "--dump-error-details", "--dont-launch", "--keep-logs", "-v", "--leave-running", "--only-bios", "--clean-run", "--sanity-test", "--wallet-port" }) server = args.host port = args.port debug = args.v defproduceraPrvtKey = args.defproducera_prvt_key defproducerbPrvtKey = args.defproducerb_prvt_key dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontLaunch = args.dont_launch dontKill = args.leave_running prodCount = 2 onlyBios = args.only_bios killAll = args.clean_run sanityTest = args.sanity_test
errorExit = Utils.errorExit from core_symbol import CORE_SYMBOL appArgs = AppArgs() extraArgs = appArgs.add(flag="--catchup-count", type=int, help="How many catchup-nodes to launch", default=10) extraArgs = appArgs.add(flag="--txn-gen-nodes", type=int, help="How many transaction generator nodes", default=2) args = TestHelper.parse_args( { "--prod-count", "--dump-error-details", "--keep-logs", "-v", "--leave-running", "--clean-run", "-p", "--wallet-port" }, applicationSpecificArgs=appArgs) Utils.Debug = args.v pnodes = args.p if args.p > 0 else 1 startedNonProdNodes = args.txn_gen_nodes if args.txn_gen_nodes >= 2 else 2 cluster = Cluster(walletd=True) dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontKill = args.leave_running prodCount = args.prod_count if args.prod_count > 1 else 2 killAll = args.clean_run walletPort = args.wallet_port catchupCount = args.catchup_count if args.catchup_count > 0 else 1 totalNodes = startedNonProdNodes + pnodes + catchupCount
# -s <topology> # -d <delay between nodes startup> # -v <verbose logging> # --kill-sig <kill signal [term|kill]> # --kill-count <nodeos instances to kill> # --dont-kill <Leave cluster running after test finishes> # --dump-error-details <Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout> # --keep-logs <Don't delete var/lib/node_* folders upon test completion> ############################################################### Print = Utils.Print errorExit = Utils.errorExit args = TestHelper.parse_args({ "-p", "-d", "-s", "-c", "--kill-sig", "--kill-count", "--keep-logs", "--p2p-plugin", "--dump-error-details", "-v", "--leave-running", "--clean-run", "--mongodb" }) pnodes = args.p topo = args.s delay = args.d chainSyncStrategyStr = args.c debug = args.v enableMongo = args.mongodb total_nodes = pnodes killCount = args.kill_count if args.kill_count > 0 else 1 killSignal = args.kill_sig killEosInstances = not args.leave_running dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs killAll = args.clean_run
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice('Callback.ice') import Ice import Test class CallbackI(Test.Callback): def initiateCallback(self, proxy, current): proxy.callback(current.ctx) def shutdown(self, current): current.adapter.getCommunicator().shutdown() class Server(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: communicator.getProperties().setProperty("DeactivatedAdapter.Endpoints", self.getTestEndpoint(num=1)) communicator.createObjectAdapter("DeactivatedAdapter") communicator.getProperties().setProperty("CallbackAdapter.Endpoints", self.getTestEndpoint()) adapter = communicator.createObjectAdapter("CallbackAdapter") adapter.add(CallbackI(), Ice.stringToIdentity("callback")) adapter.activate()
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice('Test.ice') import Ice import TestAMDI import TestActivationAMDI class ServerAMD(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint()) communicator.getProperties().setProperty("Ice.Warn.Dispatch", "0") adapter = communicator.createObjectAdapter("TestAdapter") adapter.addServantLocator(TestAMDI.ServantLocatorI("category"), "category") adapter.addServantLocator(TestAMDI.ServantLocatorI(""), "") adapter.add(TestAMDI.TestI(), Ice.stringToIdentity("asm")) adapter.add(TestActivationAMDI.TestActivationAMDI(), Ice.stringToIdentity("test/activation")) adapter.activate() adapter.waitForDeactivate()
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("Test.ice ServerPrivate.ice") import TestI import Ice def MyValueFactory(type): if type == '::Test::I': return TestI.II() elif type == '::Test::J': return TestI.JI() elif type == '::Test::H': return TestI.HI() assert(False) # Should never be reached class Server(TestHelper): def run(self, args): properties = self.createTestProperties(args) properties.setProperty("Ice.Warn.Dispatch", "0") with self.initialize(properties=properties) as communicator: communicator.getValueFactoryManager().add(MyValueFactory, '::Test::I') communicator.getValueFactoryManager().add(MyValueFactory, '::Test::J') communicator.getValueFactoryManager().add(MyValueFactory, '::Test::H') communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint())
from Node import Node from Node import ReturnType from TestHelper import TestHelper ############################################################### # http_plugin_tests.py # # Integration tests for HTTP plugin # ############################################################### Print = Utils.Print errorExit = Utils.errorExit cmdError = Utils.cmdError args = TestHelper.parse_args( {"-v", "--clean-run", "--dump-error-details", "--keep-logs"}) debug = args.v killAll = args.clean_run killEosInstances = True keepLogs = args.keep_logs dumpErrorDetails = dumpErrorDetails = args.dump_error_details Utils.Debug = debug https_port = 5555 cluster = Cluster(walletd=True) testSuccessful = False ClientName = "cleos" timeout = .5 * 12 * 2 + 60 # time for finalization with 1 producer + 60 seconds padding Utils.setIrreversibleTimeout(timeout)
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("Test.ice ClientPrivate.ice") import Ice import TestI import AllTests class Collocated(TestHelper): def run(self, args): properties = self.createTestProperties(args) properties.setProperty("Ice.Warn.Dispatch", "0") with self.initialize(properties=properties) as communicator: communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint()) adapter = communicator.createObjectAdapter("TestAdapter") initial = TestI.InitialI(adapter) adapter.add(initial, Ice.stringToIdentity("initial")) adapter.add(TestI.UnexpectedObjectExceptionTestI(), Ice.stringToIdentity("uoet")) # adapter.activate() // Don't activate OA to ensure collocation is used. AllTests.allTests(self, communicator) # We must call shutdown even in the collocated case for cyclic dependency cleanup initial.shutdown()
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # import Ice from TestHelper import TestHelper TestHelper.loadSlice("--checksum Test.ice STypes.ice") import Test class ChecksumI(Test.Checksum): def getSliceChecksums(self, current=None): return Ice.sliceChecksums def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() class Server(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint()) adapter = communicator.createObjectAdapter("TestAdapter") adapter.add(ChecksumI(), Ice.stringToIdentity("test")) adapter.activate() communicator.waitForShutdown()
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None ############ # Main # ############ if __name__ == "__main__": # Execute only if run as a script # Create TestHelper helper = TestHelper() # Apply TestHelper to various possible use cases helper.execute(addIntegers, 1, 2, 3) helper.execute(addIntegers, 1, 10, 100) # Array's work fine, but... helper.execute(addListOrArray, array('i', [0, 1, 2, 3, 4])) # you'll probably want to stick with lists helper.execute(addListOrArray, [0, 1, 2, 3, 4]) helper.execute(remixChars, "Hello World", [9, 7, 8, 10], [0, 4, 6, 1, 2, 3]) # A List example could also be of some use list = ListNode(1) list.next = ListNode(2)
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice('--all -I. Test.ice') import Test import Test1 import testpkg import modpkg import Ice class InitialI(Test.Initial): def getTest1C2AsObject(self, current): return Test1.C2() def getTest1C2AsC1(self, current): return Test1.C2() def getTest1C2AsC2(self, current): return Test1.C2() def throwTest1E2AsE1(self, current): raise Test1.E2() def throwTest1E2AsE2(self, current): raise Test1.E2()
#!/usr/bin/env python3 # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("--all -I. Test.ice") import AllTests class Client(TestHelper): def run(self, args): properties = self.createTestProperties(args) properties.setProperty('Ice.Warn.Dispatch', '0') with self.initialize(properties=properties) as communicator: initial = AllTests.allTests(self, communicator) initial.shutdown()
msg+="did not expect nodes to indicate different block producers for the same blocks." msg+="\n Matching Blocks= %s \n Diverging branch node0= %s \n Diverging branch node1= %s" % (bpsStr,bpsStr0,bpsStr1) Utils.errorExit(msg) return firstDivergence def getMinHeadAndLib(prodNodes): info0=prodNodes[0].getInfo(exitOnError=True) info1=prodNodes[1].getInfo(exitOnError=True) headBlockNum=min(int(info0["head_block_num"]),int(info1["head_block_num"])) libNum=min(int(info0["last_irreversible_block_num"]), int(info1["last_irreversible_block_num"])) return (headBlockNum, libNum) args = TestHelper.parse_args({"--prod-count","--dump-error-details","--keep-logs","-v","--leave-running","--clean-run", "--p2p-plugin","--wallet-port"}) Utils.Debug=args.v totalProducerNodes=2 totalNonProducerNodes=1 totalNodes=totalProducerNodes+totalNonProducerNodes maxActiveProducers=21 totalProducers=maxActiveProducers cluster=Cluster(walletd=True) dumpErrorDetails=args.dump_error_details keepLogs=args.keep_logs dontKill=args.leave_running prodCount=args.prod_count killAll=args.clean_run p2pPlugin=args.p2p_plugin walletPort=args.wallet_port
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice('Callback.ice') import Ice import Test class CallbackI(Test.Callback): def initiateCallback(self, proxy, current): proxy.callback(current.ctx) def shutdown(self, current): current.adapter.getCommunicator().shutdown() class Server(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: communicator.getProperties().setProperty( "DeactivatedAdapter.Endpoints", self.getTestEndpoint(num=1)) communicator.createObjectAdapter("DeactivatedAdapter") communicator.getProperties().setProperty( "CallbackAdapter.Endpoints", self.getTestEndpoint()) adapter = communicator.createObjectAdapter("CallbackAdapter") adapter.add(CallbackI(), Ice.stringToIdentity("callback")) adapter.activate()
import re ############################################################### # nodeos_run_test # --dump-error-details <Upon error print etc/DA-DAPPSio/node_*/config.ini and var/lib/node_*/stderr.log to stdout> # --keep-logs <Don't delete var/lib/node_* folders upon test completion> ############################################################### Print = Utils.Print errorExit = Utils.errorExit cmdError = Utils.cmdError from core_symbol import CORE_SYMBOL args = TestHelper.parse_args({ "--host", "--port", "--prod-count", "--defproducera_prvt_key", "--defproducerb_prvt_key", "--mongodb", "--dump-error-details", "--dont-launch", "--keep-logs", "-v", "--leave-running", "--only-bios", "--clean-run", "--sanity-test", "--p2p-plugin", "--wallet-port" }) server = args.host port = args.port debug = args.v enableMongo = args.mongodb defproduceraPrvtKey = args.defproducera_prvt_key defproducerbPrvtKey = args.defproducerb_prvt_key dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontLaunch = args.dont_launch dontKill = args.leave_running prodCount = args.prod_count onlyBios = args.only_bios killAll = args.clean_run
import subprocess ############################################################### # nodeos_run_remote_test # Tests remote capability of the nodeos_run_test. Test will setup cluster and pass nodes info to nodeos_run_test. E.g. # nodeos_run_remote_test.py -v --clean-run --dump-error-detail ############################################################### Print=Utils.Print def errorExit(msg="", errorCode=1): Print("ERROR:", msg) exit(errorCode) args = TestHelper.parse_args({"--dump-error-details","-v","--leave-running","--only-bios","--clean-run"}) debug=args.v dontKill=args.leave_running dumpErrorDetails=args.dump_error_details onlyBios=args.only_bios killAll=args.clean_run Utils.Debug=debug killEosInstances=not dontKill topo="mesh" delay=1 prodCount=1 # producers per producer node pnodes=1 total_nodes=pnodes actualTest="tests/nodeos_run_test.py"
#!/usr/bin/env python3 from testUtils import Utils from Cluster import Cluster from WalletMgr import WalletMgr from TestHelper import TestHelper import random Print = Utils.Print errorExit = Utils.errorExit args = TestHelper.parse_args({ "-p", "-n", "-d", "-s", "--nodes-file", "--seed", "--p2p-plugin", "--dump-error-details", "-v", "--leave-running", "--clean-run", "--keep-logs" }) pnodes = args.p topo = args.s delay = args.d total_nodes = pnodes if args.n < pnodes else args.n debug = args.v nodesFile = args.nodes_file dontLaunch = nodesFile is not None seed = args.seed dontKill = args.leave_running dumpErrorDetails = args.dump_error_details killAll = args.clean_run keepLogs = args.keep_logs p2pPlugin = args.p2p_plugin
import random import subprocess import signal ############################################################### # Test for validating the dirty db flag sticks repeated nodeos restart attempts ############################################################### Print=Utils.Print def errorExit(msg="", errorCode=1): Print("ERROR:", msg) exit(errorCode) args = TestHelper.parse_args({"--keep-logs","--dump-error-details","-v","--leave-running","--clean-run"}) debug=args.v pnodes=1 topo="mesh" delay=1 chainSyncStrategyStr=Utils.SyncResyncTag total_nodes = pnodes killCount=1 killSignal=Utils.SigKillTag killEosInstances= not args.leave_running dumpErrorDetails=args.dump_error_details keepLogs=args.keep_logs killAll=args.clean_run seed=1
from testUtils import Utils from Cluster import Cluster from TestHelper import TestHelper import subprocess ############################################################### # snaxnode_run_remote_test # Tests remote capability of the snaxnode_run_test. Test will setup cluster and pass nodes info to snaxnode_run_test. E.g. # snaxnode_run_remote_test.py -v --clean-run --dump-error-detail ############################################################### Print=Utils.Print errorExit=Utils.errorExit args = TestHelper.parse_args({"--dump-error-details","-v","--leave-running","--only-bios","--clean-run"}) debug=args.v dontKill=args.leave_running dumpErrorDetails=args.dump_error_details onlyBios=args.only_bios killAll=args.clean_run Utils.Debug=debug killSnaxInstances=not dontKill topo="mesh" delay=1 prodCount=1 # producers per producer node pnodes=1 total_nodes=pnodes actualTest="tests/snaxnode_run_test.py"
# # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("Test.ice") import TestI class Server(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint()) adapter = communicator.createObjectAdapter("TestAdapter") locator = TestI.ServantLocatorI() adapter.addServantLocator(locator, "") adapter.activate() adapter.waitForDeactivate()
#!/usr/bin/env python3 # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("-I. --all ServerPrivate.ice") import Ice import Test def test(b): if not b: raise RuntimeError('test assertion failed') class TestI(Test.TestIntf): def SBaseAsObject(self, current=None): sb = Test.SBase() sb.sb = "SBase.sb" return sb def SBaseAsSBase(self, current=None): sb = Test.SBase() sb.sb = "SBase.sb" return sb def SBSKnownDerivedAsSBase(self, current=None): sbskd = Test.SBSKnownDerived() sbskd.sb = "SBSKnownDerived.sb" sbskd.sbskd = "SBSKnownDerived.sbskd"
import signal ############################################################### # Test for validating the dirty db flag sticks repeated myeosnode restart attempts ############################################################### Print = Utils.Print def errorExit(msg="", errorCode=1): Print("ERROR:", msg) exit(errorCode) args = TestHelper.parse_args({ "--keep-logs", "--dump-error-details", "-v", "--leave-running", "--clean-run" }) debug = args.v pnodes = 1 topo = "mesh" delay = 1 chainSyncStrategyStr = Utils.SyncResyncTag total_nodes = pnodes killCount = 1 killSignal = Utils.SigKillTag killEnuInstances = not args.leave_running dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs killAll = args.clean_run
#!/usr/bin/env python3 # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("Test.ice Forward.ice ServerPrivate.ice") import TestI import Ice def MyValueFactory(type): if type == '::Test::I': return TestI.II() elif type == '::Test::J': return TestI.JI() elif type == '::Test::H': return TestI.HI() assert (False) # Should never be reached class Server(TestHelper): def run(self, args): properties = self.createTestProperties(args) properties.setProperty("Ice.Warn.Dispatch", "0") with self.initialize(properties=properties) as communicator: communicator.getValueFactoryManager().add(MyValueFactory, '::Test::I') communicator.getValueFactoryManager().add(MyValueFactory, '::Test::J') communicator.getValueFactoryManager().add(MyValueFactory,
from Cluster import Cluster from WalletMgr import WalletMgr from TestHelper import TestHelper import random Print = Utils.Print def errorExit(msg="", errorCode=1): Print("ERROR:", msg) exit(errorCode) args = TestHelper.parse_args({ "-p", "-n", "-d", "-s", "--nodes-file", "--seed", "--dump-error-details", "-v", "--leave-running", "--clean-run" }) pnodes = args.p topo = args.s delay = args.d total_nodes = pnodes if args.n == 0 else args.n debug = args.v nodesFile = args.nodes_file seed = args.seed dontKill = args.leave_running dumpErrorDetails = args.dump_error_details killAll = args.clean_run killWallet = not dontKill killEosInstances = not dontKill
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-present ZeroC, Inc. All rights reserved. # # ********************************************************************** from TestHelper import TestHelper TestHelper.loadSlice('--all -I. Test.ice') import Test import Test1 import testpkg import modpkg import Ice class InitialI(Test.Initial): def getTest1C2AsObject(self, current): return Test1.C2() def getTest1C2AsC1(self, current): return Test1.C2() def getTest1C2AsC2(self, current): return Test1.C2() def throwTest1E2AsE1(self, current): raise Test1.E2() def throwTest1E2AsE2(self, current):
import subprocess import tempfile import os ############################################################### # distributed-transactions-remote-test # # Tests remote capability of the distributed-transactions-test. Test will setup cluster and pass nodes info to distributed-transactions-test. E.g. # distributed-transactions-remote-test.py -v --clean-run --dump-error-detail # ############################################################### Print=Utils.Print errorExit=Utils.errorExit args = TestHelper.parse_args({"-p","--dump-error-details","-v","--leave-running","--clean-run"}) pnodes=args.p debug=args.v dontKill=args.leave_running dumpErrorDetails=args.dump_error_details killAll=args.clean_run Utils.Debug=debug killrsnInstances=not dontKill topo="mesh" delay=1 prodCount=1 # producers per producer node total_nodes=pnodes+3 actualTest="tests/distributed-transactions-test.py" testSuccessful=False
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("Key.ice Clash.ice") import sys import Ice import _and class delI(_and._del): def _elifAsync(self, _else, current=None): pass class execI(_and._exec): def _finally(self, current=None): assert current.operation == "finally" class ifI(_and._if): def _elifAsync(self, _else, current=None): pass def _finally(self, current=None): pass def foo(self, _from, current=None): pass
errorExit=Utils.errorExit from core_symbol import CORE_SYMBOL def verifyBlockLog(expected_block_num, trimmedBlockLog): firstBlockNum = expected_block_num for block in trimmedBlockLog: assert 'block_num' in block, print("ERROR: mtpio-blocklog didn't return block output") block_num = block['block_num'] assert block_num == expected_block_num expected_block_num += 1 Print("Block_log contiguous from block number %d to %d" % (firstBlockNum, expected_block_num - 1)) appArgs=AppArgs() args = TestHelper.parse_args({"--dump-error-details","--keep-logs","-v","--leave-running","--clean-run"}) Utils.Debug=args.v pnodes=2 cluster=Cluster(walletd=True) dumpErrorDetails=args.dump_error_details keepLogs=args.keep_logs dontKill=args.leave_running prodCount=2 killAll=args.clean_run walletPort=TestHelper.DEFAULT_WALLET_PORT totalNodes=pnodes+1 walletMgr=WalletMgr(True, port=walletPort) testSuccessful=False killmtpInstances=not dontKill killWallet=not dontKill
from core_symbol import CORE_SYMBOL def cmdError(name, cmdCode=0, exitNow=False): msg = "FAILURE - %s%s" % (name, ("" if cmdCode == 0 else (" returned error code %d" % cmdCode))) if exitNow: errorExit(msg, True) else: Print(msg) args = TestHelper.parse_args({ "--host", "--port", "--prod-count", "--defproducera_prvt_key", "--defproducerb_prvt_key", "--mongodb", "--dump-error-details", "--dont-launch", "--keep-logs", "-v", "--leave-running", "--only-bios", "--clean-run" }) server = args.host port = args.port debug = args.v enableMongo = args.mongodb defproduceraPrvtKey = args.defproducera_prvt_key defproducerbPrvtKey = args.defproducerb_prvt_key dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontLaunch = args.dont_launch dontKill = args.leave_running prodCount = args.prod_count onlyBios = args.only_bios killAll = args.clean_run
# Id,ActionTypeId,MemberId,Created,CampaignId,TrademarkId,ProductTypeId,InventoryId,CategoryId,CustomListId,Identifier,UserIp,Url,RefererUrl,UserAgentString,ExtraData line = "1,2,3,1/20/2012 13:53,,,,,,,,1.2.3.4,,,," res = walp.parse_line(line) th.should_be(res[walp.ID], 1) th.should_be(res[walp.ACTION_TYPE_ID], 2) th.should_be(res[walp.MEMBER_ID], 3) th.should_be(res[walp.ACTIVITY_DATE], "1/20/2012 13:53") th.should_be(res[walp.CAMPAIGN_ID], None) th.should_be(res[walp.TRADEMARK_ID], None) th.should_be(res[walp.PRODUCT_TYPE_ID], None) th.should_be(res[walp.INVENTORY_ID], None) th.should_be(res[walp.CATEGORY_ID], None) th.should_be(res[walp.CUSTOM_LIST_ID], None) th.should_be(res[walp.IDENTIFIER], None) th.should_be(res[walp.USER_IP], "1.2.3.4") th.should_be(res[walp.REQUESTED_URL], "") th.should_be(res[walp.USER_AGENT], "") th.should_be(res[walp.EXTRA_DATA], "") def can_build_record(th): line = "1,2,3,1/20/2012 13:53,4,5,6,7,8,9,10,212.156.132.66,http://localhost:8080/markalar/4/,REF,Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,EXD" record = WebActivityRecord(line) th.should_be(record.day_of_week, 4) th.should_be(record.category_id, 8) if __name__ == "__main__": th = TestHelper() th.run_test(test_line_parser_all_fields) th.run_test(test_line_parser_missing_fields) th.run_test(can_build_record)
import signal ############################################################### # nodeos_contrl_c_lr_test # # This test sets up one producing nodes and one "bridge" node using test_control_api_plugin. We send # transactions to the bridge node. After the accounts are initialized and allocated with symbols, we # kill the producing node. Then we flood hundreds transactions to the bridge node. At the end, we # kill the bridge. It tests that no crashes happen when the nodes are killed. # ############################################################### errorExit = Utils.errorExit args = TestHelper.parse_args({"--wallet-port", "-v"}) cluster = Cluster(walletd=True) killAll = True totalProducerNodes = 1 totalNonProducerNodes = 1 totalNodes = totalProducerNodes + totalNonProducerNodes walletPort = args.wallet_port walletMgr = WalletMgr(True, port=walletPort) producerEndpoint = '127.0.0.1:8888' httpServerAddress = '127.0.0.1:8889' try: TestHelper.printSystemInfo("BEGIN") cluster.setWalletMgr(walletMgr) cluster.killall(allInstances=killAll)
def setUp(self): self.parser = LinksysParser() self.helper = TestHelper()
############################################################### Print=Utils.Print errorExit=Utils.errorExit from core_symbol import CORE_SYMBOL def cmdError(name, cmdCode=0, exitNow=False): msg="FAILURE - %s%s" % (name, ("" if cmdCode == 0 else (" returned error code %d" % cmdCode))) if exitNow: errorExit(msg, True) else: Print(msg) args = TestHelper.parse_args({"--host","--port","--prod-count","--defproducera_prvt_key","--defproducerb_prvt_key","--mongodb" ,"--dump-error-details","--dont-launch","--keep-logs","-v","--leave-running","--only-bios","--clean-run" ,"--sanity-test"}) server=args.host port=args.port debug=args.v enableMongo=args.mongodb defproduceraPrvtKey=args.defproducera_prvt_key defproducerbPrvtKey=args.defproducerb_prvt_key dumpErrorDetails=args.dump_error_details keepLogs=args.keep_logs dontLaunch=args.dont_launch dontKill=args.leave_running prodCount=args.prod_count onlyBios=args.only_bios killAll=args.clean_run sanityTest=args.sanity_test
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("Test.ice ClientPrivate.ice") import AllTests class Client(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: initial = AllTests.allTests(self, communicator) initial.shutdown()
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("--all -I. ClientPrivate.ice") import AllTests class Client(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: initial = AllTests.allTests(self, communicator) initial.shutdown()
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # import sys import threading import Ice import Glacier2 from TestHelper import TestHelper TestHelper.loadSlice("Callback.ice") import Test def test(b): if not b: raise RuntimeError('test assertion failed') class CallbackReceiverI(Test.CallbackReceiver): def __init__(self): self._received = False self._cond = threading.Condition() def callback(self, current): with self._cond: self._received = True self._cond.notify()
#!/usr/bin/env python3 # # Copyright (c) ZeroC, Inc. All rights reserved. # import sys import threading import Ice import Glacier2 from TestHelper import TestHelper TestHelper.loadSlice("Callback.ice") import Test def test(b): if not b: raise RuntimeError('test assertion failed') class CallbackReceiverI(Test.CallbackReceiver): def __init__(self): self._received = False self._cond = threading.Condition() def callback(self, current): with self._cond: self._received = True self._cond.notify()
#!/usr/bin/env python3 from testUtils import Utils from Cluster import Cluster from WalletMgr import WalletMgr from TestHelper import TestHelper import random Print=Utils.Print def errorExit(msg="", errorCode=1): Print("ERROR:", msg) exit(errorCode) args=TestHelper.parse_args({"-p","-n","-d","-s","--nodes-file","--seed" ,"--dump-error-details","-v","--leave-running","--clean-run"}) pnodes=args.p topo=args.s delay=args.d total_nodes = pnodes if args.n == 0 else args.n debug=args.v nodesFile=args.nodes_file seed=args.seed dontKill=args.leave_running dumpErrorDetails=args.dump_error_details killAll=args.clean_run killWallet=not dontKill killEosInstances=not dontKill if nodesFile is not None:
import json import time import os from os.path import join, exists from datetime import datetime ############################################################### # nodeos_multiple_version_protocol_feature_test # # Test for verifying that older versions of nodeos can work with newer versions of nodeos. # ############################################################### # Parse command line arguments args = TestHelper.parse_args({ "-v", "--clean-run", "--dump-error-details", "--leave-running", "--keep-logs", "--alternate-version-labels-file" }) Utils.Debug = args.v killAll = args.clean_run dumpErrorDetails = args.dump_error_details dontKill = args.leave_running killEosInstances = not dontKill killWallet = not dontKill keepLogs = args.keep_logs alternateVersionLabelsFile = args.alternate_version_labels_file walletMgr = WalletMgr(True) cluster = Cluster(walletd=True) cluster.setWalletMgr(walletMgr)
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice('Test.ice') import Ice import TestI import AllTests import TestActivationI class Collocated(TestHelper): def run(self, args): with self.initialize(args=args) as communicator: communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint()) communicator.getProperties().setProperty("Ice.Warn.Dispatch", "0") adapter = communicator.createObjectAdapter("TestAdapter") # adapter.activate() // Don't activate OA to ensure collocation is used. adapter.addServantLocator(TestI.ServantLocatorI("category"), "category") adapter.addServantLocator(TestI.ServantLocatorI(""), "") adapter.add(TestI.TestI(), Ice.stringToIdentity("asm")) adapter.add(TestActivationI.TestActivationI(), Ice.stringToIdentity("test/activation")) AllTests.allTests(self, communicator)
# --kill-sig <kill signal [term|kill]> # --kill-count <nodeos instances to kill> # --dont-kill <Leave cluster running after test finishes> # --dump-error-details <Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout> # --keep-logs <Don't delete var/lib/node_* folders upon test completion> ############################################################### Print=testUtils.Utils.Print def errorExit(msg="", errorCode=1): Print("ERROR:", msg) traceback.print_stack(limit=-1) exit(errorCode) args=TestHelper.parse_args({"-p","-d","-s","-c","--kill-sig","--kill-count","--keep-logs","--p2p-plugin" ,"--dump-error-details","-v","--leave-running","--clean-run"}) pnodes=args.p topo=args.s delay=args.d chainSyncStrategyStr=args.c debug=args.v total_nodes = pnodes killCount=args.kill_count if args.kill_count > 0 else 1 killSignal=args.kill_sig killEosInstances= not args.leave_running dumpErrorDetails=args.dump_error_details keepLogs=args.keep_logs killAll=args.clean_run p2pPlugin=args.p2p_plugin seed=1
import re ############################################################### # launcher-test # # Specifically tests using the bios bootstrap script that is created by lcscs-launcher # ############################################################### Print = Utils.Print errorExit = Utils.errorExit cmdError = Utils.cmdError from core_symbol import CORE_SYMBOL args = TestHelper.parse_args({ "--defproducera_prvt_key", "--dump-error-details", "--dont-launch", "--keep-logs", "-v", "--leave-running", "--clean-run" }) debug = args.v defproduceraPrvtKey = args.defproducera_prvt_key dumpErrorDetails = args.dump_error_details keepLogs = args.keep_logs dontLaunch = args.dont_launch dontKill = args.leave_running killAll = args.clean_run Utils.Debug = debug cluster = Cluster(walletd=True, defproduceraPrvtKey=defproduceraPrvtKey) walletMgr = WalletMgr(True) testSuccessful = False killscsInstances = not dontKill killWallet = not dontKill
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # from TestHelper import TestHelper TestHelper.loadSlice("-I. --all ServerPrivate.ice") import Ice import Test class TestI(Test.TestIntf): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() def baseAsBase(self, current=None): b = Test.Base() b.b = "Base.b" raise b def unknownDerivedAsBase(self, current=None): d = Test.UnknownDerived() d.b = "UnknownDerived.b" d.ud = "UnknownDerived.ud" raise d def knownDerivedAsBase(self, current=None): d = Test.KnownDerived() d.b = "KnownDerived.b" d.kd = "KnownDerived.kd" raise d