Search in sources :

Example 61 with VplsData

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

the class VplsOperationManagerTest method testOptimizeOperationsAToU.

/**
 * Optimize operations with first is ADD operation and last is UPDATE
 * operation.
 */
@Test
public void testOptimizeOperationsAToU() {
    Deque<VplsOperation> operations = new ArrayDeque<>();
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1));
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.ADD);
    operations.add(vplsOperation);
    vplsData = VplsData.of(VPLS1, EncapsulationType.VLAN);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.UPDATE);
    operations.add(vplsOperation);
    vplsOperation = VplsOperationManager.getOptimizedVplsOperation(operations);
    assertEquals(VplsOperation.of(vplsData, VplsOperation.Operation.ADD), vplsOperation);
}
Also used : VplsOperation(org.onosproject.vpls.api.VplsOperation) VplsData(org.onosproject.vpls.api.VplsData) ArrayDeque(java.util.ArrayDeque) Test(org.junit.Test)

Example 62 with VplsData

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

the class VplsOperationManagerTest method testSubmitUpdateOperation.

/**
 * Submits an UPDATE operation with VPLS interface update to the operation manager; check if the VPLS
 * store changed after a period.
 */
@Test
public void testSubmitUpdateOperation() {
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1));
    vplsData.state(VplsData.VplsState.ADDED);
    vplsOperationManager.vplsStore.addVpls(vplsData);
    vplsData = VplsData.of(VPLS1, EncapsulationType.VLAN);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    vplsData.state(VplsData.VplsState.UPDATING);
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.UPDATE);
    vplsOperationManager.submit(vplsOperation);
    assertAfter(OPERATION_DELAY, OPERATION_DURATION, () -> {
        Collection<VplsData> vplss = vplsOperationManager.vplsStore.getAllVpls();
        VplsData result = vplss.iterator().next();
        VplsData expected = VplsData.of(VPLS1, EncapsulationType.VLAN);
        expected.addInterfaces(ImmutableSet.of(V100H1, V100H2));
        expected.state(VplsData.VplsState.ADDED);
        assertEquals(1, vplss.size());
        assertEquals(expected, result);
        Set<Intent> intentsInstalled = Sets.newHashSet(vplsOperationManager.intentService.getIntents());
        assertEquals(4, intentsInstalled.size());
    });
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsOperation(org.onosproject.vpls.api.VplsOperation) Intent(org.onosproject.net.intent.Intent) Test(org.junit.Test)

Example 63 with VplsData

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

the class VplsOperationManagerTest method testOptimizeOperationsRToA.

/**
 * Optimize operations with first is REMOVE operation and last is ADD
 * operation.
 */
@Test
public void testOptimizeOperationsRToA() {
    Deque<VplsOperation> operations = new ArrayDeque<>();
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1));
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.REMOVE);
    operations.add(vplsOperation);
    vplsData = VplsData.of(VPLS1, EncapsulationType.VLAN);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.ADD);
    operations.add(vplsOperation);
    vplsOperation = VplsOperationManager.getOptimizedVplsOperation(operations);
    assertEquals(VplsOperation.of(vplsData, VplsOperation.Operation.UPDATE), vplsOperation);
}
Also used : VplsOperation(org.onosproject.vpls.api.VplsOperation) VplsData(org.onosproject.vpls.api.VplsData) ArrayDeque(java.util.ArrayDeque) Test(org.junit.Test)

Example 64 with VplsData

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

the class VplsOperationManagerTest method testSubmitUpdateHostOperation.

/**
 * Submits an UPDATE operation with VPLS host update to the operation manager; check if the VPLS
 * store changed after a period.
 */
@Test
public void testSubmitUpdateHostOperation() {
    vplsOperationManager.hostService = new EmptyHostService();
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.ADD);
    vplsOperationManager.submit(vplsOperation);
    delay(1000);
    vplsOperationManager.hostService = new TestHostService();
    vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    vplsData.state(VplsData.VplsState.UPDATING);
    vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.UPDATE);
    vplsOperationManager.submit(vplsOperation);
    assertAfter(OPERATION_DELAY, OPERATION_DURATION, () -> {
        Collection<VplsData> vplss = vplsOperationManager.vplsStore.getAllVpls();
        VplsData result = vplss.iterator().next();
        VplsData expected = VplsData.of(VPLS1);
        expected.addInterfaces(ImmutableSet.of(V100H1, V100H2));
        expected.state(VplsData.VplsState.ADDED);
        assertEquals(1, vplss.size());
        assertEquals(expected, result);
        assertEquals(4, vplsOperationManager.intentService.getIntentCount());
    });
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsOperation(org.onosproject.vpls.api.VplsOperation) Test(org.junit.Test)

Example 65 with VplsData

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

the class VplsOperationManagerTest method testDoNothingOperation.

/**
 * Submits REMOVE operation after submits ADD operation; there should be no
 * pending or running operation in the manager.
 */
@Test
public void testDoNothingOperation() {
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.ADD);
    vplsOperationManager.submit(vplsOperation);
    vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.REMOVE);
    vplsOperationManager.submit(vplsOperation);
    assertAfter(OPERATION_DELAY, OPERATION_DURATION, () -> {
        assertEquals(0, vplsOperationManager.pendingVplsOperations.size());
        // Should not have any running operation
        assertEquals(0, vplsOperationManager.runningOperations.size());
    });
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsOperation(org.onosproject.vpls.api.VplsOperation) 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