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.junit.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;
24 import org.opendaylight.yangtools.yang.common.Uint16;
25 import org.opendaylight.yangtools.yang.common.Uint32;
27 @RunWith(MockitoJUnitRunner.class)
28 public class OpenFlowProviderConfigImplTest {
29 private static final Boolean IS_STATISTICS_POLLING_ON = true;
30 private static final Uint16 BARRIER_COUNT_LIMIT = Uint16.valueOf(2000);
31 private static final Uint32 BARRIER_INTERVAL_TIMEOUT_LIMIT = Uint32.valueOf(3000);
32 private static final Uint32 ECHO_REPLY_TIMEOUT = Uint32.valueOf(4000);
33 private static final Boolean ENABLE_FLOW_REMOVED_NOTIFICATION = true;
34 private static final Boolean SKIP_TABLE_FEATURES = true;
35 private static final Uint32 BASIC_TIMER_DELAY = Uint32.valueOf(2690);
36 private static final Uint32 MAXIMUM_TIMER_DELAY = Uint32.valueOf(3679);
37 private static final Boolean SWITCH_FEATURES_MANDATORY = false;
38 private static final Boolean IS_STATISTICS_RPC_ENABLED = false;
39 private static final Boolean USE_SINGLE_LAYER_SERIALIZATION = true;
40 private static final Uint16 RPC_REQUESTS_QUOTA = Uint16.valueOf(2500);
41 private static final Uint32 GLOBAL_NOTIFICATION_QUOTA = Uint32.valueOf(9000);
42 private static final Uint16 THREAD_POOL_MIN_THREADS = Uint16.valueOf(3);
43 private static final Uint16 THREAD_POOL_MAX_THREADS = Uint16.valueOf(1000);
44 private static final Uint32 THREAD_POOL_TIMEOUT = Uint32.valueOf(60);
45 private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO;
46 private static final Uint16 DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = Uint16.valueOf(60);
47 private static final Uint32 DEVICE_DATASTORE_REMOVAL_DELAY = Uint32.valueOf(500);
50 private ConfigurationService configurationService;
51 private OpenflowProviderConfig openflowProviderConfig;
55 when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString()), any()))
56 .thenReturn(IS_STATISTICS_POLLING_ON);
57 when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_COUNT_LIMIT.toString()), any()))
58 .thenReturn(BARRIER_COUNT_LIMIT);
59 when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_INTERVAL_TIMEOUT_LIMIT.toString()),
60 any())).thenReturn(BARRIER_INTERVAL_TIMEOUT_LIMIT);
61 when(configurationService.getProperty(eq(ConfigurationProperty.ECHO_REPLY_TIMEOUT.toString()), any()))
62 .thenReturn(ECHO_REPLY_TIMEOUT);
63 when(configurationService.getProperty(eq(ConfigurationProperty.ENABLE_FLOW_REMOVED_NOTIFICATION.toString()),
64 any())).thenReturn(ENABLE_FLOW_REMOVED_NOTIFICATION);
65 when(configurationService.getProperty(eq(ConfigurationProperty.SKIP_TABLE_FEATURES.toString()), any()))
66 .thenReturn(SKIP_TABLE_FEATURES);
67 when(configurationService.getProperty(eq(ConfigurationProperty.BASIC_TIMER_DELAY.toString()), any()))
68 .thenReturn(BASIC_TIMER_DELAY);
69 when(configurationService.getProperty(eq(ConfigurationProperty.MAXIMUM_TIMER_DELAY.toString()), any()))
70 .thenReturn(MAXIMUM_TIMER_DELAY);
71 when(configurationService.getProperty(eq(ConfigurationProperty.SWITCH_FEATURES_MANDATORY.toString()), any()))
72 .thenReturn(SWITCH_FEATURES_MANDATORY);
73 when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_RPC_ENABLED.toString()), any()))
74 .thenReturn(IS_STATISTICS_RPC_ENABLED);
75 when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()),
76 any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION);
77 when(configurationService.getProperty(eq(ConfigurationProperty.RPC_REQUESTS_QUOTA.toString()), any()))
78 .thenReturn(RPC_REQUESTS_QUOTA);
79 when(configurationService.getProperty(eq(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString()), any()))
80 .thenReturn(GLOBAL_NOTIFICATION_QUOTA);
81 when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString()), any()))
82 .thenReturn(THREAD_POOL_MIN_THREADS);
83 when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString()), any()))
84 .thenReturn(THREAD_POOL_MAX_THREADS);
85 when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString()), any()))
86 .thenReturn(THREAD_POOL_TIMEOUT);
87 when(configurationService.getProperty(eq(ConfigurationProperty.DEVICE_CONNECTION_RATE_LIMIT_PER_MIN.toString()),
88 any())).thenReturn(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN);
89 when(configurationService.getProperty(
90 eq(ConfigurationProperty.DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toString()),
91 any())).thenReturn(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS);
92 when(configurationService.getProperty(eq(ConfigurationProperty.DEVICE_DATASTORE_REMOVAL_DELAY.toString()),
93 any())).thenReturn(DEVICE_DATASTORE_REMOVAL_DELAY);
94 openflowProviderConfig = new OpenFlowProviderConfigImpl(configurationService);
98 public void tearDown() throws Exception {
99 configurationService.close();
103 public void getRpcRequestsQuota() {
104 assertEquals(RPC_REQUESTS_QUOTA, openflowProviderConfig.getRpcRequestsQuota().getValue());
108 public void isSwitchFeaturesMandatory() {
109 assertEquals(SWITCH_FEATURES_MANDATORY, openflowProviderConfig.getSwitchFeaturesMandatory());
113 public void getGlobalNotificationQuota() {
114 assertEquals(GLOBAL_NOTIFICATION_QUOTA, openflowProviderConfig.getGlobalNotificationQuota());
118 public void isIsStatisticsPollingOn() {
119 assertEquals(IS_STATISTICS_POLLING_ON, openflowProviderConfig.getIsStatisticsPollingOn());
123 public void isIsStatisticsRpcEnabled() {
124 assertEquals(IS_STATISTICS_RPC_ENABLED, openflowProviderConfig.getIsStatisticsRpcEnabled());
128 public void getBarrierIntervalTimeoutLimit() {
129 assertEquals(BARRIER_INTERVAL_TIMEOUT_LIMIT,
130 openflowProviderConfig.getBarrierIntervalTimeoutLimit().getValue());
134 public void getBarrierCountLimit() {
135 assertEquals(BARRIER_COUNT_LIMIT, openflowProviderConfig.getBarrierCountLimit().getValue());
139 public void getEchoReplyTimeout() {
140 assertEquals(ECHO_REPLY_TIMEOUT, openflowProviderConfig.getEchoReplyTimeout().getValue());
144 public void getThreadPoolMinThreads() {
145 assertEquals(THREAD_POOL_MIN_THREADS, openflowProviderConfig.getThreadPoolMinThreads());
149 public void getThreadPoolMaxThreads() {
150 assertEquals(THREAD_POOL_MAX_THREADS, openflowProviderConfig.getThreadPoolMaxThreads().getValue());
154 public void getThreadPoolTimeout() {
155 assertEquals(THREAD_POOL_TIMEOUT, openflowProviderConfig.getThreadPoolTimeout());
159 public void isEnableFlowRemovedNotification() {
160 assertEquals(ENABLE_FLOW_REMOVED_NOTIFICATION, openflowProviderConfig.getEnableFlowRemovedNotification());
164 public void isSkipTableFeatures() {
165 assertEquals(SKIP_TABLE_FEATURES, openflowProviderConfig.getSkipTableFeatures());
169 public void getBasicTimerDelay() {
170 assertEquals(BASIC_TIMER_DELAY, openflowProviderConfig.getBasicTimerDelay().getValue());
174 public void getMaximumTimerDelay() {
175 assertEquals(MAXIMUM_TIMER_DELAY, openflowProviderConfig.getMaximumTimerDelay().getValue());
179 public void isUseSingleLayerSerialization() {
180 assertEquals(USE_SINGLE_LAYER_SERIALIZATION, openflowProviderConfig.getUseSingleLayerSerialization());
184 public void getDeviceConnectionRateLimitPerMin() {
185 assertEquals(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN, openflowProviderConfig.getDeviceConnectionRateLimitPerMin());
189 public void getDeviceConnectionHoldTimeInSeconds() {
190 assertEquals(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS,
191 openflowProviderConfig.getDeviceConnectionHoldTimeInSeconds());
195 public void getDeviceDatastoreRemovalDelay() {
196 assertEquals(DEVICE_DATASTORE_REMOVAL_DELAY,
197 openflowProviderConfig.getDeviceDatastoreRemovalDelay().getValue());