Search in sources :

Example 1 with EventIdentifier

use of org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier in project openflowplugin by opendaylight.

the class ResetEventTimesComandProviderTest method testDoExecute_dirty.

/**
 * Test for {@link ResetEventTimesComandProvider#doExecute()} when stats were touched before.
 */
@Test
public void testDoExecute_dirty() throws Exception {
    final EventIdentifier dummyEvent = new EventIdentifier("junit", "junitDevice");
    Assert.assertTrue(checkNoActivity(EventsTimeCounter.provideTimes(), CHECK_NO_ACTIVITY_FUNCTION));
    EventsTimeCounter.markStart(dummyEvent);
    EventsTimeCounter.markEnd(dummyEvent);
    Assert.assertFalse(checkNoActivity(EventsTimeCounter.provideTimes(), CHECK_NO_ACTIVITY_FUNCTION));
    resetEventTimesComandProvider.execute(cmdSession);
    Assert.assertTrue(checkNoActivity(EventsTimeCounter.provideTimes(), CHECK_NO_ACTIVITY_FUNCTION));
}
Also used : EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) Test(org.junit.Test)

Example 2 with EventIdentifier

use of org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier in project openflowplugin by opendaylight.

the class ShowEventTimesComandProviderTest method testDoExecute_dirty.

/**
 * Test for {@link ShowEventTimesComandProvider#doExecute()} when stats were touched before.
 */
@Test
public void testDoExecute_dirty() throws Exception {
    final EventIdentifier dummyEvent = new EventIdentifier("junit", "junitDevice");
    Assert.assertTrue(checkNoActivity(EventsTimeCounter.provideTimes(), CHECK_NO_ACTIVITY_FUNCTION));
    EventsTimeCounter.markStart(dummyEvent);
    EventsTimeCounter.markEnd(dummyEvent);
    Assert.assertFalse(checkNoActivity(EventsTimeCounter.provideTimes(), CHECK_NO_ACTIVITY_FUNCTION));
    showEventTimesComandProvider.execute(cmdSession);
    Assert.assertFalse(checkNoActivity(EventsTimeCounter.provideTimes(), CHECK_NO_ACTIVITY_FUNCTION));
    Mockito.verify(console).print(Matchers.contains("junitDevice"));
}
Also used : EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) Test(org.junit.Test)

Example 3 with EventIdentifier

use of org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier in project openflowplugin by opendaylight.

the class StatisticsGatheringServiceTest method testGetStatisticsOfType.

@Test
public void testGetStatisticsOfType() throws Exception {
    final EventIdentifier eventIdentifier = new EventIdentifier("ut-event", "ut-device-id:1");
    for (MultipartType mpType : MultipartType.values()) {
        statisticsGatheringService.getStatisticsOfType(eventIdentifier, mpType);
    }
    Mockito.verify(mockedRequestContextStack, Mockito.times(15)).createRequestContext();
}
Also used : EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) Test(org.junit.Test)

Example 4 with EventIdentifier

use of org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier in project openflowplugin by opendaylight.

the class StatisticsGatheringOnTheFlyServiceTest method testGetStatisticsOfType.

@Test
public void testGetStatisticsOfType() throws Exception {
    final EventIdentifier eventIdentifier = new EventIdentifier("ut-event", "ut-device-id:1");
    statisticsGatheringService.getStatisticsOfType(eventIdentifier, MultipartType.OFPMPFLOW);
    Mockito.verify(mockedRequestContextStack).createRequestContext();
}
Also used : EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) Test(org.junit.Test)

Example 5 with EventIdentifier

use of org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier in project openflowplugin by opendaylight.

the class SalTableServiceImplTest method testUpdateTableSuccess.

@Test
public void testUpdateTableSuccess() throws ExecutionException, InterruptedException {
    Mockito.doAnswer((Answer<Void>) invocation -> {
        TableFeaturesBuilder tableFeaturesBld = new TableFeaturesBuilder().setTableId((short) 0).setName("Zafod").setMaxEntries(42L).setTableFeatureProperties(Collections.<TableFeatureProperties>emptyList());
        MultipartReplyTableFeaturesBuilder mpTableFeaturesBld = new MultipartReplyTableFeaturesBuilder().setTableFeatures(Collections.singletonList(tableFeaturesBld.build()));
        MultipartReplyTableFeaturesCaseBuilder mpBodyBld = new MultipartReplyTableFeaturesCaseBuilder().setMultipartReplyTableFeatures(mpTableFeaturesBld.build());
        MultipartReplyMessageBuilder mpResultBld = new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPTABLEFEATURES).setMultipartReplyBody(mpBodyBld.build()).setXid(21L);
        final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.singletonList((MultipartReply) mpResultBld.build())).build();
        handleResultFuture.set(rpcResult);
        return null;
    }).when(multiMessageCollector).endCollecting(Matchers.<EventIdentifier>any());
    final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = salTableService.updateTable(prepareUpdateTable());
    Assert.assertNotNull(rpcResultFuture);
    verify(mockedRequestContextStack).createRequestContext();
}
Also used : UpdateTableInput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ServiceMocking(org.opendaylight.openflowplugin.impl.services.ServiceMocking) UpdatedTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) RpcProviderRegistry(org.opendaylight.controller.sal.binding.api.RpcProviderRegistry) MultipartWriterProviderFactory(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) SettableFuture(com.google.common.util.concurrent.SettableFuture) Answer(org.mockito.stubbing.Answer) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) Future(java.util.concurrent.Future) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) ConvertorManagerFactory(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory) UpdateTableInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder) UpdateTableOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput) Test(org.junit.Test) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) Mockito.when(org.mockito.Mockito.when) FutureCallback(com.google.common.util.concurrent.FutureCallback) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) Mockito(org.mockito.Mockito) List(java.util.List) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) Assert(org.junit.Assert) Collections(java.util.Collections) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 EventIdentifier (org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier)5 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 Collections (java.util.Collections)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 Assert (org.junit.Assert)1 Matchers (org.mockito.Matchers)1 Mock (org.mockito.Mock)1 Mockito (org.mockito.Mockito)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1 Answer (org.mockito.stubbing.Answer)1 RpcProviderRegistry (org.opendaylight.controller.sal.binding.api.RpcProviderRegistry)1 MultipartWriterProviderFactory (org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory)1 ServiceMocking (org.opendaylight.openflowplugin.impl.services.ServiceMocking)1 ConvertorManager (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager)1