summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-03-10 10:21:37 +0200
committerimarom <imarom@cisco.com>2016-03-10 17:16:38 +0200
commit3c2f0346b3743d27ef0a02e44726f11fdb73417d (patch)
treef4f1837f135581383afbb667cde20a96645113db /scripts/automation/trex_control_plane
parent8b0bb76f7987e33ff1b13b5bdf360a9e15f96c68 (diff)
RX stats #2
Diffstat (limited to 'scripts/automation/trex_control_plane')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py18
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py10
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py12
3 files changed, 21 insertions, 19 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
index 82891b68..ae6cb497 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
@@ -178,7 +178,8 @@ class CTRexAsyncClient():
self.connected = True
- rc = self.barrier()
+ # sync all stats data as a baseline from the server
+ rc = self.barrier(baseline = True)
if not rc:
self.disconnect()
return rc
@@ -245,11 +246,11 @@ class CTRexAsyncClient():
name = msg['name']
data = msg['data']
type = msg['type']
- sync = msg.get('sync', False)
+ baseline = msg.get('baseline', False)
self.raw_snapshot[name] = data
- self.__dispatch(name, type, data, sync)
+ self.__dispatch(name, type, data, baseline)
# closing of socket must be from the same thread
@@ -270,10 +271,11 @@ class CTRexAsyncClient():
return self.raw_snapshot
# dispatch the message to the right place
- def __dispatch (self, name, type, data, sync):
+ def __dispatch (self, name, type, data, baseline):
+
# stats
if name == "trex-global":
- self.event_handler.handle_async_stats_update(data, sync)
+ self.event_handler.handle_async_stats_update(data, baseline)
# events
elif name == "trex-event":
@@ -284,7 +286,7 @@ class CTRexAsyncClient():
self.handle_async_barrier(type, data)
elif name == "flow_stats":
- self.event_handler.handle_async_rx_stats_event(data, sync)
+ self.event_handler.handle_async_rx_stats_event(data, baseline)
else:
pass
@@ -297,7 +299,7 @@ class CTRexAsyncClient():
# block on barrier for async channel
- def barrier(self, timeout = 5):
+ def barrier(self, timeout = 5, baseline = False):
# set a random key
key = random.getrandbits(32)
@@ -309,7 +311,7 @@ class CTRexAsyncClient():
while not self.async_barrier['ack']:
# inject
- rc = self.stateless_client._transmit("publish_now", params = {'key' : key})
+ rc = self.stateless_client._transmit("publish_now", params = {'key' : key, 'baseline': baseline})
if not rc:
return rc
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 1905d44f..5ecb1120 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -155,12 +155,12 @@ class AsyncEventHandler(object):
pass
- def handle_async_rx_stats_event (self, data, sync):
- self.client.flow_stats.update(data, sync)
+ def handle_async_rx_stats_event (self, data, baseline):
+ self.client.flow_stats.update(data, baseline)
# handles an async stats update from the subscriber
- def handle_async_stats_update(self, dump_data, sync):
+ def handle_async_stats_update(self, dump_data, baseline):
global_stats = {}
port_stats = {}
@@ -182,11 +182,11 @@ class AsyncEventHandler(object):
global_stats[key] = value
# update the general object with the snapshot
- self.client.global_stats.update(global_stats, sync)
+ self.client.global_stats.update(global_stats, baseline)
# update all ports
for port_id, data in port_stats.iteritems():
- self.client.ports[port_id].port_stats.update(data, sync)
+ self.client.ports[port_id].port_stats.update(data, baseline)
# dispatcher for server async events (port started, port stopped and etc.)
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index 60c8229d..cf394445 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -389,7 +389,7 @@ class CTRexStats(object):
self.last_update_ts = time.time()
self.history = deque(maxlen = 10)
self.lock = threading.Lock()
- self.is_synced = False
+ self.has_baseline = False
######## abstract methods ##########
@@ -402,15 +402,15 @@ class CTRexStats(object):
raise NotImplementedError()
# called when a snapshot arrives - add more fields
- def _update (self, snapshot, sync):
+ def _update (self, snapshot, baseline):
raise NotImplementedError()
######## END abstract methods ##########
- def update(self, snapshot, sync):
+ def update(self, snapshot, baseline):
- if not self.is_synced and not sync:
+ if not self.has_baseline and not baseline:
return
rc = self._update(snapshot)
@@ -418,9 +418,9 @@ class CTRexStats(object):
return
# sync one time
- if not self.is_synced and sync:
+ if not self.has_baseline and baseline:
self.reference_stats = copy.deepcopy(self.latest_stats)
- self.is_synced = True
+ self.has_baseline = True
# save history
with self.lock: