use of org.onosproject.event.Event in project onos by opennetworkinglab.
the class TopologyManagerTest method validateEvents.
protected void validateEvents(Enum... types) {
int i = 0;
assertEquals("wrong events received", types.length, listener.events.size());
for (Event event : listener.events) {
assertEquals("incorrect event type", types[i], event.type());
i++;
}
listener.events.clear();
}
use of org.onosproject.event.Event in project onos by opennetworkinglab.
the class VirtualNetworkManagerTest method testTopologyChanged.
/**
* Test the topologyChanged() method.
*/
@Test
public void testTopologyChanged() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology(tenantIdValue1);
VirtualNetworkProviderService providerService = manager.createProviderService(topologyProvider);
// Initial setup is two clusters of devices/links.
assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
// Adding this link will join the two clusters together.
List<Event> reasons = new ArrayList<>();
VirtualLink link = manager.createVirtualLink(virtualNetwork.id(), cp6, cp7);
virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.ACTIVE);
VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp7, cp6);
virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
Topology topology = topologyService.currentTopology();
providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
// Validate that all links are still active.
manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
});
virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.INACTIVE);
virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.INACTIVE);
providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
// Validate that all links are active again.
manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
});
}
use of org.onosproject.event.Event in project onos by opennetworkinglab.
the class KubevirtPortManagerTest method validateEvents.
private void validateEvents(Enum... types) {
int i = 0;
assertEquals("Number of events did not match", types.length, testListener.events.size());
for (Event event : testListener.events) {
assertEquals("Incorrect event received", types[i], event.type());
i++;
}
testListener.events.clear();
}
use of org.onosproject.event.Event in project onos by opennetworkinglab.
the class KubevirtNodeManagerTest method validateEvents.
private void validateEvents(Enum... types) {
int i = 0;
assertEquals("Number of events did not match", types.length, testListener.events.size());
for (Event event : testListener.events) {
assertEquals("Incorrect event received", types[i], event.type());
i++;
}
testListener.events.clear();
}
use of org.onosproject.event.Event in project onos by opennetworkinglab.
the class TopologyEventsListCommand method json.
/**
* Produces JSON object for a topology event.
*
* @param mapper the JSON object mapper to use
* @param event the topology event with the data
* @return JSON object for the topology event
*/
private ObjectNode json(ObjectMapper mapper, Event event) {
ObjectNode result = mapper.createObjectNode();
result.put("time", event.time()).put("type", event.type().toString()).put("event", event.toString());
// Add the reasons if a TopologyEvent
if (event instanceof TopologyEvent) {
TopologyEvent topologyEvent = (TopologyEvent) event;
ArrayNode reasons = mapper.createArrayNode();
for (Event reason : topologyEvent.reasons()) {
reasons.add(json(mapper, reason));
}
result.set("reasons", reasons);
}
return result;
}
Aggregations