fix: archive gb32960 decode failures
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -97,6 +97,29 @@ class Gb32960ChannelHandlerAckBoundaryTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void decodeFailureIsArchivedWithParseErrorMetadata() {
|
||||
try (DispatchHarness dispatch = new DispatchHarness()) {
|
||||
EmbeddedChannel channel = new EmbeddedChannel(handlerWith(dispatch.dispatcher()));
|
||||
byte[] malformed = new byte[]{0x23, 0x23, 0x02};
|
||||
|
||||
assertThat(channel.writeInbound(malformed)).isFalse();
|
||||
|
||||
dispatch.awaitPublishCount(1);
|
||||
VehicleEvent event = dispatch.event(0);
|
||||
assertThat(event).isInstanceOf(VehicleEvent.RawArchive.class);
|
||||
VehicleEvent.RawArchive raw = (VehicleEvent.RawArchive) event;
|
||||
assertThat(raw.source()).isEqualTo(com.lingniu.ingest.api.ProtocolId.GB32960);
|
||||
assertThat(raw.command()).isZero();
|
||||
assertThat(raw.rawBytes()).containsExactly(malformed);
|
||||
assertThat(raw.metadata())
|
||||
.containsEntry("vin", "unknown")
|
||||
.containsEntry("parseError", "true")
|
||||
.containsKey("parseErrorMessage");
|
||||
channel.finishAndReleaseAll();
|
||||
}
|
||||
}
|
||||
|
||||
private static ByteBuf readOutboundAfterRunningTasks(EmbeddedChannel channel) {
|
||||
long deadline = System.currentTimeMillis() + 3000;
|
||||
while (System.currentTimeMillis() < deadline) {
|
||||
@@ -190,6 +213,12 @@ class Gb32960ChannelHandlerAckBoundaryTest {
|
||||
throw new AssertionError("expected " + count + " sink publishes, actual=" + sink.futures.size());
|
||||
}
|
||||
|
||||
VehicleEvent event(int index) {
|
||||
synchronized (sink.futures) {
|
||||
return sink.events.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
batchExecutor.close();
|
||||
@@ -199,6 +228,7 @@ class Gb32960ChannelHandlerAckBoundaryTest {
|
||||
|
||||
private static final class ControlledSink implements EventSink {
|
||||
private final List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
private final List<VehicleEvent> events = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
@@ -209,6 +239,7 @@ class Gb32960ChannelHandlerAckBoundaryTest {
|
||||
public CompletableFuture<Void> publish(VehicleEvent event) {
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
synchronized (futures) {
|
||||
events.add(event);
|
||||
futures.add(future);
|
||||
}
|
||||
return future;
|
||||
|
||||
Reference in New Issue
Block a user