Test: New changes and test scenarios for
different net conditions triggered by corrupted
packets , burst of packets, delayed packets etc.
Change-Id: Id0aa8adfe0eb9f13458c42618d6810b2845c8ef6
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index 24aa6b5..3b62f68 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -155,6 +155,22 @@
self.id = ctn['Id']
return ctn
+ @classmethod
+ def pause_container(cls, image, delay):
+ cnt_list = filter(lambda c: c['Image'] == image, cls.dckr.containers(all=True))
+ for cnt in cnt_list:
+ print('Pause the container %s' %cnt['Id'])
+ if cnt.has_key('State') and cnt['State'] == 'running':
+ cls.dckr.pause(cnt['Id'])
+ if delay != 0:
+ time.sleep(delay)
+ for cnt in cnt_list:
+ print('Unpause the container %s' %cnt['Id'])
+ cls.dckr.unpause(cnt['Id'])
+ else:
+ print('Infinity time pause the container %s' %cnt['Id'])
+ return 'success'
+
def connect_to_br(self):
index = 0
with docker_netns(self.name) as pid:
@@ -191,7 +207,7 @@
ip.link('set', index=guest, state='up')
index += 1
- def execute(self, cmd, tty = True, stream = False, shell = False):
+ def execute(self, cmd, tty = True, stream = False, shell = False, detach = True):
res = 0
if type(cmd) == str:
cmds = (cmd,)
@@ -203,7 +219,7 @@
return res
for c in cmds:
i = self.dckr.exec_create(container=self.name, cmd=c, tty = tty, privileged = True)
- self.dckr.exec_start(i['Id'], stream = stream, detach=True)
+ self.dckr.exec_start(i['Id'], stream = stream, detach=detach)
result = self.dckr.exec_inspect(i['Id'])
res += 0 if result['ExitCode'] == None else result['ExitCode']
return res
diff --git a/src/test/utils/EapolAAA.py b/src/test/utils/EapolAAA.py
index 5cf79fd..d256e0b 100644
--- a/src/test/utils/EapolAAA.py
+++ b/src/test/utils/EapolAAA.py
@@ -223,3 +223,45 @@
code, id, eaplen = unpack("!BBH", p[4:8])
return code
+ @classmethod
+ def eap_invalid_tls_packets_info(self, invalid_field_name = None, invalid_field_value = None):
+ log.info( 'Changing invalid field values in tls auth packets' )
+ if invalid_field_name == 'eapolTlsVersion':
+ global EAPOL_VERSION
+ log.info( 'Changing invalid field values in tls auth packets====== version changing' )
+ EAPOL_VERSION = invalid_field_value
+ if invalid_field_name == 'eapolTlsType':
+ global EAP_TYPE_TLS
+ log.info( 'Changing invalid field values in tls auth packets====== EAP TYPE TLS changing' )
+ EAP_TYPE_TLS = invalid_field_value
+ if invalid_field_name == 'eapolTypeID':
+ global EAP_TYPE_ID
+ log.info( 'Changing invalid field values in tls auth packets====== EAP TYPE TLS changing' )
+ EAP_TYPE_ID = invalid_field_value
+ if invalid_field_name == 'eapolResponse':
+ global EAP_RESPONSE
+ log.info( 'Changing invalid field values in tls auth packets====== EAP TYPE TLS changing' )
+ EAP_RESPONSE = invalid_field_value
+
+
+ @classmethod
+ def eap_tls_packets_field_value_replace(self, invalid_field_name = None):
+ log.info( 'Changing invalid field values in tls auth packets' )
+ if invalid_field_name == 'eapolTlsVersion':
+ global EAPOL_VERSION
+ EAPOL_VERSION = 1
+ log.info( 'Changing invalid field values in tls auth packets====== version changing' )
+ if invalid_field_name == 'eapolTlsType':
+ global EAP_TYPE_TLS
+ EAP_TYPE_TLS = 13
+ log.info( 'Changing invalid field values in tls auth packets====== version changing' )
+ if invalid_field_name == 'eapolTypeID':
+ global EAP_TYPE_ID
+ EAP_TYPE_ID = 1
+ log.info( 'Changing invalid field values in tls auth packets====== version changing' )
+ if invalid_field_name == 'eapolResponse':
+ global EAP_RESPONSE
+ EAP_RESPONSE = 2
+ log.info( 'Changing invalid field values in tls auth packets====== version changing' )
+
+
diff --git a/src/test/utils/IGMP.py b/src/test/utils/IGMP.py
index c91dfdd..7e348bc 100644
--- a/src/test/utils/IGMP.py
+++ b/src/test/utils/IGMP.py
@@ -1,12 +1,9 @@
-#
# Copyright 2016-present Ciena Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
# http://www.apache.org/licenses/LICENSE-2.0
-#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,11 +17,13 @@
IGMP_TYPE_MEMBERSHIP_QUERY = 0x11
IGMP_TYPE_V3_MEMBERSHIP_REPORT = 0x22
+IGMP_TYPE_V3_MEMBERSHIP_REPORT_NEGATIVE = 0xdd
IGMP_TYPE_V1_MEMBERSHIP_REPORT = 0x12
IGMP_TYPE_V2_MEMBERSHIP_REPORT = 0x16
IGMP_TYPE_V2_LEAVE_GROUP = 0x17
IGMP_V3_GR_TYPE_INCLUDE = 0x01
+IGMP_V3_GR_TYPE_INCLUDE_NEGATIVE = 0xaa
IGMP_V3_GR_TYPE_EXCLUDE = 0x02
IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE = 0x03
IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE = 0x04
@@ -48,6 +47,7 @@
igmp_v3_gr_types = {
IGMP_V3_GR_TYPE_INCLUDE: "Include Mode",
+ IGMP_V3_GR_TYPE_INCLUDE_NEGATIVE: "Include Mode in negative scenario",
IGMP_V3_GR_TYPE_EXCLUDE: "Exclude Mode",
IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE: "Change to Include Mode",
IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE: "Change to Exclude Mode",
@@ -149,7 +149,7 @@
return (byte1 & 0xf0) == 0xe0
@staticmethod
- def fixup(pkt):
+ def fixup(pkt, invalid_ttl = None):
"""Fixes up the underlying IP() and Ether() headers."""
assert pkt.haslayer(IGMPv3), "This packet is not an IGMPv4 packet; cannot fix it up"
@@ -157,7 +157,10 @@
if pkt.haslayer(IP):
ip = pkt.getlayer(IP)
- ip.ttl = 1
+ if invalid_ttl is None:
+ ip.ttl = 1
+ else:
+ ip.ttl = 20
ip.proto = 2
ip.tos = 0xc0
ip.options = [IPOption_Router_Alert()]
@@ -225,7 +228,8 @@
hexdump(str(pkt))
print "after fixup:"
- IGMPv3.fixup(pkt)
+
+ IGMPv3.fixup(pkt,'no')
hexdump(str(pkt))
print "construct v3 membership report - join a single group"