Search in sources :

Example 1 with LinkPropsRequest

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);
    }
}
Also used : LinkPropsRequest(org.openkilda.messaging.nbtopology.request.LinkPropsRequest) InfoMessage(org.openkilda.messaging.info.InfoMessage) LinkPropsDto(org.openkilda.messaging.model.LinkPropsDto) LinkPropsDropTest(org.openkilda.messaging.nbtopology.request.LinkPropsDropTest) LinkPropsPutTest(org.openkilda.messaging.nbtopology.request.LinkPropsPutTest) Test(org.junit.Test) LinkPropsTest(org.openkilda.messaging.model.LinkPropsTest)

Example 2 with LinkPropsRequest

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());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) HashMap(java.util.HashMap) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) SwitchId(org.openkilda.model.SwitchId) BatchResults(org.openkilda.northbound.dto.BatchResults) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) LinkPropsRequest(org.openkilda.messaging.nbtopology.request.LinkPropsRequest) LinkPropsPut(org.openkilda.messaging.nbtopology.request.LinkPropsPut) Test(org.junit.Test)

Example 3 with LinkPropsRequest

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());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) HashMap(java.util.HashMap) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) SwitchId(org.openkilda.model.SwitchId) LinkMaxBandwidthRequest(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthRequest) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) LinkPropsRequest(org.openkilda.messaging.nbtopology.request.LinkPropsRequest) LinkPropsPut(org.openkilda.messaging.nbtopology.request.LinkPropsPut) LinkMaxBandwidthDto(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 LinkPropsRequest (org.openkilda.messaging.nbtopology.request.LinkPropsRequest)3 HashMap (java.util.HashMap)2 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)2 LinkPropsPut (org.openkilda.messaging.nbtopology.request.LinkPropsPut)2 LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)2 SwitchId (org.openkilda.model.SwitchId)2 LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 LinkPropsDto (org.openkilda.messaging.model.LinkPropsDto)1 LinkPropsTest (org.openkilda.messaging.model.LinkPropsTest)1 LinkPropsDropTest (org.openkilda.messaging.nbtopology.request.LinkPropsDropTest)1 LinkPropsPutTest (org.openkilda.messaging.nbtopology.request.LinkPropsPutTest)1 BatchResults (org.openkilda.northbound.dto.BatchResults)1 LinkMaxBandwidthDto (org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto)1 LinkMaxBandwidthRequest (org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthRequest)1