Search in sources :

Example 6 with CtrlResponse

use of org.openkilda.messaging.ctrl.CtrlResponse 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 7 with CtrlResponse

use of org.openkilda.messaging.ctrl.CtrlResponse 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 8 with CtrlResponse

use of org.openkilda.messaging.ctrl.CtrlResponse 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 9 with CtrlResponse

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

the class FlowTopologyTest method sendClearState.

private void sendClearState() throws IOException, InterruptedException {
    CtrlRequest request = new CtrlRequest("flowtopology/" + ComponentType.CRUD_BOLT.toString(), new RequestData("clearState"), 1, "clear-state-correlation-id", Destination.WFM_CTRL);
    sendMessage(request, topologyConfig.getKafkaCtrlTopic());
    ConsumerRecord<String, String> raw = ctrlConsumer.pollMessage();
    assertNotNull(raw);
    CtrlResponse response = (CtrlResponse) objectMapper.readValue(raw.value(), Message.class);
    assertEquals(request.getCorrelationId(), response.getCorrelationId());
}
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) CtrlResponse(org.openkilda.messaging.ctrl.CtrlResponse)

Aggregations

CtrlResponse (org.openkilda.messaging.ctrl.CtrlResponse)9 Message (org.openkilda.messaging.Message)8 CommandMessage (org.openkilda.messaging.command.CommandMessage)7 CtrlRequest (org.openkilda.messaging.ctrl.CtrlRequest)7 RequestData (org.openkilda.messaging.ctrl.RequestData)7 InfoMessage (org.openkilda.messaging.info.InfoMessage)7 DumpStateResponseData (org.openkilda.messaging.ctrl.DumpStateResponseData)4 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)4 ResponseData (org.openkilda.messaging.ctrl.ResponseData)3 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 NoOpConsumerRebalanceListener (org.apache.kafka.clients.consumer.internals.NoOpConsumerRebalanceListener)1 RecordMetadata (org.apache.kafka.clients.producer.RecordMetadata)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 CacheBoltState (org.openkilda.messaging.ctrl.state.CacheBoltState)1