import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
-import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImplTest.class);
- private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444");
- private static final Short DUMMY_VERSION = OFConstants.OFP_VERSION_1_3;
public static final NodeId NODE_ID = new NodeId("ofp-unit-dummy-node-id");
@Mock
@Mock
private DeviceManager deviceManager;
@Mock
- private LifecycleConductor conductor;
- @Mock
private GetFeaturesOutput featuresOutput;
@Mock
private DeviceInitializationPhaseHandler deviceInitializationPhaseHandler;
when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
- when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl(dataBroker, nodePath));
+ when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl(OFConstants.OFP_VERSION_1_3, dataBroker, nodePath));
when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
when(mockedDeviceContext.getMultiMsgCollector(
Matchers.<RequestContext<List<MultipartReply>>>any())).thenAnswer(
Matchers.<StatisticsManagerControlService>any())).thenReturn(serviceControlRegistration);
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
- statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, conductor, convertorManager);
+ final long basicTimerDelay = 3000L;
+ final long maximumTimerDelay = 900000L;
+ statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, new HashedWheelTimer(),
+ convertorManager, basicTimerDelay, maximumTimerDelay);
statisticsManager.setDeviceInitializationPhaseHandler(deviceInitializationPhaseHandler);
- when(conductor.getDeviceContext(deviceInfo)).thenReturn(mockedDeviceContext);
}
@Test
}).when(outboundQueue)
.commitEntry(Matchers.anyLong(), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
+ Mockito.when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+ Mockito.when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+
statisticsManager.setDeviceInitializationPhaseHandler(mockedDevicePhaseHandler);
statisticsManager.onDeviceContextLevelUp(deviceInfo, lifecycleService);
verify(mockedDevicePhaseHandler).onDeviceContextLevelUp(deviceInfo, lifecycleService);
statisticsManager.onDeviceContextLevelDown(deviceInfo);
verify(statisticContext).close();
verify(mockedTerminationPhaseHandler).onDeviceContextLevelDown(deviceInfo);
- Assert.assertEquals(0, contextsMap.size());
+ Assert.assertEquals(1, contextsMap.size());
}
private static Map<DeviceInfo, StatisticsContext> getContextsMap(final StatisticsManagerImpl statisticsManager)
when(itemLifeCycleRegistry.getLifeCycleSources()).thenReturn(
Collections.<ItemLifeCycleSource>emptyList());
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
+ when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
+ when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
new ChangeStatisticsWorkModeInputBuilder()
.setMode(StatisticsWorkMode.FULLYDISABLED);
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
+ when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
+
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
new ChangeStatisticsWorkModeInputBuilder()
.setMode(StatisticsWorkMode.FULLYDISABLED);