Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.sdnip; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 18 | import com.google.common.collect.Sets; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 19 | import org.junit.Before; |
| 20 | import org.junit.Ignore; |
| 21 | import org.junit.Test; |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 22 | import org.onlab.junit.TestUtils.TestUtilsException; |
Jonathan Hart | 5137218 | 2014-12-03 21:32:34 -0800 | [diff] [blame] | 23 | import org.onlab.packet.Ethernet; |
| 24 | import org.onlab.packet.IPv4; |
| 25 | import org.onlab.packet.IpAddress; |
| 26 | import org.onlab.packet.IpPrefix; |
| 27 | import org.onlab.packet.MacAddress; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 28 | import org.onlab.packet.TpPort; |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 29 | import org.onlab.packet.VlanId; |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 30 | import org.onosproject.TestApplicationId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 31 | import org.onosproject.core.ApplicationId; |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 32 | import org.onosproject.incubator.net.intf.Interface; |
| 33 | import org.onosproject.incubator.net.intf.InterfaceService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 34 | import org.onosproject.net.ConnectPoint; |
| 35 | import org.onosproject.net.DeviceId; |
| 36 | import org.onosproject.net.PortNumber; |
Jonathan Hart | 08105be | 2015-10-10 18:31:06 -0700 | [diff] [blame] | 37 | import org.onosproject.net.config.NetworkConfigListener; |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 38 | import org.onosproject.net.config.NetworkConfigService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 39 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 40 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 41 | import org.onosproject.net.flow.TrafficSelector; |
| 42 | import org.onosproject.net.flow.TrafficTreatment; |
| 43 | import org.onosproject.net.host.InterfaceIpAddress; |
| 44 | import org.onosproject.net.intent.AbstractIntentTest; |
| 45 | import org.onosproject.net.intent.Intent; |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 46 | import org.onosproject.net.intent.Key; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 47 | import org.onosproject.net.intent.PointToPointIntent; |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 48 | import org.onosproject.routing.IntentSynchronizationService; |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 49 | import org.onosproject.routing.config.BgpConfig; |
Jonathan Hart | 2da1e60 | 2015-02-18 19:09:24 -0800 | [diff] [blame] | 50 | import org.onosproject.routing.config.BgpPeer; |
| 51 | import org.onosproject.routing.config.BgpSpeaker; |
Jonathan Hart | 2da1e60 | 2015-02-18 19:09:24 -0800 | [diff] [blame] | 52 | import org.onosproject.routing.config.InterfaceAddress; |
| 53 | import org.onosproject.routing.config.RoutingConfigurationService; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 54 | |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 55 | import java.util.ArrayList; |
| 56 | import java.util.Collections; |
| 57 | import java.util.HashMap; |
| 58 | import java.util.LinkedList; |
| 59 | import java.util.List; |
| 60 | import java.util.Map; |
Jonathan Hart | a862548 | 2015-09-08 16:14:56 -0700 | [diff] [blame] | 61 | import java.util.Optional; |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 62 | import java.util.Set; |
Jonathan Hart | 552e31f | 2015-02-06 11:11:59 -0800 | [diff] [blame] | 63 | |
Jonathan Hart | 08105be | 2015-10-10 18:31:06 -0700 | [diff] [blame] | 64 | import static org.easymock.EasyMock.anyObject; |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 65 | import static org.easymock.EasyMock.createMock; |
| 66 | import static org.easymock.EasyMock.expect; |
Jonathan Hart | 08105be | 2015-10-10 18:31:06 -0700 | [diff] [blame] | 67 | import static org.easymock.EasyMock.expectLastCall; |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 68 | import static org.easymock.EasyMock.replay; |
| 69 | import static org.easymock.EasyMock.reset; |
| 70 | import static org.easymock.EasyMock.verify; |
Jonathan Hart | 33b81f2 | 2016-02-05 09:25:50 -0800 | [diff] [blame] | 71 | import static org.onosproject.routing.TestIntentServiceHelper.eqExceptId; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
Jonathan Hart | 5137218 | 2014-12-03 21:32:34 -0800 | [diff] [blame] | 74 | * Unit tests for PeerConnectivityManager. |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 75 | */ |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 76 | public class PeerConnectivityManagerTest extends AbstractIntentTest { |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 77 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 78 | private static final ApplicationId APPID = TestApplicationId.create("foo"); |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 79 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 80 | private static final ApplicationId CONFIG_APP_ID = APPID; |
| 81 | |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 82 | private PeerConnectivityManager peerConnectivityManager; |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 83 | private IntentSynchronizationService intentSynchronizer; |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 84 | private RoutingConfigurationService routingConfig; |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 85 | private InterfaceService interfaceService; |
| 86 | private NetworkConfigService networkConfigService; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 87 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 88 | private Set<BgpConfig.BgpSpeakerConfig> bgpSpeakers; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 89 | private Map<String, Interface> interfaces; |
| 90 | private Map<IpAddress, BgpPeer> peers; |
| 91 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 92 | private BgpConfig bgpConfig; |
| 93 | |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 94 | private List<PointToPointIntent> intentList; |
| 95 | |
| 96 | private final String dpid1 = "00:00:00:00:00:00:00:01"; |
| 97 | private final String dpid2 = "00:00:00:00:00:00:00:02"; |
| 98 | |
| 99 | private final DeviceId deviceId1 = |
| 100 | DeviceId.deviceId(SdnIp.dpidToUri(dpid1)); |
| 101 | private final DeviceId deviceId2 = |
| 102 | DeviceId.deviceId(SdnIp.dpidToUri(dpid2)); |
| 103 | |
| 104 | // Interfaces connected to BGP speakers |
| 105 | private final ConnectPoint s1Eth100 = |
| 106 | new ConnectPoint(deviceId1, PortNumber.portNumber(100)); |
| 107 | private final ConnectPoint s2Eth100 = |
| 108 | new ConnectPoint(deviceId2, PortNumber.portNumber(100)); |
| 109 | |
| 110 | // Interfaces connected to BGP peers |
| 111 | private final ConnectPoint s1Eth1 = |
| 112 | new ConnectPoint(deviceId1, PortNumber.portNumber(1)); |
| 113 | private final ConnectPoint s2Eth1 = |
| 114 | new ConnectPoint(deviceId2, PortNumber.portNumber(1)); |
| 115 | |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 116 | private final TrafficTreatment noTreatment = |
Brian O'Connor | 6b52813 | 2015-03-10 16:39:52 -0700 | [diff] [blame] | 117 | DefaultTrafficTreatment.emptyTreatment(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 118 | |
| 119 | @Before |
| 120 | public void setUp() throws Exception { |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 121 | super.setUp(); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 122 | routingConfig = createMock(RoutingConfigurationService.class); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 123 | interfaceService = createMock(InterfaceService.class); |
| 124 | networkConfigService = createMock(NetworkConfigService.class); |
Jonathan Hart | 08105be | 2015-10-10 18:31:06 -0700 | [diff] [blame] | 125 | networkConfigService.addListener(anyObject(NetworkConfigListener.class)); |
| 126 | expectLastCall().anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 127 | bgpConfig = createMock(BgpConfig.class); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 128 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 129 | // These will set expectations on routingConfig and interfaceService |
| 130 | bgpSpeakers = setUpBgpSpeakers(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 131 | interfaces = Collections.unmodifiableMap(setUpInterfaces()); |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 132 | peers = setUpPeers(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 133 | |
| 134 | initPeerConnectivity(); |
| 135 | intentList = setUpIntentList(); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Sets up BGP speakers. |
| 140 | * |
| 141 | * @return configured BGP speakers as a map from speaker name to speaker |
| 142 | */ |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 143 | private Set<BgpConfig.BgpSpeakerConfig> setUpBgpSpeakers() { |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 144 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 145 | BgpConfig.BgpSpeakerConfig speaker1 = new BgpConfig.BgpSpeakerConfig( |
Jonathan Hart | a862548 | 2015-09-08 16:14:56 -0700 | [diff] [blame] | 146 | Optional.empty(), |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 147 | s1Eth100, Collections.singleton(IpAddress.valueOf("192.168.10.1"))); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 148 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 149 | BgpConfig.BgpSpeakerConfig speaker2 = new BgpConfig.BgpSpeakerConfig( |
Jonathan Hart | a862548 | 2015-09-08 16:14:56 -0700 | [diff] [blame] | 150 | Optional.empty(), |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 151 | s1Eth100, Sets.newHashSet(IpAddress.valueOf("192.168.20.1"), |
| 152 | IpAddress.valueOf("192.168.30.1"))); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 153 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 154 | Set<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Sets.newHashSet(); |
| 155 | bgpSpeakers.add(speaker1); |
| 156 | bgpSpeakers.add(speaker2); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 157 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 158 | return bgpSpeakers; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Sets up logical interfaces, which emulate the configured interfaces |
| 163 | * in SDN-IP application. |
| 164 | * |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 165 | * @return configured interfaces as a map from interface name to Interface |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 166 | */ |
| 167 | private Map<String, Interface> setUpInterfaces() { |
| 168 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 169 | Map<String, Interface> configuredInterfaces = new HashMap<>(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 170 | |
| 171 | String interfaceSw1Eth1 = "s1-eth1"; |
Pavlin Radoslavov | 76b0ae2 | 2014-10-27 15:33:19 -0700 | [diff] [blame] | 172 | InterfaceIpAddress ia1 = |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 173 | new InterfaceIpAddress(IpAddress.valueOf("192.168.10.101"), |
Pavlin Radoslavov | 76b0ae2 | 2014-10-27 15:33:19 -0700 | [diff] [blame] | 174 | IpPrefix.valueOf("192.168.10.0/24")); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 175 | Interface intfsw1eth1 = new Interface(s1Eth1, |
Jonathan Hart | 00cddda | 2016-02-16 10:30:37 -0800 | [diff] [blame] | 176 | Collections.singletonList(ia1), |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 177 | MacAddress.valueOf("00:00:00:00:00:01"), |
| 178 | VlanId.NONE); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 179 | |
| 180 | configuredInterfaces.put(interfaceSw1Eth1, intfsw1eth1); |
| 181 | String interfaceSw2Eth1 = "s2-eth1"; |
Pavlin Radoslavov | 76b0ae2 | 2014-10-27 15:33:19 -0700 | [diff] [blame] | 182 | InterfaceIpAddress ia2 = |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 183 | new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"), |
Pavlin Radoslavov | 76b0ae2 | 2014-10-27 15:33:19 -0700 | [diff] [blame] | 184 | IpPrefix.valueOf("192.168.20.0/24")); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 185 | Interface intfsw2eth1 = new Interface(s2Eth1, |
Jonathan Hart | 00cddda | 2016-02-16 10:30:37 -0800 | [diff] [blame] | 186 | Collections.singletonList(ia2), |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 187 | MacAddress.valueOf("00:00:00:00:00:02"), |
| 188 | VlanId.NONE); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 189 | configuredInterfaces.put(interfaceSw2Eth1, intfsw2eth1); |
| 190 | |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 191 | String interfaceSw2Eth1intf2 = "s2-eth1_2"; |
| 192 | InterfaceIpAddress ia3 = |
| 193 | new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"), |
| 194 | IpPrefix.valueOf("192.168.30.0/24")); |
| 195 | Interface intfsw2eth1intf2 = new Interface(s2Eth1, |
Jonathan Hart | 00cddda | 2016-02-16 10:30:37 -0800 | [diff] [blame] | 196 | Collections.singletonList(ia3), |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 197 | MacAddress.valueOf("00:00:00:00:00:03"), |
| 198 | VlanId.NONE); |
| 199 | configuredInterfaces.put(interfaceSw2Eth1intf2, intfsw2eth1intf2); |
| 200 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 201 | expect(interfaceService.getInterfacesByPort(s1Eth1)) |
| 202 | .andReturn(Collections.singleton(intfsw1eth1)).anyTimes(); |
| 203 | expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.10.101"))) |
| 204 | .andReturn(Collections.singleton(intfsw1eth1)).anyTimes(); |
| 205 | expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.10.1"))) |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 206 | .andReturn(intfsw1eth1).anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 207 | expect(interfaceService.getInterfacesByPort(s2Eth1)) |
| 208 | .andReturn(Collections.singleton(intfsw2eth1)).anyTimes(); |
| 209 | expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.20.101"))) |
| 210 | .andReturn(Collections.singleton(intfsw2eth1)).anyTimes(); |
| 211 | expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.20.1"))) |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 212 | .andReturn(intfsw2eth1).anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 213 | |
| 214 | expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.30.101"))) |
| 215 | .andReturn(Collections.singleton(intfsw2eth1intf2)).anyTimes(); |
| 216 | expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.30.1"))) |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 217 | .andReturn(intfsw2eth1intf2).anyTimes(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 218 | |
| 219 | // Non-existent interface used during one of the tests |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 220 | expect(interfaceService.getInterfacesByPort(new ConnectPoint( |
| 221 | DeviceId.deviceId(SdnIp.dpidToUri("00:00:00:00:00:00:01:00")), |
| 222 | PortNumber.portNumber(1)))) |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 223 | .andReturn(null).anyTimes(); |
| 224 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 225 | expect(interfaceService.getInterfaces()).andReturn( |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 226 | Sets.newHashSet(configuredInterfaces.values())).anyTimes(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 227 | |
| 228 | return configuredInterfaces; |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Sets up BGP daemon peers. |
| 233 | * |
| 234 | * @return configured BGP peers as a MAP from peer IP address to BgpPeer |
| 235 | */ |
| 236 | private Map<IpAddress, BgpPeer> setUpPeers() { |
| 237 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 238 | Map<IpAddress, BgpPeer> configuredPeers = new HashMap<>(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 239 | |
| 240 | String peerSw1Eth1 = "192.168.10.1"; |
| 241 | configuredPeers.put(IpAddress.valueOf(peerSw1Eth1), |
| 242 | new BgpPeer(dpid1, 1, peerSw1Eth1)); |
| 243 | |
| 244 | // Two BGP peers are connected to switch 2 port 1. |
| 245 | String peer1Sw2Eth1 = "192.168.20.1"; |
| 246 | configuredPeers.put(IpAddress.valueOf(peer1Sw2Eth1), |
| 247 | new BgpPeer(dpid2, 1, peer1Sw2Eth1)); |
| 248 | |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 249 | String peer2Sw2Eth1 = "192.168.30.1"; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 250 | configuredPeers.put(IpAddress.valueOf(peer2Sw2Eth1), |
| 251 | new BgpPeer(dpid2, 1, peer2Sw2Eth1)); |
| 252 | |
| 253 | return configuredPeers; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Sets up expected point to point intent list. |
| 258 | * |
| 259 | * @return point to point intent list |
| 260 | */ |
| 261 | private List<PointToPointIntent> setUpIntentList() { |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 262 | intentList = new ArrayList<>(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 263 | |
| 264 | setUpBgpIntents(); |
| 265 | setUpIcmpIntents(); |
| 266 | |
| 267 | return intentList; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Constructs a BGP intent and put it into the intentList. |
| 272 | * <p/> |
| 273 | * The purpose of this method is too simplify the setUpBgpIntents() method, |
| 274 | * and to make the setUpBgpIntents() easy to read. |
| 275 | * |
| 276 | * @param srcPrefix source IP prefix to match |
| 277 | * @param dstPrefix destination IP prefix to match |
| 278 | * @param srcTcpPort source TCP port to match |
| 279 | * @param dstTcpPort destination TCP port to match |
| 280 | * @param srcConnectPoint source connect point for PointToPointIntent |
| 281 | * @param dstConnectPoint destination connect point for PointToPointIntent |
| 282 | */ |
| 283 | private void bgpPathintentConstructor(String srcPrefix, String dstPrefix, |
| 284 | Short srcTcpPort, Short dstTcpPort, |
| 285 | ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) { |
| 286 | |
| 287 | TrafficSelector.Builder builder = DefaultTrafficSelector.builder() |
| 288 | .matchEthType(Ethernet.TYPE_IPV4) |
| 289 | .matchIPProtocol(IPv4.PROTOCOL_TCP) |
| 290 | .matchIPSrc(IpPrefix.valueOf(srcPrefix)) |
| 291 | .matchIPDst(IpPrefix.valueOf(dstPrefix)); |
| 292 | |
| 293 | if (srcTcpPort != null) { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 294 | builder.matchTcpSrc(TpPort.tpPort(srcTcpPort)); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 295 | } |
| 296 | if (dstTcpPort != null) { |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 297 | builder.matchTcpDst(TpPort.tpPort(dstTcpPort)); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 300 | Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] |
| 301 | + "-" + ((srcTcpPort == null) ? "dst" : "src"), APPID); |
| 302 | |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 303 | PointToPointIntent intent = PointToPointIntent.builder() |
| 304 | .appId(APPID) |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 305 | .key(key) |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 306 | .selector(builder.build()) |
| 307 | .treatment(noTreatment) |
| 308 | .ingressPoint(srcConnectPoint) |
| 309 | .egressPoint(dstConnectPoint) |
| 310 | .build(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 311 | |
| 312 | intentList.add(intent); |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Sets up intents for BGP paths. |
| 317 | */ |
| 318 | private void setUpBgpIntents() { |
| 319 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 320 | Short bgpPort = 179; |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 321 | |
| 322 | // Start to build intents between BGP speaker1 and BGP peer1 |
| 323 | bgpPathintentConstructor( |
| 324 | "192.168.10.101/32", "192.168.10.1/32", null, bgpPort, |
| 325 | s1Eth100, s1Eth1); |
| 326 | bgpPathintentConstructor( |
| 327 | "192.168.10.101/32", "192.168.10.1/32", bgpPort, null, |
| 328 | s1Eth100, s1Eth1); |
| 329 | |
| 330 | bgpPathintentConstructor( |
| 331 | "192.168.10.1/32", "192.168.10.101/32", null, bgpPort, |
| 332 | s1Eth1, s1Eth100); |
| 333 | bgpPathintentConstructor( |
| 334 | "192.168.10.1/32", "192.168.10.101/32", bgpPort, null, |
| 335 | s1Eth1, s1Eth100); |
| 336 | |
| 337 | // Start to build intents between BGP speaker1 and BGP peer2 |
| 338 | bgpPathintentConstructor( |
| 339 | "192.168.20.101/32", "192.168.20.1/32", null, bgpPort, |
| 340 | s1Eth100, s2Eth1); |
| 341 | bgpPathintentConstructor( |
| 342 | "192.168.20.101/32", "192.168.20.1/32", bgpPort, null, |
| 343 | s1Eth100, s2Eth1); |
| 344 | |
| 345 | bgpPathintentConstructor( |
| 346 | "192.168.20.1/32", "192.168.20.101/32", null, bgpPort, |
| 347 | s2Eth1, s1Eth100); |
| 348 | bgpPathintentConstructor( |
| 349 | "192.168.20.1/32", "192.168.20.101/32", bgpPort, null, |
| 350 | s2Eth1, s1Eth100); |
| 351 | |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 352 | // |
| 353 | // Start to build intents between BGP speaker3 and BGP peer1 |
| 354 | bgpPathintentConstructor( |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 355 | "192.168.30.101/32", "192.168.30.1/32", null, bgpPort, |
| 356 | s1Eth100, s2Eth1); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 357 | bgpPathintentConstructor( |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 358 | "192.168.30.101/32", "192.168.30.1/32", bgpPort, null, |
| 359 | s1Eth100, s2Eth1); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 360 | |
| 361 | bgpPathintentConstructor( |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 362 | "192.168.30.1/32", "192.168.30.101/32", null, bgpPort, |
| 363 | s2Eth1, s1Eth100); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 364 | bgpPathintentConstructor( |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 365 | "192.168.30.1/32", "192.168.30.101/32", bgpPort, null, |
| 366 | s2Eth1, s1Eth100); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | /** |
| 370 | * Constructs a BGP intent and put it into the intentList. |
| 371 | * <p/> |
| 372 | * The purpose of this method is too simplify the setUpBgpIntents() method, |
| 373 | * and to make the setUpBgpIntents() easy to read. |
| 374 | * |
| 375 | * @param srcPrefix source IP prefix to match |
| 376 | * @param dstPrefix destination IP prefix to match |
| 377 | * @param srcConnectPoint source connect point for PointToPointIntent |
| 378 | * @param dstConnectPoint destination connect point for PointToPointIntent |
| 379 | */ |
| 380 | private void icmpPathintentConstructor(String srcPrefix, String dstPrefix, |
| 381 | ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) { |
| 382 | |
| 383 | TrafficSelector selector = DefaultTrafficSelector.builder() |
| 384 | .matchEthType(Ethernet.TYPE_IPV4) |
| 385 | .matchIPProtocol(IPv4.PROTOCOL_ICMP) |
| 386 | .matchIPSrc(IpPrefix.valueOf(srcPrefix)) |
| 387 | .matchIPDst(IpPrefix.valueOf(dstPrefix)) |
| 388 | .build(); |
| 389 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 390 | Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] |
| 391 | + "-" + "icmp", APPID); |
| 392 | |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 393 | PointToPointIntent intent = PointToPointIntent.builder() |
| 394 | .appId(APPID) |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 395 | .key(key) |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 396 | .selector(selector) |
| 397 | .treatment(noTreatment) |
| 398 | .ingressPoint(srcConnectPoint) |
| 399 | .egressPoint(dstConnectPoint) |
| 400 | .build(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 401 | |
| 402 | intentList.add(intent); |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * Sets up intents for ICMP paths. |
| 407 | */ |
| 408 | private void setUpIcmpIntents() { |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 409 | // Start to build intents between BGP speaker1 and BGP peer1 |
| 410 | icmpPathintentConstructor( |
| 411 | "192.168.10.101/32", "192.168.10.1/32", s1Eth100, s1Eth1); |
| 412 | icmpPathintentConstructor( |
| 413 | "192.168.10.1/32", "192.168.10.101/32", s1Eth1, s1Eth100); |
| 414 | |
| 415 | // Start to build intents between BGP speaker1 and BGP peer2 |
| 416 | icmpPathintentConstructor( |
| 417 | "192.168.20.101/32", "192.168.20.1/32", s1Eth100, s2Eth1); |
| 418 | icmpPathintentConstructor( |
| 419 | "192.168.20.1/32", "192.168.20.101/32", s2Eth1, s1Eth100); |
| 420 | |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 421 | icmpPathintentConstructor( |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 422 | "192.168.30.101/32", "192.168.30.1/32", s1Eth100, s2Eth1); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 423 | icmpPathintentConstructor( |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 424 | "192.168.30.1/32", "192.168.30.101/32", s2Eth1, s1Eth100); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | /** |
| 428 | * Initializes peer connectivity testing environment. |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 429 | * |
| 430 | * @throws TestUtilsException if exceptions when using TestUtils |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 431 | */ |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 432 | private void initPeerConnectivity() throws TestUtilsException { |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 433 | expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 434 | expect(bgpConfig.bgpSpeakers()).andReturn(bgpSpeakers).anyTimes(); |
| 435 | replay(bgpConfig); |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 436 | expect(networkConfigService.getConfig(APPID, BgpConfig.class)) |
| 437 | .andReturn(bgpConfig).anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 438 | replay(networkConfigService); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 439 | replay(routingConfig); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 440 | replay(interfaceService); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 441 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 442 | intentSynchronizer = createMock(IntentSynchronizationService.class); |
| 443 | replay(intentSynchronizer); |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 444 | |
| 445 | peerConnectivityManager = |
| 446 | new PeerConnectivityManager(APPID, intentSynchronizer, |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 447 | networkConfigService, |
| 448 | CONFIG_APP_ID, |
| 449 | interfaceService); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 450 | } |
| 451 | |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 452 | /** |
| 453 | * Tests whether peer connectivity manager can set up correct BGP and |
| 454 | * ICMP intents according to specific configuration. |
| 455 | * <p/> |
| 456 | * Two tricky cases included in the configuration are: 2 peers on a same |
| 457 | * switch port, peer on the same switch with BGPd. |
| 458 | */ |
| 459 | @Test |
| 460 | public void testConnectionSetup() { |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 461 | reset(intentSynchronizer); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 462 | |
Pavlin Radoslavov | dde22ae | 2014-11-24 11:47:17 -0800 | [diff] [blame] | 463 | // Setup the expected intents |
Pavlin Radoslavov | dde22ae | 2014-11-24 11:47:17 -0800 | [diff] [blame] | 464 | for (Intent intent : intentList) { |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 465 | intentSynchronizer.submit(eqExceptId(intent)); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 466 | } |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 467 | replay(intentSynchronizer); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 468 | |
| 469 | // Running the interface to be tested. |
| 470 | peerConnectivityManager.start(); |
| 471 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 472 | verify(intentSynchronizer); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | /** |
| 476 | * Tests a corner case, when there are no interfaces in the configuration. |
| 477 | */ |
| 478 | @Test |
| 479 | public void testNullInterfaces() { |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 480 | reset(interfaceService); |
| 481 | |
| 482 | expect(interfaceService.getInterfaces()).andReturn( |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 483 | Sets.newHashSet()).anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 484 | expect(interfaceService.getInterfacesByPort(s2Eth1)) |
| 485 | .andReturn(Collections.emptySet()).anyTimes(); |
| 486 | expect(interfaceService.getInterfacesByPort(s1Eth1)) |
| 487 | .andReturn(Collections.emptySet()).anyTimes(); |
| 488 | expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.10.101"))) |
| 489 | .andReturn(Collections.emptySet()).anyTimes(); |
| 490 | expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.10.1"))) |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 491 | .andReturn(null).anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 492 | expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.20.101"))) |
| 493 | .andReturn(Collections.emptySet()).anyTimes(); |
| 494 | expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.20.1"))) |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 495 | .andReturn(null).anyTimes(); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 496 | expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.30.101"))) |
| 497 | .andReturn(Collections.emptySet()).anyTimes(); |
| 498 | expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.30.1"))) |
Jonathan Hart | e30fcda | 2015-08-06 16:22:34 -0700 | [diff] [blame] | 499 | .andReturn(null).anyTimes(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 500 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 501 | replay(interfaceService); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 502 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 503 | reset(intentSynchronizer); |
| 504 | replay(intentSynchronizer); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 505 | peerConnectivityManager.start(); |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 506 | verify(intentSynchronizer); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Tests a corner case, when there is no BGP speakers in the configuration. |
| 511 | */ |
| 512 | @Test |
| 513 | public void testNullBgpSpeakers() { |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 514 | reset(routingConfig); |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 515 | reset(bgpConfig); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 516 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 517 | expect(bgpConfig.bgpSpeakers()).andReturn(Collections.emptySet()).anyTimes(); |
| 518 | replay(bgpConfig); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 519 | expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes(); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 520 | replay(routingConfig); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 521 | |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 522 | reset(intentSynchronizer); |
| 523 | replay(intentSynchronizer); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 524 | peerConnectivityManager.start(); |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 525 | verify(intentSynchronizer); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | /** |
| 529 | * Tests a corner case, when there is no Interface configured for one BGP |
| 530 | * peer. |
| 531 | */ |
| 532 | @Test |
| 533 | public void testNoPeerInterface() { |
| 534 | String peerSw100Eth1 = "192.168.200.1"; |
Jonathan Hart | 9a426f8 | 2015-09-03 15:43:13 +0200 | [diff] [blame] | 535 | peers.put(IpAddress.valueOf(peerSw100Eth1), |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 536 | new BgpPeer("00:00:00:00:00:00:01:00", 1, peerSw100Eth1)); |
| 537 | testConnectionSetup(); |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Tests a corner case, when there is no Interface configured for one BGP |
| 542 | * speaker. |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 543 | */ |
| 544 | @Ignore |
| 545 | @Test |
| 546 | public void testNoSpeakerInterface() { |
| 547 | BgpSpeaker bgpSpeaker100 = new BgpSpeaker( |
| 548 | "bgpSpeaker100", |
| 549 | "00:00:00:00:00:00:01:00", 100, |
| 550 | "00:00:00:00:01:00"); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 551 | List<InterfaceAddress> interfaceAddresses100 = new LinkedList<>(); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 552 | interfaceAddresses100.add(new InterfaceAddress(dpid1, 1, "192.168.10.201")); |
| 553 | interfaceAddresses100.add(new InterfaceAddress(dpid2, 1, "192.168.20.201")); |
| 554 | bgpSpeaker100.setInterfaceAddresses(interfaceAddresses100); |
Jonathan Hart | ce430a4 | 2014-10-16 20:44:29 -0700 | [diff] [blame] | 555 | testConnectionSetup(); |
| 556 | } |
| 557 | } |