Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 1 | ''' |
| 2 | More complex (composite) test-cases for the OLT |
| 3 | ''' |
| 4 | |
| 5 | import logging |
| 6 | from oftest.testutils import * |
| 7 | from oltbase import OltBaseTest |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 8 | from oltconstants import * |
| 9 | |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 10 | |
| 11 | class 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 | |
| 17 | class 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 | |
| 29 | class 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 Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 66 | mcast_vlan_id = 140 |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 67 | mcast_groups = Thing( |
| 68 | ch1="230.10.10.10", |
| 69 | ch2="231.11.11.11", |
| 70 | ch3="232.12.12.12", |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 71 | ch4="233.13.13.13", |
| 72 | ch5="234.14.14.14" |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 73 | ) |
| 74 | onu1 = Thing( |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 75 | port=onu_port, |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 76 | 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 Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 92 | self.setupIgmpCaptureFlowRules(self.getCookieBlock()) |
| 93 | self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows |
| 94 | |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 95 | # 5. Send periodic IGMP queries out toward the ONU and verify its arrival |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 96 | self.testIgmpQueryOut() |
| 97 | self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows |
| 98 | |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 99 | # 6. Send in an IGMP join request for one channel (specific multicast address) and verify that |
| 100 | # the controller receives it. |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 101 | self.sendIgmpReport(join=[mcast_groups.ch1]) |
| 102 | |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 103 | # 7. Setup flows for forwarding multicast traffic from the OLT port toward the ONU(s) |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 104 | 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 Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 108 | # 8. Verify that multicast packets can reach the ONU |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 109 | self.testMcastFlow(mcast_groups.ch1, mcast_vlan_id, [onu1.port], 10) |
| 110 | |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 111 | # 9. Verify that bidirectional unicast traffic still works across the PON |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 112 | self.testSustainedPacketFlow(onu1.s_vlan_id, c_vlan_id, 10) # to check that unicast still flows |
| 113 | |
Zsolt Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 114 | # 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 Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 123 | 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 Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 132 | # 11. Add a second channel while keeping the existing one. Verify all what needs to be verified |
| 133 | # (similar as above) |
Zsolt Haraszti | d057140 | 2016-03-02 18:40:50 -0800 | [diff] [blame^] | 134 | 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 Haraszti | f5c6aba | 2016-03-02 11:41:22 -0800 | [diff] [blame] | 170 | |
| 171 | # 14. Tear down the test. |
| 172 | self.resetOlt() |