src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
FermaPortPropertiesRepository extends FermaGenericRepository<PortProperties, PortPropertiesData, PortPropertiesFrame> implements PortPropertiesRepository { @Override public Optional<PortProperties> getBySwitchIdAndPort(SwitchId switchId, int port) { List<? extends PortPropertiesFrame> portPropertiesFrames = framedGraph... | @Test public void shouldGetPortPropertiesBySwitchIdAndPort() { Switch origSwitch = createTestSwitch(TEST_SWITCH_ID.getId()); int port = 7; PortProperties portProperties = PortProperties.builder() .switchObj(origSwitch) .port(port) .discoveryEnabled(false) .build(); portPropertiesRepository.add(portProperties); Optional... |
FermaFlowCookieRepository extends FermaGenericRepository<FlowCookie, FlowCookieData, FlowCookieFrame> implements FlowCookieRepository { @Override public Collection<FlowCookie> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(FlowCookieFrame.FRAME_LABEL)) .toListExplicit(FlowCookieFrame.class).stream() .ma... | @Test public void shouldCreateFlowCookie() { createFlowCookie(); Collection<FlowCookie> allCookies = flowCookieRepository.findAll(); FlowCookie foundCookie = allCookies.iterator().next(); assertEquals(TEST_COOKIE, foundCookie.getUnmaskedCookie()); assertEquals(TEST_FLOW_ID, foundCookie.getFlowId()); }
@Test public void... |
FermaFlowCookieRepository extends FermaGenericRepository<FlowCookie, FlowCookieData, FlowCookieFrame> implements FlowCookieRepository { @Override public Optional<FlowCookie> findByCookie(long unmaskedCookie) { List<? extends FlowCookieFrame> flowCookieFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowCookieFrame... | @Test public void shouldSelectNextInOrderResourceWhenFindUnassignedCookie() { long first = findUnassignedCookieAndCreate("flow_1"); assertEquals(5, first); long second = findUnassignedCookieAndCreate("flow_2"); assertEquals(6, second); long third = findUnassignedCookieAndCreate("flow_3"); assertEquals(7, third); transa... |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Optional<FlowPath> findById(PathId pathId) { List<? extends FlowPathFrame> flowPathFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowPathFrame.FRAME_LABEL) .has(FlowPathF... | @Test public void shouldFlowPathUpdateKeepRelations() { createTestFlowPathPair(); Flow foundFlow = flowRepository.findById(TEST_FLOW_ID).get(); assertThat(foundFlow.getPaths(), hasSize(2)); FlowPath foundPath = flowPathRepository.findById(flow.getForwardPathId()).get(); foundPath.setStatus(FlowPathStatus.INACTIVE); fou... |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Optional<FlowPath> findByFlowIdAndCookie(String flowId, FlowSegmentCookie cookie) { List<? extends FlowPathFrame> flowPathFrames = framedGraph().traverse(g -> g.V() .hasLabel(Fl... | @Test public void shouldFindPathByFlowIdAndCookie() { FlowPath flowPath = createTestFlowPath(); Optional<FlowPath> foundPath = flowPathRepository.findByFlowIdAndCookie(TEST_FLOW_ID, flowPath.getCookie()); assertTrue(foundPath.isPresent()); } |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findByEndpointSwitch(SwitchId switchId, boolean includeProtected) { Map<PathId, FlowPath> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLa... | @Test public void shouldFindByEndpointSwitch() { createTestFlowPathPair(); Collection<FlowPath> paths = flowPathRepository.findByEndpointSwitch(switchA.getSwitchId()); assertThat(paths, containsInAnyOrder(flow.getForwardPath(), flow.getReversePath())); }
@Test public void shouldNotFindProtectedIngressByEndpointSwitch()... |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findBySrcSwitch(SwitchId switchId, boolean includeProtected) { List<FlowPath> result = new ArrayList<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowPa... | @Test public void shouldFindProtectedPathsBySrcSwitchIncludeProtected() { createTestFlowPathPair(); flow.setProtectedForwardPath(createFlowPath(flow, "_forward_protected", 10, 10, switchA, switchB)); flow.setProtectedReversePath(createFlowPath(flow, "_reverse_protected", 11, 11, switchB, switchA)); assertThat(flowPathR... |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findWithPathSegment(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort) { return framedGraph().traverse(g -> g.V() .hasLabel(PathSegmentFr... | @Test public void shouldFindFlowPathsForIsl() { FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100); flow.setForwardPath(flowPath); Collection<FlowPath> paths = flowPathRepository.findWithPathSegment(switchA.getSwitchId(), 1, switchC.getSwitchId(), 100); assertThat(paths, Matchers.hasSize(1)); assertTh... |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findBySegmentEndpoint(SwitchId switchId, int port) { Map<PathId, FlowPath> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLabel(PathSegment... | @Test public void shouldFindActiveAffectedPaths() { FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100); flow.setForwardPath(flowPath); Collection<FlowPath> paths = flowPathRepository.findBySegmentEndpoint( switchC.getSwitchId(), 100); assertThat(paths, containsInAnyOrder(flowPath)); } |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findByFlowId(String flowId) { return framedGraph().traverse(g -> g.V() .hasLabel(FlowPathFrame.FRAME_LABEL) .has(FlowPathFrame.FLOW_ID_PROPERTY, flowId)) .t... | @Test public void shouldFindPathByFlowId() { createTestFlowPath(); Collection<FlowPath> foundPaths = flowPathRepository.findByFlowId(TEST_FLOW_ID); assertThat(foundPaths, hasSize(1)); } |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findBySegmentSwitch(SwitchId switchId) { Map<PathId, FlowPath> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLabel(PathSegmentFrame.FRAME_... | @Test public void shouldFindPathBySegmentSwitch() { FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100); flow.setForwardPath(flowPath); Collection<FlowPath> foundPaths = flowPathRepository.findBySegmentSwitch(switchC.getSwitchId()); assertThat(foundPaths, hasSize(1)); } |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findInactiveBySegmentSwitch(SwitchId switchId) { String downFlowStatus = FlowStatusConverter.INSTANCE.toGraphProperty(FlowStatus.DOWN); String degragedFlowS... | @Test public void shouldFindInactivePathBySegmentSwitch() { Flow activeFlow = Flow.builder() .flowId("active flow") .srcSwitch(switchA) .srcPort(1) .destSwitch(switchB) .destPort(2) .status(FlowStatus.UP) .build(); flowRepository.add(activeFlow); FlowPath activeFlowPath = createFlowPath(activeFlow, "active", 100L, 200L... |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findBySegmentDestSwitch(SwitchId switchId) { return framedGraph().traverse(g -> g.V() .hasLabel(PathSegmentFrame.FRAME_LABEL) .has(PathSegmentFrame.DST_SWIT... | @Test public void shouldFindPathBySegmentDestSwitch() { FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100); flow.setForwardPath(flowPath); Collection<FlowPath> foundPaths = flowPathRepository.findBySegmentDestSwitch(switchC.getSwitchId()); assertThat(foundPaths, hasSize(1)); }
@Test public void should... |
FermaFlowPathRepository extends FermaGenericRepository<FlowPath, FlowPathData, FlowPathFrame> implements FlowPathRepository { @Override public Collection<FlowPath> findActualByFlowIds(Set<String> flowIds) { Set<String> pathIds = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(Fl... | @Test public void shouldFindFlowPathIdsByFlowIds() { Flow flowA = buildTestProtectedFlow(TEST_FLOW_ID_1, switchA, PORT_1, VLAN_1, switchB, PORT_2, VLAN_2); flowRepository.add(flowA); Flow flowB = buildTestFlow(TEST_FLOW_ID_2, switchA, PORT_1, VLAN_2, switchB, PORT_2, 0); flowRepository.add(flowB); Flow flowC = buildTes... |
FermaApplicationRepository extends FermaGenericRepository<ApplicationRule, ApplicationRuleData,
ApplicationRuleFrame> implements ApplicationRepository { @Override public Optional<ApplicationRule> lookupRuleByMatchAndFlow(SwitchId switchId, String flowId, String srcIp, Integer srcPort, String dstIp, Integer dstP... | @Test public void shouldLookupRuleByMatchAndFlow() { ApplicationRule ruleA = buildRuleA(); ApplicationRule foundRule = applicationRepository.lookupRuleByMatchAndFlow(ruleA.getSwitchId(), ruleA.getFlowId(), ruleA.getSrcIp(), ruleA.getSrcPort(), ruleA.getDstIp(), ruleA.getDstPort(), ruleA.getProto(), ruleA.getEthType(), ... |
FermaApplicationRepository extends FermaGenericRepository<ApplicationRule, ApplicationRuleData,
ApplicationRuleFrame> implements ApplicationRepository { @Override public Optional<ApplicationRule> lookupRuleByMatchAndCookie(SwitchId switchId, ExclusionCookie cookie, String srcIp, Integer srcPort, String dstIp, I... | @Test public void shouldLookupRuleByMatchAndCookie() { ApplicationRule ruleA = buildRuleA(); ApplicationRule foundRule = applicationRepository.lookupRuleByMatchAndCookie(ruleA.getSwitchId(), ruleA.getCookie(), ruleA.getSrcIp(), ruleA.getSrcPort(), ruleA.getDstIp(), ruleA.getDstPort(), ruleA.getProto(), ruleA.getEthType... |
FermaApplicationRepository extends FermaGenericRepository<ApplicationRule, ApplicationRuleData,
ApplicationRuleFrame> implements ApplicationRepository { @Override public Collection<ApplicationRule> findBySwitchId(SwitchId switchId) { return framedGraph().traverse(g -> g.V() .hasLabel(ApplicationRuleFrame.FRAME_... | @Test public void shouldFindBySwitchId() { Collection<ApplicationRule> foundRules = applicationRepository.findBySwitchId(TEST_SWITCH_ID); assertEquals(2, foundRules.size()); assertTrue(foundRules.contains(buildRuleA())); assertTrue(foundRules.contains(buildRuleC())); } |
FermaApplicationRepository extends FermaGenericRepository<ApplicationRule, ApplicationRuleData,
ApplicationRuleFrame> implements ApplicationRepository { @Override public Collection<ApplicationRule> findByFlowId(String flowId) { return framedGraph().traverse(g -> g.V() .hasLabel(ApplicationRuleFrame.FRAME_LABEL)... | @Test public void shouldFindByFlowId() { Collection<ApplicationRule> foundRules = applicationRepository.findByFlowId(TEST_FLOW_ID); assertEquals(2, foundRules.size()); assertTrue(foundRules.contains(buildRuleA())); assertTrue(foundRules.contains(buildRuleB())); } |
FermaFlowEventRepository extends FermaGenericRepository<FlowEvent, FlowEventData, FlowEventFrame> implements FlowEventRepository { @Override public List<FlowEvent> findByFlowIdAndTimeFrame(String flowId, Instant timeFrom, Instant timeTo, int maxCount) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex... | @Test public void findByFlowIdAndTimeFrameOrderTest() { List<FlowEvent> expected = new ArrayList<>(); expected.add(buildFlowEvent(FLOW_1, ACTION_1, TIME_1)); expected.add(buildFlowEvent(FLOW_1, ACTION_2, TIME_2)); expected.add(buildFlowEvent(FLOW_1, ACTION_3, TIME_3)); for (FlowEvent flowHistory : expected) { repositor... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL)) .toListExplicit(FlowFrame.class).stream() .map(Flow::new) .collect(Collectors.toList()); } Fe... | @Test public void shouldCreateFlow() { createTestFlow(TEST_FLOW_ID, switchA, switchB); Collection<Flow> allFlows = flowRepository.findAll(); Flow foundFlow = allFlows.iterator().next(); assertEquals(switchA.getSwitchId(), foundFlow.getSrcSwitchId()); assertEquals(switchB.getSwitchId(), foundFlow.getDestSwitchId()); } |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Optional<Flow> findById(String flowId) { List<? extends FlowFrame> flowFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.FLOW_ID_PROPERTY, flowId)) .toListE... | @Test public void shouldNotFindByIdWithEndpoints() { assertFalse(flowRepository.findById("Non_existent").isPresent()); }
@Test public void shouldFindFlowById() { createTestFlow(TEST_FLOW_ID, switchA, switchB); Optional<Flow> foundFlow = flowRepository.findById(TEST_FLOW_ID); assertTrue(foundFlow.isPresent()); }
@Test p... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public boolean exists(String flowId) { try (GraphTraversal<?, ?> traversal = framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.FLOW_ID_PROPERTY, flowId)) .getRawTraversal()... | @Test public void shouldCheckForExistence() { createTestFlow(TEST_FLOW_ID, switchA, switchB); assertTrue(flowRepository.exists(TEST_FLOW_ID)); } |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByGroupId(String flowGroupId) { return framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.GROUP_ID_PROPERTY, flowGroupId)) .toListExplicit(FlowFr... | @Test public void shouldFindFlowByGroupId() { Flow flow = createTestFlow(TEST_FLOW_ID, switchA, switchB); flow.setGroupId(TEST_GROUP_ID); List<Flow> foundFlow = Lists.newArrayList(flowRepository.findByGroupId(TEST_GROUP_ID)); assertThat(foundFlow, Matchers.hasSize(1)); assertEquals(Collections.singletonList(flow), foun... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<String> findFlowsIdByGroupId(String flowGroupId) { return framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.GROUP_ID_PROPERTY, flowGroupId) .values(FlowFr... | @Test public void shouldFindFlowsIdByGroupId() { Flow flow = createTestFlow(TEST_FLOW_ID, switchA, switchB); flow.setGroupId(TEST_GROUP_ID); List<String> foundFlowId = Lists.newArrayList(flowRepository.findFlowsIdByGroupId(TEST_GROUP_ID)); assertThat(foundFlowId, Matchers.hasSize(1)); assertEquals(Collections.singleton... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByEndpointSwitchWithEnabledArp(SwitchId switchId) { Map<String, Flow> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFram... | @Test public void shouldFindFlowByEndpointSwitchWithEnabledArp() { createFlowWithArp(TEST_FLOW_ID, switchA, false, switchB, false); createFlowWithArp(TEST_FLOW_ID_2, switchA, true, switchB, false); createFlowWithArp(TEST_FLOW_ID_3, switchB, false, switchA, true); createFlowWithArp(TEST_FLOW_ID_4, switchA, true, switchA... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByEndpoint(SwitchId switchId, int port) { Map<String, Flow> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWIT... | @Test public void shouldFindFlowByEndpoint() { Flow flow = createTestFlow(TEST_FLOW_ID, switchA, switchB); Collection<Flow> foundFlows = flowRepository.findByEndpoint(TEST_SWITCH_A_ID, 1); Set<String> foundFlowIds = foundFlows.stream().map(foundFlow -> flow.getFlowId()).collect(Collectors.toSet()); assertThat(foundFlow... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Optional<Flow> findByEndpointAndVlan(SwitchId switchId, int port, int vlan) { List<? extends FlowFrame> flowFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFram... | @Test public void shouldNotFindFlowByEndpointAndVlan() { assertFalse(flowRepository.findByEndpointAndVlan(new SwitchId(1234), 999, 999).isPresent()); } |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Optional<Flow> findOneSwitchFlowBySwitchIdInPortAndOutVlan(SwitchId switchId, int inPort, int outVlan) { List<? extends FlowFrame> flowFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame... | @Test public void shouldNotFindOneSwitchFlowBySwitchIdInPortAndOutVlanIfFlowNotExist() { assertFalse(flowRepository.findOneSwitchFlowBySwitchIdInPortAndOutVlan( new SwitchId(1234), 999, 999).isPresent()); }
@Test public void shouldNotFindNotOneSwitchFlowBySwitchIdInPortAndOutVlan() { createTestFlow(TEST_FLOW_ID, switch... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port) { Set<String> result = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL... | @Test public void shouldFindIsByEndpointWithMultiTableSupport() { createTestFlow(TEST_FLOW_ID, switchA, PORT_1, VLAN_1, switchB, PORT_2, VLAN_2, true); createTestFlow(TEST_FLOW_ID_2, switchA, PORT_1, VLAN_2, switchB, PORT_2, 0, true); createTestFlow(TEST_FLOW_ID_3, switchA, PORT_1, VLAN_3, switchB, PORT_2, 0, false); c... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<String> findFlowIdsForMultiSwitchFlowsByEndpointWithMultiTableSupport(SwitchId switchId, int port) { Set<String> result = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(Flo... | @Test public void shouldFindFlowIdsForMultiSwitchFlowsByEndpointWithMultiTableSupport() { createTestFlow(TEST_FLOW_ID, switchA, PORT_1, VLAN_1, switchB, PORT_2, VLAN_2, true); createTestFlow(TEST_FLOW_ID_2, switchA, PORT_2, VLAN_2, switchB, PORT_2, 0, true); createTestFlow(TEST_FLOW_ID_3, switchA, PORT_1, VLAN_3, switc... |
PathsService { public List<PathsInfoData> getPaths( SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType, PathComputationStrategy requestPathComputationStrategy) throws RecoverableException, SwitchNotFoundException, UnroutableFlowException { if (Objects.equals(srcSwitchId, dstSwitc... | @Test public void findNPathsByTransitVlanAndCost() throws SwitchNotFoundException, RecoverableException, UnroutableFlowException { List<PathsInfoData> paths = pathsService.getPaths(SWITCH_ID_1, SWITCH_ID_2, TRANSIT_VLAN, COST); assertEquals(MAX_PATH_COUNT, paths.size()); for (PathsInfoData path : paths) { assertEquals(... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByEndpointSwitch(SwitchId switchId) { Map<String, Flow> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWITCH_I... | @Test public void shouldFindFlowBySwitchEndpoint() { Flow flow = createTestFlow(TEST_FLOW_ID, switchA, switchB); Collection<Flow> foundFlows = flowRepository.findByEndpointSwitch(TEST_SWITCH_A_ID); Set<String> foundFlowIds = foundFlows.stream().map(foundFlow -> flow.getFlowId()).collect(Collectors.toSet()); assertThat(... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByEndpointSwitchWithMultiTableSupport(SwitchId switchId) { Map<String, Flow> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(F... | @Test public void shouldFindFlowBySwitchEndpointWithMultiTable() { Flow firstFlow = createTestFlow(TEST_FLOW_ID, switchA, switchB); firstFlow.setSrcWithMultiTable(true); Flow secondFlow = createTestFlow(TEST_FLOW_ID_2, switchA, switchB); secondFlow.setSrcWithMultiTable(false); Collection<Flow> foundFlows = flowReposito... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByEndpointSwitchWithEnabledLldp(SwitchId switchId) { Map<String, Flow> result = new HashMap<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFra... | @Test public void shouldFindFlowByEndpointSwitchWithEnabledLldp() { createFlowWithLldp(TEST_FLOW_ID, switchA, false, switchB, false); createFlowWithLldp(TEST_FLOW_ID_2, switchA, true, switchB, false); createFlowWithLldp(TEST_FLOW_ID_3, switchB, false, switchA, true); createFlowWithLldp(TEST_FLOW_ID_4, switchA, true, sw... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findOneSwitchFlows(SwitchId switchId) { return framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.... | @Test public void shouldFindOneFlowByEndpoint() { Flow flow1 = createTestFlow(TEST_FLOW_ID, switchA, switchA); flow1.setSrcPort(1); flow1.setDestPort(2); Flow flow2 = createTestFlow(TEST_FLOW_ID_2, switchB, switchB); flow2.setSrcPort(1); flow2.setDestPort(2); createTestFlow(TEST_FLOW_ID_3, switchA, switchB); Collection... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findInactiveFlows() { String downFlowStatus = FlowStatusConverter.INSTANCE.toGraphProperty(FlowStatus.DOWN); String degragedFlowStatus = FlowStatusConverter.INSTANCE.toGraphPropert... | @Test public void shouldFindDownFlowIdsByEndpoint() { Flow flow = createTestFlow(TEST_FLOW_ID, switchA, switchB); flow.setStatus(FlowStatus.DOWN); Collection<Flow> foundFlows = flowRepository.findInactiveFlows(); assertThat(foundFlows, Matchers.hasSize(1)); } |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Optional<String> getOrCreateFlowGroupId(String flowId) { return transactionManager.doInTransaction(() -> findById(flowId) .map(diverseFlow -> { if (diverseFlow.getGroupId() == null) { String groupI... | @Test public void shouldGetFlowGroupIdForFlow() { Flow flow = createTestFlow(TEST_FLOW_ID, switchA, switchB); flow.setGroupId(TEST_GROUP_ID); Optional<String> groupOptional = flowRepository.getOrCreateFlowGroupId(TEST_FLOW_ID); assertTrue(groupOptional.isPresent()); assertEquals(TEST_GROUP_ID, groupOptional.get()); } |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public long computeFlowsBandwidthSum(Set<String> flowIds) { try (GraphTraversal<?, ?> traversal = framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.FLOW_ID_PROPERTY, P.with... | @Test public void shouldComputeSumOfFlowsBandwidth() { long firstFlowBandwidth = 100000L; long secondFlowBandwidth = 500000L; Flow firstFlow = createTestFlow(TEST_FLOW_ID, switchA, switchB); firstFlow.setBandwidth(firstFlowBandwidth); Flow secondFlow = createTestFlow(TEST_FLOW_ID_2, switchA, switchB); secondFlow.setBan... |
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByFlowFilter(FlowFilter flowFilter) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(FlowFrame.FRAME_LABEL); if (flowFilter.get... | @Test public void shouldGetAllDownFlows() { Flow flowA = createTestFlow(TEST_FLOW_ID, switchA, switchB); flowA.setStatus(FlowStatus.DOWN); Flow flowB = createTestFlow(TEST_FLOW_ID_2, switchA, switchB); flowB.setStatus(FlowStatus.DOWN); createTestFlow(TEST_FLOW_ID_3, switchA, switchB); Collection<String> foundDownFlows ... |
FermaSwitchRepository extends FermaGenericRepository<Switch, SwitchData, SwitchFrame> implements SwitchRepository { @Override public Collection<Switch> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(SwitchFrame.FRAME_LABEL)) .toListExplicit(SwitchFrame.class).stream() .map(Switch::new) .collect(Collecto... | @Test public void shouldCreateSwitch() { switchRepository.add(Switch.builder() .switchId(TEST_SWITCH_ID_A) .description("Some description") .build()); assertEquals(1, switchRepository.findAll().size()); }
@Test public void shouldDeleteSwitch() { Switch origSwitch = Switch.builder() .switchId(TEST_SWITCH_ID_A) .descript... |
FermaSwitchRepository extends FermaGenericRepository<Switch, SwitchData, SwitchFrame> implements SwitchRepository { @Override public Collection<Switch> findActive() { return framedGraph().traverse(g -> g.V() .hasLabel(SwitchFrame.FRAME_LABEL) .has(SwitchFrame.STATUS_PROPERTY, SwitchStatusConverter.INSTANCE.toGraphPrope... | @Test public void shouldFindActive() { Switch activeSwitch = Switch.builder().switchId(TEST_SWITCH_ID_A) .status(SwitchStatus.ACTIVE).build(); Switch inactiveSwitch = Switch.builder().switchId(TEST_SWITCH_ID_B) .status(SwitchStatus.INACTIVE).build(); switchRepository.add(activeSwitch); switchRepository.add(inactiveSwit... |
FermaSwitchRepository extends FermaGenericRepository<Switch, SwitchData, SwitchFrame> implements SwitchRepository { @Override public Optional<Switch> findById(SwitchId switchId) { return SwitchFrame.load(framedGraph(), SwitchIdConverter.INSTANCE.toGraphProperty(switchId)).map(Switch::new); } FermaSwitchRepository(Frame... | @Test public void shouldFindSwitchById() { Switch origSwitch = Switch.builder() .switchId(TEST_SWITCH_ID_A) .description("Some description") .build(); switchRepository.add(origSwitch); Switch foundSwitch = switchRepository.findById(TEST_SWITCH_ID_A).get(); assertEquals(origSwitch.getDescription(), foundSwitch.getDescri... |
FermaSwitchRepository extends FermaGenericRepository<Switch, SwitchData, SwitchFrame> implements SwitchRepository { @Override public Collection<Switch> findSwitchesInFlowPathByFlowId(String flowId) { List<? extends FlowPathFrame> flowPathFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowPathFrame.FRAME_LABEL) .h... | @Test public void shouldFindSwitchesByFlowId() { createTwoFlows(); Collection<SwitchId> switches = switchRepository.findSwitchesInFlowPathByFlowId(TEST_FLOW_ID_A).stream() .map(Switch::getSwitchId) .collect(Collectors.toList()); assertEquals(2, switches.size()); assertTrue(switches.contains(TEST_SWITCH_ID_A)); assertTr... |
FermaTransitVlanRepository extends FermaGenericRepository<TransitVlan, TransitVlanData, TransitVlanFrame> implements TransitVlanRepository { @Override public Collection<TransitVlan> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(TransitVlanFrame.FRAME_LABEL)) .toListExplicit(TransitVlanFrame.class).stre... | @Test public void shouldCreateTransitVlan() { TransitVlan vlan = createTransitVlan(); Collection<TransitVlan> allVlans = transitVlanRepository.findAll(); TransitVlan foundVlan = allVlans.iterator().next(); assertEquals(vlan.getVlan(), foundVlan.getVlan()); assertEquals(TEST_FLOW_ID, foundVlan.getFlowId()); }
@Test publ... |
FermaTransitVlanRepository extends FermaGenericRepository<TransitVlan, TransitVlanData, TransitVlanFrame> implements TransitVlanRepository { @Override public Optional<TransitVlan> findByVlan(int vlan) { List<? extends TransitVlanFrame> transitVlanFrames = framedGraph().traverse(g -> g.V() .hasLabel(TransitVlanFrame.FRA... | @Test public void shouldFindTransitVlan() { TransitVlan vlan = createTransitVlan(); vlan.setVlan(VLAN); Optional<TransitVlan> foundVlan = transitVlanRepository.findByVlan(VLAN); assertTrue(foundVlan.isPresent()); assertEquals(vlan.getVlan(), foundVlan.get().getVlan()); assertEquals(vlan.getFlowId(), foundVlan.get().get... |
FermaVxlanRepository extends FermaGenericRepository<Vxlan, VxlanData, VxlanFrame> implements VxlanRepository { @Override public Collection<Vxlan> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(VxlanFrame.FRAME_LABEL)) .toListExplicit(VxlanFrame.class).stream() .map(Vxlan::new) .collect(Collectors.toList... | @Test public void shouldCreateVxlan() { Vxlan vxlan = createVxlan(); Collection<Vxlan> allVxlans = vxlanRepository.findAll(); Vxlan foundVxlan = allVxlans.iterator().next(); assertEquals(vxlan.getVni(), foundVxlan.getVni()); assertEquals(TEST_FLOW_ID, foundVxlan.getFlowId()); }
@Test public void shouldDeleteVxlan() { V... |
FermaFlowMeterRepository extends FermaGenericRepository<FlowMeter, FlowMeterData, FlowMeterFrame> implements FlowMeterRepository { @Override public Collection<FlowMeter> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(FlowMeterFrame.FRAME_LABEL)) .toListExplicit(FlowMeterFrame.class).stream() .map(FlowMe... | @Test public void shouldCreateFlowMeter() { createFlowMeter(); Collection<FlowMeter> allMeters = flowMeterRepository.findAll(); FlowMeter foundMeter = allMeters.iterator().next(); assertEquals(theSwitch.getSwitchId(), foundMeter.getSwitchId()); assertEquals(TEST_FLOW_ID, foundMeter.getFlowId()); }
@Test public void sho... |
FermaFlowMeterRepository extends FermaGenericRepository<FlowMeter, FlowMeterData, FlowMeterFrame> implements FlowMeterRepository { @Override public Optional<FlowMeter> findByPathId(PathId pathId) { List<? extends FlowMeterFrame> flowMeterFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowMeterFrame.FRAME_LABEL) .... | @Ignore("InMemoryGraph doesn't enforce constraint") @Test(expected = PersistenceException.class) public void shouldNotGetMoreThanOneMetersForPath() { createFlowMeter(1, new PathId(TEST_PATH_ID)); createFlowMeter(2, new PathId(TEST_PATH_ID)); flowMeterRepository.findByPathId(new PathId(TEST_PATH_ID)); }
@Test public voi... |
FermaSwitchConnectedDevicesRepository extends FermaGenericRepository<SwitchConnectedDevice, SwitchConnectedDeviceData, SwitchConnectedDeviceFrame> implements SwitchConnectedDeviceRepository { @Override public Collection<SwitchConnectedDevice> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(SwitchConnecte... | @Test public void createConnectedDeviceTest() { connectedDeviceRepository.add(lldpConnectedDeviceA); Collection<SwitchConnectedDevice> devices = connectedDeviceRepository.findAll(); assertEquals(lldpConnectedDeviceA, devices.iterator().next()); assertNotNull(devices.iterator().next().getSwitchObj()); }
@Test public voi... |
FermaSwitchConnectedDevicesRepository extends FermaGenericRepository<SwitchConnectedDevice, SwitchConnectedDeviceData, SwitchConnectedDeviceFrame> implements SwitchConnectedDeviceRepository { @Override public Collection<SwitchConnectedDevice> findBySwitchId(SwitchId switchId) { return framedGraph().traverse(g -> g.V() ... | @Test public void findBySwitchIdTest() { connectedDeviceRepository.add(lldpConnectedDeviceA); connectedDeviceRepository.add(lldpConnectedDeviceB); connectedDeviceRepository.add(arpConnectedDeviceC); connectedDeviceRepository.add(arpConnectedDeviceD); Collection<SwitchConnectedDevice> firstSwitchDevices = connectedDevic... |
FermaSwitchConnectedDevicesRepository extends FermaGenericRepository<SwitchConnectedDevice, SwitchConnectedDeviceData, SwitchConnectedDeviceFrame> implements SwitchConnectedDeviceRepository { @Override public Collection<SwitchConnectedDevice> findByFlowId(String flowId) { return framedGraph().traverse(g -> g.V() .hasLa... | @Test public void findByFlowIdTest() { connectedDeviceRepository.add(lldpConnectedDeviceA); connectedDeviceRepository.add(lldpConnectedDeviceB); connectedDeviceRepository.add(arpConnectedDeviceC); connectedDeviceRepository.add(arpConnectedDeviceD); Collection<SwitchConnectedDevice> firstDevice = connectedDeviceReposito... |
FermaSwitchConnectedDevicesRepository extends FermaGenericRepository<SwitchConnectedDevice, SwitchConnectedDeviceData, SwitchConnectedDeviceFrame> implements SwitchConnectedDeviceRepository { @Override public Optional<SwitchConnectedDevice> findLldpByUniqueFieldCombination( SwitchId switchId, int portNumber, int vlan, ... | @Test public void findByLldpUniqueFields() { connectedDeviceRepository.add(lldpConnectedDeviceA); connectedDeviceRepository.add(lldpConnectedDeviceB); connectedDeviceRepository.add(arpConnectedDeviceC); runFindByLldpUniqueFields(lldpConnectedDeviceA); runFindByLldpUniqueFields(lldpConnectedDeviceB); runFindByLldpUnique... |
FermaPortHistoryRepository extends FermaGenericRepository<PortHistory, PortHistoryData, PortHistoryFrame> implements PortHistoryRepository { @Override public List<PortHistory> findBySwitchIdAndPortNumber(SwitchId switchId, int portNumber, Instant timeFrom, Instant timeTo) { return framedGraph().traverse(g -> { GraphTra... | @Test public void shouldFindHistoryRecordsBySwitchByIdAndPortNumber() { Instant start = new Date().toInstant(); Instant end = new Date().toInstant().plus(1, ChronoUnit.DAYS); PortHistory portUp = createPortHistory(SWITCH_ID, PORT_NUMBER, "PORT_UP", start.plus(1, ChronoUnit.HOURS)); PortHistory portDown = createPortHist... |
FermaFeatureTogglesRepository extends FermaGenericRepository<FeatureToggles, FeatureTogglesData, FeatureTogglesFrame> implements FeatureTogglesRepository { @Override public Optional<FeatureToggles> find() { List<? extends FeatureTogglesFrame> featureTogglesFrames = framedGraph().traverse(g -> g.V() .hasLabel(FeatureTog... | @Test public void shouldCreateAndUpdateFeatureToggles() { FeatureToggles featureTogglesA = FeatureToggles.builder() .flowsRerouteOnIslDiscoveryEnabled(false) .createFlowEnabled(false) .updateFlowEnabled(false) .deleteFlowEnabled(false) .useBfdForIslIntegrityCheck(false) .floodlightRoutePeriodicSync(false) .flowsReroute... |
FermaBfdSessionRepository extends FermaGenericRepository<BfdSession, BfdSessionData, BfdSessionFrame> implements BfdSessionRepository { @Override public Collection<BfdSession> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(BfdSessionFrame.FRAME_LABEL)) .toListExplicit(BfdSessionFrame.class).stream() .ma... | @Test public void shouldCreateBfdPort() { createBfdSession(); assertEquals(1, repository.findAll().size()); }
@Test public void shouldDeleteBfdPort() { BfdSession bfdSession = createBfdSession(); assertEquals(1, repository.findAll().size()); transactionManager.doInTransaction(() -> repository.remove(bfdSession)); asser... |
FermaBfdSessionRepository extends FermaGenericRepository<BfdSession, BfdSessionData, BfdSessionFrame> implements BfdSessionRepository { @Override public Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port) { List<? extends BfdSessionFrame> bfdSessionFrames = framedGraph().traverse(g -> g.V() .has... | @Test public void shouldFindBySwitchIdAndPort() { BfdSession bfdSession = createBfdSession(); BfdSession foundPort = repository.findBySwitchIdAndPort(TEST_SWITCH_ID, TEST_PORT).get(); assertEquals(bfdSession.getDiscriminator(), foundPort.getDiscriminator()); } |
SwitchOperationsService implements ILinkOperationsServiceCarrier { public SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto) { if (isEmpty(switchPropertiesDto.getSupportedTransitEncapsulation())) { throw new IllegalSwitchPropertiesException("Supported transit encapsul... | @Test(expected = IllegalSwitchPropertiesException.class) public void shouldValidateSupportedEncapsulationTypeWhenUpdatingSwitchProperties() { Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build(); switchRepository.add(sw); createSwitchProperties(sw, Collections.singleton(FlowEncapsul... |
FermaSwitchPropertiesRepository extends FermaGenericRepository<SwitchProperties, SwitchPropertiesData, SwitchPropertiesFrame> implements SwitchPropertiesRepository { @Override public Collection<SwitchProperties> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(SwitchPropertiesFrame.FRAME_LABEL)) .toListEx... | @Test public void shouldCreateSwitchPropertiesWithRelation() { Switch origSwitch = Switch.builder() .switchId(TEST_SWITCH_ID) .description("Some description") .build(); switchRepository.add(origSwitch); SwitchProperties switchProperties = SwitchProperties.builder() .switchObj(origSwitch) .supportedTransitEncapsulation(... |
FermaSwitchPropertiesRepository extends FermaGenericRepository<SwitchProperties, SwitchPropertiesData, SwitchPropertiesFrame> implements SwitchPropertiesRepository { @Override public Optional<SwitchProperties> findBySwitchId(SwitchId switchId) { List<? extends SwitchPropertiesFrame> switchPropertiesFrames = framedGraph... | @Test public void shouldFindSwitchPropertiesBySwitchId() { Switch origSwitch = Switch.builder() .switchId(TEST_SWITCH_ID) .description("Some description") .build(); switchRepository.add(origSwitch); SwitchProperties switchProperties = SwitchProperties.builder() .switchObj(origSwitch) .supportedTransitEncapsulation(Swit... |
FermaLinkPropsRepository extends FermaGenericRepository<LinkProps, LinkPropsData, LinkPropsFrame> implements LinkPropsRepository { @Override public Collection<LinkProps> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(LinkPropsFrame.FRAME_LABEL)) .toListExplicit(LinkPropsFrame.class).stream() .map(LinkPr... | @Test public void shouldCreateLinkProps() { createLinkProps(1); assertEquals(1, linkPropsRepository.findAll().size()); }
@Test public void shouldDeleteLinkProps() { LinkProps linkProps = createLinkProps(1); transactionManager.doInTransaction(() -> { linkPropsRepository.remove(linkProps); }); assertEquals(0, linkPropsRe... |
FermaLinkPropsRepository extends FermaGenericRepository<LinkProps, LinkPropsData, LinkPropsFrame> implements LinkPropsRepository { @Override public Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) { return framedGraph().traverse(g -> { GraphTraversal<Vertex... | @Test public void shouldFindLinkPropsByEndpoints() { createLinkProps(2); List<LinkProps> foundLinkProps = Lists.newArrayList( linkPropsRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2)); assertThat(foundLinkProps, Matchers.hasSize(1)); }
@Test public void shouldFindLinkPropsBySrcEndpoint() { createLi... |
FlowValidationService { public List<SwitchId> getSwitchIdListByFlowId(String flowId) { return switchRepository.findSwitchesInFlowPathByFlowId(flowId).stream() .map(Switch::getSwitchId) .collect(Collectors.toList()); } FlowValidationService(PersistenceManager persistenceManager, FlowResourcesConfig flowResourcesConfig,
... | @Test public void shouldGetSwitchIdListByFlowId() { buildTransitVlanFlow(""); List<SwitchId> switchIds = service.getSwitchIdListByFlowId(TEST_FLOW_ID_A); assertEquals(4, switchIds.size()); buildOneSwitchPortFlow(); switchIds = service.getSwitchIdListByFlowId(TEST_FLOW_ID_B); assertEquals(1, switchIds.size()); } |
OneToOneMapping implements MappingApproach { public void remove(SwitchId switchId, String region) { remove(switchId); } OneToOneMapping(Clock clock, Duration staleWipeDelay); Optional<String> lookup(SwitchId switchId); @Override void set(SwitchId switchId, String region); void add(SwitchId switchId, String region); voi... | @Test public void testRemove() { OneToOneMapping subject = makeSubject(); subject.add(SWITCH_ALPHA, REGION_A); subject.add(SWITCH_BETA, REGION_A); subject.remove(SWITCH_ALPHA); Optional<String> result = subject.lookup(SWITCH_ALPHA); Assert.assertTrue(result.isPresent()); Assert.assertEquals(REGION_A, result.get()); Ass... |
SwitchReadWriteConnectMonitor extends SwitchConnectMonitor { @Override protected boolean isReadWriteMode() { return true; } SwitchReadWriteConnectMonitor(SwitchMonitorCarrier carrier, Clock clock, SwitchId switchId); } | @Test public void multipleConnections() { SwitchReadWriteConnectMonitor subject = makeSubject(SWITCH_ALPHA); SwitchInfoData connectEvent = makeConnectNotification(SWITCH_ALPHA); subject.handleSwitchStatusNotification(connectEvent, REGION_A); verify(carrier, times(1)) .switchStatusUpdateNotification(eq(connectEvent.getS... |
SwitchMonitorService { public void handleStatusUpdateNotification(SwitchInfoData notification, String region) { SwitchMonitorEntry entry = lookupOrCreateSwitchMonitor(notification.getSwitchId()); entry.handleStatusUpdateNotification(notification, region); } SwitchMonitorService(Clock clock, SwitchMonitorCarrier carrier... | @Test public void regularSwitchConnectSequence() { SwitchMonitorService subject = makeSubject(); SwitchInfoData swAdd = new SwitchInfoData(SWITCH_ALPHA, SwitchChangeType.ADDED); subject.handleStatusUpdateNotification(swAdd, REGION_ALPHA); verify(carrier).regionUpdateNotification( eq(new RegionMappingAdd(swAdd.getSwitch... |
PacketService { public void handleLldpData(LldpInfoData data) { transactionManager.doInTransaction(() -> { FlowRelatedData flowRelatedData = findFlowRelatedData(data); if (flowRelatedData == null) { return; } SwitchConnectedDevice device = getOrCreateLldpDevice(data, flowRelatedData.originalVlan); if (device == null) {... | @Test public void testHandleLldpDataSameTimeOnCreate() { LldpInfoData data = createLldpInfoDataData(); packetService.handleLldpData(data); Collection<SwitchConnectedDevice> devices = switchConnectedDeviceRepository.findAll(); assertEquals(1, devices.size()); assertEquals(devices.iterator().next().getTimeFirstSeen(), de... |
PacketService { public void handleArpData(ArpInfoData data) { transactionManager.doInTransaction(() -> { FlowRelatedData flowRelatedData = findFlowRelatedData(data); if (flowRelatedData == null) { return; } SwitchConnectedDevice device = getOrCreateArpDevice(data, flowRelatedData.originalVlan); if (device == null) { re... | @Test public void testHandleArpDataSameTimeOnCreate() { packetService.handleArpData(createArpInfoData()); Collection<SwitchConnectedDevice> devices = switchConnectedDeviceRepository.findAll(); assertEquals(1, devices.size()); assertEquals(devices.iterator().next().getTimeFirstSeen(), devices.iterator().next().getTimeLa... |
FlowValidationService { public List<FlowValidationResponse> validateFlow(String flowId, List<SwitchFlowEntries> switchFlowEntries, List<SwitchMeterEntries> switchMeterEntries) throws FlowNotFoundException, SwitchNotFoundException { Map<SwitchId, List<SimpleSwitchRule>> switchRules = new HashMap<>(); int rulesCount = 0;... | @Test public void shouldValidateFlowWithTransitVlanEncapsulation() throws FlowNotFoundException, SwitchNotFoundException { buildTransitVlanFlow(""); validateFlow(true); }
@Test public void shouldValidateFlowWithVxlanEncapsulation() throws FlowNotFoundException, SwitchNotFoundException { buildVxlanFlow(); validateFlow(f... |
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForOneSwitchFlow(ConnectedDevicePacketBase data) { int outputVlan = data.getVlans().isEmpty() ? 0 : data.getVlans().get(0); int customerVlan = data.getVlans().size() > 1 ? data.getVlans().get(1) : 0; Flow flow = getFlowBySwitchIdInPortAndOutVlan( dat... | @Test @Parameters(method = "getOneSwitchOnePortFlowParameters") public void findFlowRelatedDataForOneSwitchOnePortFlowTest( int inVlan, int srcVlan, int dstVlan, List<Integer> vlansInPacket, boolean source) { createFlow(FLOW_ID, srcVlan, dstVlan, null, true, true); LldpInfoData data = createLldpInfoDataData(SWITCH_ID_1... |
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForVlanFlow(ConnectedDevicePacketBase data) { if (data.getVlans().isEmpty()) { log.warn("Got {} packet without transit VLAN: {}", getPacketName(data), data); return null; } int transitVlan = data.getVlans().get(0); Flow flow = findFlowByTransitVlan(t... | @Test @Parameters(method = "getVlanFlowParameters") public void findFlowRelatedDataForVlanFlowTest( int inVlan, int srcVlan, int dstVlan, int transitVlan, List<Integer> vlansInPacket, boolean source) { createFlow(FLOW_ID, srcVlan, dstVlan, transitVlan, false, false); LldpInfoData data = createLldpInfoDataData( source ?... |
PacketService { @VisibleForTesting FlowRelatedData findFlowRelatedDataForVxlanFlow(ConnectedDevicePacketBase data) { int inputVlan = data.getVlans().isEmpty() ? 0 : data.getVlans().get(0); Flow flow = getFlowBySwitchIdPortAndVlan( data.getSwitchId(), data.getPortNumber(), inputVlan, getPacketName(data)); if (flow == nu... | @Test @Parameters(method = "getInOutVlanCombinationForVxlanParameters") public void findFlowRelatedDataForVxlanFlowTest( int inVlan, int srcVlan, int dstVlan, List<Integer> vlansInPacket, boolean source) { createFlow(FLOW_ID, srcVlan, dstVlan, null, false, false); LldpInfoData data = createLldpInfoDataData( source ? SW... |
RerouteService { public void rerouteInactiveFlows(MessageSender sender, String correlationId, RerouteInactiveFlows command) { PathNode pathNode = command.getPathNode(); int port = pathNode.getPortNo(); SwitchId switchId = pathNode.getSwitchId(); transactionManager.doInTransaction(() -> { Map<Flow, Set<PathId>> flowsFor... | @Test public void testRerouteInactivePinnedFlowsOneFailedSegment() { pinnedFlow.setStatus(FlowStatus.DOWN); for (FlowPath flowPath : pinnedFlow.getPaths()) { flowPath.setStatus(FlowPathStatus.INACTIVE); for (PathSegment pathSegment : flowPath.getSegments()) { if (pathSegment.containsNode(SWITCH_ID_A, PORT)) { pathSegme... |
RerouteService { public void rerouteAffectedFlows(MessageSender sender, String correlationId, RerouteAffectedFlows command) { PathNode pathNode = command.getPathNode(); int port = pathNode.getPortNo(); SwitchId switchId = pathNode.getSwitchId(); final IslEndpoint affectedIsl = new IslEndpoint(switchId, port); transacti... | @Test public void handlePathNoFoundException() { PathNode islSide = new PathNode(SWITCH_A.getSwitchId(), 1, 0); FlowPathRepository pathRepository = mock(FlowPathRepository.class); when(pathRepository.findBySegmentEndpoint(eq(islSide.getSwitchId()), eq(islSide.getPortNo()))) .thenReturn(Arrays.asList(regularFlow.getForw... |
RerouteService { public void processSingleSwitchFlowStatusUpdate(SwitchStateChanged request) { transactionManager.doInTransaction(() -> { Collection<Flow> affectedFlows = flowRepository.findOneSwitchFlows(request.getSwitchId()); FlowStatus newFlowStatus = request.getStatus() == SwitchStatus.ACTIVE ? FlowStatus.UP : Flo... | @Test public void handleUpdateSingleSwitchFlows() { FlowRepository flowRepository = mock(FlowRepository.class); when(flowRepository.findOneSwitchFlows(oneSwitchFlow.getSrcSwitch().getSwitchId())) .thenReturn(Arrays.asList(oneSwitchFlow)); FlowPathRepository flowPathRepository = mock(FlowPathRepository.class); Repositor... |
RerouteService { public void rerouteInactiveAffectedFlows(MessageSender sender, String correlationId, SwitchId switchId) { Set<Flow> flowsForRerouting = getAffectedInactiveFlowsForRerouting(switchId); for (Flow flow : flowsForRerouting) { if (flow.isPinned()) { log.info("Skipping reroute command for pinned flow {}", fl... | @Test public void handleRerouteInactiveAffectedFlows() { FlowPathRepository pathRepository = mock(FlowPathRepository.class); when(pathRepository.findInactiveBySegmentSwitch(regularFlow.getSrcSwitchId())) .thenReturn(Arrays.asList(regularFlow.getForwardPath(), regularFlow.getReversePath())); RepositoryFactory repository... |
RerouteService { public void processManualRerouteRequest(MessageSender sender, String correlationId, FlowRerouteRequest request) { Optional<Flow> flow = flowRepository.findById(request.getFlowId()); FlowThrottlingData flowThrottlingData = getFlowThrottlingDataBuilder(flow.orElse(null)) .correlationId(correlationId) .af... | @Test public void processManualRerouteRequest() { FlowRepository flowRepository = mock(FlowRepository.class); when(flowRepository.findById(regularFlow.getFlowId())) .thenReturn(Optional.of(regularFlow)); RepositoryFactory repositoryFactory = mock(RepositoryFactory.class); when(repositoryFactory.createFlowRepository()) ... |
ExtendableTimeWindow { public boolean flushIfReady() { if (firstEventTime == null) { return false; } LocalDateTime now = LocalDateTime.now(clock); boolean isTimeToFlush = lastEventTime.plus(minDelay, ChronoUnit.SECONDS).isBefore(now) || firstEventTime.plus(maxDelay, ChronoUnit.SECONDS).isBefore(now); if (isTimeToFlush)... | @Test public void noFlushEmptyWindow() { assertFalse(extendableTimeWindow.flushIfReady()); }
@Test public void noFlushEmptyWindow2() { when(clock.instant()).thenReturn(Instant.now()); assertFalse(extendableTimeWindow.flushIfReady()); } |
NetworkUniIslService { public void uniIslSetup(Endpoint endpoint, Isl history) { log.info("Uni-ISL service receive SETUP request for {}", endpoint); IslReference reference; if (history != null) { reference = IslReference.of(history); carrier.setupIslFromHistory(endpoint, reference, history); } else { reference = IslRef... | @Test public void newIslWithHistory() { NetworkUniIslService service = new NetworkUniIslService(carrier); Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1); Endpoint endpoint2 = Endpoint.of(alphaDatapath, 2); Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build(); Switch betaSwitch = Switch.builder().sw... |
NetworkSwitchService { public void switchEvent(SwitchInfoData payload) { log.info("Switch service receive SWITCH event for {} status:{}", payload.getSwitchId(), payload.getState()); SwitchFsmContext.SwitchFsmContextBuilder fsmContextBuilder = SwitchFsmContext.builder(carrier); SwitchFsmEvent event = null; switch (paylo... | @Test public void newSwitch() { List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews(); SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder() .ports(ports) .build(); SwitchInfoData switchAddEvent = new SwitchInfoData( alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), al... |
NetworkSwitchService { public void switchAddWithHistory(HistoryFacts history) { log.info("Switch service receive switch ADD from history request for {}", history.getSwitchId()); SwitchFsm switchFsm = controllerFactory.produce(persistenceManager, history.getSwitchId(), options); SwitchFsmContext fsmContext = SwitchFsmCo... | @Test public void switchFromHistoryToOffline() { when(switchRepository.findById(alphaDatapath)).thenReturn( Optional.of(Switch.builder().switchId(alphaDatapath) .build())); HistoryFacts history = new HistoryFacts(alphaDatapath); Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build(); Switch betaSwitch = ... |
NetworkSwitchService { public void switchBecomeManaged(SpeakerSwitchView switchView) { log.debug("Switch service receive MANAGED notification for {}", switchView.getDatapath()); SwitchFsm fsm = locateControllerCreateIfAbsent(switchView.getDatapath()); SwitchFsmContext context = SwitchFsmContext.builder(carrier) .speake... | @Test public void switchFromOnlineToOnlineWithLostBfdFeature() { NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options); List<SpeakerSwitchPortView> ports = doSpeakerOnline(service, Collections.singleton(SwitchFeature.BFD)); List<SpeakerSwitchPortView> ports2 = swapBfdPortsState(p... |
NetworkIslService { public void islUp(Endpoint endpoint, IslReference reference, IslDataHolder islData) { log.debug("ISL service receive DISCOVERY notification for {} (on {})", reference, endpoint); IslFsm islFsm = locateControllerCreateIfAbsent(endpoint, reference).fsm; IslFsmContext context = IslFsmContext.builder(ca... | @Test @Ignore("incomplete") public void initialUp() { persistenceManager = new InMemoryGraphPersistenceManager( new PropertiesBasedConfigurationProvider().getConfiguration(NetworkConfig.class)); emulateEmptyPersistentDb(); SwitchRepository switchRepository = persistenceManager.getRepositoryFactory() .createSwitchReposi... |
NetworkIslService { public void islMove(Endpoint endpoint, IslReference reference) { log.debug("ISL service receive MOVED(FAIL) notification for {} (on {})", reference, endpoint); IslFsm islFsm = locateController(reference).fsm; IslFsmContext context = IslFsmContext.builder(carrier, endpoint).build(); controllerExecuto... | @Test @Ignore("become invalid due to change initialisation logic") public void initialMoveEvent() { emulateEmptyPersistentDb(); IslReference ref = new IslReference(endpointAlpha1, endpointBeta2); service.islMove(ref.getSource(), ref); verify(carrier, times(2)).triggerReroute(any(RerouteAffectedFlows.class)); verify(isl... |
NetworkIslService { public void islDown(Endpoint endpoint, IslReference reference, IslDownReason reason) { log.debug("ISL service receive FAIL notification for {} (on {})", reference, endpoint); IslFsm islFsm = locateController(reference).fsm; IslFsmContext context = IslFsmContext.builder(carrier, endpoint) .downReason... | @Test public void setIslUnstableTimeOnPortDown() { setupIslStorageStub(); IslReference reference = prepareActiveIsl(); Instant updateTime = clock.adjust(Duration.ofSeconds(1)); service.islDown(endpointAlpha1, reference, IslDownReason.PORT_DOWN); Isl forward = lookupIsl(reference.getSource(), reference.getDest()); Asser... |
NetworkBfdPortService { public void updateLinkStatus(Endpoint logicalEndpoint, LinkStatus linkStatus) { log.debug("BFD-port service receive logical port status update for {} (logical) status:{}", logicalEndpoint, linkStatus); BfdPortFsm controller = lookupControllerByLogicalEndpoint(logicalEndpoint); controller.updateL... | @Test public void upDownUp() { setupAndEnable(); service.updateLinkStatus(alphaLogicalEndpoint, LinkStatus.DOWN); verify(carrier).bfdDownNotification(alphaEndpoint); verifyNoMoreInteractions(carrier); reset(carrier); service.updateLinkStatus(alphaLogicalEndpoint, LinkStatus.UP); verify(carrier).bfdUpNotification(alphaE... |
NetworkBfdPortService { public Endpoint remove(Endpoint logicalEndpoint) { log.info("BFD-port service receive REMOVE request for {} (logical)", logicalEndpoint); BfdPortFsm controller = controllerByLogicalPort.remove(logicalEndpoint); if (controller == null) { throw BfdPortControllerNotFoundException.ofLogical(logicalE... | @Test public void killDuringInstalling() { setupController(); doAnswer(invocation -> invocation.getArgument(0)) .when(bfdSessionRepository).add(any()); NoviBfdSession session = doEnable(); when(carrier.removeBfdSession(any(NoviBfdSession.class))).thenReturn(removeRequestKey); service.remove(alphaLogicalEndpoint); verif... |
NetworkBfdPortService { public void setup(Endpoint endpoint, int physicalPortNumber) { log.info("BFD-port service receive SETUP request for {} (physical-port:{})", endpoint, physicalPortNumber); BfdPortFsm controller = controllerFactory.produce(persistenceManager, endpoint, physicalPortNumber); BfdPortFsmContext contex... | @Test public void enableBeforeSetup() { IslReference reference = new IslReference(alphaEndpoint, betaEndpoint); doEnableBeforeSetup(reference); doAnswer(invocation -> invocation.getArgument(0)) .when(bfdSessionRepository).add(any()); mockSwitchLookup(alphaSwitch); mockSwitchLookup(betaSwitch); mockMissingBfdSession(alp... |
NetworkWatcherService { public void addWatch(Endpoint endpoint) { addWatch(endpoint, now()); } NetworkWatcherService(
IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime, Integer taskId); @VisibleForTesting NetworkWatcherService(
Clock clock, IWatcherCarrier carrier, D... | @Test public void addWatch() { NetworkWatcherService w = makeService(); w.addWatch(Endpoint.of(new SwitchId(1), 1), 1); w.addWatch(Endpoint.of(new SwitchId(1), 2), 1); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 2), 3); assertTh... |
NetworkWatcherService { public void removeWatch(Endpoint endpoint) { log.debug("Watcher service receive REMOVE-watch request for {}", endpoint); carrier.clearDiscovery(endpoint); discoveryPackets.removeIf(packet -> packet.endpoint.equals(endpoint)); roundTripPackets.removeIf(packet -> packet.endpoint.equals(endpoint));... | @Test public void removeWatch() { NetworkWatcherService w = makeService(); w.addWatch(Endpoint.of(new SwitchId(1), 1), 1); w.addWatch(Endpoint.of(new SwitchId(1), 2), 2); w.addWatch(Endpoint.of(new SwitchId(2), 1), 3); w.addWatch(Endpoint.of(new SwitchId(2), 2), 4); w.addWatch(Endpoint.of(new SwitchId(3), 1), 5); verif... |
NetworkWatcherService { public void tick() { tick(now()); } NetworkWatcherService(
IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime, Integer taskId); @VisibleForTesting NetworkWatcherService(
Clock clock, IWatcherCarrier carrier, Duration roundTripNotificationPeriod... | @Test public void tick() { NetworkWatcherService w = makeService(); w.addWatch(Endpoint.of(new SwitchId(1), 1), 1); w.addWatch(Endpoint.of(new SwitchId(1), 2), 1); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 2), 3); assertThat(w... |
NetworkWatcherService { public void discovery(IslInfoData discoveryEvent) { Endpoint source = new Endpoint(discoveryEvent.getSource()); Long packetId = discoveryEvent.getPacketId(); if (packetId == null) { log.error("Got corrupted discovery packet into {} - packetId field is empty", source); } else { discovery(discover... | @Test public void discovery() { NetworkWatcherService w = makeService(); w.addWatch(Endpoint.of(new SwitchId(1), 1), 1); w.addWatch(Endpoint.of(new SwitchId(1), 2), 1); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 2), 3); assertT... |
NetworkDecisionMakerService { public void discovered(Endpoint endpoint, long packetId, IslInfoData discoveryEvent) { discovered(endpoint, packetId, discoveryEvent, now()); } NetworkDecisionMakerService(IDecisionMakerCarrier carrier, long failTimeout, long awaitTime); void discovered(Endpoint endpoint, long packetId, Is... | @Test public void discovered() { NetworkDecisionMakerService w = new NetworkDecisionMakerService(carrier, 10, 5); w.discovered(endpointBeta, 1L, islAlphaBeta, 1L); w.discovered(endpointAlpha, 2L, islBetaAlpha, 2L); verify(carrier).linkDiscovered(eq(islAlphaBeta)); verify(carrier).linkDiscovered(eq(islBetaAlpha)); } |
NetworkDecisionMakerService { public void failed(Endpoint endpoint, long packetId) { failed(endpoint, packetId, now()); } NetworkDecisionMakerService(IDecisionMakerCarrier carrier, long failTimeout, long awaitTime); void discovered(Endpoint endpoint, long packetId, IslInfoData discoveryEvent); void failed(Endpoint endp... | @Test public void failed() { NetworkDecisionMakerService w = new NetworkDecisionMakerService(carrier, 10, 5); w.failed(endpointAlpha, 0L, 0); w.failed(endpointAlpha, 1L, 1); w.failed(endpointAlpha, 2L, 4); verify(carrier, never()).linkDestroyed(any(Endpoint.class)); w.failed(endpointAlpha, 3L, 5); verify(carrier).linkD... |
SwitchId implements Comparable<SwitchId>, Serializable { @VisibleForTesting String colonSeparatedBytes(char[] hex, int offset) { if (offset < 0 || offset % 2 != 0 || offset >= hex.length) { throw new IllegalArgumentException(String.format( "Illegal offset value %d (expect offset > 0 and offset %% 2 == 0 and offset < he... | @Test public void colonSeparatedBytesIllegalArgumentExceptionNegativeOffset() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage(String.format( "Illegal offset value %d (expect offset > 0 and offset %% 2 == 0 and offset < hex.length)", -1)); new SwitchId("00").colonSeparatedBytes(new char[]{'t', 'e',... |
Isl implements CompositeDataEntity<Isl.IslData> { public boolean isUnstable() { if (islConfig == null) { throw new IllegalStateException("IslConfig has not initialized."); } return getTimeUnstable() != null && getTimeUnstable().plus(islConfig.getUnstableIslTimeout()).isAfter(Instant.now()); } private Isl(); Isl(@NonN... | @Test public void shouldComputeIsUnstable() { Isl isl = Isl.builder() .srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()) .destSwitch(Switch.builder().switchId(new SwitchId(2)).build()) .build(); isl.setIslConfig(islConfig); isl.setTimeUnstable(Instant.now().minus(islConfig.getUnstableIslTimeout())); assertF... |
Meter implements Serializable { public static long calculateBurstSize(long bandwidth, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient, String switchDescription) { return calculateBurstSize(bandwidth, flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient, switchDescription, switchDescription); } s... | @Test public void calculateBurstSize() { assertEquals(1024, Meter.calculateBurstSize(512L, 1024L, 1.0, "centec")); assertEquals(32000, Meter.calculateBurstSize(32333L, 1024L, 1.0, "centec")); assertEquals(10030, Meter.calculateBurstSize(10000L, 1024L, 1.003, "centec")); assertEquals(1105500, Meter.calculateBurstSize(11... |
Meter implements Serializable { public static long convertRateToKiloBits(long rateInPackets, long packetSizeInBytes) { return Math.max(MIN_RATE_IN_KBPS, (rateInPackets * packetSizeInBytes * 8) / 1024L); } static long calculateBurstSize(long bandwidth, long flowMeterMinBurstSizeInKbits,
... | @Test public void convertRateToKiloBitsTest() { assertEquals(800, Meter.convertRateToKiloBits(100, 1024)); assertEquals(64, Meter.convertRateToKiloBits(1, 1)); assertEquals(64, Meter.convertRateToKiloBits(8, 16)); } |
Meter implements Serializable { public static long convertBurstSizeToKiloBits(long burstSizeInPackets, long packetSizeInBytes) { return (burstSizeInPackets * packetSizeInBytes * 8) / 1024L; } static long calculateBurstSize(long bandwidth, long flowMeterMinBurstSizeInKbits,
dou... | @Test public void convertBurstSizeToKiloBitsTest() { assertEquals(800, Meter.convertBurstSizeToKiloBits(100, 1024)); assertEquals(1, Meter.convertBurstSizeToKiloBits(8, 16)); } |
Meter implements Serializable { public static long calculateBurstSizeConsideringHardwareLimitations( long bandwidth, long requestedBurstSize, Set<SwitchFeature> features) { if (features.contains(SwitchFeature.MAX_BURST_COEFFICIENT_LIMITATION)) { return Math.min(requestedBurstSize, Math.round(bandwidth * MAX_NOVIFLOW_BU... | @Test public void convertCalculateBurstSizeConsideringHardwareLimitations() { Set<SwitchFeature> limitationFeature = newHashSet(MAX_BURST_COEFFICIENT_LIMITATION); assertEquals(4096, Meter.calculateBurstSizeConsideringHardwareLimitations(1, 4096, newHashSet())); assertEquals(1, Meter.calculateBurstSizeConsideringHardwar... |
FlowSegmentCookie extends Cookie { @Override public FlowSegmentCookieBuilder toBuilder() { return new FlowSegmentCookieBuilder() .type(getType()) .direction(getDirection()) .flowEffectiveId(getFlowEffectiveId()); } @JsonCreator FlowSegmentCookie(long value); FlowSegmentCookie(FlowPathDirection direction, long flowEff... | @Test public void changingOfFlowSegmentCookieTypeTest() { FlowSegmentCookie flowCookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 10); Assert.assertEquals(CookieType.SERVICE_OR_FLOW_SEGMENT, flowCookie.getType()); FlowSegmentCookie server42Cookie = flowCookie.toBuilder() .type(CookieType.SERVER_42_INGRESS) .bui... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.