Committed by
Gerrit Code Review
[ONOS] SR resilency, CR resilency and delete problem , old tunnels not deleting issue
Change-Id: Ib4b9732c28a1f87a8a76347a5936593b1b5bf72a
Showing
7 changed files
with
111 additions
and
52 deletions
| ... | @@ -325,7 +325,7 @@ public final class BasicPceccHandler { | ... | @@ -325,7 +325,7 @@ public final class BasicPceccHandler { |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | // Install a rule for pushing local labels to the device which is specific to path. | 327 | // Install a rule for pushing local labels to the device which is specific to path. |
| 328 | - private void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId, | 328 | + private synchronized void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId, |
| 329 | PortNumber portNum, TunnelId tunnelId, | 329 | PortNumber portNum, TunnelId tunnelId, |
| 330 | Boolean isBos, Long labelType, | 330 | Boolean isBos, Long labelType, |
| 331 | Objective.Operation type) { | 331 | Objective.Operation type) { | ... | ... |
| ... | @@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledExecutorService; | ... | @@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledExecutorService; |
| 31 | 31 | ||
| 32 | import org.onlab.packet.Ethernet; | 32 | import org.onlab.packet.Ethernet; |
| 33 | import org.onlab.packet.IPv4; | 33 | import org.onlab.packet.IPv4; |
| 34 | - | ||
| 35 | import org.apache.felix.scr.annotations.Activate; | 34 | import org.apache.felix.scr.annotations.Activate; |
| 36 | import org.apache.felix.scr.annotations.Component; | 35 | import org.apache.felix.scr.annotations.Component; |
| 37 | import org.apache.felix.scr.annotations.Deactivate; | 36 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -110,14 +109,14 @@ import org.slf4j.LoggerFactory; | ... | @@ -110,14 +109,14 @@ import org.slf4j.LoggerFactory; |
| 110 | import com.google.common.collect.ImmutableList; | 109 | import com.google.common.collect.ImmutableList; |
| 111 | import com.google.common.collect.ImmutableSet; | 110 | import com.google.common.collect.ImmutableSet; |
| 112 | 111 | ||
| 113 | -import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | 112 | +import static org.onosproject.incubator.net.tunnel.Tunnel.State.ACTIVE; |
| 114 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; | 113 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; |
| 115 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; | 114 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; |
| 116 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; | 115 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; |
| 116 | +import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | ||
| 117 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; | 117 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; |
| 118 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; | 118 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; |
| 119 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 119 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
| 120 | - | ||
| 121 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH; | 120 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH; |
| 122 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID; | 121 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID; |
| 123 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE; | 122 | import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE; |
| ... | @@ -621,6 +620,12 @@ public class PceManager implements PceService { | ... | @@ -621,6 +620,12 @@ public class PceManager implements PceService { |
| 621 | return false; | 620 | return false; |
| 622 | } | 621 | } |
| 623 | 622 | ||
| 623 | + LspType lspType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)); | ||
| 624 | + // Release basic PCECC labels. | ||
| 625 | + if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) { | ||
| 626 | + crHandler.releaseLabel(tunnel); | ||
| 627 | + } | ||
| 628 | + | ||
| 624 | // 2. Call tunnel service. | 629 | // 2. Call tunnel service. |
| 625 | return tunnelService.downTunnel(appId, tunnel.tunnelId()); | 630 | return tunnelService.downTunnel(appId, tunnel.tunnelId()); |
| 626 | } | 631 | } |
| ... | @@ -1148,6 +1153,22 @@ public class PceManager implements PceService { | ... | @@ -1148,6 +1153,22 @@ public class PceManager implements PceService { |
| 1148 | } | 1153 | } |
| 1149 | } | 1154 | } |
| 1150 | 1155 | ||
| 1156 | + //In CR case, release labels when new tunnel for it is updated. | ||
| 1157 | + if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR && tunnel.state() == ACTIVE | ||
| 1158 | + && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { | ||
| 1159 | + Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst()); | ||
| 1160 | + | ||
| 1161 | + for (Tunnel t : tunnels) { | ||
| 1162 | + if (tunnel.annotations().value(PLSP_ID).equals(t.annotations().value(PLSP_ID)) | ||
| 1163 | + && !tunnel.annotations().value(LOCAL_LSP_ID) | ||
| 1164 | + .equals(t.annotations().value(LOCAL_LSP_ID))) { | ||
| 1165 | + // Release basic PCECC labels. | ||
| 1166 | + crHandler.releaseLabel(t); | ||
| 1167 | + break; | ||
| 1168 | + } | ||
| 1169 | + } | ||
| 1170 | + } | ||
| 1171 | + | ||
| 1151 | if (tunnel.state() == UNSTABLE) { | 1172 | if (tunnel.state() == UNSTABLE) { |
| 1152 | /* | 1173 | /* |
| 1153 | * During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into | 1174 | * During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into |
| ... | @@ -1183,23 +1204,16 @@ public class PceManager implements PceService { | ... | @@ -1183,23 +1204,16 @@ public class PceManager implements PceService { |
| 1183 | if (lspType != WITH_SIGNALLING) { | 1204 | if (lspType != WITH_SIGNALLING) { |
| 1184 | localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID))); | 1205 | localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID))); |
| 1185 | } | 1206 | } |
| 1186 | - | ||
| 1187 | // If not zero bandwidth, and delegated (initiated LSPs will also be delegated). | 1207 | // If not zero bandwidth, and delegated (initiated LSPs will also be delegated). |
| 1188 | - if (bwConstraintValue != 0) { | 1208 | + if (Double.parseDouble(tunnel.annotations().value(BANDWIDTH)) != 0.0 |
| 1189 | - releaseBandwidth(event.subject()); | 1209 | + && mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { |
| 1190 | - | 1210 | + releaseBandwidth(tunnel); |
| 1191 | - // Release basic PCECC labels. | 1211 | + } |
| 1192 | - if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) { | 1212 | + |
| 1193 | - // Delete stored tunnel consumer id from PCE store (while still retaining label list.) | 1213 | + if (pceStore.getTunnelInfo(tunnel.tunnelId()) != null) { |
| 1194 | - PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId()); | 1214 | + pceStore.removeTunnelInfo(tunnel.tunnelId()); |
| 1195 | - pceccTunnelInfo.tunnelConsumerId(null); | ||
| 1196 | - if (mastershipService.getLocalRole(tunnel.path().src().deviceId()) == MastershipRole.MASTER) { | ||
| 1197 | - crHandler.releaseLabel(tunnel); | ||
| 1198 | - } | ||
| 1199 | - } else { | ||
| 1200 | - pceStore.removeTunnelInfo(tunnel.tunnelId()); | ||
| 1201 | - } | ||
| 1202 | } | 1215 | } |
| 1216 | + | ||
| 1203 | break; | 1217 | break; |
| 1204 | 1218 | ||
| 1205 | default: | 1219 | default: | ... | ... |
| ... | @@ -641,11 +641,14 @@ public class PceManagerTest { | ... | @@ -641,11 +641,14 @@ public class PceManagerTest { |
| 641 | build4RouterTopo(false, false, false, false, 5); | 641 | build4RouterTopo(false, false, false, false, 5); |
| 642 | List<Constraint> constraints = new LinkedList<Constraint>(); | 642 | List<Constraint> constraints = new LinkedList<Constraint>(); |
| 643 | CostConstraint costConstraint = new CostConstraint(TE_COST); | 643 | CostConstraint costConstraint = new CostConstraint(TE_COST); |
| 644 | + BandwidthConstraint bwConst = new BandwidthConstraint(Bandwidth.bps(3)); | ||
| 645 | + constraints.add(bwConst); | ||
| 644 | constraints.add(costConstraint); | 646 | constraints.add(costConstraint); |
| 645 | 647 | ||
| 646 | pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING); | 648 | pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING); |
| 647 | 649 | ||
| 648 | Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath(); | 650 | Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath(); |
| 651 | + | ||
| 649 | assertThat(tunnels.size(), is(1)); | 652 | assertThat(tunnels.size(), is(1)); |
| 650 | boolean result; | 653 | boolean result; |
| 651 | for (Tunnel tunnel : tunnels) { | 654 | for (Tunnel tunnel : tunnels) { | ... | ... |
| ... | @@ -63,8 +63,6 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; | ... | @@ -63,8 +63,6 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; |
| 63 | import org.onosproject.core.CoreService; | 63 | import org.onosproject.core.CoreService; |
| 64 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; | 64 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; |
| 65 | import org.onosproject.incubator.net.resource.label.LabelResourceId; | 65 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
| 66 | -import org.onosproject.mastership.MastershipEvent; | ||
| 67 | -import org.onosproject.mastership.MastershipListener; | ||
| 68 | import org.onosproject.mastership.MastershipService; | 66 | import org.onosproject.mastership.MastershipService; |
| 69 | import org.onosproject.net.AnnotationKeys; | 67 | import org.onosproject.net.AnnotationKeys; |
| 70 | import org.onosproject.net.ConnectPoint; | 68 | import org.onosproject.net.ConnectPoint; |
| ... | @@ -79,6 +77,8 @@ import org.onosproject.net.config.basics.BandwidthCapacity; | ... | @@ -79,6 +77,8 @@ import org.onosproject.net.config.basics.BandwidthCapacity; |
| 79 | import org.onosproject.net.device.DefaultDeviceDescription; | 77 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 80 | import org.onosproject.net.device.DefaultPortDescription; | 78 | import org.onosproject.net.device.DefaultPortDescription; |
| 81 | import org.onosproject.net.device.DeviceDescription; | 79 | import org.onosproject.net.device.DeviceDescription; |
| 80 | +import org.onosproject.net.device.DeviceEvent; | ||
| 81 | +import org.onosproject.net.device.DeviceListener; | ||
| 82 | import org.onosproject.net.device.DeviceProvider; | 82 | import org.onosproject.net.device.DeviceProvider; |
| 83 | import org.onosproject.net.device.DeviceProviderRegistry; | 83 | import org.onosproject.net.device.DeviceProviderRegistry; |
| 84 | import org.onosproject.net.device.DeviceProviderService; | 84 | import org.onosproject.net.device.DeviceProviderService; |
| ... | @@ -140,7 +140,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -140,7 +140,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
| 140 | private DeviceProviderService deviceProviderService; | 140 | private DeviceProviderService deviceProviderService; |
| 141 | private LinkProviderService linkProviderService; | 141 | private LinkProviderService linkProviderService; |
| 142 | 142 | ||
| 143 | - private InternalMastershipListener masterListener = new InternalMastershipListener(); | 143 | + private DeviceListener deviceListener = new InternalDeviceListener(); |
| 144 | private InternalBgpProvider listener = new InternalBgpProvider(); | 144 | private InternalBgpProvider listener = new InternalBgpProvider(); |
| 145 | private static final String UNKNOWN = "unknown"; | 145 | private static final String UNKNOWN = "unknown"; |
| 146 | public static final long IDENTIFIER_SET = 0x100000000L; | 146 | public static final long IDENTIFIER_SET = 0x100000000L; |
| ... | @@ -169,7 +169,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -169,7 +169,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
| 169 | deviceProviderService = deviceProviderRegistry.register(this); | 169 | deviceProviderService = deviceProviderRegistry.register(this); |
| 170 | linkProviderService = linkProviderRegistry.register(this); | 170 | linkProviderService = linkProviderRegistry.register(this); |
| 171 | controller.addListener(listener); | 171 | controller.addListener(listener); |
| 172 | - mastershipService.addListener(masterListener); | 172 | + deviceService.addListener(deviceListener); |
| 173 | controller.addLinkListener(listener); | 173 | controller.addLinkListener(listener); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| ... | @@ -182,25 +182,28 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -182,25 +182,28 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
| 182 | linkProviderService = null; | 182 | linkProviderService = null; |
| 183 | controller.removeListener(listener); | 183 | controller.removeListener(listener); |
| 184 | controller.removeLinkListener(listener); | 184 | controller.removeLinkListener(listener); |
| 185 | - mastershipService.removeListener(masterListener); | 185 | + deviceService.removeListener(deviceListener); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | - private class InternalMastershipListener implements MastershipListener { | 188 | + private class InternalDeviceListener implements DeviceListener { |
| 189 | @Override | 189 | @Override |
| 190 | - public void event(MastershipEvent event) { | 190 | + public void event(DeviceEvent event) { |
| 191 | - if (event.type() == MastershipEvent.Type.MASTER_CHANGED) { | 191 | + Device device = event.subject(); |
| 192 | - if (mastershipService.getMasterFor(event.subject()) != null) { | 192 | + |
| 193 | - //Only for L3 device create label pool for that device | 193 | + switch (event.type()) { |
| 194 | - Device device = deviceService.getDevice(event.subject()); | 194 | + case DEVICE_ADDED: |
| 195 | - if (device == null) { | 195 | + if (!mastershipService.isLocalMaster(device.id())) { |
| 196 | - log.debug("Device {} doesn't exist", event.subject()); | 196 | + break; |
| 197 | - return; | ||
| 198 | } | 197 | } |
| 199 | - //Reserve device label pool for L3 devices | 198 | + |
| 199 | + // Reserve device label pool for L3 devices | ||
| 200 | if (device.annotations().value(LSRID) != null) { | 200 | if (device.annotations().value(LSRID) != null) { |
| 201 | - createDevicePool(event.subject()); | 201 | + createDevicePool(device.id()); |
| 202 | } | 202 | } |
| 203 | - } | 203 | + break; |
| 204 | + | ||
| 205 | + default: | ||
| 206 | + break; | ||
| 204 | } | 207 | } |
| 205 | } | 208 | } |
| 206 | } | 209 | } |
| ... | @@ -444,7 +447,6 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -444,7 +447,6 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
| 444 | @Override | 447 | @Override |
| 445 | public void deleteLink(BgpLinkLsNlriVer4 linkNlri) throws BgpParseException { | 448 | public void deleteLink(BgpLinkLsNlriVer4 linkNlri) throws BgpParseException { |
| 446 | log.debug("Delete link {}", linkNlri.toString()); | 449 | log.debug("Delete link {}", linkNlri.toString()); |
| 447 | - | ||
| 448 | if (linkProviderService == null) { | 450 | if (linkProviderService == null) { |
| 449 | return; | 451 | return; |
| 450 | } | 452 | } |
| ... | @@ -461,6 +463,10 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -461,6 +463,10 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
| 461 | } | 463 | } |
| 462 | 464 | ||
| 463 | linkProviderService.linkVanished(linkDes); | 465 | linkProviderService.linkVanished(linkDes); |
| 466 | + | ||
| 467 | + linkDes = new DefaultLinkDescription(linkDes.dst(), linkDes.src(), Link.Type.DIRECT, | ||
| 468 | + false, linkDes.annotations()); | ||
| 469 | + linkProviderService.linkVanished(linkDes); | ||
| 464 | } | 470 | } |
| 465 | } | 471 | } |
| 466 | 472 | ... | ... |
| ... | @@ -53,10 +53,7 @@ import org.onosproject.bgpio.types.LinkStateAttributes; | ... | @@ -53,10 +53,7 @@ import org.onosproject.bgpio.types.LinkStateAttributes; |
| 53 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; | 53 | import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; |
| 54 | import org.onosproject.incubator.net.resource.label.LabelResourceId; | 54 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
| 55 | import org.onosproject.incubator.net.resource.label.LabelResourcePool; | 55 | import org.onosproject.incubator.net.resource.label.LabelResourcePool; |
| 56 | -import org.onosproject.mastership.MastershipEvent; | ||
| 57 | -import org.onosproject.mastership.MastershipListener; | ||
| 58 | import org.onosproject.mastership.MastershipServiceAdapter; | 56 | import org.onosproject.mastership.MastershipServiceAdapter; |
| 59 | -import org.onosproject.mastership.MastershipEvent.Type; | ||
| 60 | import org.onosproject.net.link.LinkServiceAdapter; | 57 | import org.onosproject.net.link.LinkServiceAdapter; |
| 61 | import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; | 58 | import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; |
| 62 | import org.onosproject.bgpio.types.RouteDistinguisher; | 59 | import org.onosproject.bgpio.types.RouteDistinguisher; |
| ... | @@ -68,8 +65,8 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth; | ... | @@ -68,8 +65,8 @@ import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth; |
| 68 | import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; | 65 | import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric; |
| 69 | import org.onosproject.bgpio.util.Constants; | 66 | import org.onosproject.bgpio.util.Constants; |
| 70 | import org.onosproject.cluster.NodeId; | 67 | import org.onosproject.cluster.NodeId; |
| 71 | -import org.onosproject.cluster.RoleInfo; | ||
| 72 | import org.onosproject.net.ConnectPoint; | 68 | import org.onosproject.net.ConnectPoint; |
| 69 | +import org.onosproject.net.DefaultAnnotations; | ||
| 73 | import org.onosproject.net.DefaultDevice; | 70 | import org.onosproject.net.DefaultDevice; |
| 74 | import org.onosproject.net.DefaultLink; | 71 | import org.onosproject.net.DefaultLink; |
| 75 | import org.onosproject.net.Device; | 72 | import org.onosproject.net.Device; |
| ... | @@ -82,6 +79,8 @@ import org.onosproject.net.config.ConfigApplyDelegate; | ... | @@ -82,6 +79,8 @@ import org.onosproject.net.config.ConfigApplyDelegate; |
| 82 | import org.onosproject.net.config.ConfigFactory; | 79 | import org.onosproject.net.config.ConfigFactory; |
| 83 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; | 80 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; |
| 84 | import org.onosproject.net.device.DeviceDescription; | 81 | import org.onosproject.net.device.DeviceDescription; |
| 82 | +import org.onosproject.net.device.DeviceEvent; | ||
| 83 | +import org.onosproject.net.device.DeviceListener; | ||
| 85 | import org.onosproject.net.device.DeviceProvider; | 84 | import org.onosproject.net.device.DeviceProvider; |
| 86 | import org.onosproject.net.device.DeviceProviderRegistry; | 85 | import org.onosproject.net.device.DeviceProviderRegistry; |
| 87 | import org.onosproject.net.device.DeviceProviderService; | 86 | import org.onosproject.net.device.DeviceProviderService; |
| ... | @@ -122,7 +121,7 @@ public class BgpTopologyProviderTest { | ... | @@ -122,7 +121,7 @@ public class BgpTopologyProviderTest { |
| 122 | private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); | 121 | private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); |
| 123 | private MockLabelResourceService labelResourceAdminService = new MockLabelResourceService(); | 122 | private MockLabelResourceService labelResourceAdminService = new MockLabelResourceService(); |
| 124 | private Map<DeviceId, Device> deviceMap = new HashMap<>(); | 123 | private Map<DeviceId, Device> deviceMap = new HashMap<>(); |
| 125 | - private MastershipListener listener; | 124 | + private DeviceListener listener; |
| 126 | 125 | ||
| 127 | @Before | 126 | @Before |
| 128 | public void startUp() throws TestUtilsException { | 127 | public void startUp() throws TestUtilsException { |
| ... | @@ -134,7 +133,7 @@ public class BgpTopologyProviderTest { | ... | @@ -134,7 +133,7 @@ public class BgpTopologyProviderTest { |
| 134 | provider.labelResourceAdminService = labelResourceAdminService; | 133 | provider.labelResourceAdminService = labelResourceAdminService; |
| 135 | provider.mastershipService = mastershipService; | 134 | provider.mastershipService = mastershipService; |
| 136 | provider.networkConfigService = networkConfigService; | 135 | provider.networkConfigService = networkConfigService; |
| 137 | - listener = TestUtils.getField(provider, "masterListener"); | 136 | + listener = TestUtils.getField(provider, "deviceListener"); |
| 138 | provider.activate(); | 137 | provider.activate(); |
| 139 | assertThat("device provider should be registered", not(nodeRegistry.provider)); | 138 | assertThat("device provider should be registered", not(nodeRegistry.provider)); |
| 140 | assertThat("link provider should be registered", not(linkRegistry.linkProvider)); | 139 | assertThat("link provider should be registered", not(linkRegistry.linkProvider)); |
| ... | @@ -887,10 +886,14 @@ public class BgpTopologyProviderTest { | ... | @@ -887,10 +886,14 @@ public class BgpTopologyProviderTest { |
| 887 | l.addNode(nodeNlri, details); | 886 | l.addNode(nodeNlri, details); |
| 888 | assertThat(nodeRegistry.connected.size(), is(1)); | 887 | assertThat(nodeRegistry.connected.size(), is(1)); |
| 889 | } | 888 | } |
| 889 | + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); | ||
| 890 | 890 | ||
| 891 | - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), | 891 | + newBuilder.set("lsrId", "1.1.1.1"); |
| 892 | - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); | ||
| 893 | 892 | ||
| 893 | + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, nodeRegistry.connected.iterator().next(), | ||
| 894 | + Device.Type.ROUTER, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build()); | ||
| 895 | + | ||
| 896 | + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device); | ||
| 894 | listener.event(event); | 897 | listener.event(event); |
| 895 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); | 898 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); |
| 896 | } | 899 | } |
| ... | @@ -926,9 +929,16 @@ public class BgpTopologyProviderTest { | ... | @@ -926,9 +929,16 @@ public class BgpTopologyProviderTest { |
| 926 | for (BgpNodeListener l : controller.nodeListener) { | 929 | for (BgpNodeListener l : controller.nodeListener) { |
| 927 | l.addNode(nodeNlri, details); | 930 | l.addNode(nodeNlri, details); |
| 928 | assertThat(nodeRegistry.connected.size(), is(1)); | 931 | assertThat(nodeRegistry.connected.size(), is(1)); |
| 929 | - // Check label resource reserved for that device | 932 | + |
| 930 | - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), | 933 | + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
| 931 | - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); | 934 | + |
| 935 | + newBuilder.set("lsrId", "1.1.1.1"); | ||
| 936 | + | ||
| 937 | + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, | ||
| 938 | + nodeRegistry.connected.iterator().next(), Device.Type.ROUTER, UNKNOWN, | ||
| 939 | + UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build()); | ||
| 940 | + | ||
| 941 | + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device); | ||
| 932 | listener.event(event); | 942 | listener.event(event); |
| 933 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); | 943 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); |
| 934 | 944 | ||
| ... | @@ -988,8 +998,15 @@ public class BgpTopologyProviderTest { | ... | @@ -988,8 +998,15 @@ public class BgpTopologyProviderTest { |
| 988 | l.addNode(nodeNlri, details); | 998 | l.addNode(nodeNlri, details); |
| 989 | assertThat(nodeRegistry.connected.size(), is(1)); | 999 | assertThat(nodeRegistry.connected.size(), is(1)); |
| 990 | //Check label resource reserved for that device | 1000 | //Check label resource reserved for that device |
| 991 | - MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(), | 1001 | + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
| 992 | - new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>())); | 1002 | + |
| 1003 | + newBuilder.set("lsrId", "1.1.1.1"); | ||
| 1004 | + | ||
| 1005 | + Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, | ||
| 1006 | + nodeRegistry.connected.iterator().next(), Device.Type.ROUTER, | ||
| 1007 | + UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build()); | ||
| 1008 | + | ||
| 1009 | + DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device); | ||
| 993 | listener.event(event); | 1010 | listener.event(event); |
| 994 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); | 1011 | assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1)); |
| 995 | l.addNode(remNodeNlri, details); | 1012 | l.addNode(remNodeNlri, details); | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -36,6 +36,7 @@ import java.util.Collection; | ... | @@ -36,6 +36,7 @@ import java.util.Collection; |
| 36 | import java.util.Collections; | 36 | import java.util.Collections; |
| 37 | import java.util.HashMap; | 37 | import java.util.HashMap; |
| 38 | import java.util.HashSet; | 38 | import java.util.HashSet; |
| 39 | +import java.util.Iterator; | ||
| 39 | import java.util.LinkedList; | 40 | import java.util.LinkedList; |
| 40 | import java.util.List; | 41 | import java.util.List; |
| 41 | import java.util.concurrent.TimeUnit; | 42 | import java.util.concurrent.TimeUnit; |
| ... | @@ -88,6 +89,7 @@ import org.onosproject.pcep.controller.ClientCapability; | ... | @@ -88,6 +89,7 @@ import org.onosproject.pcep.controller.ClientCapability; |
| 88 | import org.onosproject.pcep.controller.LspKey; | 89 | import org.onosproject.pcep.controller.LspKey; |
| 89 | import org.onosproject.pcep.controller.PccId; | 90 | import org.onosproject.pcep.controller.PccId; |
| 90 | 91 | ||
| 92 | +import com.esotericsoftware.minlog.Log; | ||
| 91 | import com.google.common.collect.FluentIterable; | 93 | import com.google.common.collect.FluentIterable; |
| 92 | import com.google.common.collect.ImmutableSet; | 94 | import com.google.common.collect.ImmutableSet; |
| 93 | 95 | ||
| ... | @@ -223,6 +225,7 @@ public class PcepTunnelAddedTest { | ... | @@ -223,6 +225,7 @@ public class PcepTunnelAddedTest { |
| 223 | tunnel.path(), | 225 | tunnel.path(), |
| 224 | tunnel.resource(), | 226 | tunnel.resource(), |
| 225 | tunnel.annotations()); | 227 | tunnel.annotations()); |
| 228 | + Log.info("tunnel.annotations().toString() " + tunnel.annotations().toString()); | ||
| 226 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); | 229 | tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); |
| 227 | return id; | 230 | return id; |
| 228 | } | 231 | } |
| ... | @@ -237,6 +240,18 @@ public class PcepTunnelAddedTest { | ... | @@ -237,6 +240,18 @@ public class PcepTunnelAddedTest { |
| 237 | 240 | ||
| 238 | @Override | 241 | @Override |
| 239 | public void tunnelUpdated(TunnelDescription tunnel, State state) { | 242 | public void tunnelUpdated(TunnelDescription tunnel, State state) { |
| 243 | + TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | ||
| 244 | + Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE, | ||
| 245 | + tunnel.src(), tunnel.dst(), | ||
| 246 | + tunnel.type(), | ||
| 247 | + tunnel.groupId(), | ||
| 248 | + id, | ||
| 249 | + tunnel.tunnelName(), | ||
| 250 | + tunnel.path(), | ||
| 251 | + tunnel.resource(), | ||
| 252 | + tunnel.annotations()); | ||
| 253 | + tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel); | ||
| 254 | + Log.info("tunnelService.tunnelIdAsKeyStore ++ " + tunnelService.tunnelIdAsKeyStore.toString()); | ||
| 240 | } | 255 | } |
| 241 | 256 | ||
| 242 | @Override | 257 | @Override |
| ... | @@ -254,6 +269,7 @@ public class PcepTunnelAddedTest { | ... | @@ -254,6 +269,7 @@ public class PcepTunnelAddedTest { |
| 254 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { | 269 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { |
| 255 | TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | 270 | TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); |
| 256 | tunnelIdAsKeyStore.put(tunnelId, tunnel); | 271 | tunnelIdAsKeyStore.put(tunnelId, tunnel); |
| 272 | + Log.info("tunnelIdAsKeyStore insetup :: " + tunnelIdAsKeyStore.toString()); | ||
| 257 | return tunnelId; | 273 | return tunnelId; |
| 258 | } | 274 | } |
| 259 | 275 | ||
| ... | @@ -592,8 +608,11 @@ public class PcepTunnelAddedTest { | ... | @@ -592,8 +608,11 @@ public class PcepTunnelAddedTest { |
| 592 | 608 | ||
| 593 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); | 609 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); |
| 594 | TimeUnit.MILLISECONDS.sleep(4000); | 610 | TimeUnit.MILLISECONDS.sleep(4000); |
| 595 | - assertThat(registry.tunnelIdCounter, is((long) 1)); | 611 | + assertThat(registry.tunnelIdCounter, is((long) 2)); |
| 596 | - assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE), | 612 | + |
| 613 | + Iterator<Tunnel> iterator = tunnelService.tunnelIdAsKeyStore.values().iterator(); | ||
| 614 | + iterator.next(); | ||
| 615 | + assertThat(iterator.next().annotations().value(DELEGATE), | ||
| 597 | is("true")); | 616 | is("true")); |
| 598 | } | 617 | } |
| 599 | 618 | ... | ... |
-
Please register or login to post a comment