Committed by
Gerrit Code Review
[ONOS-4164] todo removal
Change-Id: Iaed7a5d2960529ecd548897b546a8804bbc9da27 (cherry picked from commit 33536201)
Showing
12 changed files
with
136 additions
and
115 deletions
... | @@ -24,9 +24,12 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -24,9 +24,12 @@ import org.apache.karaf.shell.commands.Argument; |
24 | import org.apache.karaf.shell.commands.Command; | 24 | import org.apache.karaf.shell.commands.Command; |
25 | import org.apache.karaf.shell.commands.Option; | 25 | import org.apache.karaf.shell.commands.Option; |
26 | 26 | ||
27 | +import org.onlab.util.DataRateUnit; | ||
27 | import org.onosproject.cli.AbstractShellCommand; | 28 | import org.onosproject.cli.AbstractShellCommand; |
28 | import org.onosproject.net.DeviceId; | 29 | import org.onosproject.net.DeviceId; |
30 | +import org.onosproject.net.intent.constraint.BandwidthConstraint; | ||
29 | import org.onosproject.net.intent.Constraint; | 31 | import org.onosproject.net.intent.Constraint; |
32 | +import org.onosproject.pce.pceservice.constraint.CostConstraint; | ||
30 | import org.onosproject.pce.pceservice.LspType; | 33 | import org.onosproject.pce.pceservice.LspType; |
31 | import org.onosproject.pce.pceservice.api.PceService; | 34 | import org.onosproject.pce.pceservice.api.PceService; |
32 | 35 | ||
... | @@ -71,20 +74,32 @@ public class PceSetupPathCommand extends AbstractShellCommand { | ... | @@ -71,20 +74,32 @@ public class PceSetupPathCommand extends AbstractShellCommand { |
71 | 74 | ||
72 | DeviceId srcDevice = DeviceId.deviceId(src); | 75 | DeviceId srcDevice = DeviceId.deviceId(src); |
73 | DeviceId dstDevice = DeviceId.deviceId(dst); | 76 | DeviceId dstDevice = DeviceId.deviceId(dst); |
74 | - LspType lspType = LspType.values()[type]; | ||
75 | List<Constraint> listConstrnt = new LinkedList<>(); | 77 | List<Constraint> listConstrnt = new LinkedList<>(); |
76 | 78 | ||
77 | - // add cost | 79 | + // LSP type validation |
78 | - //TODO: need to uncomment below lines once CostConstraint is ready | 80 | + if ((type < 0) || (type > 2)) { |
79 | - //CostConstraint.Type costType = CostConstraint.Type.values()[cost]; | 81 | + error("The LSP type value can be PCE tunnel with signalling in network (0), " + |
80 | - //listConstrnt.add(CostConstraint.of(costType)); | 82 | + "PCE tunnel without signalling in network with segment routing (1), " + |
83 | + "PCE tunnel without signalling in network (2)."); | ||
84 | + return; | ||
85 | + } | ||
86 | + LspType lspType = LspType.values()[type]; | ||
81 | 87 | ||
82 | - // add bandwidth | 88 | + // Add bandwidth |
83 | // bandwidth default data rate unit is in BPS | 89 | // bandwidth default data rate unit is in BPS |
84 | if (bandwidth != 0.0) { | 90 | if (bandwidth != 0.0) { |
85 | - //TODO: need to uncomment below line once BandwidthConstraint is ready | 91 | + listConstrnt.add(BandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("BPS"))); |
86 | - //listConstrnt.add(LocalBandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("BPS"))); | 92 | + } |
93 | + | ||
94 | + // Add cost | ||
95 | + // Cost validation | ||
96 | + if ((cost < 1) || (cost > 2)) { | ||
97 | + error("The cost attribute value either IGP cost(1) or TE cost(2)."); | ||
98 | + return; | ||
87 | } | 99 | } |
100 | + // Here 'cost - 1' indicates the index of enum | ||
101 | + CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1]; | ||
102 | + listConstrnt.add(CostConstraint.of(costType)); | ||
88 | 103 | ||
89 | if (!service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType)) { | 104 | if (!service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType)) { |
90 | error("Path creation failed."); | 105 | error("Path creation failed."); | ... | ... |
... | @@ -24,8 +24,12 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -24,8 +24,12 @@ import org.apache.karaf.shell.commands.Argument; |
24 | import org.apache.karaf.shell.commands.Command; | 24 | import org.apache.karaf.shell.commands.Command; |
25 | import org.apache.karaf.shell.commands.Option; | 25 | import org.apache.karaf.shell.commands.Option; |
26 | 26 | ||
27 | +import org.onlab.util.DataRateUnit; | ||
27 | import org.onosproject.cli.AbstractShellCommand; | 28 | import org.onosproject.cli.AbstractShellCommand; |
29 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
30 | +import org.onosproject.net.intent.constraint.BandwidthConstraint; | ||
28 | import org.onosproject.net.intent.Constraint; | 31 | import org.onosproject.net.intent.Constraint; |
32 | +import org.onosproject.pce.pceservice.constraint.CostConstraint; | ||
29 | import org.onosproject.pce.pceservice.api.PceService; | 33 | import org.onosproject.pce.pceservice.api.PceService; |
30 | 34 | ||
31 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
... | @@ -56,23 +60,25 @@ public class PceUpdatePathCommand extends AbstractShellCommand { | ... | @@ -56,23 +60,25 @@ public class PceUpdatePathCommand extends AbstractShellCommand { |
56 | PceService service = get(PceService.class); | 60 | PceService service = get(PceService.class); |
57 | 61 | ||
58 | List<Constraint> constrntList = new LinkedList<>(); | 62 | List<Constraint> constrntList = new LinkedList<>(); |
63 | + // Assign bandwidth. Data rate unit is in Bps. | ||
64 | + if (bandwidth != 0.0) { | ||
65 | + constrntList.add(BandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS"))); | ||
66 | + } | ||
67 | + | ||
59 | // Assign cost | 68 | // Assign cost |
60 | if (cost != 0) { | 69 | if (cost != 0) { |
61 | - //TODO: need to uncomment below lines once CostConstraint is ready | 70 | + // Cost validation |
62 | - //CostConstraint.Type costType = CostConstraint.Type.values()[Integer.valueOf(cost)]; | 71 | + if ((cost < 1) || (cost > 2)) { |
63 | - //constrntList.add(CostConstraint.of(costType)); | 72 | + error("The cost attribute value is either IGP cost(1) or TE cost(2)."); |
73 | + return; | ||
64 | } | 74 | } |
65 | - | 75 | + CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1]; |
66 | - // Assign bandwidth. Data rate unit is in Bps. | 76 | + constrntList.add(CostConstraint.of(costType)); |
67 | - if (bandwidth != 0.0) { | ||
68 | - //TODO: need to uncomment below line once BandwidthConstraint is ready | ||
69 | - //constrntList.add(LocalBandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS"))); | ||
70 | } | 77 | } |
71 | 78 | ||
72 | - //TODO: need to uncomment below lines once updatePath method is added to PceService | 79 | + if (!service.updatePath(TunnelId.valueOf(id), constrntList)) { |
73 | - //if (null == service.updatePath(PcePathId.of(id), constrntList)) { | 80 | + error("Path updation failed."); |
74 | - // error("Path updation failed."); | 81 | + return; |
75 | - // return; | 82 | + } |
76 | - //} | ||
77 | } | 83 | } |
78 | } | 84 | } | ... | ... |
... | @@ -20,9 +20,12 @@ import static com.google.common.base.MoreObjects.toStringHelper; | ... | @@ -20,9 +20,12 @@ import static com.google.common.base.MoreObjects.toStringHelper; |
20 | 20 | ||
21 | import java.util.Objects; | 21 | import java.util.Objects; |
22 | 22 | ||
23 | +import org.onlab.util.DataRateUnit; | ||
23 | import org.onosproject.incubator.net.tunnel.Tunnel; | 24 | import org.onosproject.incubator.net.tunnel.Tunnel; |
24 | import org.onosproject.incubator.net.tunnel.TunnelId; | 25 | import org.onosproject.incubator.net.tunnel.TunnelId; |
26 | +import org.onosproject.net.intent.constraint.BandwidthConstraint; | ||
25 | import org.onosproject.net.intent.Constraint; | 27 | import org.onosproject.net.intent.Constraint; |
28 | +import org.onosproject.pce.pceservice.constraint.CostConstraint; | ||
26 | 29 | ||
27 | /** | 30 | /** |
28 | * Implementation of an entity which provides functionalities of pce path. | 31 | * Implementation of an entity which provides functionalities of pce path. |
... | @@ -43,9 +46,10 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -43,9 +46,10 @@ public final class DefaultPcePath implements PcePath { |
43 | * @param id path id | 46 | * @param id path id |
44 | * @param src ingress | 47 | * @param src ingress |
45 | * @param dst egress | 48 | * @param dst egress |
46 | - * @param lspType lsp type | 49 | + * @param lspType LSP type |
47 | * @param name symbolic-path-name | 50 | * @param name symbolic-path-name |
48 | - * @param constrnt pce constraint | 51 | + * @param costConstrnt cost constraint |
52 | + * @param bandwidthConstrnt bandwidth constraint | ||
49 | */ | 53 | */ |
50 | private DefaultPcePath(TunnelId id, String src, String dst, LspType lspType, | 54 | private DefaultPcePath(TunnelId id, String src, String dst, LspType lspType, |
51 | String name, Constraint costConstrnt, Constraint bandwidthConstrnt) { | 55 | String name, Constraint costConstrnt, Constraint bandwidthConstrnt) { |
... | @@ -210,7 +214,7 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -210,7 +214,7 @@ public final class DefaultPcePath implements PcePath { |
210 | @Override | 214 | @Override |
211 | public Builder lspType(String type) { | 215 | public Builder lspType(String type) { |
212 | if (null != type) { | 216 | if (null != type) { |
213 | - this.lspType = LspType.values()[Integer.valueOf(type) - 1]; | 217 | + this.lspType = LspType.values()[Integer.valueOf(type)]; |
214 | } | 218 | } |
215 | return this; | 219 | return this; |
216 | } | 220 | } |
... | @@ -223,19 +227,14 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -223,19 +227,14 @@ public final class DefaultPcePath implements PcePath { |
223 | 227 | ||
224 | @Override | 228 | @Override |
225 | public Builder costConstraint(String cost) { | 229 | public Builder costConstraint(String cost) { |
226 | - this.costConstraint = null; | 230 | + this.costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(cost) - 1]); |
227 | - //TODO: below lines will be uncommented once CostConstraint class is ready | ||
228 | - // this.costConstraint = CostConstraint.of(cost); | ||
229 | - //} | ||
230 | return this; | 231 | return this; |
231 | } | 232 | } |
232 | 233 | ||
233 | @Override | 234 | @Override |
234 | public Builder bandwidthConstraint(String bandwidth) { | 235 | public Builder bandwidthConstraint(String bandwidth) { |
235 | - this.bandwidthConstraint = null; | 236 | + this.bandwidthConstraint = BandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit |
236 | - //TODO: below lines will be uncommented once LocalBandwidthConstraint class is ready | 237 | + .valueOf("BPS")); |
237 | - // this.bandwidthConstraint = LocalBandwidthConstraint.of(bandwidth); | ||
238 | - //} | ||
239 | return this; | 238 | return this; |
240 | } | 239 | } |
241 | 240 | ||
... | @@ -244,14 +243,24 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -244,14 +243,24 @@ public final class DefaultPcePath implements PcePath { |
244 | this.id = TunnelId.valueOf(tunnel.tunnelId().id()); | 243 | this.id = TunnelId.valueOf(tunnel.tunnelId().id()); |
245 | this.source = tunnel.src().toString(); | 244 | this.source = tunnel.src().toString(); |
246 | this.destination = tunnel.dst().toString(); | 245 | this.destination = tunnel.dst().toString(); |
247 | - //TODO: need to uncomment below line once LSP_SIG_TYPE is added to AnnotationKeys. | ||
248 | - this.lspType = null; // = LspType.valueOf(tunnel.annotations() | ||
249 | - //.value(AnnotationKeys.LSP_SIG_TYPE)); | ||
250 | this.name = tunnel.tunnelName().toString(); | 246 | this.name = tunnel.tunnelName().toString(); |
251 | - //TODO: uncomment below lines once CostConstraint and LocalBandwidthConstraint classes are ready | 247 | + // LSP type |
252 | - this.costConstraint = null; // = CostConstraint.of(tunnel.path().cost()); | 248 | + String lspType = tunnel.annotations().value(PcepAnnotationKeys.LSP_SIG_TYPE); |
253 | - this.bandwidthConstraint = null; // = LocalBandwidthConstraint.of(tunnel.annotations() | 249 | + if (lspType != null) { |
254 | - //.value(AnnotationKeys.BANDWIDTH)); | 250 | + this.lspType = LspType.values()[Integer.valueOf(lspType) - 1]; |
251 | + } | ||
252 | + // Cost type | ||
253 | + String costType = tunnel.annotations().value(PcepAnnotationKeys.COST_TYPE); | ||
254 | + if (costType != null) { | ||
255 | + this.costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(costType) - 1]); | ||
256 | + } | ||
257 | + // Bandwidth | ||
258 | + String bandwidth = tunnel.annotations().value(PcepAnnotationKeys.BANDWIDTH); | ||
259 | + if (bandwidth != null) { | ||
260 | + this.bandwidthConstraint = BandwidthConstraint.of(Double.parseDouble(bandwidth), | ||
261 | + DataRateUnit.valueOf("BPS")); | ||
262 | + } | ||
263 | + | ||
255 | return this; | 264 | return this; |
256 | } | 265 | } |
257 | 266 | ... | ... |
... | @@ -34,10 +34,11 @@ import org.onlab.util.KryoNamespace; | ... | @@ -34,10 +34,11 @@ import org.onlab.util.KryoNamespace; |
34 | import org.onosproject.incubator.net.tunnel.TunnelId; | 34 | import org.onosproject.incubator.net.tunnel.TunnelId; |
35 | import org.onosproject.incubator.net.resource.label.LabelResource; | 35 | import org.onosproject.incubator.net.resource.label.LabelResource; |
36 | import org.onosproject.incubator.net.resource.label.LabelResourceId; | 36 | import org.onosproject.incubator.net.resource.label.LabelResourceId; |
37 | +import org.onosproject.net.intent.constraint.BandwidthConstraint; | ||
37 | import org.onosproject.net.DeviceId; | 38 | import org.onosproject.net.DeviceId; |
38 | -import org.onosproject.net.intent.Constraint; | ||
39 | import org.onosproject.net.Link; | 39 | import org.onosproject.net.Link; |
40 | import org.onosproject.net.resource.ResourceConsumer; | 40 | import org.onosproject.net.resource.ResourceConsumer; |
41 | +import org.onosproject.pce.pceservice.constraint.CostConstraint; | ||
41 | import org.onosproject.pce.pceservice.TunnelConsumerId; | 42 | import org.onosproject.pce.pceservice.TunnelConsumerId; |
42 | import org.onosproject.pce.pceservice.LspType; | 43 | import org.onosproject.pce.pceservice.LspType; |
43 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; | 44 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; |
... | @@ -128,10 +129,9 @@ public class DistributedPceStore implements PceStore { | ... | @@ -128,10 +129,9 @@ public class DistributedPceStore implements PceStore { |
128 | new KryoNamespace.Builder() | 129 | new KryoNamespace.Builder() |
129 | .register(KryoNamespaces.API) | 130 | .register(KryoNamespaces.API) |
130 | .register(PcePathInfo.class, | 131 | .register(PcePathInfo.class, |
131 | - //TODO: Instead of Constraint.class need to add actual implemented class | 132 | + CostConstraint.class, |
132 | - //TODO: on this interface like CostConstraint.class and | 133 | + CostConstraint.Type.class, |
133 | - //TODO: BandwidthConstraint.class. Will be added once it is confirmed. | 134 | + BandwidthConstraint.class, |
134 | - Constraint.class, | ||
135 | LspType.class) | 135 | LspType.class) |
136 | .build())) | 136 | .build())) |
137 | 137 | ... | ... |
... | @@ -15,10 +15,10 @@ | ... | @@ -15,10 +15,10 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.pce.pcestore; | 16 | package org.onosproject.pce.pcestore; |
17 | 17 | ||
18 | -import java.util.List; | ||
19 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
20 | 19 | ||
21 | import java.util.Objects; | 20 | import java.util.Objects; |
21 | +import java.util.List; | ||
22 | 22 | ||
23 | import org.onosproject.net.resource.ResourceConsumer; | 23 | import org.onosproject.net.resource.ResourceConsumer; |
24 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; | 24 | import org.onosproject.pce.pcestore.api.LspLocalLabelInfo; | ... | ... |
... | @@ -87,7 +87,7 @@ public final class PcePathCodec extends JsonCodec<PcePath> { | ... | @@ -87,7 +87,7 @@ public final class PcePathCodec extends JsonCodec<PcePath> { |
87 | jNode = constraintJNode.get(COST); | 87 | jNode = constraintJNode.get(COST); |
88 | if (jNode != null) { | 88 | if (jNode != null) { |
89 | String cost = jNode.asText(); | 89 | String cost = jNode.asText(); |
90 | - resultBuilder.bandwidthConstraint(cost); | 90 | + resultBuilder.costConstraint(cost); |
91 | } | 91 | } |
92 | 92 | ||
93 | // retrieve bandwidth | 93 | // retrieve bandwidth | ... | ... |
... | @@ -53,7 +53,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; | ... | @@ -53,7 +53,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; |
53 | /** | 53 | /** |
54 | * Query and program pce path. | 54 | * Query and program pce path. |
55 | */ | 55 | */ |
56 | - | ||
57 | @Path("path") | 56 | @Path("path") |
58 | public class PcePathWebResource extends AbstractWebResource { | 57 | public class PcePathWebResource extends AbstractWebResource { |
59 | 58 | ||
... | @@ -124,14 +123,11 @@ public class PcePathWebResource extends AbstractWebResource { | ... | @@ -124,14 +123,11 @@ public class PcePathWebResource extends AbstractWebResource { |
124 | LspType lspType = path.lspType(); | 123 | LspType lspType = path.lspType(); |
125 | List<Constraint> listConstrnt = new LinkedList<Constraint>(); | 124 | List<Constraint> listConstrnt = new LinkedList<Constraint>(); |
126 | 125 | ||
127 | - // add cost | 126 | + // Add bandwidth |
128 | - //TODO: need to uncomment below lines once Bandwidth and Cost constraint classes are ready | 127 | + listConstrnt.add(path.bandwidthConstraint()); |
129 | - //CostConstraint.Type costType = CostConstraint.Type.values()[Integer.valueOf(path.constraint().cost())]; | ||
130 | - //listConstrnt.add(CostConstraint.of(costType)); | ||
131 | 128 | ||
132 | - // add bandwidth. Data rate unit is in BPS. | 129 | + // Add cost |
133 | - //listConstrnt.add(LocalBandwidthConstraint.of(Double.valueOf(path.constraint().bandwidth()), DataRateUnit | 130 | + listConstrnt.add(path.costConstraint()); |
134 | - // .valueOf("BPS"))); | ||
135 | 131 | ||
136 | Boolean issuccess = nullIsNotFound(get(PceService.class) | 132 | Boolean issuccess = nullIsNotFound(get(PceService.class) |
137 | .setupPath(srcDevice, dstDevice, path.name(), listConstrnt, lspType), | 133 | .setupPath(srcDevice, dstDevice, path.name(), listConstrnt, lspType), |
... | @@ -161,19 +157,15 @@ public class PcePathWebResource extends AbstractWebResource { | ... | @@ -161,19 +157,15 @@ public class PcePathWebResource extends AbstractWebResource { |
161 | ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); | 157 | ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); |
162 | JsonNode pathNode = jsonTree.get("path"); | 158 | JsonNode pathNode = jsonTree.get("path"); |
163 | PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this); | 159 | PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this); |
164 | - // Assign cost | ||
165 | List<Constraint> constrntList = new LinkedList<Constraint>(); | 160 | List<Constraint> constrntList = new LinkedList<Constraint>(); |
166 | - //TODO: need to uncomment below lines once CostConstraint class is ready | 161 | + // Assign bandwidth |
167 | - if (path.costConstraint() != null) { | 162 | + if (path.bandwidthConstraint() != null) { |
168 | - //CostConstraint.Type costType = CostConstraint.Type.values()[path.constraint().cost()]; | 163 | + constrntList.add(path.bandwidthConstraint()); |
169 | - //constrntList.add(CostConstraint.of(costType)); | ||
170 | } | 164 | } |
171 | 165 | ||
172 | - // Assign bandwidth. Data rate unit is in BPS. | 166 | + // Assign cost |
173 | - if (path.bandwidthConstraint() != null) { | 167 | + if (path.costConstraint() != null) { |
174 | - //TODO: need to uncomment below lines once BandwidthConstraint class is ready | 168 | + constrntList.add(path.costConstraint()); |
175 | - //constrntList.add(LocalBandwidthConstraint | ||
176 | - // .of(path.constraint().bandwidth(), DataRateUnit.valueOf("BPS"))); | ||
177 | } | 169 | } |
178 | 170 | ||
179 | Boolean result = nullIsNotFound(get(PceService.class).updatePath(TunnelId.valueOf(id), constrntList), | 171 | Boolean result = nullIsNotFound(get(PceService.class).updatePath(TunnelId.valueOf(id), constrntList), | ... | ... |
... | @@ -21,7 +21,11 @@ import org.junit.Test; | ... | @@ -21,7 +21,11 @@ import org.junit.Test; |
21 | import static org.hamcrest.MatcherAssert.assertThat; | 21 | import static org.hamcrest.MatcherAssert.assertThat; |
22 | import static org.hamcrest.Matchers.is; | 22 | import static org.hamcrest.Matchers.is; |
23 | 23 | ||
24 | +import com.google.common.testing.EqualsTester; | ||
25 | + | ||
24 | import org.onosproject.incubator.net.tunnel.TunnelId; | 26 | import org.onosproject.incubator.net.tunnel.TunnelId; |
27 | +import org.onosproject.pce.pceservice.constraint.CostConstraint; | ||
28 | +import org.onosproject.net.intent.constraint.BandwidthConstraint; | ||
25 | 29 | ||
26 | /** | 30 | /** |
27 | * Unit tests for DefaultPcePath class. | 31 | * Unit tests for DefaultPcePath class. |
... | @@ -78,8 +82,8 @@ public class DefaultPcePathTest { | ... | @@ -78,8 +82,8 @@ public class DefaultPcePathTest { |
78 | .bandwidthConstraint(bandwidth2) | 82 | .bandwidthConstraint(bandwidth2) |
79 | .build(); | 83 | .build(); |
80 | path2.id(TunnelId.valueOf("2")); | 84 | path2.id(TunnelId.valueOf("2")); |
81 | - //TODO: will be uncommented below line once CostConstraint and LocalBandwidthConstraint classes are ready | 85 | + |
82 | - //new EqualsTester().addEqualityGroup(path1, samePath1).addEqualityGroup(path2).testEquals(); | 86 | + new EqualsTester().addEqualityGroup(path1, samePath1).addEqualityGroup(path2).testEquals(); |
83 | } | 87 | } |
84 | 88 | ||
85 | /** | 89 | /** |
... | @@ -91,7 +95,7 @@ public class DefaultPcePathTest { | ... | @@ -91,7 +95,7 @@ public class DefaultPcePathTest { |
91 | final String bandwidth = "600"; | 95 | final String bandwidth = "600"; |
92 | final String src = "indiatimes"; | 96 | final String src = "indiatimes"; |
93 | final String dst = "deccan"; | 97 | final String dst = "deccan"; |
94 | - final String type = "3"; | 98 | + final String type = "2"; |
95 | final String name = "pcc4"; | 99 | final String name = "pcc4"; |
96 | 100 | ||
97 | PcePath path = DefaultPcePath.builder() | 101 | PcePath path = DefaultPcePath.builder() |
... | @@ -103,12 +107,14 @@ public class DefaultPcePathTest { | ... | @@ -103,12 +107,14 @@ public class DefaultPcePathTest { |
103 | .bandwidthConstraint(bandwidth) | 107 | .bandwidthConstraint(bandwidth) |
104 | .build(); | 108 | .build(); |
105 | 109 | ||
106 | - assertThat(src, is(path.source())); | 110 | + assertThat(path.source(), is(src)); |
107 | - assertThat(dst, is(path.destination())); | 111 | + assertThat(path.destination(), is(dst)); |
108 | - assertThat(LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR, is(path.lspType())); | 112 | + assertThat(path.lspType(), is(LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR)); |
109 | - assertThat(name, is(path.name())); | 113 | + assertThat(path.name(), is(name)); |
110 | - //TODO: will be uncommented below lines once CostConstraint and LocalBandwidthConstraint classes are ready | 114 | + CostConstraint costConstExpected = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(cost) - 1]); |
111 | - //assertThat(cost, is(path.costConstraint().toString())); | 115 | + CostConstraint costConstActual = (CostConstraint) path.costConstraint(); |
112 | - //assertThat(bandwidth, is(path.bandwidthConstraint().toString())); | 116 | + assertThat(costConstActual.type(), is(costConstExpected.type())); |
117 | + BandwidthConstraint bandwidthActual = (BandwidthConstraint) path.bandwidthConstraint(); | ||
118 | + assertThat(bandwidthActual.bandwidth().bps(), is(Double.valueOf(bandwidth))); | ||
113 | } | 119 | } |
114 | } | 120 | } | ... | ... |
... | @@ -48,7 +48,6 @@ public class MockPceCodecContext implements CodecContext { | ... | @@ -48,7 +48,6 @@ public class MockPceCodecContext implements CodecContext { |
48 | @SuppressWarnings("unchecked") | 48 | @SuppressWarnings("unchecked") |
49 | @Override | 49 | @Override |
50 | public <T> T getService(Class<T> serviceClass) { | 50 | public <T> T getService(Class<T> serviceClass) { |
51 | - // TODO | ||
52 | return null; | 51 | return null; |
53 | } | 52 | } |
54 | 53 | ... | ... |
... | @@ -24,8 +24,13 @@ import java.io.InputStream; | ... | @@ -24,8 +24,13 @@ import java.io.InputStream; |
24 | 24 | ||
25 | import org.junit.Before; | 25 | import org.junit.Before; |
26 | import org.junit.Test; | 26 | import org.junit.Test; |
27 | + | ||
28 | +import org.onlab.util.DataRateUnit; | ||
27 | import org.onosproject.codec.JsonCodec; | 29 | import org.onosproject.codec.JsonCodec; |
28 | import org.onosproject.pce.pceservice.PcePath; | 30 | import org.onosproject.pce.pceservice.PcePath; |
31 | +import org.onosproject.net.intent.constraint.BandwidthConstraint; | ||
32 | +import org.onosproject.net.intent.Constraint; | ||
33 | +import org.onosproject.pce.pceservice.constraint.CostConstraint; | ||
29 | 34 | ||
30 | import com.fasterxml.jackson.databind.JsonNode; | 35 | import com.fasterxml.jackson.databind.JsonNode; |
31 | import com.fasterxml.jackson.databind.ObjectMapper; | 36 | import com.fasterxml.jackson.databind.ObjectMapper; |
... | @@ -80,9 +85,15 @@ public class PcePathCodecTest { | ... | @@ -80,9 +85,15 @@ public class PcePathCodecTest { |
80 | 85 | ||
81 | assertThat(pcePath.source().toString(), is("11.0.0.1")); | 86 | assertThat(pcePath.source().toString(), is("11.0.0.1")); |
82 | assertThat(pcePath.destination(), is("11.0.0.2")); | 87 | assertThat(pcePath.destination(), is("11.0.0.2")); |
83 | - assertThat(pcePath.lspType().toString(), is("SR_WITHOUT_SIGNALLING")); | 88 | + assertThat(pcePath.lspType().toString(), is("WITHOUT_SIGNALLING_AND_WITHOUT_SR")); |
84 | - //TODO: uncomment below lines once CostConstraint and LocalBandwidthConstraint are ready | 89 | + // testing cost type |
85 | - //assertThat(pcePath.costConstraint().toString(), is(2)); | 90 | + String cost = "2"; |
86 | - //assertThat(pcePath.bandwidthConstraint().toString(), is(200.0)); | 91 | + Constraint costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(cost) - 1]); |
92 | + assertThat(pcePath.costConstraint(), is(costConstraint)); | ||
93 | + // testing bandwidth | ||
94 | + String bandwidth = "200"; | ||
95 | + Constraint bandwidthConstraint = BandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit | ||
96 | + .valueOf("BPS")); | ||
97 | + assertThat(pcePath.bandwidthConstraint(), is(bandwidthConstraint)); | ||
87 | } | 98 | } |
88 | } | 99 | } | ... | ... |
... | @@ -21,15 +21,14 @@ import static org.easymock.EasyMock.expect; | ... | @@ -21,15 +21,14 @@ import static org.easymock.EasyMock.expect; |
21 | import static org.easymock.EasyMock.replay; | 21 | import static org.easymock.EasyMock.replay; |
22 | import static org.hamcrest.Matchers.containsString; | 22 | import static org.hamcrest.Matchers.containsString; |
23 | import static org.hamcrest.Matchers.is; | 23 | import static org.hamcrest.Matchers.is; |
24 | -//TODO: below imports needs to be uncommented once TODO in DefaultPcePath class are removed | 24 | +import static org.hamcrest.Matchers.notNullValue; |
25 | -//import static org.hamcrest.Matchers.notNullValue; | ||
26 | import static org.junit.Assert.assertThat; | 25 | import static org.junit.Assert.assertThat; |
27 | import static org.junit.Assert.fail; | 26 | import static org.junit.Assert.fail; |
28 | 27 | ||
29 | import static org.onosproject.net.Link.Type.DIRECT; | 28 | import static org.onosproject.net.Link.Type.DIRECT; |
30 | 29 | ||
31 | -//import com.eclipsesource.json.Json; | 30 | +import com.eclipsesource.json.Json; |
32 | -//import com.eclipsesource.json.JsonObject; | 31 | +import com.eclipsesource.json.JsonObject; |
33 | 32 | ||
34 | import java.io.InputStream; | 33 | import java.io.InputStream; |
35 | import java.net.HttpURLConnection; | 34 | import java.net.HttpURLConnection; |
... | @@ -64,6 +63,7 @@ import org.onosproject.net.DefaultPath; | ... | @@ -64,6 +63,7 @@ import org.onosproject.net.DefaultPath; |
64 | import org.onosproject.net.DeviceId; | 63 | import org.onosproject.net.DeviceId; |
65 | import org.onosproject.net.Link; | 64 | import org.onosproject.net.Link; |
66 | import org.onosproject.pce.pceservice.api.PceService; | 65 | import org.onosproject.pce.pceservice.api.PceService; |
66 | +import org.onosproject.pce.pceservice.PcepAnnotationKeys; | ||
67 | import org.onosproject.net.Path; | 67 | import org.onosproject.net.Path; |
68 | import org.onosproject.net.PortNumber; | 68 | import org.onosproject.net.PortNumber; |
69 | import org.onosproject.net.provider.ProviderId; | 69 | import org.onosproject.net.provider.ProviderId; |
... | @@ -158,10 +158,16 @@ public class PcePathResourceTest extends PceResourceTest { | ... | @@ -158,10 +158,16 @@ public class PcePathResourceTest extends PceResourceTest { |
158 | // Path | 158 | // Path |
159 | path = new DefaultPath(providerId, linkList, 10); | 159 | path = new DefaultPath(providerId, linkList, 10); |
160 | 160 | ||
161 | + // Annotations | ||
162 | + DefaultAnnotations.Builder builderAnn = DefaultAnnotations.builder(); | ||
163 | + builderAnn.set(PcepAnnotationKeys.LSP_SIG_TYPE, "2"); | ||
164 | + builderAnn.set(PcepAnnotationKeys.COST_TYPE, "2"); | ||
165 | + builderAnn.set(PcepAnnotationKeys.BANDWIDTH, "200"); | ||
166 | + | ||
161 | // Tunnel | 167 | // Tunnel |
162 | tunnel = new DefaultTunnel(producerName, src, dst, Tunnel.Type.VXLAN, | 168 | tunnel = new DefaultTunnel(producerName, src, dst, Tunnel.Type.VXLAN, |
163 | Tunnel.State.ACTIVE, groupId, tunnelId, | 169 | Tunnel.State.ACTIVE, groupId, tunnelId, |
164 | - tunnelName, path); | 170 | + tunnelName, path, builderAnn.build()); |
165 | } | 171 | } |
166 | 172 | ||
167 | /** | 173 | /** |
... | @@ -190,16 +196,15 @@ public class PcePathResourceTest extends PceResourceTest { | ... | @@ -190,16 +196,15 @@ public class PcePathResourceTest extends PceResourceTest { |
190 | */ | 196 | */ |
191 | @Test | 197 | @Test |
192 | public void testGetTunnelId() { | 198 | public void testGetTunnelId() { |
193 | - //TODO: uncomment below lines once TODO in DefaultPcePath class are removed | 199 | + expect(pceService.queryPath(anyObject())) |
194 | - //expect(pceService.queryPath(anyObject())) | 200 | + .andReturn(tunnel) |
195 | - // .andReturn(tunnel) | 201 | + .anyTimes(); |
196 | - // .anyTimes(); | 202 | + replay(pceService); |
197 | - //replay(pceService); | ||
198 | 203 | ||
199 | - //WebTarget wt = target(); | 204 | + WebTarget wt = target(); |
200 | - //String response = wt.path("path/1").request().get(String.class); | 205 | + String response = wt.path("path/1").request().get(String.class); |
201 | - //JsonObject result = Json.parse(response).asObject(); | 206 | + JsonObject result = Json.parse(response).asObject(); |
202 | - //assertThat(result, notNullValue()); | 207 | + assertThat(result, notNullValue()); |
203 | } | 208 | } |
204 | 209 | ||
205 | /** | 210 | /** | ... | ... |
... | @@ -38,121 +38,99 @@ public class TunnelServiceAdapter implements TunnelService { | ... | @@ -38,121 +38,99 @@ public class TunnelServiceAdapter implements TunnelService { |
38 | 38 | ||
39 | @Override | 39 | @Override |
40 | public void addListener(TunnelListener listener) { | 40 | public void addListener(TunnelListener listener) { |
41 | - // TODO Auto-generated method stub | ||
42 | - | ||
43 | } | 41 | } |
44 | 42 | ||
45 | @Override | 43 | @Override |
46 | public void removeListener(TunnelListener listener) { | 44 | public void removeListener(TunnelListener listener) { |
47 | - // TODO Auto-generated method stub | ||
48 | - | ||
49 | } | 45 | } |
50 | 46 | ||
51 | @Override | 47 | @Override |
52 | public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { | 48 | public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { |
53 | - // TODO Auto-generated method stub | ||
54 | return null; | 49 | return null; |
55 | } | 50 | } |
56 | 51 | ||
57 | @Override | 52 | @Override |
58 | public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName, | 53 | public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName, |
59 | Annotations... annotations) { | 54 | Annotations... annotations) { |
60 | - // TODO Auto-generated method stub | ||
61 | return null; | 55 | return null; |
62 | } | 56 | } |
63 | 57 | ||
64 | @Override | 58 | @Override |
65 | public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, | 59 | public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, |
66 | Annotations... annotations) { | 60 | Annotations... annotations) { |
67 | - // TODO Auto-generated method stub | ||
68 | return null; | 61 | return null; |
69 | } | 62 | } |
70 | 63 | ||
71 | @Override | 64 | @Override |
72 | public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, | 65 | public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, |
73 | Annotations... annotations) { | 66 | Annotations... annotations) { |
74 | - // TODO Auto-generated method stub | ||
75 | return null; | 67 | return null; |
76 | } | 68 | } |
77 | 69 | ||
78 | @Override | 70 | @Override |
79 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { | 71 | public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { |
80 | - // TODO Auto-generated method stub | ||
81 | return null; | 72 | return null; |
82 | } | 73 | } |
83 | 74 | ||
84 | @Override | 75 | @Override |
85 | public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) { | 76 | public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) { |
86 | - // TODO Auto-generated method stub | ||
87 | return false; | 77 | return false; |
88 | } | 78 | } |
89 | 79 | ||
90 | @Override | 80 | @Override |
91 | public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { | 81 | public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { |
92 | - // TODO Auto-generated method stub | ||
93 | return false; | 82 | return false; |
94 | } | 83 | } |
95 | 84 | ||
96 | @Override | 85 | @Override |
97 | public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) { | 86 | public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) { |
98 | - // TODO Auto-generated method stub | ||
99 | return false; | 87 | return false; |
100 | } | 88 | } |
101 | 89 | ||
102 | @Override | 90 | @Override |
103 | public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, | 91 | public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, |
104 | Annotations... annotations) { | 92 | Annotations... annotations) { |
105 | - // TODO Auto-generated method stub | ||
106 | return false; | 93 | return false; |
107 | } | 94 | } |
108 | 95 | ||
109 | @Override | 96 | @Override |
110 | public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, | 97 | public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, |
111 | Annotations... annotations) { | 98 | Annotations... annotations) { |
112 | - // TODO Auto-generated method stub | ||
113 | return false; | 99 | return false; |
114 | } | 100 | } |
115 | 101 | ||
116 | @Override | 102 | @Override |
117 | public Tunnel queryTunnel(TunnelId tunnelId) { | 103 | public Tunnel queryTunnel(TunnelId tunnelId) { |
118 | - // TODO Auto-generated method stub | ||
119 | return null; | 104 | return null; |
120 | } | 105 | } |
121 | 106 | ||
122 | @Override | 107 | @Override |
123 | public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) { | 108 | public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) { |
124 | - // TODO Auto-generated method stub | ||
125 | return null; | 109 | return null; |
126 | } | 110 | } |
127 | 111 | ||
128 | @Override | 112 | @Override |
129 | public Collection<Tunnel> queryTunnel(Type type) { | 113 | public Collection<Tunnel> queryTunnel(Type type) { |
130 | - // TODO Auto-generated method stub | ||
131 | return null; | 114 | return null; |
132 | } | 115 | } |
133 | 116 | ||
134 | @Override | 117 | @Override |
135 | public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { | 118 | public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { |
136 | - // TODO Auto-generated method stub | ||
137 | return null; | 119 | return null; |
138 | } | 120 | } |
139 | 121 | ||
140 | @Override | 122 | @Override |
141 | public Collection<Tunnel> queryAllTunnels() { | 123 | public Collection<Tunnel> queryAllTunnels() { |
142 | - // TODO Auto-generated method stub | ||
143 | return null; | 124 | return null; |
144 | } | 125 | } |
145 | 126 | ||
146 | @Override | 127 | @Override |
147 | public int tunnelCount() { | 128 | public int tunnelCount() { |
148 | - // TODO Auto-generated method stub | ||
149 | return 0; | 129 | return 0; |
150 | } | 130 | } |
151 | 131 | ||
152 | @Override | 132 | @Override |
153 | public Iterable<Tunnel> getTunnels(DeviceId deviceId) { | 133 | public Iterable<Tunnel> getTunnels(DeviceId deviceId) { |
154 | - // TODO Auto-generated method stub | ||
155 | return null; | 134 | return null; |
156 | } | 135 | } |
157 | - | ||
158 | } | 136 | } | ... | ... |
-
Please register or login to post a comment