Search in sources :

Example 16 with VplsOperation

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

the class VplsOperationManagerTest method testOptimizeOperationsUToR.

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

Example 17 with VplsOperation

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

the class VplsOperationManagerTest method testOptimizeOperationsAToA.

/**
 * Optimize operations with first is ADD operation and last is also ADD
 * operation.
 */
@Test
public void testOptimizeOperationsAToA() {
    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.ADD);
    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 18 with VplsOperation

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

the class VplsOperationManagerTest method testDuplicateOperationInQueue.

/**
 * Submits same operation twice to the manager; the manager should ignore
 * duplicated operation.
 */
@Test
@Ignore("Test is brittle - revisit")
public void testDuplicateOperationInQueue() {
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.ADD);
    vplsOperationManager.submit(vplsOperation);
    vplsOperationManager.submit(vplsOperation);
    Deque<VplsOperation> opQueue = vplsOperationManager.pendingVplsOperations.get(VPLS1);
    assertEquals(1, opQueue.size());
    // Clear operation queue before scheduler process it
    opQueue.clear();
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsOperation(org.onosproject.vpls.api.VplsOperation) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with VplsOperation

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

the class VplsOperationManagerTest method testOptimizeOperationsUToA.

/**
 * Optimize operations with first is UPDATE operation and last is ADD
 * operation.
 */
@Test
public void testOptimizeOperationsUToA() {
    Deque<VplsOperation> operations = new ArrayDeque<>();
    VplsData vplsData = VplsData.of(VPLS1);
    vplsData.addInterfaces(ImmutableSet.of(V100H1));
    VplsOperation vplsOperation = VplsOperation.of(vplsData, VplsOperation.Operation.UPDATE);
    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)

Aggregations

VplsOperation (org.onosproject.vpls.api.VplsOperation)19 Test (org.junit.Test)18 VplsData (org.onosproject.vpls.api.VplsData)18 ArrayDeque (java.util.ArrayDeque)10 Intent (org.onosproject.net.intent.Intent)2 Ignore (org.junit.Ignore)1 VplsStoreEvent (org.onosproject.vpls.store.VplsStoreEvent)1