Search in sources :

Example 11 with IpSocketAddress

use of org.openkilda.model.IpSocketAddress in project open-kilda by telstra.

the class InMemoryGraphBasedTest method createTestSwitch.

protected Switch createTestSwitch(SwitchId switchId) {
    Switch sw = Switch.builder().switchId(switchId).description("test_description").socketAddress(new IpSocketAddress("10.0.0.1", 30070)).controller("test_ctrl").hostname("test_host_" + switchId).status(SwitchStatus.ACTIVE).build();
    repositoryFactory.createSwitchRepository().add(sw);
    return sw;
}
Also used : Switch(org.openkilda.model.Switch) IpSocketAddress(org.openkilda.model.IpSocketAddress)

Example 12 with IpSocketAddress

use of org.openkilda.model.IpSocketAddress in project open-kilda by telstra.

the class SpeakerStatsRequesterBoltTest method requestGrpcStatsForNoviflowSwitchesTest.

@Test
public void requestGrpcStatsForNoviflowSwitchesTest() {
    KildaFeatureToggles featureToggles = new KildaFeatureToggles(KildaFeatureToggles.DEFAULTS);
    featureToggles.setCollectGrpcStats(true);
    String address = "192.168.1.1";
    Switch sw = Switch.builder().switchId(new SwitchId(1)).socketAddress(new IpSocketAddress(address, 20)).build();
    sw.setOfDescriptionSoftware("NW500.1.1");
    when(switchRepository.findActive()).thenReturn(Collections.singleton(sw));
    when(featureTogglesRepository.getOrDefault()).thenReturn(featureToggles);
    StatsRequesterBolt statsRequesterBolt = new StatsRequesterBolt(persistenceManager, ZooKeeperSpout.SPOUT_ID);
    statsRequesterBolt.prepare(Collections.emptyMap(), topologyContext, output);
    statsRequesterBolt.execute(startTuple);
    verify(output).emit(eq(ZkStreams.ZK.toString()), any(Tuple.class), anyList());
    statsRequesterBolt.execute(input);
    ArgumentCaptor<Values> values = ArgumentCaptor.forClass(Values.class);
    verify(output, times(1)).emit(eq(STATS_REQUEST_STREAM), any(Tuple.class), anyList());
    verify(output, times(1)).emit(eq(GRPC_REQUEST_STREAM), any(Tuple.class), values.capture());
    Values capturedValues = values.getValue();
    assertTrue(capturedValues.get(0) instanceof CommandMessage);
    CommandMessage commandMessage = (CommandMessage) capturedValues.get(0);
    assertTrue(commandMessage.getData() instanceof GetPacketInOutStatsRequest);
    GetPacketInOutStatsRequest request = (GetPacketInOutStatsRequest) commandMessage.getData();
    assertEquals(address, request.getAddress());
}
Also used : Switch(org.openkilda.model.Switch) KildaFeatureToggles(org.openkilda.model.KildaFeatureToggles) Values(org.apache.storm.tuple.Values) SwitchId(org.openkilda.model.SwitchId) GetPacketInOutStatsRequest(org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest) IpSocketAddress(org.openkilda.model.IpSocketAddress) Tuple(org.apache.storm.tuple.Tuple) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Aggregations

IpSocketAddress (org.openkilda.model.IpSocketAddress)12 Switch (org.openkilda.model.Switch)6 Test (org.junit.Test)5 SwitchId (org.openkilda.model.SwitchId)5 SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)3 Values (org.apache.storm.tuple.Values)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 GetPacketInOutStatsRequest (org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest)2 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)2 SpeakerSwitchDescription (org.openkilda.messaging.model.SpeakerSwitchDescription)2 SpeakerSwitchPortView (org.openkilda.messaging.model.SpeakerSwitchPortView)2 InetSocketAddress (java.net.InetSocketAddress)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1 OFConnection (net.floodlightcontroller.core.internal.OFConnection)1 OFSwitch (net.floodlightcontroller.core.internal.OFSwitch)1 Tuple (org.apache.storm.tuple.Tuple)1