def wait_for_bootstrap_completion(context, timeout): peers = context.interface.get_peers(context) brokers = [] try: with common_util.Timeout(timeout): common_util.wait_until_in_log( peers, "Starting profiling server with listenAddress = 0.0.0.0:6060") # Check Kafka logs if "kafka0" in context.composition.collectServiceNames(): kafkas = orderer_util.getKafkaBrokerList( context, "orderer0.example.com") # Remove the ports from the list for kafka in kafkas: broker = kafka.split(":") brokers.append(broker[0]) common_util.wait_until_in_log(brokers, " Startup complete. ") finally: assert common_util.is_in_log( peers, "Starting profiling server with listenAddress = 0.0.0.0:6060" ), "The peer containers are not ready in the allotted time ({} seconds)".format( timeout) assert common_util.is_in_log( brokers, " Startup complete. " ), "The kafka containers are not ready in the allotted time ({} seconds)".format( timeout) # A 5-second additional delay ensures ready state time.sleep(5)
def wait_for_deploy_completion(self, context, chaincode_container, timeout): containers = subprocess.check_output(["docker ps -a"], shell=True) try: with common_util.Timeout(timeout): while chaincode_container not in containers: containers = subprocess.check_output(["docker ps -a"], shell=True) time.sleep(1) finally: assert chaincode_container in containers, "The expected chaincode container {} is not running".format(chaincode_container)
def step_impl(context, org): assert hasattr(context, 'initial_non_leader'), "Error: initial non-leader was not set previously. This statement works only with pre-set initial non-leader." max_waittime=15 waittime=5 try: with common_util.Timeout(max_waittime): while not common_util.is_in_log([context.initial_non_leader[org]], "Becoming a leader"): time.sleep(waittime) finally: assert common_util.is_in_log([context.initial_non_leader[org]], "Becoming a leader"), "The initial non-leader peer has not become leader, after "+str(max_waittime)+" seconds."
def wait_for_deploy_completion(self, context, chaincode_container, timeout): if context.remote: time.sleep(30) containers = subprocess.check_output(["docker ps -a"], shell=True) try: with common_util.Timeout(timeout): while chaincode_container not in containers: containers = subprocess.check_output(["docker ps -a"], shell=True) time.sleep(1) finally: assert chaincode_container in containers, "The expected chaincode container {0} is not running\n{1}".format(chaincode_container, containers) # Allow time for chaincode initialization to complete time.sleep(15)
def get_initial_leader(self, context, org): if not hasattr(context, 'initial_leader'): context.initial_leader={} max_waittime=30 waittime=5 try: with common_util.Timeout(max_waittime): while org not in context.initial_leader: for container in self.get_peers(context): if ((org in container) and common_util.is_in_log([container], "Becoming a leader")): context.initial_leader[org]=container print("initial leader is "+context.initial_leader[org]) break time.sleep(waittime) finally: assert org in context.initial_leader, "Error: After " + str(max_waittime) + " seconds, no gossip-leader found by looking at the logs, for "+org return context.initial_leader[org]
def start_firstnetwork_impl(context): curpath = os.path.realpath('.') composeFiles = [ "%s/fabric-samples/first-network/docker-compose-cli.yaml" % (curpath) ] config_util.makeProjectConfigDir(context) shutil.copyfile( "{0}/fabric-samples/first-network/crypto-config.yaml".format(curpath), "{0}/configs/{1}/crypto-config.yaml".format(curpath, context.projectName)) shutil.copyfile( "{0}/fabric-samples/first-network/configtx.yaml".format(curpath), "{0}/configs/{1}/configtx.yaml".format(curpath, context.projectName)) os.mkdir("{0}/configs/{1}/channel-artifacts".format( curpath, context.projectName)) # config_util.buildCryptoFile(context, 2, 2, numOrderers, 2, ouEnable=ouEnabled) generateCryptoArtifacts(context, "mychannel") # config_util.generateCrypto(context, "./configs/{0}/crypto.yaml".format(context.projectName)) # config_util.generateConfig(context, "byfn-sys-channel", "TwoOrgsChannel", "TwoOrgsOrdererGenesis") # shutil.copyfile("{0}/configs/{1}/byfn-sys-channel.tx".format(curpath, context.projectName), "{0}/configs/{1}/channel.tx".format(curpath, context.projectName)) timeout = 120 with common_util.Timeout(timeout): if not hasattr(context, "composition"): context.composition = compose_util.Composition( context, composeFiles, projectName=context.projectName, startContainers=True) else: context.composition.composeFilesYaml = composeFiles context.composition.up() context.compose_containers = context.composition.collectServiceNames() common_util.wait_until_in_log( ["cli"], "Query successful on peer1.org2 on channel ")
def step_impl(context, component, data, timeout): with common_util.Timeout(timeout): common_util.wait_until_in_log([component], data)