Esempio n. 1
0
def multiPoolNodesCreated(request, tconf, looper, tdir,
                          cliTempLogger, namesOfPools=("pool1", "pool2")):

    multiNodes = []
    for poolName in namesOfPools:
        newPoolTxnNodeNames = [poolName + n for n
                               in ("Alpha", "Beta", "Gamma", "Delta")]
        newTdir = os.path.join(tdir, poolName)
        newPoolTxnData = getPoolTxnData(poolName, newPoolTxnNodeNames)
        newTdirWithPoolTxns = tdirWithPoolTxns(newPoolTxnData, newTdir, tconf)
        newTdirWithDomainTxns = tdirWithDomainTxns(
            newPoolTxnData, newTdir, tconf, domainTxnOrderedFields())
        testPoolNode = TestMultiNode(
            poolName, newPoolTxnNodeNames, newTdir, tconf,
            newPoolTxnData, newTdirWithPoolTxns, newTdirWithDomainTxns, None)

        poolCLIBabyGen = CliBuilder(newTdir, newTdirWithPoolTxns,
                                    newTdirWithDomainTxns, tconf,
                                    cliTempLogger)
        poolCLIBaby = next(poolCLIBabyGen(poolName, looper))
        poolCli = poolCLI(poolCLIBaby, newPoolTxnData, newPoolTxnNodeNames,
                          tconf)
        testPoolNode.poolCli = poolCli
        multiNodes.append(testPoolNode)
        ensureNodesCreated(poolCli, newPoolTxnNodeNames)

    return multiNodes
Esempio n. 2
0
def multiPoolNodesCreated(request,
                          tconf,
                          looper,
                          tdir,
                          cliTempLogger,
                          namesOfPools=("pool1", "pool2")):

    multiNodes = []
    for poolName in namesOfPools:
        newPoolTxnNodeNames = [
            poolName + n for n in ("Alpha", "Beta", "Gamma", "Delta")
        ]
        config_helper = ConfigHelper(tconf, chroot=tdir)
        ledger_dir = os.path.join(config_helper.ledger_base_dir, poolName)
        newPoolTxnData = getPoolTxnData(poolName, newPoolTxnNodeNames)
        newTdirWithPoolTxns = custom_tdir_with_pool_txns(
            newPoolTxnData, ledger_dir, tconf.poolTransactionsFile)
        newTdirWithDomainTxns = custom_tdir_with_domain_txns(
            newPoolTxnData, ledger_dir, domainTxnOrderedFields(),
            tconf.domainTransactionsFile)
        testPoolNode = TestMultiNode(poolName, newPoolTxnNodeNames, tdir,
                                     tconf, newPoolTxnData,
                                     newTdirWithPoolTxns,
                                     newTdirWithDomainTxns, None)

        poolCLIBabyGen = CliBuilder(tdir, newTdirWithPoolTxns,
                                    newTdirWithDomainTxns, looper, tconf,
                                    cliTempLogger)
        poolCLIBaby = next(poolCLIBabyGen(poolName))

        # Ugly hack to build several networks
        network_bak = tconf.NETWORK_NAME
        tconf.NETWORK_NAME = poolName
        tdirWithNodeKeepInited(tdir, tconf, NodeConfigHelper, newPoolTxnData,
                               newPoolTxnNodeNames)

        nodes = []
        for nm in newPoolTxnNodeNames:
            config_helper = NodeConfigHelper(nm, tconf, chroot=tdir)
            node = TestNode(nm,
                            config_helper=config_helper,
                            config=tconf,
                            pluginPaths=None)
            looper.add(node)
            nodes.append(node)
        looper.run(checkNodesConnected(nodes))
        ensureElectionsDone(looper=looper, nodes=nodes)

        poolCli = poolCLI(tdir, tconf, poolCLIBaby, newPoolTxnData,
                          newPoolTxnNodeNames, nodes)
        testPoolNode.poolCli = poolCli
        multiNodes.append(testPoolNode)
        tconf.NETWORK_NAME = network_bak

    return multiNodes
