@Test public void testIgnoreGeneratedFilters() { // generate unreachable IpAccessList aclGenerated = _aclb .setLines( ImmutableList.of( IpAccessListLine.accepting().setMatchCondition(FalseExpr.INSTANCE).build())) .setName("~aclGenerated") .build(); SpecifierContext ctxt = MockSpecifierContext.builder().setConfigs(ImmutableMap.of("c1", _c1)).build(); // we should get an empty set when we are ignoring generated filters assertThat( getSpecifiedFilters(new FilterLineReachabilityQuestion(null, null, true), ctxt), equalTo(ImmutableMap.of("c1", ImmutableSet.of()))); // we should get the one acl we put in otherwise assertThat( getSpecifiedFilters(new FilterLineReachabilityQuestion(null, null, false), ctxt), equalTo(ImmutableMap.of("c1", ImmutableSet.of(aclGenerated)))); }
@Test public void resolve() { Configuration node1 = new Configuration("node1", ConfigurationFormat.CISCO_IOS); Configuration node2 = new Configuration("node2", ConfigurationFormat.CISCO_IOS); MockSpecifierContext ctxt = MockSpecifierContext.builder() .setConfigs(ImmutableMap.of("node1", node1, "node2", node2)) .build(); assertThat( new ShorthandNodeSpecifier(new NodesSpecifier("node1")).resolve(ctxt), equalTo(ImmutableSet.of("node1"))); } }
@Override public SpecifierContext specifierContext() { return firstNonNull( _specifierContext, MockSpecifierContext.builder().setConfigs(loadConfigurations()).build()); } }
.setConfigs(ImmutableMap.of("node1", node1, "node2", node2)) .build();
configs, MockSpecifierContext.builder() .setConfigs(configs) .setInterfaceOwnedIps( ImmutableMap.of(
.setConfigs(ImmutableSortedMap.of(_c1.getHostname(), _c1, _c2.getHostname(), _c2)) .setInterfaceOwnedIps( ImmutableMap.of(
.setConfigs(ImmutableMap.of("node1", node1, "node2", node2)) .build();
.setConfigs(ImmutableMap.of(node1.getHostname(), node1, node2.getHostname(), node2)) .setReferenceBooks(ImmutableSortedSet.of(referenceBook)) .build();
.setConfigs(ImmutableMap.of("node1", node1, "node2", node2)) .build();
@Test public void resolve() { Configuration node1 = new Configuration("node1", ConfigurationFormat.CISCO_IOS); Configuration node2 = new Configuration("node2", ConfigurationFormat.CISCO_IOS); Interface iface11 = Interface.builder().setName("iface11").setOwner(node1).build(); Interface iface12 = Interface.builder().setName("iface12").setOwner(node1).build(); Interface iface2 = Interface.builder().setName("iface2").setOwner(node2).build(); node1.setInterfaces(ImmutableSortedMap.of("iface11", iface11, "iface12", iface12)); node2.setInterfaces(ImmutableSortedMap.of("iface2", iface2)); MockSpecifierContext ctxt = MockSpecifierContext.builder() .setConfigs(ImmutableMap.of("node1", node1, "node2", node2)) .build(); assertThat( new ShorthandInterfaceSpecifier(new InterfacesSpecifier("iface11")) .resolve(ImmutableSet.of("node1"), ctxt), equalTo(ImmutableSet.of(iface11))); } }
@Test public void testErrorForNoMatchingFilters() throws IOException { Configuration c1 = _cb.setHostname("c1").build(); SortedMap<String, Configuration> configs = ImmutableSortedMap.of(c1.getHostname(), c1); IBatfish batfish = new MockBatfish(configs, MockSpecifierContext.builder().setConfigs(configs).build()); // Test that exception is thrown if node is found, but no filters match TestFiltersQuestion question = new TestFiltersQuestion(new NodesSpecifier(c1.getHostname()), "fake_filter", null, null); TestFiltersAnswerer answerer = new TestFiltersAnswerer(question, batfish); _thrown.expect(BatfishException.class); _thrown.expectMessage("No matching filters"); answerer.answer(); } }
@Test public void testErrorForNoMatchingNodes() throws IOException { Configuration c1 = _cb.setHostname("c1").build(); SortedMap<String, Configuration> configs = ImmutableSortedMap.of(c1.getHostname(), c1); IBatfish batfish = new MockBatfish(configs, MockSpecifierContext.builder().setConfigs(configs).build()); // Test that exception is thrown if no nodes match TestFiltersQuestion question = new TestFiltersQuestion(new NodesSpecifier("fake_node"), null, null, null); TestFiltersAnswerer answerer = new TestFiltersAnswerer(question, batfish); _thrown.expect(BatfishException.class); _thrown.expectMessage("No matching filters"); answerer.answer(); }
@Override public SpecifierContext specifierContext() { Configuration c1 = new Configuration("h", ConfigurationFormat.CISCO_IOS); Configuration c2 = new Configuration("h2", ConfigurationFormat.CISCO_IOS); return MockSpecifierContext.builder() .setConfigs(ImmutableSortedMap.of("h", c1, "h2", c2)) .build(); } }
@Override public SpecifierContext specifierContext() { Configuration c1 = new Configuration("h", ConfigurationFormat.CISCO_IOS); Configuration c2 = new Configuration("h2", ConfigurationFormat.CISCO_IOS); return MockSpecifierContext.builder() .setConfigs(ImmutableSortedMap.of("h", c1, "h2", c2)) .build(); } }
@Override public SpecifierContext specifierContext() { return MockSpecifierContext.builder().setConfigs(loadConfigurations()).build(); } }