@Test public void testAddVniEdges() { Map<String, Configuration> configurations = ImmutableMap.of(NODE1, _c1, NODE2, _c2); MutableGraph<VxlanNode> graph = GraphBuilder.undirected().allowsSelfLoops(false).build(); Layer2Vni.Builder vniSettingsBuilder = testBuilder() .setBumTransportIps(ImmutableSortedSet.of(MULTICAST_GROUP)) .setBumTransportMethod(BumTransportMethod.MULTICAST_GROUP) .setUdpPort(UDP_PORT) .setVni(VNI); Layer2Vni vniSettingsTail = vniSettingsBuilder.setSourceAddress(SRC_IP1).setVlan(VLAN1).build(); _v1.setLayer2Vnis(ImmutableSet.of(vniSettingsTail)); Layer2Vni vniSettingsHead = vniSettingsBuilder.setSourceAddress(SRC_IP2).setVlan(VLAN2).build(); _v2.setLayer2Vnis(ImmutableSet.of(vniSettingsHead)); addVniEdges( graph, computeVniSettingsTable(configurations), VNI, ImmutableMap.of( new VrfId(_c1.getHostname(), _v1.getName()), vniSettingsTail, new VrfId(_c2.getHostname(), _v2.getName()), vniSettingsHead)); VxlanNode nodeTail = VxlanNode.builder().setHostname(NODE1).setVni(VNI).build(); VxlanNode nodeHead = VxlanNode.builder().setHostname(NODE2).setVni(VNI).build(); assertThat(graph.edges(), equalTo(ImmutableSet.of(EndpointPair.unordered(nodeTail, nodeHead)))); }
@VisibleForTesting static void addVniEdges( MutableGraph<VxlanNode> graph, Table<VrfId, Integer, Layer2Vni> allVniSettings, Integer vni, Map<VrfId, Layer2Vni> vrfs) { for (VrfId vrfTail : vrfs.keySet()) { for (VrfId vrfHead : vrfs.keySet()) { if (vrfTail.equals(vrfHead)) { continue; } addVniEdge( graph, vrfTail, allVniSettings.get(vrfTail, vni), vrfHead, allVniSettings.get(vrfHead, vni)); } } }
VxlanTopologyUtils { @VisibleForTesting static void addVniEdges( MutableGraph<VxlanNode> graph, Table<VrfId, Integer, Layer2Vni> allVniSettings, Integer vni, Map<VrfId, Layer2Vni> vrfs) { for (VrfId vrfTail : vrfs.keySet()) { for (VrfId vrfHead : vrfs.keySet()) { if (vrfTail.equals(vrfHead)) { continue; } addVniEdge( graph, vrfTail, allVniSettings.get(vrfTail, vni), vrfHead, allVniSettings.get(vrfHead, vni)); } } } }
VxlanTopologyUtils { @VisibleForTesting static void addVniEdges( MutableGraph<VxlanNode> graph, Table<VrfId, Integer, Layer2Vni> allVniSettings, Integer vni, Map<VrfId, Layer2Vni> vrfs) { for (VrfId vrfTail : vrfs.keySet()) { for (VrfId vrfHead : vrfs.keySet()) { if (vrfTail.equals(vrfHead)) { continue; } addVniEdge( graph, vrfTail, allVniSettings.get(vrfTail, vni), vrfHead, allVniSettings.get(vrfHead, vni)); } } } private  VxlanTopologyUtils(); }
VxlanTopologyUtils { @VisibleForTesting static void addVniEdges( MutableGraph<VxlanNode> graph, Table<VrfId, Integer, Layer2Vni> allVniSettings, Integer vni, Map<VrfId, Layer2Vni> vrfs) { for (VrfId vrfTail : vrfs.keySet()) { for (VrfId vrfHead : vrfs.keySet()) { if (vrfTail.equals(vrfHead)) { continue; } addVniEdge( graph, vrfTail, allVniSettings.get(vrfTail, vni), vrfHead, allVniSettings.get(vrfHead, vni)); } } } private  VxlanTopologyUtils(); static @Nonnull VxlanTopology computeVxlanTopology(
      Map<String, Configuration> configurations); static @Nonnull VxlanTopology computeVxlanTopology(
      Table<String, String, ? extends Collection<Layer2Vni>> allVniSettings); static @Nonnull VxlanTopology prunedVxlanTopology(
      VxlanTopology initialVxlanTopology,
      Map<String, Configuration> configurations,
      TracerouteEngine tracerouteEngine); }
VxlanTopologyUtils { @VisibleForTesting static void addVniEdges( MutableGraph<VxlanNode> graph, Table<VrfId, Integer, Layer2Vni> allVniSettings, Integer vni, Map<VrfId, Layer2Vni> vrfs) { for (VrfId vrfTail : vrfs.keySet()) { for (VrfId vrfHead : vrfs.keySet()) { if (vrfTail.equals(vrfHead)) { continue; } addVniEdge( graph, vrfTail, allVniSettings.get(vrfTail, vni), vrfHead, allVniSettings.get(vrfHead, vni)); } } } private  VxlanTopologyUtils(); static @Nonnull VxlanTopology computeVxlanTopology(
      Map<String, Configuration> configurations); static @Nonnull VxlanTopology computeVxlanTopology(
      Table<String, String, ? extends Collection<Layer2Vni>> allVniSettings); static @Nonnull VxlanTopology prunedVxlanTopology(
      VxlanTopology initialVxlanTopology,
      Map<String, Configuration> configurations,
      TracerouteEngine tracerouteEngine);  }