Esempio n. 3
0
def multiPoolNodesCreated(request, tconf, looper, tdir,
                          cliTempLogger, namesOfPools=("pool1", "pool2")):

    multiNodes = []
    for poolName in namesOfPools:
        newPoolTxnNodeNames = [poolName + n for n
                               in ("Alpha", "Beta", "Gamma", "Delta")]
        config_helper = ConfigHelper(tconf, chroot=tdir)
        ledger_dir = os.path.join(config_helper.ledger_base_dir, poolName)
        newPoolTxnData = getPoolTxnData(poolName, newPoolTxnNodeNames)
        newTdirWithPoolTxns = custom_tdir_with_pool_txns(newPoolTxnData, ledger_dir,
                                                         tconf.poolTransactionsFile)
        newTdirWithDomainTxns = custom_tdir_with_domain_txns(
            newPoolTxnData, ledger_dir, domainTxnOrderedFields(), tconf.domainTransactionsFile)
        testPoolNode = TestMultiNode(
            poolName, newPoolTxnNodeNames, tdir, tconf,
            newPoolTxnData, newTdirWithPoolTxns, newTdirWithDomainTxns, None)

        poolCLIBabyGen = CliBuilder(tdir, newTdirWithPoolTxns,
                                    newTdirWithDomainTxns, looper, tconf,
                                    cliTempLogger)
        poolCLIBaby = next(poolCLIBabyGen(poolName))

        # Ugly hack to build several networks
        network_bak = tconf.NETWORK_NAME
        tconf.NETWORK_NAME = poolName
        tdirWithNodeKeepInited(tdir, tconf, NodeConfigHelper, newPoolTxnData, newPoolTxnNodeNames)

        nodes = []
        for nm in newPoolTxnNodeNames:
            config_helper = NodeConfigHelper(nm, tconf, chroot=tdir)
            node = TestNode(nm,
                            config_helper=config_helper,
                            config=tconf,
                            pluginPaths=None)
            looper.add(node)
            nodes.append(node)
        looper.run(checkNodesConnected(nodes))
        ensureElectionsDone(looper=looper, nodes=nodes)

        poolCli = poolCLI(tdir, tconf, poolCLIBaby, newPoolTxnData,
                          newPoolTxnNodeNames, nodes)
        testPoolNode.poolCli = poolCli
        multiNodes.append(testPoolNode)
        tconf.NETWORK_NAME = network_bak

    return multiNodes
Esempio n. 4
0
def multiPoolNodesCreated(request,
                          tconf,
                          looper,
                          tdir,
                          cliTempLogger,
                          namesOfPools=("pool1", "pool2")):
    oldENVS = tconf.ENVS
    oldPoolTxnFile = tconf.poolTransactionsFile
    oldDomainTxnFile = tconf.domainTransactionsFile

    multiNodes = []
    for poolName in namesOfPools:
        newPoolTxnNodeNames = [
            poolName + n for n in ("Alpha", "Beta", "Gamma", "Delta")
        ]
        newTdir = os.path.join(tdir, poolName + "basedir")
        newPoolTxnData = getPoolTxnData(poolName, newPoolTxnNodeNames)
        newTdirWithPoolTxns = tdirWithPoolTxns(newPoolTxnData, newTdir, tconf)
        newTdirWithDomainTxns = tdirWithDomainTxns(newPoolTxnData, newTdir,
                                                   tconf,
                                                   domainTxnOrderedFields())
        testPoolNode = TestMultiNode(poolName, newPoolTxnNodeNames, newTdir,
                                     tconf, newPoolTxnData,
                                     newTdirWithPoolTxns,
                                     newTdirWithDomainTxns, None)

        poolCLIBabyGen = CliBuilder(newTdir, newTdirWithPoolTxns,
                                    newTdirWithDomainTxns, tconf,
                                    cliTempLogger)
        poolCLIBaby = next(poolCLIBabyGen(poolName, looper))
        poolCli = poolCLI(poolCLIBaby, newPoolTxnData, newPoolTxnNodeNames,
                          tconf)
        testPoolNode.poolCli = poolCli
        multiNodes.append(testPoolNode)
        ensureNodesCreated(poolCli, newPoolTxnNodeNames)

    def reset():
        tconf.ENVS = oldENVS
        tconf.poolTransactionsFile = oldPoolTxnFile
        tconf.domainTransactionsFile = oldDomainTxnFile

    request.addfinalizer(reset)
    return multiNodes