before.td 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #
  10. # A general test for use with failpoints. We ingest some data, then we activate
  11. # a parameterized failpoint and then we ingest some more.
  12. #
  13. $ set keyschema={
  14. "type": "record",
  15. "name": "Key",
  16. "fields": [
  17. {"name": "f1", "type": "string"}
  18. ]
  19. }
  20. $ set schema={
  21. "type" : "record",
  22. "name" : "test",
  23. "fields" : [
  24. {"name":"f2", "type":"string"}
  25. ]
  26. }
  27. $ kafka-create-topic topic=failpoint partitions=5
  28. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  29. {"f1": "a${kafka-ingest.iteration}"} {"f2": "a${kafka-ingest.iteration}"}
  30. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  31. {"f1": "b${kafka-ingest.iteration}"} {"f2": "b${kafka-ingest.iteration}"}
  32. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  33. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  34. URL '${testdrive.schema-registry-url}'
  35. );
  36. > CREATE SOURCE failpoint
  37. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-failpoint-${testdrive.seed}')
  38. > CREATE TABLE failpoint_tbl FROM SOURCE failpoint (REFERENCE "testdrive-failpoint-${testdrive.seed}")
  39. KEY FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  40. VALUE FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  41. INCLUDE KEY AS f1
  42. ENVELOPE UPSERT
  43. > CREATE SINK failpoint_sink FROM failpoint_tbl
  44. INTO KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-failpoint-sink-${testdrive.seed}')
  45. KEY (f1)
  46. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  47. ENVELOPE DEBEZIUM
  48. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  49. {"f1": "c${kafka-ingest.iteration}"} {"f2": "c${kafka-ingest.iteration}"}
  50. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  51. {"f1": "d${kafka-ingest.iteration}"} {"f2": "d${kafka-ingest.iteration}"}
  52. # Make sure that we read (and persisted) at least one message before activating the failpoint.
  53. > SELECT COUNT(*) > 0 FROM failpoint_tbl;
  54. true
  55. > SET failpoints = '${arg.failpoint}=${arg.action}';
  56. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  57. {"f1": "e${kafka-ingest.iteration}"} {"f2": "e${kafka-ingest.iteration}"}
  58. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  59. {"f1": "f${kafka-ingest.iteration}"} {"f2": "f${kafka-ingest.iteration}"}
  60. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  61. {"f1": "g${kafka-ingest.iteration}"} {"f2": "g${kafka-ingest.iteration}"}
  62. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  63. {"f1": "h${kafka-ingest.iteration}"} {"f2": "h${kafka-ingest.iteration}"}
  64. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  65. {"f1": "i${kafka-ingest.iteration}"} {"f2": "i${kafka-ingest.iteration}"}
  66. $ kafka-ingest format=avro topic=failpoint key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  67. {"f1": "j${kafka-ingest.iteration}"} {"f2": "j${kafka-ingest.iteration}"}