@Test public void testInitTopologyRemotePrefixNotMatchingLocalIp() { Ip ip1 = Ip.parse("1.1.1.1"); Ip ip2 = Ip.parse("2.2.2.2"); Prefix peer1PeerPrefix = ip2.toPrefix(); BgpActivePeerConfig peer1 = BgpActivePeerConfig.builder() .setLocalIp(ip1) .setLocalAs(1L) .setPeerAddress(ip2) .setRemoteAs(2L) .setIpv4UnicastAddressFamily( Ipv4UnicastAddressFamily.builder() .setAddressFamilyCapabilities(AddressFamilyCapabilities.builder().build()) .build()) .build(); _node1BgpProcess.setNeighbors(ImmutableSortedMap.of(peer1PeerPrefix, peer1)); Prefix peer2PeerPrefix = Prefix.create(ip1, 24); BgpPassivePeerConfig peer2 = BgpPassivePeerConfig.builder() .setLocalIp(Ip.AUTO) .setLocalAs(2L) .setRemoteAs(1L) .setPeerPrefix(peer2PeerPrefix) .setIpv4UnicastAddressFamily( Ipv4UnicastAddressFamily.builder() .setAddressFamilyCapabilities(AddressFamilyCapabilities.builder().build()) .build()) .build(); _node2BgpProcess.setPassiveNeighbors(ImmutableSortedMap.of(peer2PeerPrefix, peer2)); Map<Ip, Map<String, Set<String>>> ipOwners = ImmutableMap.of( ip1, ImmutableMap.of(NODE1, ImmutableSet.of(DEFAULT_VRF_NAME)), ip2, ImmutableMap.of(NODE2, ImmutableSet.of(DEFAULT_VRF_NAME))); ValueGraph<BgpPeerConfigId, BgpSessionProperties> bgpTopology = initBgpTopology(_configs, ipOwners, true, false, null, null).getGraph(); assertThat(bgpTopology.edges(), hasSize(2)); EndpointPair<BgpPeerConfigId> edge = bgpTopology.edges().iterator().next(); assertThat(edge.source().getHostname(), equalTo(NODE1)); assertThat(edge.target().getHostname(), equalTo(NODE2)); }
public static @Nonnull BgpTopology initBgpTopology( Map<String, Configuration> configurations, Map<Ip, Map<String, Set<String>>> ipOwners, boolean keepInvalid, @Nullable Layer2Topology layer2Topology) { return initBgpTopology(configurations, ipOwners, keepInvalid, false, null, layer2Topology); }
BgpTopologyUtils { public static @Nonnull BgpTopology initBgpTopology( Map<String, Configuration> configurations, Map<Ip, Map<String, Set<String>>> ipOwners, boolean keepInvalid, @Nullable Layer2Topology layer2Topology) { return initBgpTopology(configurations, ipOwners, keepInvalid, false, null, layer2Topology); } }
BgpTopologyUtils { public static @Nonnull BgpTopology initBgpTopology( Map<String, Configuration> configurations, Map<Ip, Map<String, Set<String>>> ipOwners, boolean keepInvalid, @Nullable Layer2Topology layer2Topology) { return initBgpTopology(configurations, ipOwners, keepInvalid, false, null, layer2Topology); } private  BgpTopologyUtils(); }
BgpTopologyUtils { public static @Nonnull BgpTopology initBgpTopology( Map<String, Configuration> configurations, Map<Ip, Map<String, Set<String>>> ipOwners, boolean keepInvalid, @Nullable Layer2Topology layer2Topology) { return initBgpTopology(configurations, ipOwners, keepInvalid, false, null, layer2Topology); } private  BgpTopologyUtils(); static @Nonnull BgpTopology initBgpTopology(
      Map<String, Configuration> configurations,
      Map<Ip, Map<String, Set<String>>> ipOwners,
      boolean keepInvalid,
      @Nullable Layer2Topology layer2Topology); static @Nonnull BgpTopology initBgpTopology(
      Map<String, Configuration> configurations,
      Map<Ip, Map<String, Set<String>>> ipVrfOwners,
      boolean keepInvalid,
      boolean checkReachability,
      @Nullable TracerouteEngine tracerouteEngine,
      @Nullable Layer2Topology layer2Topology); @VisibleForTesting static boolean isReachableBgpNeighbor(
      @Nonnull BgpPeerConfigId initiatorId,
      @Nonnull BgpPeerConfigId listenerId,
      @Nonnull BgpActivePeerConfig initiator,
      @Nonnull TracerouteEngine tracerouteEngine); }
BgpTopologyUtils { public static @Nonnull BgpTopology initBgpTopology( Map<String, Configuration> configurations, Map<Ip, Map<String, Set<String>>> ipOwners, boolean keepInvalid, @Nullable Layer2Topology layer2Topology) { return initBgpTopology(configurations, ipOwners, keepInvalid, false, null, layer2Topology); } private  BgpTopologyUtils(); static @Nonnull BgpTopology initBgpTopology(
      Map<String, Configuration> configurations,
      Map<Ip, Map<String, Set<String>>> ipOwners,
      boolean keepInvalid,
      @Nullable Layer2Topology layer2Topology); static @Nonnull BgpTopology initBgpTopology(
      Map<String, Configuration> configurations,
      Map<Ip, Map<String, Set<String>>> ipVrfOwners,
      boolean keepInvalid,
      boolean checkReachability,
      @Nullable TracerouteEngine tracerouteEngine,
      @Nullable Layer2Topology layer2Topology); @VisibleForTesting static boolean isReachableBgpNeighbor(
      @Nonnull BgpPeerConfigId initiatorId,
      @Nonnull BgpPeerConfigId listenerId,
      @Nonnull BgpActivePeerConfig initiator,
      @Nonnull TracerouteEngine tracerouteEngine);  }