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);
}
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());
});
}
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);
}
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());
});
}
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());
});
}
Aggregations