use of org.openkilda.messaging.nbtopology.request.LinkPropsRequest in project open-kilda by telstra.
the class LinkPropsResponseTest method serializeLoop.
@Test
public void serializeLoop() throws Exception {
LinkPropsRequest[] requestsBatch = new LinkPropsRequest[] { makePutRequest(), makeDropRequest() };
for (LinkPropsRequest request : requestsBatch) {
LinkPropsDto result = LinkPropsTest.makeSubject();
LinkPropsResponse origin = new LinkPropsResponse(request, result, null);
InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getCanonicalName());
serializer.serialize(wrapper);
InfoMessage reconstructedWrapper = (InfoMessage) serializer.deserialize();
LinkPropsResponse reconstructed = (LinkPropsResponse) reconstructedWrapper.getData();
Assert.assertEquals(origin, reconstructed);
}
}
use of org.openkilda.messaging.nbtopology.request.LinkPropsRequest in project open-kilda by telstra.
the class LinkServiceTest method putLinkProps.
@Test
public void putLinkProps() {
final String correlationId = getClass().getCanonicalName();
HashMap<String, String> requestProps = new HashMap<>();
requestProps.put("test", "value");
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 9), requestProps);
LinkPropsRequest request = new LinkPropsPut(linkProps);
LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
String subCorrelationId = idFactory.produceChained(String.valueOf(requestIdIndex++), correlationId);
messageExchanger.mockResponse(subCorrelationId, payload);
LinkPropsDto inputItem = new LinkPropsDto(linkProps.getSource().getDatapath().toString(), linkProps.getSource().getPortNumber(), linkProps.getDest().getDatapath().toString(), linkProps.getDest().getPortNumber(), requestProps);
RequestCorrelationId.create(correlationId);
BatchResults result = linkService.setLinkProps(Collections.singletonList(inputItem)).join();
assertThat(result.getFailures(), is(0));
assertThat(result.getSuccesses(), is(1));
assertTrue(result.getMessages().isEmpty());
}
use of org.openkilda.messaging.nbtopology.request.LinkPropsRequest in project open-kilda by telstra.
the class LinkServiceTest method updateMaxBandwidth.
@Test
public void updateMaxBandwidth() {
final String correlationId = "update-max-bw-corrId";
Long maxBandwidth = 1000L;
SwitchId srcSwitch = new SwitchId("ff:fe:00:00:00:00:00:01");
Integer srcPort = 8;
SwitchId dstSwitch = new SwitchId("ff:fe:00:00:00:00:00:02");
Integer dstPort = 9;
LinkMaxBandwidthRequest inputRequest = new LinkMaxBandwidthRequest();
inputRequest.setMaxBandwidth(maxBandwidth);
HashMap<String, String> requestProps = new HashMap<>();
requestProps.put(LinkProps.MAX_BANDWIDTH_PROP_NAME, String.valueOf(maxBandwidth));
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), requestProps);
LinkPropsRequest request = new LinkPropsPut(linkProps);
LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
messageExchanger.mockResponse(correlationId, payload);
RequestCorrelationId.create(correlationId);
LinkMaxBandwidthDto result = linkService.updateLinkBandwidth(srcSwitch, srcPort, dstSwitch, dstPort, inputRequest).join();
assertEquals(srcSwitch.toString(), result.getSrcSwitch());
assertEquals(dstSwitch.toString(), result.getDstSwitch());
assertEquals(srcPort, result.getSrcPort());
assertEquals(dstPort, result.getDstPort());
assertEquals(maxBandwidth, result.getMaxBandwidth());
}
Aggregations