protobuf-corrupted.td 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. FORMAT PROTOBUF MESSAGE '.OneInt' USING SCHEMA '${simple-schema}'
  29. ! SELECT * FROM total_garbage
  30. contains:Decode error: protobuf deserialization error: failed to decode Protobuf message: invalid wire type value: 7 (original text: garbage, original bytes: "67617262616765")
  31. $ kafka-create-topic topic=wrong-message
  32. $ kafka-ingest topic=wrong-message format=protobuf descriptor-file=simple.pb message=OneInt
  33. {"f": 1}
  34. > CREATE SOURCE wrong_message
  35. IN CLUSTER ${arg.single-replica-cluster}
  36. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-wrong-message-${testdrive.seed}')
  37. FORMAT PROTOBUF MESSAGE '.OneString' USING SCHEMA '${simple-schema}'
  38. ! SELECT * FROM wrong_message
  39. contains:Decode error: protobuf deserialization error: failed to decode Protobuf message: invalid wire type: Varint (expected LengthDelimited)