Search in sources :

Example 6 with NetworkInfoData

use of org.openkilda.messaging.info.discovery.NetworkInfoData in project open-kilda by telstra.

the class OFELinkBoltFloodTest method warmBoltOnHighLoadedTopic.

@Test(timeout = 5000 * 60)
public void warmBoltOnHighLoadedTopic() throws Exception {
    topology = new OFEventWFMTopology(makeLaunchEnvironment());
    teConsumer = new TestKafkaConsumer(topology.getConfig().getKafkaTopoEngTopic(), kafkaProperties(UUID.nameUUIDFromBytes(Destination.TOPOLOGY_ENGINE.toString().getBytes()).toString()));
    teConsumer.start();
    // Size of messages in topic before bolt start
    final int floodSize = 100000;
    SwitchInfoData data = new SwitchInfoData("switchId", SwitchState.ADDED, "address", "hostname", "description", "controller");
    InfoMessage message = new InfoMessage(data, System.currentTimeMillis(), UUID.randomUUID().toString());
    // Floooding
    sendMessages(message, topology.getConfig().getKafkaTopoDiscoTopic(), floodSize);
    StormTopology stormTopology = topology.createTopology();
    Config config = stormConfig();
    cluster.submitTopology(OFELinkBoltFloodTest.class.getSimpleName(), config, stormTopology);
    NetworkInfoData dump = new NetworkInfoData("test", Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet());
    InfoMessage info = new InfoMessage(dump, 0, DEFAULT_CORRELATION_ID, Destination.WFM);
    String request = objectMapper.writeValueAsString(info);
    // Send DumpMessage to topic with offset floodSize+1.
    kProducer.pushMessage(topology.getConfig().getKafkaTopoDiscoTopic(), request);
    // Wait all messages
    int pooled = 0;
    while (pooled < floodSize) {
        if (teConsumer.pollMessage() != null)
            ++pooled;
    }
    assertEquals(floodSize, pooled);
}
Also used : NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) TestKafkaConsumer(org.openkilda.wfm.topology.TestKafkaConsumer) InfoMessage(org.openkilda.messaging.info.InfoMessage) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 7 with NetworkInfoData

use of org.openkilda.messaging.info.discovery.NetworkInfoData in project open-kilda by telstra.

the class OFELinkBoltTest method cacheLoadCheck.

/**
 * Part of warm mechanism checks. That test verifies appropriately unpack and fill inner
 * cache after getting network dump information from FL.
 */
@Test
public void cacheLoadCheck() throws IOException {
    // Send cache data and verify is inner state is ok
    SwitchInfoData sw1 = new SwitchInfoData("sw1", SwitchState.ADDED, "127.0.0.1", "localhost", "test switch", "kilda");
    SwitchInfoData sw2 = new SwitchInfoData("sw2", SwitchState.ADDED, "127.0.0.1", "localhost", "test switch", "kilda");
    PortInfoData sw1Port1 = new PortInfoData(sw1.getSwitchId(), 1, null, UP);
    PortInfoData sw2Port1 = new PortInfoData(sw2.getSwitchId(), 1, null, UP);
    NetworkInfoData dump = new NetworkInfoData("test", new HashSet<>(Arrays.asList(sw1, sw2)), new HashSet<>(Arrays.asList(sw1Port1, sw2Port1)), Collections.emptySet(), Collections.emptySet());
    InfoMessage info = new InfoMessage(dump, 0, DEFAULT_CORRELATION_ID, Destination.WFM);
    String request = objectMapper.writeValueAsString(info);
    Tuple dumpTuple = new TupleImpl(context, new Values(request), TASK_ID_BOLT, STREAM_ID_INPUT);
    bolt.doWork(dumpTuple);
    List<DiscoveryNode> discoveryQueue = bolt.getDiscoveryQueue();
    // I don't check discoveryQueue contents because that should be done in a test for
    // handleSwitchEvent and handlePortEvent.
    assertEquals(2, discoveryQueue.size());
}
Also used : NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) TupleImpl(org.apache.storm.tuple.TupleImpl) Tuple(org.apache.storm.tuple.Tuple) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 8 with NetworkInfoData

use of org.openkilda.messaging.info.discovery.NetworkInfoData in project open-kilda by telstra.

the class AbstractSerializerTest method dumpNetworkResponseTest.

@Test
public void dumpNetworkResponseTest() throws IOException, ClassNotFoundException {
    NetworkInfoData data = new NetworkInfoData(requester, new HashSet<>(Arrays.asList(sw1, sw2)), new HashSet<>(), Collections.singleton(isl), Collections.singleton(new ImmutablePair<>(flowModel, flowModel)));
    System.out.println(data);
    InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    info.setData(data);
    serialize(info);
    Message message = (Message) deserialize();
    assertTrue(message instanceof InfoMessage);
    InfoMessage resultInfo = (InfoMessage) message;
    assertTrue(resultInfo.getData() != null);
    NetworkInfoData resultData = (NetworkInfoData) resultInfo.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
}
Also used : NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) ImmutablePair(org.openkilda.messaging.model.ImmutablePair) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) Test(org.junit.Test)

Aggregations

NetworkInfoData (org.openkilda.messaging.info.discovery.NetworkInfoData)8 InfoMessage (org.openkilda.messaging.info.InfoMessage)7 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)5 PortInfoData (org.openkilda.messaging.info.event.PortInfoData)4 Test (org.junit.Test)3 IOException (java.io.IOException)2 TupleImpl (org.apache.storm.tuple.TupleImpl)2 Values (org.apache.storm.tuple.Values)2 BaseMessage (org.openkilda.messaging.BaseMessage)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)2 java.util (java.util)1 Arrays.asList (java.util.Arrays.asList)1 Collectors (java.util.stream.Collectors)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 Config (org.apache.storm.Config)1 StormTopology (org.apache.storm.generated.StormTopology)1 Tuple (org.apache.storm.tuple.Tuple)1