use of org.openkilda.messaging.command.discovery.DiscoveryFilterPopulateData in project open-kilda by telstra.
the class PopulateIslFilterAction method handle.
@Override
protected void handle() throws MessageFormatException, UnsupportedActionException, JsonProcessingException {
KafkaMessage input = new KafkaMessage(getTuple());
Message message = input.getPayload();
if (message.getDestination() != Destination.WFM_OF_DISCOVERY) {
return;
}
if (!(message instanceof CommandMessage)) {
return;
}
CommandMessage command = (CommandMessage) message;
if (!(command.getData() instanceof DiscoveryFilterPopulateData)) {
return;
}
DiscoveryFilterPopulateData payload = (DiscoveryFilterPopulateData) command.getData();
logger.info("Clean ISL filter");
filter.clear();
for (DiscoveryFilterEntity entity : payload.getFilter()) {
logger.info("Add ISL filter record - switcID=\"{}\" portId=\"{}\"", entity.switchId, entity.portId);
filter.add(entity.switchId, entity.portId);
}
}
use of org.openkilda.messaging.command.discovery.DiscoveryFilterPopulateData in project open-kilda by telstra.
the class OFEventWfmTest method basicLinkDiscoveryTest.
/**
* BasicLinkDiscoveryTest will exercise the basics of Link Discovery test.
* The key results should show up in a kafka topic, which are dumped to file.
*/
@Test
@Ignore
public void basicLinkDiscoveryTest() throws IOException, ConfigurationException, CmdLineException {
System.out.println("==> Starting BasicLinkDiscoveryTest");
OFEventWFMTopology manager = new OFEventWFMTopology(makeLaunchEnvironment());
TopologyConfig config = manager.getConfig();
String topo_input_topic = config.getKafkaTopoDiscoTopic();
Tuple tuple;
KeyValueState<String, Object> state = new InMemoryKeyValueState<>();
initMocks(topo_input_topic);
List<PathNode> nodes = Arrays.asList(new PathNode("sw1", 1, 0, 10L), new PathNode("sw2", 2, 1, 10L));
InfoData data = new IslInfoData(10L, nodes, 10000L, IslChangeType.DISCOVERED, 9000L);
String isl_discovered = MAPPER.writeValueAsString(data);
OFELinkBolt linkBolt = new OFELinkBolt(config);
linkBolt.prepare(stormConfig(), topologyContext, outputCollector);
linkBolt.initState(state);
ArrayList<DiscoveryFilterEntity> skipNodes = new ArrayList<>(1);
skipNodes.add(new DiscoveryFilterEntity("sw1", "1"));
CommandMessage islFilterSetup = new CommandMessage(new DiscoveryFilterPopulateData(skipNodes), 1, "discovery-test", Destination.WFM_OF_DISCOVERY);
String json = MAPPER.writeValueAsString(islFilterSetup);
tuple = new TupleImpl(topologyContext, Collections.singletonList(json), 4, "message");
linkBolt.execute(tuple);
tuple = new TupleImpl(topologyContext, Arrays.asList("sw1", OFEMessageUtils.SWITCH_UP), 0, topo_input_topic);
linkBolt.execute(tuple);
tuple = new TupleImpl(topologyContext, Arrays.asList("sw2", OFEMessageUtils.SWITCH_UP), 0, topo_input_topic);
linkBolt.execute(tuple);
tuple = new TupleImpl(topologyContext, Arrays.asList("sw1", "1", OFEMessageUtils.PORT_UP), 1, topo_input_topic);
linkBolt.execute(tuple);
tuple = new TupleImpl(topologyContext, Arrays.asList("sw1", "2", OFEMessageUtils.PORT_UP), 1, topo_input_topic);
linkBolt.execute(tuple);
Tuple tickTuple = new TupleImpl(topologyContext, Collections.emptyList(), 2, Constants.SYSTEM_TICK_STREAM_ID);
linkBolt.execute(tickTuple);
tuple = new TupleImpl(topologyContext, Collections.singletonList(isl_discovered), 3, topo_input_topic);
linkBolt.execute(tuple);
linkBolt.execute(tickTuple);
linkBolt.execute(tickTuple);
// 1 isls, 3 seconds interval, 9 seconds test duration == 3 discovery commands
// there is only 1 isl each cycle because of isl filter
// messagesExpected = 3 ;
// TODO: (crimi) validate is 7 due to merged topics
messagesExpected = 7;
messagesReceived = outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
Assert.assertEquals(messagesExpected, messagesReceived);
// "isl discovered" x1
// messagesExpected = 1;
// TODO: (crimi) validate is 7 due to merged topics
messagesExpected = 7;
messagesReceived = outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
Assert.assertEquals(messagesExpected, messagesReceived);
linkBolt.execute(tickTuple);
// no new discovery commands
// messagesExpected = 3;
// TODO .. increased from 3 to 7 due to topic changes .. confirm it
messagesExpected = 7;
messagesReceived = outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
Assert.assertEquals(messagesExpected, messagesReceived);
// +1 discovery fails
// messagesExpected = 2;
// TODO .. there should be more or we aren't looking in right place
messagesExpected = 7;
messagesReceived = outputCollectorMock.getMessagesCount(config.getKafkaTopoDiscoTopic());
Assert.assertEquals(messagesExpected, messagesReceived);
}
Aggregations