@Test public void testInitQueuesAndDeltaBuilders() { NetworkFactory nf = new NetworkFactory(); Configuration.Builder cb = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS); Configuration c1 = cb.setHostname("r1").build(); Configuration c2 = cb.setHostname("r2").build(); Vrf vrf1 = nf.vrfBuilder().setName(DEFAULT_VRF_NAME).setOwner(c1).build(); Vrf vrf2 = nf.vrfBuilder().setName(DEFAULT_VRF_NAME).setOwner(c2).build(); BgpProcess.Builder pb = nf.bgpProcessBuilder().setAdminCostsToVendorDefaults(ConfigurationFormat.CISCO_IOS); BgpProcess proc1 = pb.setVrf(vrf1).setRouterId(Ip.parse("1.1.1.1")).build(); BgpProcess proc2 = pb.setVrf(vrf2).setRouterId(Ip.parse("1.1.1.2")).build(); nf.bgpNeighborBuilder() .setPeerAddress(Ip.parse("1.1.1.2")) .setLocalIp(Ip.parse("1.1.1.1")) .setBgpProcess(proc1) .setRemoteAs(2L) .setLocalAs(1L) .build(); nf.bgpNeighborBuilder() .setPeerAddress(Ip.parse("1.1.1.1")) .setLocalIp(Ip.parse("1.1.1.2")) .setBgpProcess(proc2) .setRemoteAs(1L) .setLocalAs(2L) .build(); Interface.Builder ib = nf.interfaceBuilder().setActive(true); ib.setAddress(ConcreteInterfaceAddress.parse("1.1.1.1/30")).setOwner(c1).setVrf(vrf1).build(); ib.setAddress(ConcreteInterfaceAddress.parse("1.1.1.2/30")).setOwner(c2).setVrf(vrf2).build(); Topology topology = synthesizeL3Topology(ImmutableMap.of("r1", c1, "r2", c2)); Map<String, Configuration> configs = ImmutableMap.of("r1", c1, "r2", c2); BgpTopology bgpTopology = BgpTopology.EMPTY; IsisTopology isisTopology = initIsisTopology(configs, topology); Map<String, Node> nodes = ImmutableMap.of(c1.getHostname(), new Node(c1), c2.getHostname(), new Node(c2)); Map<String, VirtualRouter> vrs = nodes.values().stream() .map(n -> n.getVirtualRouters().get(DEFAULT_VRF_NAME)) .collect( ImmutableMap.toImmutableMap( vr -> vr.getConfiguration().getHostname(), Function.identity())); IsisTopology initialIsisTopology = initIsisTopology(configs, topology); EigrpTopology eigrpTopology = initEigrpTopology(configs, topology); vrs.values() .forEach( vr -> vr.initForEgpComputationWithNewTopology( TopologyContext.builder() .setBgpTopology(bgpTopology) .setEigrpTopology(eigrpTopology) .setIsisTopology(initialIsisTopology) .build())); vrs.values() .forEach( vr -> { assertThat(vr._bgpRoutingProcess._bgpv4Edges, empty()); vr._eigrpProcesses .values() .forEach(process -> assertThat(process._incomingExternalRoutes, anEmptyMap())); assertThat(vr._isisIncomingRoutes, anEmptyMap()); }); BgpTopology bgpTopology2 = initBgpTopology(configs, new IpOwners(configs).getIpVrfOwners(), false, null); for (Node n : nodes.values()) { n.getVirtualRouters() .get(DEFAULT_VRF_NAME) .initForEgpComputationWithNewTopology( TopologyContext.builder() .setBgpTopology(bgpTopology2) .setEigrpTopology(eigrpTopology) .setIsisTopology(isisTopology) .build()); } vrs.values() .forEach( vr -> { assertThat(vr._bgpRoutingProcess._bgpv4Edges, is(notNullValue())); assertThat(vr._bgpRoutingProcess._bgpv4Edges, hasSize(1)); }); }
@VisibleForTesting void initQueuesAndDeltaBuilders(TopologyContext topologyContext) { _eigrpProcesses .values() .forEach(proc -> proc.updateTopology(topologyContext.getEigrpTopology())); initIsisQueues(topologyContext.getIsisTopology()); initCrossVrfQueues(); }
VirtualRouter { @VisibleForTesting void initQueuesAndDeltaBuilders(TopologyContext topologyContext) { _eigrpProcesses .values() .forEach(proc -> proc.updateTopology(topologyContext.getEigrpTopology())); initIsisQueues(topologyContext.getIsisTopology()); initCrossVrfQueues(); } }
VirtualRouter { @VisibleForTesting void initQueuesAndDeltaBuilders(TopologyContext topologyContext) { _eigrpProcesses .values() .forEach(proc -> proc.updateTopology(topologyContext.getEigrpTopology())); initIsisQueues(topologyContext.getIsisTopology()); initCrossVrfQueues(); } VirtualRouter(@Nonnull String name, @Nonnull Node node); }
VirtualRouter { @VisibleForTesting void initQueuesAndDeltaBuilders(TopologyContext topologyContext) { _eigrpProcesses .values() .forEach(proc -> proc.updateTopology(topologyContext.getEigrpTopology())); initIsisQueues(topologyContext.getIsisTopology()); initCrossVrfQueues(); } VirtualRouter(@Nonnull String name, @Nonnull Node node); void computeFib(); Configuration getConfiguration(); Fib getFib(); void enqueueCrossVrfRoutes(
      @Nonnull CrossVrfEdgeId remoteVrfToOurRib,
      @Nonnull Stream<RouteAdvertisement<AnnotatedRoute<AbstractRoute>>> routeAdverts,
      @Nullable String policyName); Map<String, OspfRoutingProcess> getOspfProcesses(); Set<Layer2Vni> getLayer2Vnis(); Set<Layer3Vni> getLayer3Vnis(); @Nonnull String getName(); }
VirtualRouter { @VisibleForTesting void initQueuesAndDeltaBuilders(TopologyContext topologyContext) { _eigrpProcesses .values() .forEach(proc -> proc.updateTopology(topologyContext.getEigrpTopology())); initIsisQueues(topologyContext.getIsisTopology()); initCrossVrfQueues(); } VirtualRouter(@Nonnull String name, @Nonnull Node node); void computeFib(); Configuration getConfiguration(); Fib getFib(); void enqueueCrossVrfRoutes(
      @Nonnull CrossVrfEdgeId remoteVrfToOurRib,
      @Nonnull Stream<RouteAdvertisement<AnnotatedRoute<AbstractRoute>>> routeAdverts,
      @Nullable String policyName); Map<String, OspfRoutingProcess> getOspfProcesses(); Set<Layer2Vni> getLayer2Vnis(); Set<Layer3Vni> getLayer3Vnis(); @Nonnull String getName();  }