diff options
-rwxr-xr-x | scripts/automation/trex_control_plane/client/trex_client.py | 67 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/run-gtest-clean | 0 | ||||
-rw-r--r-- | src/latency.cpp | 6 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 2 |
4 files changed, 72 insertions, 3 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_client.py b/scripts/automation/trex_control_plane/client/trex_client.py index 5709b7a5..1d94dc06 100755 --- a/scripts/automation/trex_control_plane/client/trex_client.py +++ b/scripts/automation/trex_control_plane/client/trex_client.py @@ -294,6 +294,34 @@ class CTRexClient(object): finally: self.prompt_verbose_data() + def is_idle (self): + """ + Poll for TRex running status, check if TRex is in Idle state. + + :parameters: + None + + :return: + + **True** if TRex is idle. + + **False** if TRex is starting or running. + + :raises: + + :exc:`trex_exceptions.TRexIncompleteRunError`, in case one of failed TRex run (unexpected termination). + + :exc:`TypeError`, in case JSON stream decoding error. + + ProtocolError, in case of error in JSON-RPC protocol. + + """ + try: + if self.get_running_status()['state'] == TRexStatus.Idle: + return True + return False + except TRexException: + raise + except ProtocolError as err: + raise + finally: + self.prompt_verbose_data() + def get_trex_files_path (self): """ Fetches the local path in which files are stored when pushed to TRex server from client. @@ -455,6 +483,41 @@ class CTRexClient(object): results = self.get_result_obj() return results + def sample_x_seconds (self, sample_time, time_between_samples = 5): + """ + Automatically sets ongoing sampling of TRex data for sample_time seconds, with sampling rate described by time_between_samples. + Does not stop the TRex afterwards! + + .. tip:: Useful for changing the device (Router, ASA etc.) configuration after given time. + + :parameters: + sample_time : int + sample the TRex this number of seconds + + time_between_samples : int + determines the time between each sample of the server + + default value : **5** + + :return: + the first result object (see :class:`CTRexResult` for further details) of the TRex run after given sample_time. + + :raises: + + :exc:`UserWarning`, in case the TRex run ended before sample_time duration + + :exc:`trex_exceptions.TRexIncompleteRunError`, in case one of failed TRex run (unexpected termination). + + :exc:`TypeError`, in case JSON stream decoding error. + + ProtocolError, in case of error in JSON-RPC protocol. + + """ + # make sure TRex is running. raise exceptions here if any + self.wait_until_kickoff_finish() + elapsed_time = 0 + while self.is_running(): + if elapsed_time >= sample_time: + return self.get_result_obj() + time.sleep(time_between_samples) + elapsed_time += time_between_samples + raise UserWarning("TRex has stopped at %s seconds (before expected %s seconds)\nTry increasing test duration or decreasing sample_time" % (elapsed_time, sample_time)) def get_result_obj (self, copy_obj = True): """ @@ -1041,11 +1104,11 @@ class CTRexResult(object): # handle latency data if self.latency_checked: latency_pre = "trex-latency" - self._max_latency = self.get_last_value("{latency}.data".format(latency = latency_pre), ".*max-")#None # TBC + self._max_latency = self.get_last_value("{latency}.data".format(latency = latency_pre), "max-")#None # TBC # support old typo if self._max_latency is None: latency_pre = "trex-latecny" - self._max_latency = self.get_last_value("{latency}.data".format(latency = latency_pre), ".*max-") + self._max_latency = self.get_last_value("{latency}.data".format(latency = latency_pre), "max-") self._avg_latency = self.get_last_value("{latency}.data".format(latency = latency_pre), "avg-")#None # TBC self._avg_latency = CTRexResult.__avg_all_and_rename_keys(self._avg_latency) diff --git a/scripts/run-gtest-clean b/scripts/run-gtest-clean index 99994e31..99994e31 100644..100755 --- a/scripts/run-gtest-clean +++ b/scripts/run-gtest-clean diff --git a/src/latency.cpp b/src/latency.cpp index 02b54f75..3969c357 100644 --- a/src/latency.cpp +++ b/src/latency.cpp @@ -268,7 +268,7 @@ void CCPortLatency::dump_json(std::string & json ){ void CCPortLatency::DumpShort(FILE *fd){ - m_hist.update(); +// m_hist.update(); <- moved to CLatencyManager::update() fprintf(fd,"%8lu,%8lu,%10lu,%4lu,", m_tx_pkt_ok, m_pkt_ok, @@ -907,6 +907,10 @@ void CLatencyManager::rx_check_dump_json(std::string & json){ void CLatencyManager::update(){ m_cpu_cp_u.Update() ; + for (int i=0; i<m_max_ports; i++) { + CLatencyManagerPerPort * lp=&m_ports[i]; + lp->m_port.m_hist.update(); + } } void CLatencyManager::DumpShort(FILE *fd){ diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 3a64f8c5..aa34e87b 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -72,6 +72,8 @@ TrexStatelessPort::TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api /* init the events DP DB */ m_dp_events.create(this); + + m_graph_obj = NULL; } |