correctness-property-2.td 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  10. ALTER SYSTEM SET unsafe_enable_unorchestrated_cluster_replicas = true
  11. $ set keyschema={
  12. "type": "record",
  13. "name": "Key",
  14. "fields": [
  15. {"name": "key", "type": "string"}
  16. ]
  17. }
  18. $ set schema={
  19. "type" : "record",
  20. "name" : "test",
  21. "fields" : [
  22. {"name":"f1", "type":"string"},
  23. {"name":"f2", "type":"long"}
  24. ]
  25. }
  26. $ set count=100000
  27. $ kafka-create-topic topic=correctness-data
  28. $ kafka-ingest format=avro topic=correctness-data key-format=avro key-schema=${keyschema} schema=${schema} repeat=${count} start-iteration=1
  29. {"key": "1"} {"f1": "crustycrab", "f2": ${kafka-ingest.iteration} }
  30. # Create a cluster with no replicas so that we have time to submit queries at the minimum frontier.
  31. > CREATE CLUSTER storage REPLICAS ()
  32. # Create a cluster with no replicas so that we have time to submit queries at the minimum frontier.
  33. > CREATE CONNECTION kafka_conn
  34. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT)
  35. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  36. URL '${testdrive.schema-registry-url}'
  37. );
  38. > CREATE SOURCE correctness_data
  39. IN CLUSTER storage
  40. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-correctness-data-${testdrive.seed}')
  41. WITH (RETAIN HISTORY = FOR '365000 days');
  42. > CREATE TABLE correctness_data_tbl FROM SOURCE correctness_data (REFERENCE "testdrive-correctness-data-${testdrive.seed}")
  43. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  44. ENVELOPE UPSERT;
  45. # Prime tokio-postgres with the missing OIDs.
  46. > SELECT mz_now(), * FROM correctness_data_tbl WHERE false AS OF AT LEAST 0
  47. # Grab a cursor at timestamp 0
  48. > BEGIN
  49. > DECLARE c CURSOR FOR SELECT mz_now(), * FROM correctness_data_tbl AS OF 0
  50. # Start ingestion by adding a replica to the cluster. We must do this from a
  51. # different connection to not disturbe the transaction we're in.
  52. $ postgres-execute connection=postgres://materialize:materialize@${testdrive.materialize-sql-addr}
  53. CREATE CLUSTER REPLICA storage.r1 SIZE = '1';
  54. # Verify that at timestamp 0 there is only one record whose value is the final value
  55. > FETCH 1 c WITH (timeout = '1d');
  56. 0 1 crustycrab ${count}
  57. > COMMIT