test-schema-registry-basic.td 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 up. <==
  10. > CREATE SECRET password AS 'sekurity'
  11. > CREATE SECRET password_wrong AS 'wrong'
  12. > CREATE CONNECTION kafka to KAFKA (
  13. BROKER 'kafka:9092',
  14. SECURITY PROTOCOL PLAINTEXT
  15. )
  16. $ set schema={
  17. "name": "row",
  18. "type": "record",
  19. "fields": [
  20. {"name": "a", "type": "long"}
  21. ]
  22. }
  23. $ kafka-create-topic topic=avro-data
  24. $ kafka-ingest topic=avro-data format=avro schema=${schema}
  25. {"a": 1}
  26. # ==> Test invalid configurations. <==
  27. ! CREATE CONNECTION schema_registry_invalid TO CONFLUENT SCHEMA REGISTRY (
  28. URL 'http://basic.schema-registry.local:8081',
  29. USERNAME 'materialize',
  30. PASSWORD SECRET password_wrong
  31. )
  32. contains:server error 401: Unauthorized
  33. # ==> Test without an SSH tunnel. <==
  34. > CREATE CONNECTION schema_registry TO CONFLUENT SCHEMA REGISTRY (
  35. URL 'http://basic.schema-registry.local:8081',
  36. USERNAME 'materialize',
  37. PASSWORD SECRET password
  38. )
  39. > CREATE SOURCE avro_data FROM KAFKA CONNECTION kafka (
  40. TOPIC 'testdrive-avro-data-${testdrive.seed}'
  41. )
  42. > CREATE TABLE avro_data_tbl FROM SOURCE avro_data (REFERENCE "testdrive-avro-data-${testdrive.seed}")
  43. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION schema_registry
  44. > SELECT * FROM avro_data_tbl
  45. a
  46. ----
  47. 1
  48. # ==> Test with an SSH tunnel. <==
  49. > CREATE CONNECTION schema_registry_ssh TO CONFLUENT SCHEMA REGISTRY (
  50. URL 'http://basic.schema-registry.local:8081',
  51. USERNAME 'materialize',
  52. PASSWORD SECRET password,
  53. SSH TUNNEL testdrive_no_reset_connections.public.ssh
  54. )
  55. > CREATE SOURCE avro_data_ssh FROM KAFKA CONNECTION kafka (
  56. TOPIC 'testdrive-avro-data-${testdrive.seed}'
  57. )
  58. > CREATE TABLE avro_data_ssh_tbl FROM SOURCE avro_data_ssh (REFERENCE "testdrive-avro-data-${testdrive.seed}")
  59. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION schema_registry
  60. > SELECT * FROM avro_data_ssh_tbl
  61. a
  62. ----
  63. 1