@Test public void testComputeDefaultInterAreaRouteToInjectRepeatedCalls() { OspfArea area = OspfArea.builder() .setNumber(1L) .setStubType(StubType.STUB) .setStubSettings(StubSettings.builder().build()) .build(); Ip nextHopIp = ACTIVE_ADDR_1.getIp(); OspfNeighborConfigId n1 = new OspfNeighborConfigId(HOSTNAME, VRF_NAME, "1", ACTIVE_IFACE_NAME, ACTIVE_ADDR_1); OspfNeighborConfigId n2 = new OspfNeighborConfigId("r2", VRF_NAME, "1", "someIface", ACTIVE_ADDR_1_NEIGHBOR); EdgeId edge = OspfTopology.makeEdge(n1, n2); assertThat( _routingProcess .computeDefaultInterAreaRouteToInject(edge, area, nextHopIp) .collect(ImmutableList.toImmutableList()), contains( allOf( hasRoute(allOf(hasPrefix(Prefix.ZERO), hasNextHopIp(equalTo(nextHopIp)))), hasReason(ADD)))); for (int i = 0; i < 10; i++) { assertThat( "No default route to inject", _routingProcess.computeDefaultInterAreaRouteToInject(edge, area, nextHopIp).count(), equalTo(0L)); } OspfNeighborConfigId n3 = new OspfNeighborConfigId("r3", VRF_NAME, "1", "someIface", ACTIVE_ADDR_1_NEIGHBOR2); edge = OspfTopology.makeEdge(n3, n2); assertThat( _routingProcess .computeDefaultInterAreaRouteToInject(edge, area, nextHopIp) .collect(ImmutableList.toImmutableList()), contains( allOf( hasRoute(allOf(hasPrefix(Prefix.ZERO), hasNextHopIp(equalTo(nextHopIp)))), hasReason(ADD)))); }
@VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty();  }