Search in sources :

Example 46 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class CacheTopologyTest method ctrlListHandler.

@Test
public void ctrlListHandler() throws Exception {
    CtrlRequest request = new CtrlRequest("cachetopology/*", new RequestData("list"), 1, "list-correlation-id", Destination.WFM_CTRL);
    sendMessage(request, topology.getConfig().getKafkaCtrlTopic());
    ConsumerRecord<String, String> raw = ctrlConsumer.pollMessage();
    // TODO: FAILED
    assertNotNull(raw);
    assertNotNull(raw.value());
    Message responseGeneric = objectMapper.readValue(raw.value(), Message.class);
    CtrlResponse response = (CtrlResponse) responseGeneric;
    ResponseData payload = response.getData();
    assertEquals(request.getCorrelationId(), response.getCorrelationId());
    assertEquals(CacheTopology.BOLT_ID_CACHE, payload.getComponent());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) CtrlRequest(org.openkilda.messaging.ctrl.CtrlRequest) RequestData(org.openkilda.messaging.ctrl.RequestData) DumpStateResponseData(org.openkilda.messaging.ctrl.DumpStateResponseData) ResponseData(org.openkilda.messaging.ctrl.ResponseData) CtrlResponse(org.openkilda.messaging.ctrl.CtrlResponse) AbstractStormTest(org.openkilda.wfm.AbstractStormTest)

Example 47 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class CacheTopologyTest method ctrlDumpHandler.

@Test
public void ctrlDumpHandler() throws Exception {
    CtrlRequest request = new CtrlRequest("cachetopology/*", new RequestData("dump"), 1, "dump-correlation-id", Destination.WFM_CTRL);
    sendMessage(request, topology.getConfig().getKafkaCtrlTopic());
    ConsumerRecord<String, String> raw = ctrlConsumer.pollMessage();
    // TODO: FAILED
    assertNotNull(raw);
    assertNotNull(raw.value());
    Message responseGeneric = objectMapper.readValue(raw.value(), Message.class);
    CtrlResponse response = (CtrlResponse) responseGeneric;
    ResponseData payload = response.getData();
    assertEquals(request.getCorrelationId(), response.getCorrelationId());
    assertEquals(CacheTopology.BOLT_ID_CACHE, payload.getComponent());
    assertTrue(payload instanceof DumpStateResponseData);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) CtrlRequest(org.openkilda.messaging.ctrl.CtrlRequest) RequestData(org.openkilda.messaging.ctrl.RequestData) DumpStateResponseData(org.openkilda.messaging.ctrl.DumpStateResponseData) ResponseData(org.openkilda.messaging.ctrl.ResponseData) DumpStateResponseData(org.openkilda.messaging.ctrl.DumpStateResponseData) CtrlResponse(org.openkilda.messaging.ctrl.CtrlResponse) AbstractStormTest(org.openkilda.wfm.AbstractStormTest)

Example 48 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class FlowTopologyTest method ctrlDumpHandler.

@Test
@Ignore("Not reliable during batch run")
public void ctrlDumpHandler() throws Exception {
    CtrlRequest request = new CtrlRequest("flowtopology/" + ComponentType.CRUD_BOLT.toString(), new RequestData("dump"), 1, "dump-correlation-id", Destination.WFM_CTRL);
    sendMessage(request, flowTopology.getConfig().getKafkaFlowTopic());
    ConsumerRecord<String, String> raw = ctrlConsumer.pollMessage();
    assertNotNull(raw);
    assertNotNull(raw.value());
    Message responseGeneric = objectMapper.readValue(raw.value(), Message.class);
    CtrlResponse response = (CtrlResponse) responseGeneric;
    ResponseData payload = response.getData();
    assertEquals(request.getCorrelationId(), response.getCorrelationId());
    assertEquals(ComponentType.CRUD_BOLT.toString(), payload.getComponent());
    assertTrue(payload instanceof DumpStateResponseData);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) Message(org.openkilda.messaging.Message) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CtrlRequest(org.openkilda.messaging.ctrl.CtrlRequest) RequestData(org.openkilda.messaging.ctrl.RequestData) DumpStateResponseData(org.openkilda.messaging.ctrl.DumpStateResponseData) ResponseData(org.openkilda.messaging.ctrl.ResponseData) DumpStateResponseData(org.openkilda.messaging.ctrl.DumpStateResponseData) CtrlResponse(org.openkilda.messaging.ctrl.CtrlResponse) Ignore(org.junit.Ignore) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 49 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class AbstractSerializerTest method flowGetRequestTest.

@Test
public void flowGetRequestTest() throws IOException, ClassNotFoundException {
    FlowGetRequest data = new FlowGetRequest(flowIdStatusRequest);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowGetRequest);
    FlowGetRequest resultData = (FlowGetRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(flowIdStatusRequest.hashCode(), resultData.getPayload().hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 50 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class AbstractSerializerTest method flowPathRequestTest.

@Test
public void flowPathRequestTest() throws IOException, ClassNotFoundException {
    FlowPathRequest data = new FlowPathRequest(flowIdStatusRequest);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowPathRequest);
    FlowPathRequest resultData = (FlowPathRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(flowIdStatusRequest.hashCode(), resultData.getPayload().hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Aggregations

Message (org.openkilda.messaging.Message)71 CommandMessage (org.openkilda.messaging.command.CommandMessage)55 InfoMessage (org.openkilda.messaging.info.InfoMessage)55 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)29 Test (org.junit.Test)25 IOException (java.io.IOException)11 Values (org.apache.storm.tuple.Values)10 CtrlRequest (org.openkilda.messaging.ctrl.CtrlRequest)6 CtrlResponse (org.openkilda.messaging.ctrl.CtrlResponse)6 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)6 CommandData (org.openkilda.messaging.command.CommandData)5 RequestData (org.openkilda.messaging.ctrl.RequestData)5 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)5 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)4 DumpStateResponseData (org.openkilda.messaging.ctrl.DumpStateResponseData)4 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)3 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3