protobuf-corrupted.td 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. $ set-arg-default single-replica-cluster=quickstart
  10. # Test that corrupted Protobuf messages result in sensible error messages.
  11. $ file-append path=simple.proto
  12. syntax = "proto3";
  13. message OneInt {
  14. int64 f = 1;
  15. }
  16. message OneString {
  17. string f = 1;
  18. }
  19. $ protobuf-compile-descriptors inputs=simple.proto output=simple.pb set-var=simple-schema
  20. $ kafka-create-topic topic=total-garbage
  21. $ kafka-ingest format=bytes topic=total-garbage
  22. garbage
  23. > CREATE CONNECTION kafka_conn
  24. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  25. > CREATE SOURCE total_garbage
  26. IN CLUSTER ${arg.single-replica-cluster}
  27. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-total-garbage-${testdrive.seed}')
  28. > CREATE TABLE total_garbage_tbl FROM SOURCE total_garbage (REFERENCE "testdrive-total-garbage-${testdrive.seed}")
  29. FORMAT PROTOBUF MESSAGE '.OneInt' USING SCHEMA '${simple-schema}'
  30. ! SELECT * FROM total_garbage_tbl
  31. contains:Decode error: protobuf deserialization error: failed to decode Protobuf message: invalid wire type value: 7 (original text: garbage, original bytes: "67617262616765")
  32. $ kafka-create-topic topic=wrong-message
  33. $ kafka-ingest topic=wrong-message format=protobuf descriptor-file=simple.pb message=OneInt
  34. {"f": 1}
  35. > CREATE SOURCE wrong_message
  36. IN CLUSTER ${arg.single-replica-cluster}
  37. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-wrong-message-${testdrive.seed}')
  38. > CREATE TABLE wrong_message_tbl FROM SOURCE wrong_message (REFERENCE "testdrive-wrong-message-${testdrive.seed}")
  39. FORMAT PROTOBUF MESSAGE '.OneString' USING SCHEMA '${simple-schema}'
  40. ! SELECT * FROM wrong_message_tbl
  41. contains:Decode error: protobuf deserialization error: failed to decode Protobuf message: invalid wire type: Varint (expected LengthDelimited)