def run_test(test): """Invokes test handlers to initialize and kick off a test Populates the test result with the set of tasklets running the test to allow them to be queried later""" # Initialize test (publishers, subscribers ) = yield from self.test_handlers[test.test_type].on_start(test) if None in publishers: test.test_state = "test_failed" self.log.error( "Failed to initialize test, a publisher failed initialization" ) return if None in subscribers: test.test_state = "test_failed" self.log.error( "Failed to initialize test, a subscriber failed initialization" ) return test.tasklet_info.publisher = [ rwdtsperfmgr.PerfTest_Test_TaskletInfo_Publisher( instance_name=name) for name in publishers ] test.tasklet_info.subscriber = [ rwdtsperfmgr.PerfTest_Test_TaskletInfo_Subscriber( instance_name=name) for name in subscribers ] # Start test start_xact = rwdtsperf.StartXact() initiators = test.tasklet_info.publisher if test.test_type == 'test_latency': initiators = test.tasklet_info.subscriber yield from asyncio.sleep(5.0, loop=self._loop) for initiator in initiators: tasklet_id = initiator.instance_name.rsplit('-', 1)[1] start_xact.instance_id = int(tasklet_id) try: query_iter = yield from self._dts.query_rpc( xpath="/rwdtsperf:start-xact", flags=0, msg=start_xact) test.test_state = "test_running" except (TransactionFailed, TransactionAborted): test.test_state = "test_failed"
def prepare_xact(self, xact_info, action, ks_path, msg): """Prepare callback for xacts """ rsp_flavor = msg.xact_detail if rsp_flavor in self.xact_config.rsp_flavors: self.statistics.send_rsps += 1 xact_detail = self.xact_config.get_xact_detail(rsp_flavor) msg = xact_detail.generate_content() xact_info.respond_xpath(rwdts.XactRspCode.ACK, xact_detail.xpath, msg) return # If not a valid rsp_flavor send NA. xpath = ks_path.to_xpath(rwdtsperf.get_schema()) xact_info.respond_xpath(rwdts.XactRspCode.NA, xpath)
def __init__(self, tasklet): """ Args: tasklet (RwDtsPerfTasklet): tasklet instance. """ super().__init__(rwdtsperf.PerfStatistics()) self.tasklet = tasklet self.instance_id = int(tasklet.instance_id) self.rtt_index = [2**i for i in range(16)] self._rtt_buckets = [0] * 16 self.start_time = time.time() start_str = str(self.start_time).split(".") self.start_tv_sec = int(start_str[0]) self.start_tv_usec = int(start_str[1])
def handle_perf_statistics(self, xact_info, action, ks_path, msg): """ On prepare callback for /perf-statistics """ # Wildcard if msg.instance_id != 0 and msg.instance_id != self.instance_id: self.log.debug("Instance {}: Got perf-statistics msg for instance_id {}." "Sending NA".format(self.instance_id, msg.instance_id)) xpath = ks_path.to_xpath(rwdtsperf.get_schema()) xact_info.respond_xpath(rwdts.XactRspCode.NA, xpath) return # once the DTS issue has been fixed, change msg.instance_id to self. xpath = "/rwdtsperf:perf-statistics[rwdtsperf:instance-id='{}']".format( self.instance_id) stats = self.statistics.get_gi_object() xact_info.respond_xpath(rwdts.XactRspCode.ACK, xpath, stats)
def prepare_xact(self, xact_info, action, ks_path, msg): """Prepare callback for xacts """ rsp_flavor = msg.xact_detail if rsp_flavor in self.xact_config.rsp_flavors: self.statistics.send_rsps += 1 xact_detail = self.xact_config.get_xact_detail(rsp_flavor) msg = xact_detail.generate_content() xact_info.respond_xpath( rwdts.XactRspCode.ACK, xact_detail.xpath, msg) return # If not a valid rsp_flavor send NA. xpath = ks_path.to_xpath(rwdtsperf.get_schema()) xact_info.respond_xpath(rwdts.XactRspCode.NA, xpath)
def handle_perf_statistics(self, xact_info, action, ks_path, msg): """ On prepare callback for /perf-statistics """ # Wildcard if msg.instance_id != 0 and msg.instance_id != self.instance_id: self.log.debug( "Instance {}: Got perf-statistics msg for instance_id {}." "Sending NA".format(self.instance_id, msg.instance_id)) xpath = ks_path.to_xpath(rwdtsperf.get_schema()) xact_info.respond_xpath(rwdts.XactRspCode.NA, xpath) return # once the DTS issue has been fixed, change msg.instance_id to self. xpath = "/rwdtsperf:perf-statistics[rwdtsperf:instance-id='{}']".format( self.instance_id) stats = self.statistics.get_gi_object() xact_info.respond_xpath(rwdts.XactRspCode.ACK, xpath, stats)
def handle_start_xact(self, xact_info, action, ks_path, msg): """On prepare callback for /start-xact rpc """ xpath = ks_path.to_xpath(rwdtsperf.get_schema()) # Check if the instance can respond to the xpath if msg.instance_id != self.instance_id: xact_info.respond_xpath(rwdts.XactRspCode.NA, xpath) return if self.state == TaskletState.RUNNING: xact_info.respond_xpath(rwdts.XactRspCode.ACK, xpath) return xact_detail = next(self.xact_config.xacts) self.state = TaskletState.RUNNING xact_info.respond_xpath(rwdts.XactRspCode.ACK, xpath) self.log.info("Starting RwDtsPerfTasklet id: {}".format(self.instance_id)) self.send_xact(xact_detail)
def handle_start_xact(self, xact_info, action, ks_path, msg): """On prepare callback for /start-xact rpc """ xpath = ks_path.to_xpath(rwdtsperf.get_schema()) # Check if the instance can respond to the xpath if msg.instance_id != self.instance_id: xact_info.respond_xpath(rwdts.XactRspCode.NA, xpath) return if self.state == TaskletState.RUNNING: xact_info.respond_xpath(rwdts.XactRspCode.ACK, xpath) return xact_detail = next(self.xact_config.xacts) self.state = TaskletState.RUNNING xact_info.respond_xpath(rwdts.XactRspCode.ACK, xpath) self.log.info("Starting RwDtsPerfTasklet id: {}".format( self.instance_id)) self.send_xact(xact_detail)
def generate_content(self): """Generates the input payload based on the configuration provided. Returns: XactMsg_Content: Gi object """ msg = rwdtsperf.XactMsg_Content() msg.xact_detail = self.xact_rsp_flavor content = self.payload_pattern times = 1 if len(content) > 0: times = self.payload_len / len(content) content *= math.ceil(times) content = content[:self.payload_len] msg.input_payload = content return msg
def start(self): """Entry point for tasklet """ self.log.setLevel(logging.INFO) super().start() self._dts = rift.tasklets.DTS(self.tasklet_info, rwdtsperf.get_schema(), self._loop, self.on_dts_state_change) # Set the instance id self.instance_name = self.tasklet_info.instance_name self.instance_id = int(self.instance_name.rsplit('-', 1)[1]) self.log.debug("Starting RwDtsPerfTasklet Name: {}, Id: {}".format( self.instance_name, self.instance_id)) self.state = TaskletState.STARTING self.xact_config = None # Will contain the TestConfig data self.statistics = Statistics(self) # A container to hold the current outstanding transactions self.curr_xacts = {}
def start(self): """Entry point for tasklet """ self.log.setLevel(logging.INFO) super().start() self._dts = rift.tasklets.DTS( self.tasklet_info, rwdtsperf.get_schema(), self._loop, self.on_dts_state_change) # Set the instance id self.instance_name = self.tasklet_info.instance_name self.instance_id = int(self.instance_name.rsplit('-', 1)[1]) self.log.debug("Starting RwDtsPerfTasklet Name: {}, Id: {}".format( self.instance_name, self.instance_id)) self.state = TaskletState.STARTING self.xact_config = None # Will contain the TestConfig data self.statistics = Statistics(self) # A container to hold the current outstanding transactions self.curr_xacts = {}