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 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 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." assert not common_util.is_in_log( [context.initial_non_leader[org]], "Becoming a leader" ), "Error: initial non-leader peer has already become leader."
def get_initial_non_leader(self, context, org): if not hasattr(context, 'initial_non_leader'): context.initial_non_leader={} if org not in context.initial_non_leader: for container in self.get_peers(context): if ((org in container) and not common_util.is_in_log(container, "Becoming a leader")): context.initial_non_leader[org]=container print("initial non-leader is "+context.initial_non_leader[org]) return context.initial_non_leader[org] assert org in context.initial_non_leader.keys(), "Error: No gossip-leader found by looking at the logs, for "+org return context.initial_non_leader[org]
def step_impl(context): brokers = orderer_util.getKafkaBrokerList(context, "orderer0.example.com") kafkas = orderer_util.getKafkaIPs(context, brokers) topic, isr_list = orderer_util.getKafkaTopic(kafkaBrokers=kafkas) #as long as we have 1 broker in isr_list, check that none from stopped_brokers list exist in isr_list if isr_list >= 1: for kafka in context.stopped_brokers: assert kafka not in isr_list, "stopped broker still exists in isr_set and is not removed" #for each broker in isr_list check logs for kafka in isr_list: assert common_util.is_in_log(kafka, "Shutdown completed (kafka.server.ReplicaFetcherThread)"), "could not verify in the remaining broker logs that prevLeader is down"
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 step_impl(context): orderers = orderer_util.getOrdererList(context) for orderer in orderers: assert common_util.is_in_log( [orderer], "with genesis block hash"), "The genesis block is not received"
def step_impl(context, component, data): assert common_util.is_in_log( component, data), "Error: the {0} log does not contain {1}.".format( component, data)