2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.impl.configuration;
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.ArgumentMatchers.eq;
13 import static org.mockito.Mockito.when;
15 import org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.runners.MockitoJUnitRunner;
21 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
22 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
25 @RunWith(MockitoJUnitRunner.class)
26 public class OpenFlowProviderConfigImplTest {
27 private static final Boolean IS_STATISTICS_POLLING_ON = true;
28 private static final Integer BARRIER_COUNT_LIMIT = 2000;
29 private static final Long BARRIER_INTERVAL_TIMEOUT_LIMIT = 3000L;
30 private static final Long ECHO_REPLY_TIMEOUT = 4000L;
31 private static final Boolean ENABLE_FLOW_REMOVED_NOTIFICATION = true;
32 private static final Boolean SKIP_TABLE_FEATURES = true;
33 private static final Long BASIC_TIMER_DELAY = 2690L;
34 private static final Long MAXIMUM_TIMER_DELAY = 3679L;
35 private static final Boolean SWITCH_FEATURES_MANDATORY = false;
36 private static final Boolean IS_STATISTICS_RPC_ENABLED = false;
37 private static final Boolean USE_SINGLE_LAYER_SERIALIZATION = true;
38 private static final Integer RPC_REQUESTS_QUOTA = 2500;
39 private static final Long GLOBAL_NOTIFICATION_QUOTA = 9000L;
40 private static final Integer THREAD_POOL_MIN_THREADS = 3;
41 private static final Integer THREAD_POOL_MAX_THREADS = 1000;
42 private static final Long THREAD_POOL_TIMEOUT = 60L;
43 private static final Integer DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0;
46 private ConfigurationService configurationService;
47 private OpenflowProviderConfig openflowProviderConfig;
50 public void setUp() throws Exception {
51 when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString()), any()))
52 .thenReturn(IS_STATISTICS_POLLING_ON);
53 when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_COUNT_LIMIT.toString()), any()))
54 .thenReturn(BARRIER_COUNT_LIMIT);
55 when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_INTERVAL_TIMEOUT_LIMIT.toString()),
56 any())).thenReturn(BARRIER_INTERVAL_TIMEOUT_LIMIT);
57 when(configurationService.getProperty(eq(ConfigurationProperty.ECHO_REPLY_TIMEOUT.toString()), any()))
58 .thenReturn(ECHO_REPLY_TIMEOUT);
59 when(configurationService.getProperty(eq(ConfigurationProperty.ENABLE_FLOW_REMOVED_NOTIFICATION.toString()),
60 any())).thenReturn(ENABLE_FLOW_REMOVED_NOTIFICATION);
61 when(configurationService.getProperty(eq(ConfigurationProperty.SKIP_TABLE_FEATURES.toString()), any()))
62 .thenReturn(SKIP_TABLE_FEATURES);
63 when(configurationService.getProperty(eq(ConfigurationProperty.BASIC_TIMER_DELAY.toString()), any()))
64 .thenReturn(BASIC_TIMER_DELAY);
65 when(configurationService.getProperty(eq(ConfigurationProperty.MAXIMUM_TIMER_DELAY.toString()), any()))
66 .thenReturn(MAXIMUM_TIMER_DELAY);
67 when(configurationService.getProperty(eq(ConfigurationProperty.SWITCH_FEATURES_MANDATORY.toString()), any()))
68 .thenReturn(SWITCH_FEATURES_MANDATORY);
69 when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_RPC_ENABLED.toString()), any()))
70 .thenReturn(IS_STATISTICS_RPC_ENABLED);
71 when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()),
72 any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION);
73 when(configurationService.getProperty(eq(ConfigurationProperty.RPC_REQUESTS_QUOTA.toString()), any()))
74 .thenReturn(RPC_REQUESTS_QUOTA);
75 when(configurationService.getProperty(eq(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString()), any()))
76 .thenReturn(GLOBAL_NOTIFICATION_QUOTA);
77 when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString()), any()))
78 .thenReturn(THREAD_POOL_MIN_THREADS);
79 when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString()), any()))
80 .thenReturn(THREAD_POOL_MAX_THREADS);
81 when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString()), any()))
82 .thenReturn(THREAD_POOL_TIMEOUT);
83 when(configurationService.getProperty(eq(ConfigurationProperty.DEVICE_CONNECTION_RATE_LIMIT_PER_MIN.toString()),
84 any())).thenReturn(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN);
85 openflowProviderConfig = new OpenFlowProviderConfigImpl(configurationService);
89 public void tearDown() throws Exception {
90 configurationService.close();
94 public void getRpcRequestsQuota() throws Exception {
95 assertEquals(RPC_REQUESTS_QUOTA, openflowProviderConfig.getRpcRequestsQuota().getValue());
99 public void isSwitchFeaturesMandatory() throws Exception {
100 assertEquals(SWITCH_FEATURES_MANDATORY, openflowProviderConfig.isSwitchFeaturesMandatory());
104 public void getGlobalNotificationQuota() throws Exception {
105 assertEquals(GLOBAL_NOTIFICATION_QUOTA, openflowProviderConfig.getGlobalNotificationQuota());
109 public void isIsStatisticsPollingOn() throws Exception {
110 assertEquals(IS_STATISTICS_POLLING_ON, openflowProviderConfig.isIsStatisticsPollingOn());
114 public void isIsStatisticsRpcEnabled() throws Exception {
115 assertEquals(IS_STATISTICS_RPC_ENABLED, openflowProviderConfig.isIsStatisticsRpcEnabled());
119 public void getBarrierIntervalTimeoutLimit() throws Exception {
120 assertEquals(BARRIER_INTERVAL_TIMEOUT_LIMIT, openflowProviderConfig.getBarrierIntervalTimeoutLimit()
125 public void getBarrierCountLimit() throws Exception {
126 assertEquals(BARRIER_COUNT_LIMIT, openflowProviderConfig.getBarrierCountLimit().getValue());
130 public void getEchoReplyTimeout() throws Exception {
131 assertEquals(ECHO_REPLY_TIMEOUT, openflowProviderConfig.getEchoReplyTimeout().getValue());
135 public void getThreadPoolMinThreads() throws Exception {
136 assertEquals(THREAD_POOL_MIN_THREADS, openflowProviderConfig.getThreadPoolMinThreads());
140 public void getThreadPoolMaxThreads() throws Exception {
141 assertEquals(THREAD_POOL_MAX_THREADS, openflowProviderConfig.getThreadPoolMaxThreads().getValue());
145 public void getThreadPoolTimeout() throws Exception {
146 assertEquals(THREAD_POOL_TIMEOUT, openflowProviderConfig.getThreadPoolTimeout());
150 public void isEnableFlowRemovedNotification() throws Exception {
151 assertEquals(ENABLE_FLOW_REMOVED_NOTIFICATION, openflowProviderConfig.isEnableFlowRemovedNotification());
155 public void isSkipTableFeatures() throws Exception {
156 assertEquals(SKIP_TABLE_FEATURES, openflowProviderConfig.isSkipTableFeatures());
160 public void getBasicTimerDelay() throws Exception {
161 assertEquals(BASIC_TIMER_DELAY, openflowProviderConfig.getBasicTimerDelay().getValue());
165 public void getMaximumTimerDelay() throws Exception {
166 assertEquals(MAXIMUM_TIMER_DELAY, openflowProviderConfig.getMaximumTimerDelay().getValue());
170 public void isUseSingleLayerSerialization() throws Exception {
171 assertEquals(USE_SINGLE_LAYER_SERIALIZATION, openflowProviderConfig.isUseSingleLayerSerialization());
175 public void getDeviceConnectionRateLimitPerMin() throws Exception {
176 assertEquals(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN, openflowProviderConfig.getDeviceConnectionRateLimitPerMin());