kafka-counters-before.td 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # Insert 10K values prior to restart and check that we never re-ingest
  11. # the entire topic as observed by the librdkafka counters
  12. #
  13. $ set count=10000
  14. $ set keyschema={
  15. "type": "record",
  16. "name": "Key",
  17. "fields": [
  18. {"name": "f1", "type": "string"}
  19. ]
  20. }
  21. $ set schema={
  22. "type" : "record",
  23. "name" : "test",
  24. "fields" : [
  25. {"name":"f2", "type":"string"}
  26. ]
  27. }
  28. $ kafka-create-topic topic=kafka-counters
  29. $ kafka-ingest format=avro topic=kafka-counters key-format=avro key-schema=${keyschema} schema=${schema} repeat=${count}
  30. {"f1": "a${kafka-ingest.iteration}"} {"f2": "a${kafka-ingest.iteration}"}
  31. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  32. URL '${testdrive.schema-registry-url}'
  33. );
  34. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  35. > CREATE SOURCE kafka_counters
  36. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-kafka-counters-${testdrive.seed}')
  37. > CREATE TABLE kafka_counters_tbl FROM SOURCE kafka_counters (REFERENCE "testdrive-kafka-counters-${testdrive.seed}")
  38. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  39. ENVELOPE UPSERT
  40. > SELECT COUNT(*) FROM kafka_counters_tbl;
  41. "${count}"