use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPceBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testRepWithMonitoring.
@Test
public void testRepWithMonitoring() throws IOException, PCEPDeserializerException {
final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder rBuilder = new RepliesBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRepMon.5.bin"));
final List<Replies> replies4 = Lists.newArrayList();
rBuilder = new RepliesBuilder();
rBuilder.setRp(this.rpTrue);
rBuilder.setMonitoring(this.monitoring);
rBuilder.setPccIdReq(this.pccIdReq);
rBuilder.setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build()));
final List<Paths> paths = Lists.newArrayList();
final PathsBuilder paBuilder = new PathsBuilder();
paBuilder.setEro(this.ero);
paBuilder.setLspa(this.lspa);
paBuilder.setMetrics(Lists.newArrayList(this.metrics));
paBuilder.setIro(this.iro);
paBuilder.setOf(this.of);
paths.add(paBuilder.build());
rBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
replies4.add(rBuilder.build());
builder.setReplies(replies4);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPceBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testMonRepMsg.
@Test
public void testMonRepMsg() throws PCEPDeserializerException, IOException {
final PCEPMonitoringReplyMessageParser parser = new PCEPMonitoringReplyMessageParser(this.objectRegistry);
final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder();
builder.setMonitoring(this.monitoring);
builder.setMonitoringMetricsList(new GeneralMetricsListBuilder().setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build())).build());
final byte[] msgBytes = { 0x20, 0x09, 0x00, 0x18, /* monitoring object */
0x13, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, /* pce-id object */
0x19, 0x10, 0x00, 0x08, 0x7f, 0x00, 0x00, 0x02 };
ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
assertEquals(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
builder.setMonitoring(this.monitoring);
builder.setPccIdReq(this.pccIdReq);
final SpecificMetricsBuilder smBuilder = new SpecificMetricsBuilder();
smBuilder.setRp(this.rpTrue);
final List<MetricPce> metricPces = Lists.newArrayList();
metricPces.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId).setProcTime(this.procTime).build());
metricPces.add(new MetricPceBuilder().setPceId(this.pceId).setProcTime(this.procTime).build());
smBuilder.setMetricPce(metricPces);
final SpecificMetricsBuilder smBuilder2 = new SpecificMetricsBuilder();
final List<MetricPce> metricPces2 = Lists.newArrayList();
smBuilder2.setRp(this.rpTrue);
metricPces2.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId).build());
smBuilder2.setMetricPce(metricPces2);
builder.setMonitoringMetricsList(new SpecificMetricsListBuilder().setSpecificMetrics(Lists.newArrayList(smBuilder.build(), smBuilder2.build())).build());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCMonRep.bin"));
assertEquals(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPceBuilder in project bgpcep by opendaylight.
the class Util method validateMonitoringMetrics.
public static MetricPce validateMonitoringMetrics(final List<Object> objects) throws PCEPDeserializerException {
final MetricPceBuilder metricPceBuilder = new MetricPceBuilder();
if (!(objects.get(0) instanceof PceId)) {
throw new PCEPDeserializerException("metric-pce-list must start with PCE-ID object.");
}
metricPceBuilder.setPceId((PceId) (objects.get(0)));
objects.remove(0);
State state = State.START;
while (!objects.isEmpty() && !state.equals(State.END)) {
final Object obj = objects.get(0);
state = insertObject(metricPceBuilder, state, obj);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
return metricPceBuilder.build();
}
Aggregations