use of org.openkilda.server42.control.messaging.Control.CommandPacket in project open-kilda by telstra.
the class GateTest method pushSettingsTest.
@Test
public void pushSettingsTest() throws Exception {
PushSettings data = PushSettings.builder().packetGenerationIntervalInMs(500).build();
gate.listen(data);
CommandPacket commandPacket = getCommandPacket();
assertThat(commandPacket.getType()).isEqualTo(Type.PUSH_SETTINGS);
assertThat(commandPacket.getCommandList()).hasSize(1);
Any command = commandPacket.getCommand(0);
assertThat(command.is(Control.PushSettings.class)).isTrue();
Control.PushSettings unpack = command.unpack(Control.PushSettings.class);
assertThat(unpack.getPacketGenerationIntervalInMs()).isEqualTo(500);
}
use of org.openkilda.server42.control.messaging.Control.CommandPacket in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(PushSettings data) {
Builder builder = CommandPacket.newBuilder();
Control.PushSettings pushSettings = Control.PushSettings.newBuilder().setPacketGenerationIntervalInMs(data.getPacketGenerationIntervalInMs()).build();
builder.setType(Type.PUSH_SETTINGS);
builder.addCommand(Any.pack(pushSettings));
CommandPacket packet = builder.build();
try {
zeroMqClient.send(packet);
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data);
}
}
use of org.openkilda.server42.control.messaging.Control.CommandPacket in project open-kilda by telstra.
the class GateTest method testAddIsl.
@Test
public void testAddIsl() throws Exception {
AddIsl addIsl = AddIsl.builder().switchId(new SwitchId("00:00:1b:45:18:d6:71:5a")).port(42).build();
gate.listen(addIsl);
CommandPacket commandPacket = getCommandPacket();
assertThat(commandPacket.getType()).isEqualTo(Type.ADD_ISL);
assertThat(commandPacket.getCommandCount()).isEqualTo(1);
Any command = commandPacket.getCommand(0);
assertThat(command.is(IslRttControl.AddIsl.class)).isTrue();
IslRttControl.AddIsl unpack = command.unpack(IslRttControl.AddIsl.class);
IslRttControl.IslEndpoint endpoint = unpack.getIsl();
String switchId = addIsl.getSwitchId().toString();
assertThat(endpoint.getSwitchId()).isEqualTo(switchId);
assertThat(endpoint.getPort()).isEqualTo(addIsl.getPort());
assertThat(unpack.getUdpSrcPort()).isEqualTo(islRttUdpSrcPortOffset + addIsl.getPort());
assertThat(unpack.getSwitchMac()).isSubstringOf(switchId).isNotEqualTo(switchId);
}
use of org.openkilda.server42.control.messaging.Control.CommandPacket in project open-kilda by telstra.
the class GateTest method testRemoveIsl.
@Test
public void testRemoveIsl() throws Exception {
RemoveIsl removeIsl = RemoveIsl.builder().switchId(new SwitchId("00:00:1b:45:18:d6:71:5a")).port(42).build();
gate.listen(removeIsl);
CommandPacket commandPacket = getCommandPacket();
assertThat(commandPacket.getType()).isEqualTo(Type.REMOVE_ISL);
assertThat(commandPacket.getCommandList()).hasSize(1);
Any command = commandPacket.getCommand(0);
assertThat(command.is(IslRttControl.RemoveIsl.class)).isTrue();
IslRttControl.RemoveIsl unpack = command.unpack(IslRttControl.RemoveIsl.class);
IslRttControl.IslEndpoint endpoint = unpack.getIsl();
String switchId = removeIsl.getSwitchId().toString();
assertThat(endpoint.getSwitchId()).isEqualTo(switchId);
assertThat(endpoint.getPort()).isEqualTo(removeIsl.getPort());
}
use of org.openkilda.server42.control.messaging.Control.CommandPacket in project open-kilda by telstra.
the class GateTest method clearFlowsTest.
@Test
public void clearFlowsTest() throws Exception {
Headers headers = Headers.builder().correlationId("some-correlation-id").build();
ClearFlows clearFlows = ClearFlows.builder().headers(headers).build();
String dpId = "00:00:1b:45:18:d6:71:5a";
gate.listen(clearFlows, dpId);
CommandPacket commandPacket = getCommandPacket();
assertThat(commandPacket.getType()).isEqualTo(Type.CLEAR_FLOWS);
assertThat(commandPacket.getCommandList()).hasSize(1);
Any command = commandPacket.getCommand(0);
assertThat(command.is(FlowRttControl.ClearFlowsFilter.class)).isTrue();
FlowRttControl.ClearFlowsFilter unpack = command.unpack(FlowRttControl.ClearFlowsFilter.class);
String dstMac = "1b:45:18:d6:71:5a";
assertThat(unpack.getDstMac()).isEqualTo(dstMac);
}
Aggregations