blob: 4a3e57967bebfbd8e977308c7d4087b8b4b411f9 [file] [log] [blame]
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -08001'''
2More complex (composite) test-cases for the OLT
3'''
4
5import logging
6from oftest.testutils import *
7from oltbase import OltBaseTest
Zsolt Harasztid0571402016-03-02 18:40:50 -08008from oltconstants import *
9
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -080010
11class Thing(object):
12 """An object we can stash arbitrary attributes for easy reach"""
13 def __init__(self, **kws):
14 self.__dict__.update(kws)
15
16
17class ControllerAccess(OltBaseTest):
18 """Verify openflow access from OLT device"""
19
20 def runTest(self):
21 logging.info("Running ControllerAccess test")
22
23 # implicitly testing access to the openflow device
24 # and deleting all residual flows and groups
25 delete_all_flows(self.controller)
26 delete_all_groups(self.controller)
27
28
29class TestScenario1SingleOnu(OltBaseTest):
30 """
31 Run a comprehensive test scenrario on the OLT.
32
33 Plan:
34
35 1. Reset the OLT into a clean state
36 2. Setup the OLT to pass authentication (L2/Unicast) traffic for the ONU1
37 3. Verify that unicast traffic works in both directions (use a few hundred frames in both ways)
38 4. Setup IGMP forwarding toward the controller
39 5. Send periodic IGMP queries out toward the ONU and verify its arrival
40 6. Send in an IGMP join request for one channel (specific multicast address) and verify that
41 the controller receives it.
42 7. Setup flows for forwarding multicast traffic from the OLT port toward the ONU(s)
43 8. Verify that multicast packets can reach the ONU
44 9. Verify that bidirectional unicast traffic still works across the PON
45 10. Change channel to a new multicast group and verify both multicast receiption as well as
46 unicast traffic works. This step involves:
47 - sending a leave message by the ONU to the controller and verify its reception
48 - sending a join message and verify its reception
49 - removing the existing multicast flow
50 - adding a new multicast flow
51 - verify that original flow no longer flows
52 - verify new flow
53 - verify that unicast still works
54 11. Add a second channel while keeping the existing one. Verify all what needs to be verified
55 (similar as above)
56 12. Add two more multicast channels, and verify everything
57 13. Flip a channel for one of the multicast channels, and verify everything
58 14. Tear down the test.
59 """
60
61 def runTest(self):
62 logging.info("Running %s" % self.__class__.__name__)
63
64 # Some constants
65 c_vlan_id = 111
Zsolt Harasztid0571402016-03-02 18:40:50 -080066 mcast_vlan_id = 140
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -080067 mcast_groups = Thing(
68 ch1="230.10.10.10",
69 ch2="231.11.11.11",
70 ch3="232.12.12.12",
Zsolt Harasztid0571402016-03-02 18:40:50 -080071 ch4="233.13.13.13",
72 ch5="234.14.14.14"
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -080073 )
74 onu1 = Thing(
Zsolt Harasztid0571402016-03-02 18:40:50 -080075 port=onu_port,
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -080076 ip="13.14.14.13",
77 mac="b6:b8:3e:fb:1a:3f",
78 s_vlan_id=13
79 )
80
81 # 1. Reset the OLT into a clean state
82 self.resetOlt()
83
84 # 2. Setup the OLT to pass authentication (L2/Unicast) traffic for the ONU1
85 self.installDoubleTaggingRules(onu1.s_vlan_id, c_vlan_id, self.getCookieBlock())
86
87 # 3. Verify that unicast traffic works in both directions (use a few hundred frames in both ways)
88 self.testPacketFlow(onu1.s_vlan_id, c_vlan_id) # this tests just one packet in each way
89 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 100)
90
91 # 4. Setup IGMP forwarding toward the controller
Zsolt Harasztid0571402016-03-02 18:40:50 -080092 self.setupIgmpCaptureFlowRules(self.getCookieBlock())
93 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows
94
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -080095 # 5. Send periodic IGMP queries out toward the ONU and verify its arrival
Zsolt Harasztid0571402016-03-02 18:40:50 -080096 self.testIgmpQueryOut()
97 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows
98
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -080099 # 6. Send in an IGMP join request for one channel (specific multicast address) and verify that
100 # the controller receives it.
Zsolt Harasztid0571402016-03-02 18:40:50 -0800101 self.sendIgmpReport(join=[mcast_groups.ch1])
102
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -0800103 # 7. Setup flows for forwarding multicast traffic from the OLT port toward the ONU(s)
Zsolt Harasztid0571402016-03-02 18:40:50 -0800104 ch1_cookie = self.getCookieBlock()
105 ch1_group_id = 1
106 self.setupMcastChannel(mcast_groups.ch1, mcast_vlan_id, [onu1.port], ch1_group_id, ch1_cookie)
107
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -0800108 # 8. Verify that multicast packets can reach the ONU
Zsolt Harasztid0571402016-03-02 18:40:50 -0800109 self.testMcastFlow(mcast_groups.ch1, mcast_vlan_id, [onu1.port], 10)
110
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -0800111 # 9. Verify that bidirectional unicast traffic still works across the PON
Zsolt Harasztid0571402016-03-02 18:40:50 -0800112 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows
113
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -0800114 # 10. Change channel to a new multicast group and verify both multicast receiption as well as
115 # unicast traffic works. This step involves:
116 # - sending a leave message by the ONU to the controller and verify its reception
117 # - sending a join message and verify its reception
118 # - removing the existing multicast flow
119 # - adding a new multicast flow
120 # - verify that original flow no longer flows
121 # - verify new flow
122 # - verify that unicast still works
Zsolt Harasztid0571402016-03-02 18:40:50 -0800123 self.sendIgmpReport(leave=[mcast_groups.ch1], join=[mcast_groups.ch2])
124 self.removeMcastChannel(mcast_groups.ch1, mcast_vlan_id, [onu1.port], ch1_group_id, ch1_cookie)
125 ch2_cookie = self.getCookieBlock()
126 ch2_group_id = 2
127 self.setupMcastChannel(mcast_groups.ch2, mcast_vlan_id, [onu1.port], ch2_group_id, ch2_cookie)
128 self.testMcastFlow(mcast_groups.ch1, mcast_vlan_id, [onu1.port], expect_to_be_blocked=True)
129 self.testMcastFlow(mcast_groups.ch2, mcast_vlan_id, [onu1.port], 10)
130 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows
131
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -0800132 # 11. Add a second channel while keeping the existing one. Verify all what needs to be verified
133 # (similar as above)
Zsolt Harasztid0571402016-03-02 18:40:50 -0800134 self.sendIgmpReport(join=[mcast_groups.ch2, mcast_groups.ch3])
135 ch3_cookie = self.getCookieBlock()
136 ch3_group_id = 3
137 self.setupMcastChannel(mcast_groups.ch3, mcast_vlan_id, [onu1.port], ch3_group_id, ch3_cookie)
138 self.testMcastFlow(mcast_groups.ch1, mcast_vlan_id, [onu1.port], expect_to_be_blocked=True)
139 self.testMcastFlow(mcast_groups.ch2, mcast_vlan_id, [onu1.port], 10)
140 self.testMcastFlow(mcast_groups.ch3, mcast_vlan_id, [onu1.port], 10)
141 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows
142
143 # 12. Add two more multicast channels, and verify everything again
144 self.sendIgmpReport(join=[mcast_groups.ch2, mcast_groups.ch3, mcast_groups.ch4, mcast_groups.ch5])
145 ch4_cookie = self.getCookieBlock()
146 ch4_group_id = 4
147 self.setupMcastChannel(mcast_groups.ch4, mcast_vlan_id, [onu1.port], ch4_group_id, ch4_cookie)
148 ch5_cookie = self.getCookieBlock()
149 ch5_group_id = 5
150 self.setupMcastChannel(mcast_groups.ch5, mcast_vlan_id, [onu1.port], ch5_group_id, ch5_cookie)
151 self.testMcastFlow(mcast_groups.ch1, mcast_vlan_id, [onu1.port], expect_to_be_blocked=True)
152 self.testMcastFlow(mcast_groups.ch2, mcast_vlan_id, [onu1.port], 10)
153 self.testMcastFlow(mcast_groups.ch3, mcast_vlan_id, [onu1.port], 10)
154 self.testMcastFlow(mcast_groups.ch4, mcast_vlan_id, [onu1.port], 10)
155 self.testMcastFlow(mcast_groups.ch5, mcast_vlan_id, [onu1.port], 10)
156 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows
157
158 # 13. Flip a channel for one of the multicast channels, and verify everything (ch3 -> ch1)
159 self.sendIgmpReport(join=[mcast_groups.ch1, mcast_groups.ch2, mcast_groups.ch4, mcast_groups.ch5],
160 leave=[mcast_groups.ch3])
161 self.removeMcastChannel(mcast_groups.ch3, mcast_vlan_id, [onu1.port], ch3_group_id, ch3_cookie)
162 ## reusing the same group id and cookie
163 self.setupMcastChannel(mcast_groups.ch1, mcast_vlan_id, [onu1.port], ch1_group_id, ch1_cookie)
164 self.testMcastFlow(mcast_groups.ch1, mcast_vlan_id, [onu1.port], 10)
165 self.testMcastFlow(mcast_groups.ch2, mcast_vlan_id, [onu1.port], 10)
166 self.testMcastFlow(mcast_groups.ch3, mcast_vlan_id, [onu1.port], expect_to_be_blocked=True)
167 self.testMcastFlow(mcast_groups.ch4, mcast_vlan_id, [onu1.port], 10)
168 self.testMcastFlow(mcast_groups.ch5, mcast_vlan_id, [onu1.port], 10)
169 self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows
Zsolt Harasztif5c6aba2016-03-02 11:41:22 -0800170
171 # 14. Tear down the test.
172 self.resetOlt()