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