Committed by
Gerrit Code Review
ONOS-2184 - Adding VirtualNetworkTopologyService using Virtual networks.
Change-Id: Ib7071314b49e23dc67459f70e7ca345f8a97db4e
Showing
7 changed files
with
243 additions
and
52 deletions
... | @@ -35,6 +35,8 @@ public abstract class TestDeviceParams { | ... | @@ -35,6 +35,8 @@ public abstract class TestDeviceParams { |
35 | protected static final ProviderId PID = new ProviderId("of", "foo"); | 35 | protected static final ProviderId PID = new ProviderId("of", "foo"); |
36 | protected static final DeviceId DID1 = deviceId("of:foo"); | 36 | protected static final DeviceId DID1 = deviceId("of:foo"); |
37 | protected static final DeviceId DID2 = deviceId("of:bar"); | 37 | protected static final DeviceId DID2 = deviceId("of:bar"); |
38 | + protected static final DeviceId DID3 = deviceId("of:who"); | ||
39 | + protected static final DeviceId DID4 = deviceId("of:what"); | ||
38 | protected static final MacAddress MAC1 = MacAddress.valueOf("00:11:00:00:00:01"); | 40 | protected static final MacAddress MAC1 = MacAddress.valueOf("00:11:00:00:00:01"); |
39 | protected static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02"); | 41 | protected static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02"); |
40 | protected static final VlanId VLAN1 = VlanId.vlanId((short) 11); | 42 | protected static final VlanId VLAN1 = VlanId.vlanId((short) 11); | ... | ... |
... | @@ -47,6 +47,7 @@ import org.onosproject.net.device.DeviceService; | ... | @@ -47,6 +47,7 @@ import org.onosproject.net.device.DeviceService; |
47 | import org.onosproject.net.link.LinkService; | 47 | import org.onosproject.net.link.LinkService; |
48 | import org.onosproject.net.provider.AbstractListenerProviderRegistry; | 48 | import org.onosproject.net.provider.AbstractListenerProviderRegistry; |
49 | import org.onosproject.net.provider.AbstractProviderService; | 49 | import org.onosproject.net.provider.AbstractProviderService; |
50 | +import org.onosproject.net.topology.TopologyService; | ||
50 | import org.slf4j.Logger; | 51 | import org.slf4j.Logger; |
51 | import org.slf4j.LoggerFactory; | 52 | import org.slf4j.LoggerFactory; |
52 | 53 | ||
... | @@ -287,6 +288,8 @@ public class VirtualNetworkManager | ... | @@ -287,6 +288,8 @@ public class VirtualNetworkManager |
287 | service = new VirtualNetworkDeviceService(this, network); | 288 | service = new VirtualNetworkDeviceService(this, network); |
288 | } else if (serviceKey.serviceClass.equals(LinkService.class)) { | 289 | } else if (serviceKey.serviceClass.equals(LinkService.class)) { |
289 | service = new VirtualNetworkLinkService(this, network); | 290 | service = new VirtualNetworkLinkService(this, network); |
291 | + } else if (serviceKey.serviceClass.equals(TopologyService.class)) { | ||
292 | + service = new VirtualNetworkTopologyService(this, network); | ||
290 | } else { | 293 | } else { |
291 | return null; | 294 | return null; |
292 | } | 295 | } | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.incubator.net.virtual.impl; | ||
18 | + | ||
19 | +import org.onosproject.common.DefaultTopology; | ||
20 | +import org.onosproject.event.AbstractListenerManager; | ||
21 | +import org.onosproject.incubator.net.virtual.VirtualNetwork; | ||
22 | +import org.onosproject.incubator.net.virtual.VirtualNetworkService; | ||
23 | +import org.onosproject.net.ConnectPoint; | ||
24 | +import org.onosproject.net.Device; | ||
25 | +import org.onosproject.net.DeviceId; | ||
26 | +import org.onosproject.net.DisjointPath; | ||
27 | +import org.onosproject.net.Link; | ||
28 | +import org.onosproject.net.Path; | ||
29 | +import org.onosproject.net.topology.ClusterId; | ||
30 | +import org.onosproject.net.topology.DefaultGraphDescription; | ||
31 | +import org.onosproject.net.topology.LinkWeight; | ||
32 | +import org.onosproject.net.topology.Topology; | ||
33 | +import org.onosproject.net.topology.TopologyCluster; | ||
34 | +import org.onosproject.net.topology.TopologyEvent; | ||
35 | +import org.onosproject.net.topology.TopologyGraph; | ||
36 | +import org.onosproject.net.topology.TopologyListener; | ||
37 | +import org.onosproject.net.topology.TopologyService; | ||
38 | + | ||
39 | +import java.util.Map; | ||
40 | +import java.util.Set; | ||
41 | +import java.util.stream.Collectors; | ||
42 | + | ||
43 | +import static com.google.common.base.Preconditions.checkArgument; | ||
44 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
45 | +import static org.onosproject.incubator.net.virtual.DefaultVirtualLink.PID; | ||
46 | + | ||
47 | +/** | ||
48 | + * Topology service implementation built on the virtual network service. | ||
49 | + */ | ||
50 | +public class VirtualNetworkTopologyService extends AbstractListenerManager<TopologyEvent, TopologyListener> | ||
51 | + implements TopologyService, VnetService { | ||
52 | + | ||
53 | + private static final String NETWORK_NULL = "Network ID cannot be null"; | ||
54 | + private static final String TOPOLOGY_NULL = "Topology cannot be null"; | ||
55 | + private static final String DEVICE_ID_NULL = "Device ID cannot be null"; | ||
56 | + private static final String CLUSTER_ID_NULL = "Cluster ID cannot be null"; | ||
57 | + private static final String CLUSTER_NULL = "Topology cluster cannot be null"; | ||
58 | + private static final String CONNECTION_POINT_NULL = "Connection point cannot be null"; | ||
59 | + private static final String LINK_WEIGHT_NULL = "Link weight cannot be null"; | ||
60 | + | ||
61 | + private final VirtualNetwork network; | ||
62 | + private final VirtualNetworkService manager; | ||
63 | + | ||
64 | + /** | ||
65 | + * Creates a new VirtualNetworkTopologyService object. | ||
66 | + * | ||
67 | + * @param virtualNetworkManager virtual network manager service | ||
68 | + * @param network virtual network | ||
69 | + */ | ||
70 | + public VirtualNetworkTopologyService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) { | ||
71 | + checkNotNull(network, NETWORK_NULL); | ||
72 | + this.network = network; | ||
73 | + this.manager = virtualNetworkManager; | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public Topology currentTopology() { | ||
78 | + Iterable<Device> devices = manager.getVirtualDevices(network().id()) | ||
79 | + .stream() | ||
80 | + .collect(Collectors.toSet()); | ||
81 | + Iterable<Link> links = manager.getVirtualLinks(network().id()) | ||
82 | + .stream() | ||
83 | + .collect(Collectors.toSet()); | ||
84 | + | ||
85 | + DefaultGraphDescription graph = new DefaultGraphDescription(System.nanoTime(), System.currentTimeMillis(), | ||
86 | + devices, links); | ||
87 | + return new DefaultTopology(PID, graph); | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public boolean isLatest(Topology topology) { | ||
92 | + Topology currentTopology = currentTopology(); | ||
93 | + return defaultTopology(topology).getGraph().equals(defaultTopology(currentTopology).getGraph()); | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public TopologyGraph getGraph(Topology topology) { | ||
98 | + return defaultTopology(topology).getGraph(); | ||
99 | + } | ||
100 | + | ||
101 | + // Validates the specified topology and returns it as a default | ||
102 | + private DefaultTopology defaultTopology(Topology topology) { | ||
103 | + checkNotNull(topology, TOPOLOGY_NULL); | ||
104 | + checkArgument(topology instanceof DefaultTopology, | ||
105 | + "Topology class %s not supported", topology.getClass()); | ||
106 | + return (DefaultTopology) topology; | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public Set<TopologyCluster> getClusters(Topology topology) { | ||
111 | + return defaultTopology(topology).getClusters(); | ||
112 | + } | ||
113 | + | ||
114 | + @Override | ||
115 | + public TopologyCluster getCluster(Topology topology, ClusterId clusterId) { | ||
116 | + checkNotNull(clusterId, CLUSTER_ID_NULL); | ||
117 | + return defaultTopology(topology).getCluster(clusterId); | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) { | ||
122 | + checkNotNull(cluster, CLUSTER_NULL); | ||
123 | + return defaultTopology(topology).getClusterDevices(cluster); | ||
124 | + } | ||
125 | + | ||
126 | + @Override | ||
127 | + public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) { | ||
128 | + checkNotNull(cluster, CLUSTER_NULL); | ||
129 | + return defaultTopology(topology).getClusterLinks(cluster); | ||
130 | + } | ||
131 | + | ||
132 | + @Override | ||
133 | + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst) { | ||
134 | + checkNotNull(src, DEVICE_ID_NULL); | ||
135 | + checkNotNull(dst, DEVICE_ID_NULL); | ||
136 | + return defaultTopology(topology).getPaths(src, dst); | ||
137 | + } | ||
138 | + | ||
139 | + @Override | ||
140 | + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) { | ||
141 | + checkNotNull(src, DEVICE_ID_NULL); | ||
142 | + checkNotNull(dst, DEVICE_ID_NULL); | ||
143 | + checkNotNull(weight, LINK_WEIGHT_NULL); | ||
144 | + return defaultTopology(topology).getPaths(src, dst, weight); | ||
145 | + } | ||
146 | + | ||
147 | + @Override | ||
148 | + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) { | ||
149 | + checkNotNull(src, DEVICE_ID_NULL); | ||
150 | + checkNotNull(dst, DEVICE_ID_NULL); | ||
151 | + return defaultTopology(topology).getDisjointPaths(src, dst); | ||
152 | + } | ||
153 | + | ||
154 | + @Override | ||
155 | + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) { | ||
156 | + checkNotNull(src, DEVICE_ID_NULL); | ||
157 | + checkNotNull(dst, DEVICE_ID_NULL); | ||
158 | + checkNotNull(weight, LINK_WEIGHT_NULL); | ||
159 | + return defaultTopology(topology).getDisjointPaths(src, dst, weight); | ||
160 | + } | ||
161 | + | ||
162 | + @Override | ||
163 | + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, | ||
164 | + Map<Link, Object> riskProfile) { | ||
165 | + checkNotNull(src, DEVICE_ID_NULL); | ||
166 | + checkNotNull(dst, DEVICE_ID_NULL); | ||
167 | + return defaultTopology(topology).getDisjointPaths(src, dst, riskProfile); | ||
168 | + } | ||
169 | + | ||
170 | + @Override | ||
171 | + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, | ||
172 | + LinkWeight weight, Map<Link, Object> riskProfile) { | ||
173 | + checkNotNull(src, DEVICE_ID_NULL); | ||
174 | + checkNotNull(dst, DEVICE_ID_NULL); | ||
175 | + checkNotNull(weight, LINK_WEIGHT_NULL); | ||
176 | + return defaultTopology(topology).getDisjointPaths(src, dst, weight, riskProfile); | ||
177 | + } | ||
178 | + | ||
179 | + @Override | ||
180 | + public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) { | ||
181 | + checkNotNull(connectPoint, CONNECTION_POINT_NULL); | ||
182 | + return defaultTopology(topology).isInfrastructure(connectPoint); | ||
183 | + } | ||
184 | + | ||
185 | + @Override | ||
186 | + public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) { | ||
187 | + checkNotNull(connectPoint, CONNECTION_POINT_NULL); | ||
188 | + return defaultTopology(topology).isBroadcastPoint(connectPoint); | ||
189 | + } | ||
190 | + | ||
191 | + @Override | ||
192 | + public VirtualNetwork network() { | ||
193 | + return network; | ||
194 | + } | ||
195 | +} |
... | @@ -32,11 +32,11 @@ import org.onosproject.incubator.net.virtual.VirtualPort; | ... | @@ -32,11 +32,11 @@ import org.onosproject.incubator.net.virtual.VirtualPort; |
32 | import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore; | 32 | import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore; |
33 | import org.onosproject.net.DefaultPort; | 33 | import org.onosproject.net.DefaultPort; |
34 | import org.onosproject.net.Device; | 34 | import org.onosproject.net.Device; |
35 | -import org.onosproject.net.DeviceId; | ||
36 | import org.onosproject.net.MastershipRole; | 35 | import org.onosproject.net.MastershipRole; |
37 | import org.onosproject.net.NetTestTools; | 36 | import org.onosproject.net.NetTestTools; |
38 | import org.onosproject.net.Port; | 37 | import org.onosproject.net.Port; |
39 | import org.onosproject.net.PortNumber; | 38 | import org.onosproject.net.PortNumber; |
39 | +import org.onosproject.net.TestDeviceParams; | ||
40 | import org.onosproject.net.device.DeviceService; | 40 | import org.onosproject.net.device.DeviceService; |
41 | import org.onosproject.store.service.TestStorageService; | 41 | import org.onosproject.store.service.TestStorageService; |
42 | 42 | ||
... | @@ -48,11 +48,8 @@ import static org.junit.Assert.*; | ... | @@ -48,11 +48,8 @@ import static org.junit.Assert.*; |
48 | /** | 48 | /** |
49 | * Junit tests for VirtualNetworkDeviceService. | 49 | * Junit tests for VirtualNetworkDeviceService. |
50 | */ | 50 | */ |
51 | -public class VirtualNetworkDeviceServiceTest { | 51 | +public class VirtualNetworkDeviceServiceTest extends TestDeviceParams { |
52 | private final String tenantIdValue1 = "TENANT_ID1"; | 52 | private final String tenantIdValue1 = "TENANT_ID1"; |
53 | - private final String deviceIdValue1 = "DEVICE_ID1"; | ||
54 | - private final String deviceIdValue2 = "DEVICE_ID2"; | ||
55 | - private final String deviceIdValue3 = "DEVICE_ID3"; | ||
56 | 53 | ||
57 | private VirtualNetworkManager manager; | 54 | private VirtualNetworkManager manager; |
58 | private DistributedVirtualNetworkStore virtualNetworkManagerStore; | 55 | private DistributedVirtualNetworkStore virtualNetworkManagerStore; |
... | @@ -88,8 +85,8 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -88,8 +85,8 @@ public class VirtualNetworkDeviceServiceTest { |
88 | public void testGetDevices() { | 85 | public void testGetDevices() { |
89 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 86 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
90 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 87 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
91 | - VirtualDevice device1 = manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue1)); | 88 | + VirtualDevice device1 = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
92 | - VirtualDevice device2 = manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | 89 | + VirtualDevice device2 = manager.createVirtualDevice(virtualNetwork.id(), DID2); |
93 | 90 | ||
94 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); | 91 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
95 | 92 | ||
... | @@ -106,15 +103,15 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -106,15 +103,15 @@ public class VirtualNetworkDeviceServiceTest { |
106 | 103 | ||
107 | // test the getDevice() method | 104 | // test the getDevice() method |
108 | assertEquals("The expect device did not match.", device1, | 105 | assertEquals("The expect device did not match.", device1, |
109 | - deviceService.getDevice(DeviceId.deviceId(deviceIdValue1))); | 106 | + deviceService.getDevice(DID1)); |
110 | assertNotEquals("The expect device should not have matched.", device1, | 107 | assertNotEquals("The expect device should not have matched.", device1, |
111 | - deviceService.getDevice(DeviceId.deviceId(deviceIdValue2))); | 108 | + deviceService.getDevice(DID2)); |
112 | 109 | ||
113 | // test the isAvailable() method | 110 | // test the isAvailable() method |
114 | assertTrue("The expect device availability did not match.", | 111 | assertTrue("The expect device availability did not match.", |
115 | - deviceService.isAvailable(DeviceId.deviceId(deviceIdValue1))); | 112 | + deviceService.isAvailable(DID1)); |
116 | assertFalse("The expect device availability did not match.", | 113 | assertFalse("The expect device availability did not match.", |
117 | - deviceService.isAvailable(DeviceId.deviceId(deviceIdValue3))); | 114 | + deviceService.isAvailable(DID3)); |
118 | } | 115 | } |
119 | 116 | ||
120 | /** | 117 | /** |
... | @@ -163,8 +160,8 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -163,8 +160,8 @@ public class VirtualNetworkDeviceServiceTest { |
163 | public void testGetDeviceType() { | 160 | public void testGetDeviceType() { |
164 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 161 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
165 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 162 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
166 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue1)); | 163 | + manager.createVirtualDevice(virtualNetwork.id(), DID1); |
167 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | 164 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
168 | 165 | ||
169 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); | 166 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
170 | 167 | ||
... | @@ -203,7 +200,7 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -203,7 +200,7 @@ public class VirtualNetworkDeviceServiceTest { |
203 | 200 | ||
204 | // test the getRole() method | 201 | // test the getRole() method |
205 | assertEquals("The expect device role did not match.", MastershipRole.MASTER, | 202 | assertEquals("The expect device role did not match.", MastershipRole.MASTER, |
206 | - deviceService.getRole(DeviceId.deviceId(deviceIdValue1))); | 203 | + deviceService.getRole(DID1)); |
207 | } | 204 | } |
208 | 205 | ||
209 | /** | 206 | /** |
... | @@ -226,9 +223,8 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -226,9 +223,8 @@ public class VirtualNetworkDeviceServiceTest { |
226 | public void testGetPorts() { | 223 | public void testGetPorts() { |
227 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 224 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
228 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 225 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
229 | - VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), | 226 | + VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
230 | - DeviceId.deviceId(deviceIdValue1)); | 227 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
231 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | ||
232 | 228 | ||
233 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); | 229 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
234 | 230 | ||
... | @@ -239,9 +235,9 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -239,9 +235,9 @@ public class VirtualNetworkDeviceServiceTest { |
239 | 235 | ||
240 | // test the getPorts() method | 236 | // test the getPorts() method |
241 | assertEquals("The port set size did not match.", 2, | 237 | assertEquals("The port set size did not match.", 2, |
242 | - deviceService.getPorts(DeviceId.deviceId(deviceIdValue1)).size()); | 238 | + deviceService.getPorts(DID1).size()); |
243 | assertEquals("The port set size did not match.", 0, | 239 | assertEquals("The port set size did not match.", 0, |
244 | - deviceService.getPorts(DeviceId.deviceId(deviceIdValue2)).size()); | 240 | + deviceService.getPorts(DID2).size()); |
245 | } | 241 | } |
246 | 242 | ||
247 | /** | 243 | /** |
... | @@ -251,9 +247,8 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -251,9 +247,8 @@ public class VirtualNetworkDeviceServiceTest { |
251 | public void testGetPort() { | 247 | public void testGetPort() { |
252 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 248 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
253 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 249 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
254 | - VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), | 250 | + VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
255 | - DeviceId.deviceId(deviceIdValue1)); | 251 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
256 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | ||
257 | 252 | ||
258 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); | 253 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
259 | 254 | ||
... | @@ -265,9 +260,9 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -265,9 +260,9 @@ public class VirtualNetworkDeviceServiceTest { |
265 | 260 | ||
266 | // test the getPort() method | 261 | // test the getPort() method |
267 | assertEquals("The port did not match as expected.", virtualPort1, | 262 | assertEquals("The port did not match as expected.", virtualPort1, |
268 | - deviceService.getPort(DeviceId.deviceId(deviceIdValue1), PortNumber.portNumber(1))); | 263 | + deviceService.getPort(DID1, PortNumber.portNumber(1))); |
269 | assertNotEquals("The port did not match as expected.", virtualPort1, | 264 | assertNotEquals("The port did not match as expected.", virtualPort1, |
270 | - deviceService.getPort(DeviceId.deviceId(deviceIdValue1), PortNumber.portNumber(3))); | 265 | + deviceService.getPort(DID1, PortNumber.portNumber(3))); |
271 | } | 266 | } |
272 | 267 | ||
273 | /** | 268 | /** |
... | @@ -290,15 +285,14 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -290,15 +285,14 @@ public class VirtualNetworkDeviceServiceTest { |
290 | public void testGetPortStatistics() { | 285 | public void testGetPortStatistics() { |
291 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 286 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
292 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 287 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
293 | - VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), | 288 | + VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
294 | - DeviceId.deviceId(deviceIdValue1)); | 289 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
295 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | ||
296 | 290 | ||
297 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); | 291 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
298 | 292 | ||
299 | // test the getPortStatistics() method | 293 | // test the getPortStatistics() method |
300 | assertEquals("The port statistics set size did not match.", 0, | 294 | assertEquals("The port statistics set size did not match.", 0, |
301 | - deviceService.getPortStatistics(DeviceId.deviceId(deviceIdValue1)).size()); | 295 | + deviceService.getPortStatistics(DID1).size()); |
302 | } | 296 | } |
303 | 297 | ||
304 | /** | 298 | /** |
... | @@ -321,15 +315,14 @@ public class VirtualNetworkDeviceServiceTest { | ... | @@ -321,15 +315,14 @@ public class VirtualNetworkDeviceServiceTest { |
321 | public void testGetPortDeltaStatistics() { | 315 | public void testGetPortDeltaStatistics() { |
322 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 316 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
323 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 317 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
324 | - VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), | 318 | + VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1); |
325 | - DeviceId.deviceId(deviceIdValue1)); | 319 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
326 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | ||
327 | 320 | ||
328 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); | 321 | DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class); |
329 | 322 | ||
330 | // test the getPortDeltaStatistics() method | 323 | // test the getPortDeltaStatistics() method |
331 | assertEquals("The port delta statistics set size did not match.", 0, | 324 | assertEquals("The port delta statistics set size did not match.", 0, |
332 | - deviceService.getPortDeltaStatistics(DeviceId.deviceId(deviceIdValue1)).size()); | 325 | + deviceService.getPortDeltaStatistics(DID1).size()); |
333 | } | 326 | } |
334 | 327 | ||
335 | /** | 328 | /** | ... | ... |
... | @@ -31,10 +31,10 @@ import org.onosproject.incubator.net.virtual.VirtualLink; | ... | @@ -31,10 +31,10 @@ import org.onosproject.incubator.net.virtual.VirtualLink; |
31 | import org.onosproject.incubator.net.virtual.VirtualNetwork; | 31 | import org.onosproject.incubator.net.virtual.VirtualNetwork; |
32 | import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore; | 32 | import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore; |
33 | import org.onosproject.net.ConnectPoint; | 33 | import org.onosproject.net.ConnectPoint; |
34 | -import org.onosproject.net.DeviceId; | ||
35 | import org.onosproject.net.Link; | 34 | import org.onosproject.net.Link; |
36 | import org.onosproject.net.NetTestTools; | 35 | import org.onosproject.net.NetTestTools; |
37 | import org.onosproject.net.PortNumber; | 36 | import org.onosproject.net.PortNumber; |
37 | +import org.onosproject.net.TestDeviceParams; | ||
38 | import org.onosproject.net.link.LinkService; | 38 | import org.onosproject.net.link.LinkService; |
39 | import org.onosproject.store.service.TestStorageService; | 39 | import org.onosproject.store.service.TestStorageService; |
40 | 40 | ||
... | @@ -47,12 +47,9 @@ import static org.junit.Assert.assertNotEquals; | ... | @@ -47,12 +47,9 @@ import static org.junit.Assert.assertNotEquals; |
47 | /** | 47 | /** |
48 | * Junit tests for VirtualNetworkLinkService. | 48 | * Junit tests for VirtualNetworkLinkService. |
49 | */ | 49 | */ |
50 | -public class VirtualNetworkLinkServiceTest { | 50 | +public class VirtualNetworkLinkServiceTest extends TestDeviceParams { |
51 | 51 | ||
52 | private final String tenantIdValue1 = "TENANT_ID1"; | 52 | private final String tenantIdValue1 = "TENANT_ID1"; |
53 | - private final String deviceIdValue1 = "DEVICE_ID1"; | ||
54 | - private final String deviceIdValue2 = "DEVICE_ID2"; | ||
55 | - private final String deviceIdValue3 = "DEVICE_ID3"; | ||
56 | 53 | ||
57 | private VirtualNetworkManager manager; | 54 | private VirtualNetworkManager manager; |
58 | private DistributedVirtualNetworkStore virtualNetworkManagerStore; | 55 | private DistributedVirtualNetworkStore virtualNetworkManagerStore; |
... | @@ -92,9 +89,9 @@ public class VirtualNetworkLinkServiceTest { | ... | @@ -92,9 +89,9 @@ public class VirtualNetworkLinkServiceTest { |
92 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 89 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
93 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 90 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
94 | VirtualDevice srcVirtualDevice = | 91 | VirtualDevice srcVirtualDevice = |
95 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue1)); | 92 | + manager.createVirtualDevice(virtualNetwork.id(), DID1); |
96 | VirtualDevice dstVirtualDevice = | 93 | VirtualDevice dstVirtualDevice = |
97 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | 94 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
98 | ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1)); | 95 | ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1)); |
99 | ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2)); | 96 | ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2)); |
100 | VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), src, dst); | 97 | VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), src, dst); |
... | @@ -134,27 +131,27 @@ public class VirtualNetworkLinkServiceTest { | ... | @@ -134,27 +131,27 @@ public class VirtualNetworkLinkServiceTest { |
134 | 131 | ||
135 | // test the getDeviceLinks() method | 132 | // test the getDeviceLinks() method |
136 | assertEquals("The link set size did not match.", 2, | 133 | assertEquals("The link set size did not match.", 2, |
137 | - linkService.getDeviceLinks(DeviceId.deviceId(deviceIdValue1)).size()); | 134 | + linkService.getDeviceLinks(DID1).size()); |
138 | assertEquals("The link set size did not match.", 2, | 135 | assertEquals("The link set size did not match.", 2, |
139 | - linkService.getDeviceLinks(DeviceId.deviceId(deviceIdValue2)).size()); | 136 | + linkService.getDeviceLinks(DID2).size()); |
140 | assertEquals("The link set size did not match.", 0, | 137 | assertEquals("The link set size did not match.", 0, |
141 | - linkService.getDeviceLinks(DeviceId.deviceId(deviceIdValue3)).size()); | 138 | + linkService.getDeviceLinks(DID3).size()); |
142 | 139 | ||
143 | // test the getDeviceEgressLinks() method | 140 | // test the getDeviceEgressLinks() method |
144 | assertEquals("The link set size did not match.", 1, | 141 | assertEquals("The link set size did not match.", 1, |
145 | - linkService.getDeviceEgressLinks(DeviceId.deviceId(deviceIdValue1)).size()); | 142 | + linkService.getDeviceEgressLinks(DID1).size()); |
146 | assertEquals("The link set size did not match.", 1, | 143 | assertEquals("The link set size did not match.", 1, |
147 | - linkService.getDeviceEgressLinks(DeviceId.deviceId(deviceIdValue2)).size()); | 144 | + linkService.getDeviceEgressLinks(DID2).size()); |
148 | assertEquals("The link set size did not match.", 0, | 145 | assertEquals("The link set size did not match.", 0, |
149 | - linkService.getDeviceEgressLinks(DeviceId.deviceId(deviceIdValue3)).size()); | 146 | + linkService.getDeviceEgressLinks(DID3).size()); |
150 | 147 | ||
151 | // test the getDeviceIngressLinks() method | 148 | // test the getDeviceIngressLinks() method |
152 | assertEquals("The link set size did not match.", 1, | 149 | assertEquals("The link set size did not match.", 1, |
153 | - linkService.getDeviceIngressLinks(DeviceId.deviceId(deviceIdValue1)).size()); | 150 | + linkService.getDeviceIngressLinks(DID1).size()); |
154 | assertEquals("The link set size did not match.", 1, | 151 | assertEquals("The link set size did not match.", 1, |
155 | - linkService.getDeviceIngressLinks(DeviceId.deviceId(deviceIdValue2)).size()); | 152 | + linkService.getDeviceIngressLinks(DID2).size()); |
156 | assertEquals("The link set size did not match.", 0, | 153 | assertEquals("The link set size did not match.", 0, |
157 | - linkService.getDeviceIngressLinks(DeviceId.deviceId(deviceIdValue3)).size()); | 154 | + linkService.getDeviceIngressLinks(DID3).size()); |
158 | 155 | ||
159 | // test the getEgressLinks() method | 156 | // test the getEgressLinks() method |
160 | assertEquals("The link set size did not match.", 1, | 157 | assertEquals("The link set size did not match.", 1, |
... | @@ -182,9 +179,9 @@ public class VirtualNetworkLinkServiceTest { | ... | @@ -182,9 +179,9 @@ public class VirtualNetworkLinkServiceTest { |
182 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 179 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
183 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 180 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
184 | VirtualDevice srcVirtualDevice = | 181 | VirtualDevice srcVirtualDevice = |
185 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue1)); | 182 | + manager.createVirtualDevice(virtualNetwork.id(), DID1); |
186 | VirtualDevice dstVirtualDevice = | 183 | VirtualDevice dstVirtualDevice = |
187 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | 184 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
188 | ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1)); | 185 | ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1)); |
189 | ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2)); | 186 | ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2)); |
190 | manager.createVirtualLink(virtualNetwork.id(), src, dst); | 187 | manager.createVirtualLink(virtualNetwork.id(), src, dst); |
... | @@ -205,9 +202,9 @@ public class VirtualNetworkLinkServiceTest { | ... | @@ -205,9 +202,9 @@ public class VirtualNetworkLinkServiceTest { |
205 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); | 202 | manager.registerTenantId(TenantId.tenantId(tenantIdValue1)); |
206 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); | 203 | VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1)); |
207 | VirtualDevice srcVirtualDevice = | 204 | VirtualDevice srcVirtualDevice = |
208 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue1)); | 205 | + manager.createVirtualDevice(virtualNetwork.id(), DID1); |
209 | VirtualDevice dstVirtualDevice = | 206 | VirtualDevice dstVirtualDevice = |
210 | - manager.createVirtualDevice(virtualNetwork.id(), DeviceId.deviceId(deviceIdValue2)); | 207 | + manager.createVirtualDevice(virtualNetwork.id(), DID2); |
211 | ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1)); | 208 | ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1)); |
212 | ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2)); | 209 | ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2)); |
213 | manager.createVirtualLink(virtualNetwork.id(), src, dst); | 210 | manager.createVirtualLink(virtualNetwork.id(), src, dst); | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment