Commit 10b83104 authored by Pedro Oliveira's avatar Pedro Oliveira

added one test -> transition to NI caused by AW death

parent 07f20ce2
......@@ -3,7 +3,7 @@ import logging
import logging.handlers
import socketserver
import struct
from TestAssert import CustomFilter, Test1, Test2, Test3
from TestAssert import CustomFilter, Test1, Test2, Test3, Test4
import sys
import threading
from queue import Queue
......@@ -24,7 +24,7 @@ def worker():
class TestHandler(logging.StreamHandler):
currentTest = Test1()
currentTest.print_test()
nextTests = [Test2(), Test3()]
nextTests = [Test2(), Test3(), Test4()]
main = None
def emit(self, record):
......@@ -37,6 +37,7 @@ class TestHandler(logging.StreamHandler):
TestHandler.currentTest = None
TestHandler.main.abort = True
class LogRecordStreamHandler(socketserver.StreamRequestHandler):
"""Handler for a streaming logging request.
......@@ -110,4 +111,4 @@ def main():
if __name__ == '__main__':
main()
main()
\ No newline at end of file
import logging
from abc import ABCMeta
from abc import ABCMeta, abstractmethod
class CustomFilter(logging.Filter):
def filter(self, record):
......@@ -7,7 +8,7 @@ class CustomFilter(logging.Filter):
record.routername in ["R1", "R2", "R3", "R4", "R5", "R6"]
class Test():
class Test(object):
__metaclass__ = ABCMeta
def __init__(self, testName, expectedState, success):
......@@ -27,11 +28,12 @@ class Test():
print('\x1b[1;32;40m' + self.testName + ' Success' + '\x1b[0m')
return True
@abstractmethod
def print_test(self):
pass
class Test1(Test):
def __init__(self):
expectedState = {"R2": {"eth1": "L"},
"R3": {"eth1": "L"},
......@@ -54,8 +56,27 @@ class Test1(Test):
print("Expected: R4 WINNER")
class Test2(Test):
def __init__(self):
expectedState = {"R2": {"eth1": "NI"},
"R3": {"eth1": "NI"},
"R5": {"eth0": "NI"},
"R6": {"eth0": "NI"},
}
success = {"R2": {"eth1": False},
"R3": {"eth1": False},
"R5": {"eth0": False},
"R6": {"eth0": False},
}
super().__init__("Test2", expectedState, success)
def print_test(self):
print("Test2: Kill assert winner")
print("Expected: Every AL transitions to NI")
class Test3(Test):
def __init__(self):
expectedState = {"R2": {"eth1": "L"},
"R3": {"eth1": "W"},
......@@ -68,15 +89,14 @@ class Test2(Test):
"R5": {"eth0": False},
"R6": {"eth0": False},
}
super().__init__("Test2", expectedState, success)
super().__init__("Test3", expectedState, success)
def print_test(self):
print("Test2: Kill assert winner")
print("Test3: Source sends data causing the reelection of AW")
print("Expected: R3 WINNER")
class Test3(Test):
class Test4(Test):
def __init__(self):
expectedState = {"R2": {"eth1": "NI"},
"R3": {"eth1": "NI"},
......@@ -86,8 +106,8 @@ class Test3(Test):
"R3": {"eth1": False},
}
super().__init__("Test3", expectedState, success)
super().__init__("Test4", expectedState, success)
def print_test(self):
print("Test3: CouldAssert of AssertWinner(R3) -> False")
print("Test4: CouldAssert of AssertWinner(R3) -> False")
print("Expected: everyone NI")
rm /hosthome/Desktop/assert_capture.pcap
tcpdump -i br0 -Q in -w /hosthome/Desktop/assert_capture.pcap
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment