Search in sources :

Example 11 with VplsOperation

use of org.onosproject.vpls.api.VplsOperation 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 12 with VplsOperation

use of org.onosproject.vpls.api.VplsOperation 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 13 with VplsOperation

use of org.onosproject.vpls.api.VplsOperation 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 14 with VplsOperation

use of org.onosproject.vpls.api.VplsOperation 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 15 with VplsOperation

use of org.onosproject.vpls.api.VplsOperation 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

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