Adding subscriber channel join, recv and jump test cases.
diff --git a/src/test/utils/Channels.py b/src/test/utils/Channels.py
index 90d4f3c..3c4ff45 100644
--- a/src/test/utils/Channels.py
+++ b/src/test/utils/Channels.py
@@ -29,8 +29,12 @@
self.onos_ctrl = OnosCtrl('org.onosproject.igmp')
self.onos_ctrl.activate()
- def igmp_join(self, groups):
+ def igmp_load_ssm_config(self, groups):
self.ssm_table_load(groups)
+
+ def igmp_join(self, groups, ssm_load = False):
+ if ssm_load:
+ self.igmp_load_ssm_config(groups)
igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
gaddr='224.0.1.1')
for g in groups:
@@ -83,6 +87,9 @@
def __init__(self, num, iface = 'veth0', iface_mcast = 'veth2', mcast_cb = None):
self.num = num
self.channels = self.generate(self.num)
+ self.group_channel_map = {}
+ for i in range(self.num):
+ self.group_channel_map[self.channels[i]] = i
self.state = self.Stopped
self.streams = None
self.channel_states = {}
@@ -122,13 +129,16 @@
chan = 0
if self.get_state(chan) == self.Joined:
- return chan
+ return chan, 0
groups = [self.channels[chan]]
+ #load the ssm table first
+ self.igmp_load_ssm_config(groups)
+ join_start = monotonic.monotonic()
self.igmp_join(groups)
self.set_state(chan, self.Joined)
self.last_chan = chan
- return chan
+ return chan, join_start
def leave(self, chan):
if chan is None:
@@ -170,14 +180,23 @@
s_next = chan
else:
s_next = 0
+ if self.num - s_next < 2:
+ s_next = 0
chan = random.randint(s_next, self.num)
return self.join(chan)
def gaddr(self, chan):
+ '''Return the group address for a channel'''
if chan >= self.num:
return None
return self.channels[chan]
+ def caddr(self, group):
+ '''Return a channel given a group addr'''
+ if self.group_channel_map.has_key(group):
+ return self.group_channel_map[group]
+ return None
+
def recv_cb(self, pkt):
'''Default channel receive callback'''
log.debug('Received packet from source %s, destination %s' %(pkt[IP].src, pkt[IP].dst))
diff --git a/src/test/utils/Stats.py b/src/test/utils/Stats.py
index 3d8e40c..ef3707d 100644
--- a/src/test/utils/Stats.py
+++ b/src/test/utils/Stats.py
@@ -9,9 +9,10 @@
self.max = 0
self.delta_squares = 0
- def update(self, packets = 0, t = 0):
+ def update(self, packets = 0, t = 0, usecs = False):
self.count += packets
- t *= 1000000 ##convert to usecs
+ if usecs == False:
+ t *= 1000000 ##convert to usecs
if self.start == 0:
self.start = t
self.delta += t