Search in sources :

Example 56 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsManagerTest method testAddHost.

/**
 * Adds hosts to a VPLS.
 */
@Test
public void testAddHost() {
    VplsData vplsData = VplsData.of(VPLS1, NONE);
    vplsData.addInterface(V100H1);
    vplsData.state(ADDED);
    vplsStore.addVpls(vplsData);
    HostEvent hostEvent = new HostEvent(HostEvent.Type.HOST_ADDED, V100HOST1);
    hostService.postHostEvent(hostEvent);
    vplsData = vplsStore.getVpls(VPLS1);
    assertNotNull(vplsData);
    assertEquals(vplsData.state(), UPDATING);
}
Also used : HostEvent(org.onosproject.net.host.HostEvent) VplsData(org.onosproject.vpls.api.VplsData) Test(org.junit.Test)

Example 57 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsManagerTest method testStoreDelegate.

/**
 * Pass different VPLS store event to store delegate.
 * Include these cases:
 * <ul>
 *     <li>VPLS added</li>
 *     <li>VPLS updated</li>
 *     <li>VPLS state updated</li>
 *     <li>VPLS removed</li>
 * </ul>
 */
@Test
public void testStoreDelegate() {
    // Add
    VplsData vplsData = vplsManager.createVpls(VPLS1, NONE);
    VplsStoreEvent event = new VplsStoreEvent(VplsStoreEvent.Type.ADD, vplsData);
    vplsStore.delegate().notify(event);
    VplsOperation vplsOperation = vplsOperationService.operation();
    assertEquals(vplsOperation.op(), VplsOperation.Operation.ADD);
    assertEquals(vplsOperation.vpls(), vplsData);
    vplsOperationService.clear();
    // Update info
    vplsData.encapsulationType(EncapsulationType.VLAN);
    vplsData.state(UPDATING);
    event = new VplsStoreEvent(VplsStoreEvent.Type.UPDATE, vplsData);
    vplsStore.delegate().notify(event);
    vplsOperation = vplsOperationService.operation();
    assertEquals(vplsOperation.op(), VplsOperation.Operation.UPDATE);
    assertEquals(vplsOperation.vpls(), vplsData);
    vplsOperationService.clear();
    // Update state (no operation)
    vplsData.state(VplsData.VplsState.ADDED);
    event = new VplsStoreEvent(VplsStoreEvent.Type.UPDATE, vplsData);
    vplsStore.delegate().notify(event);
    vplsOperation = vplsOperationService.operation();
    assertNull(vplsOperation);
    vplsOperationService.clear();
    // Remove
    event = new VplsStoreEvent(VplsStoreEvent.Type.REMOVE, vplsData);
    vplsStore.delegate().notify(event);
    vplsOperation = vplsOperationService.operation();
    assertEquals(vplsOperation.op(), VplsOperation.Operation.REMOVE);
    assertEquals(vplsOperation.vpls(), vplsData);
    vplsOperationService.clear();
}
Also used : VplsStoreEvent(org.onosproject.vpls.store.VplsStoreEvent) VplsData(org.onosproject.vpls.api.VplsData) VplsOperation(org.onosproject.vpls.api.VplsOperation) Test(org.junit.Test)

Example 58 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsManagerTest method hostRemoveEventTest.

/**
 * Trigger host event listener by HOST_REMOVED event.
 */
@Test
public void hostRemoveEventTest() {
    VplsData vplsData = vplsManager.createVpls(VPLS1, NONE);
    vplsManager.addInterface(vplsData, V100H1);
    HostEvent hostEvent = new HostEvent(HostEvent.Type.HOST_REMOVED, V100HOST1);
    hostService.postHostEvent(hostEvent);
    vplsData = vplsStore.getVpls(VPLS1);
    assertEquals(UPDATING, vplsData.state());
}
Also used : HostEvent(org.onosproject.net.host.HostEvent) VplsData(org.onosproject.vpls.api.VplsData) Test(org.junit.Test)

Example 59 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsNeighbourHandlerTest method setUp.

/**
 * Sets up 4 VPLS.
 * VPLS 1 contains 3 hosts: v100h1, v200h1 and v300h1
 * VPLS 2 contains 2 hosts: v100h2, v200h2
 * VPLS 3 contains 2 hosts: vNoneh1, vNoneh2
 * VPLS 4 contains 2 hosts: v400h1, vNoneh3
 */
@Before
public void setUp() {
    vplsNeighbourHandler = new VplsNeighbourHandler();
    hostService = new TestHostService();
    vplsNeighbourHandler.vplsStore = new TestVplsStore();
    vplsNeighbourHandler.interfaceService = new TestInterfaceService();
    vplsNeighbourHandler.neighbourService = new TestNeighbourService();
    vplsNeighbourHandler.coreService = new TestCoreService();
    vplsNeighbourHandler.configService = new TestConfigService();
    // Init VPLS store
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V200H1, V300H1));
    vplsNeighbourHandler.vplsStore.addVpls(vplsData);
    vplsData = VplsData.of(VPLS2);
    vplsData.addInterfaces(ImmutableSet.of(V100H2, V200H2));
    vplsNeighbourHandler.vplsStore.addVpls(vplsData);
    vplsData = VplsData.of(VPLS3);
    vplsData.addInterfaces(ImmutableSet.of(VNONEH1, VNONEH2));
    vplsNeighbourHandler.vplsStore.addVpls(vplsData);
    vplsData = VplsData.of(VPLS4);
    vplsData.addInterfaces(ImmutableSet.of(V400H1, VNONEH3));
    vplsNeighbourHandler.vplsStore.addVpls(vplsData);
    vplsNeighbourHandler.activate();
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Before(org.junit.Before)

Example 60 with VplsData

use of org.onosproject.vpls.api.VplsData in project onos by opennetworkinglab.

the class VplsOperationManagerTest method testOptimizeOperationsNoOptimize.

/**
 * Optimize operations which don't need to be optimized.
 */
@Test
public void testOptimizeOperationsNoOptimize() {
    // empty queue
    Deque<VplsOperation> operations = new ArrayDeque<>();
    VplsOperation vplsOperation = VplsOperationManager.getOptimizedVplsOperation(operations);
    assertNull(vplsOperation);
    // one operation
    VplsData vplsData = VplsData.of(VPLS1);
    vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.ADD);
    operations.add(vplsOperation);
    VplsOperation result = VplsOperationManager.getOptimizedVplsOperation(operations);
    assertEquals(vplsOperation, result);
}
Also used : VplsOperation(org.onosproject.vpls.api.VplsOperation) VplsData(org.onosproject.vpls.api.VplsData) ArrayDeque(java.util.ArrayDeque) Test(org.junit.Test)

Aggregations

VplsData (org.onosproject.vpls.api.VplsData)73 Test (org.junit.Test)44 VplsOperation (org.onosproject.vpls.api.VplsOperation)18 VplsTest (org.onosproject.vpls.VplsTest)11 ArrayDeque (java.util.ArrayDeque)10 Interface (org.onosproject.net.intf.Interface)10 Vpls (org.onosproject.vpls.api.Vpls)7 NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)6 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Host (org.onosproject.net.Host)4 HostEvent (org.onosproject.net.host.HostEvent)4 Intent (org.onosproject.net.intent.Intent)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Objects (java.util.Objects)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 MacAddress (org.onlab.packet.MacAddress)3