github-1744.td 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. # For Debezium versions <1.5, Materialize had no way of determining the complete order
  10. # of messages coming from a Postgres source. (Details in database-issues#1744.) We fixed this upstream
  11. # in Debezium (details in DBZ-2911) by adding a new "sequence" field to the source
  12. # metadata. This test uses that new sequence field to show that we can now handle messages
  13. # that seem to go backwards in time (by LSN).
  14. $ nop
  15. # [btv] uncomment if we bring back classic debezium mode
  16. #
  17. # $ set-arg-default single-replica-cluster=quickstart
  18. #
  19. # $ set pg-dbz-schema={
  20. # "type": "record",
  21. # "name": "envelope",
  22. # "fields": [
  23. # {
  24. # "name": "before",
  25. # "type": [
  26. # {
  27. # "name": "row",
  28. # "type": "record",
  29. # "fields": [
  30. # {"name": "val", "type": "string"}
  31. # ]
  32. # },
  33. # "null"
  34. # ]
  35. # },
  36. # { "name": "after", "type": ["row", "null"] },
  37. # { "name": "op", "type": "string" },
  38. # {
  39. # "name": "source",
  40. # "type": {
  41. # "type": "record",
  42. # "name": "Source",
  43. # "namespace": "whatever",
  44. # "fields": [
  45. # {
  46. # "name": "snapshot",
  47. # "type": [
  48. # {
  49. # "type": "string",
  50. # "connect.version": 1,
  51. # "connect.parameters": {
  52. # "allowed": "true,last,false"
  53. # },
  54. # "connect.default": "false",
  55. # "connect.name": "io.debezium.data.Enum"
  56. # },
  57. # "null"
  58. # ],
  59. # "default": "false"
  60. # },
  61. # {
  62. # "name": "lsn",
  63. # "type": ["long", "null"]
  64. # },
  65. # {
  66. # "name": "sequence",
  67. # "type": ["string", "null"]
  68. # }
  69. # ]
  70. # }
  71. # }
  72. # ]
  73. # }
  74. # $ kafka-create-topic topic=pg-dbz-data partitions=1
  75. # $ kafka-ingest format=avro topic=pg-dbz-data schema=${pg-dbz-schema} timestamp=1
  76. # {"before": null, "after": {"row":{"val": "foo"}}, "source": {"lsn": {"long": 3}, "sequence": {"string": "[\"1\", \"3\"]"}, "snapshot": {"string": "false"}}, "op": "c"}
  77. # {"before": {"row":{"val": "foo"}}, "after": {"row":{"val": "bar"}}, "source": {"lsn": {"long": 5}, "sequence": {"string": "[\"1\", \"5\"]"}, "snapshot": {"string": "false"}}, "op": "u"}
  78. # {"before": {"row":{"val": "bar"}}, "after": {"row":{"val": "baz"}}, "source": {"lsn": {"long": 7}, "sequence": {"string": "[\"1\", \"7\"]"}, "snapshot": {"string": "false"}}, "op": "u"}
  79. # {"before": null, "after": {"row":{"val": "hello,"}}, "source": {"lsn": {"long": 4}, "sequence": {"string": "[\"8\", \"4\"]"}, "snapshot": {"string": "false"}}, "op": "c"}
  80. # {"before": null, "after": {"row":{"val": "world!"}}, "source": {"lsn": {"long": 6}, "sequence": {"string": "[\"8\", \"6\"]"}, "snapshot": {"string": "false"}}, "op": "c"}
  81. # {"before": null, "after": {"row":{"val": "too late"}}, "source": {"lsn": {"long": 1}, "sequence": {"string": "[\"1\", \"1\"]"}, "snapshot": {"string": "false"}}, "op": "c"}
  82. # > CREATE CONNECTION kafka_conn
  83. # TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  84. # > CREATE SOURCE pg_dbz
  85. # IN CLUSTER ${arg.single-replica-cluster}
  86. # FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-pg-dbz-data-${testdrive.seed}')
  87. # FORMAT AVRO USING SCHEMA '${pg-dbz-schema}'
  88. # ENVELOPE DEBEZIUM
  89. # > SELECT * FROM pg_dbz
  90. # val
  91. # ---
  92. # baz
  93. # hello,
  94. # world!