Example #1
0
  /**
   * Checks the case in which six ports are configured with VLANs but no hosts are registered by the
   * HostService. The first three ports have an interface configured on VLAN1, the other three on
   * VLAN2. The number of intents expected is six: three for VLAN1, three for VLAN2. three sp2mp
   * intents, three mp2sp intents.
   */
  @Test
  public void testActivateNoHosts() {
    vpls.activate();

    List<Intent> expectedIntents = Lists.newArrayList();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanTwoBrc());

    checkIntents(expectedIntents);
  }
Example #2
0
  @Before
  public void setUp() throws Exception {
    idGenerator = new TestIdGenerator();
    Intent.bindIdGenerator(idGenerator);

    applicationService = createMock(ApplicationService.class);

    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication(APP_NAME)).andReturn(APPID);
    replay(coreService);

    hostsAvailable = Sets.newHashSet();
    hostService = new TestHostService(hostsAvailable);

    intentService = new TestIntentService();

    TestIntentSynchronizer intentSynchronizer = new TestIntentSynchronizer(intentService);

    interfaceService = createMock(InterfaceService.class);
    interfaceService.addListener(anyObject(InterfaceListener.class));
    expectLastCall().anyTimes();
    addIntfConfig();

    vpls = new Vpls();
    vpls.applicationService = applicationService;
    vpls.coreService = coreService;
    vpls.hostService = hostService;
    vpls.intentService = intentService;
    vpls.interfaceService = interfaceService;
    vpls.intentSynchronizer = intentSynchronizer;
  }
Example #3
0
  /**
   * Checks the case in which six ports are configured with VLANs and initially no hosts are
   * registered by the HostService. The first three ports have an interface configured on VLAN1, the
   * other three have an interface configured on VLAN2. When the module starts up, two hosts - on
   * device one and four - port 1 (VLAN 1 and VLAN 2), are registered by the HostService and events
   * are sent to the application. sp2mp intents are created for all interfaces configured and no
   * mp2sp intents are created at all, since the minimum number of hosts needed on the same vlan to
   * create mp2sp intents is 2. The number of intents expected is six: three for VLAN1, three for
   * VLAN2. six sp2mp intents, zero mp2sp intents. IPs are added on the first host only to
   * demonstrate it doesn't influence the number of intents created.
   */
  @Test
  public void testFourInterfacesTwoHostEventsDifferentVlan() {
    vpls.activate();

    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1), Collections.singleton(IP1));
    Host h4 = new DefaultHost(PID, HID4, MAC4, VLAN2, getLocation(4), Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h4));

    hostsAvailable.forEach(
        host -> {
          hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host));
        });

    List<Intent> expectedIntents = Lists.newArrayList();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanTwoBrc());

    checkIntents(expectedIntents);
  }
Example #4
0
  /**
   * Checks the case in which six ports are configured with VLANs and initially no hosts are
   * registered by the HostService. The first three ports have an interface configured on VLAN1, the
   * other three have an interface configured on VLAN2. When the module starts up, three hosts - on
   * device one, two and three - port 1 (both on VLAN1), are registered by the HostService and
   * events are sent to the application. sp2mp intents are created for all interfaces configured and
   * mp2sp intents are created only for the hosts attached. The number of intents expected is nine:
   * six for VLAN1, three for VLAN2. Six sp2mp intents, three mp2sp intents. IPs are added on the
   * first two hosts only to demonstrate it doesn't influence the number of intents created. An
   * additional host is added on device seven, port one to demonstrate that, even if it's on the
   * same VLAN of other interfaces configured in the system, it doesn't let the application generate
   * intents, since it's not connected to the interface configured.
   */
  @Test
  public void testFourInterfacesThreeHostEventsSameVlan() {
    vpls.activate();

    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1), Collections.singleton(IP1));
    Host h2 = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(2), Collections.singleton(IP2));
    Host h3 = new DefaultHost(PID, HID3, MAC3, VLAN1, getLocation(3), Collections.EMPTY_SET);
    Host h7 = new DefaultHost(PID, HID7, MAC7, VLAN1, getLocation(7), Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h2, h3, h7));

    hostsAvailable.forEach(
        host -> hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host)));

    List<Intent> expectedIntents = Lists.newArrayList();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanOneUni());
    expectedIntents.addAll(generateVlanTwoBrc());

    checkIntents(expectedIntents);
  }
Example #5
0
  /**
   * Checks the case in which six ports are configured with VLANs and four hosts are registered by
   * the HostService. The first three ports have an interface configured on VLAN1, the other three
   * on VLAN2. The number of intents expected is twelve: six for VLAN1, six for VLAN2. six sp2mp
   * intents, six mp2sp intents. For VLAN1 IPs are added to demonstrate it doesn't influence the
   * number of intents created.
   */
  @Test
  public void testFourInterfacesConfiguredHostsPresent() {
    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1), Collections.singleton(IP1));
    Host h2 = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(2), Collections.singleton(IP2));
    Host h3 = new DefaultHost(PID, HID3, MAC3, VLAN1, getLocation(3), Collections.EMPTY_SET);
    Host h4 = new DefaultHost(PID, HID4, MAC4, VLAN2, getLocation(4), Collections.EMPTY_SET);
    Host h5 = new DefaultHost(PID, HID5, MAC5, VLAN2, getLocation(5), Collections.EMPTY_SET);
    Host h6 = new DefaultHost(PID, HID6, MAC6, VLAN2, getLocation(6), Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h2, h3, h4, h5, h6));

    vpls.activate();

    List<Intent> expectedIntents = Lists.newArrayList();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanOneUni());
    expectedIntents.addAll(generateVlanTwoBrc());
    expectedIntents.addAll(generateVlanTwoUni());

    checkIntents(expectedIntents);
  }