pg-source-ssl.td 1.3 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. # Test creating a Postgres source using SSH
  10. > CREATE SECRET pgpass AS 'postgres'
  11. > CREATE CONNECTION pg TO POSTGRES (
  12. HOST postgres,
  13. DATABASE postgres,
  14. USER postgres,
  15. PASSWORD SECRET pgpass,
  16. SSL MODE require,
  17. SSH TUNNEL thancred
  18. );
  19. $ postgres-execute connection=postgres://postgres:postgres@postgres
  20. ALTER USER postgres WITH replication;
  21. DROP SCHEMA IF EXISTS public CASCADE;
  22. DROP PUBLICATION IF EXISTS mz_source;
  23. CREATE SCHEMA public;
  24. CREATE TABLE t1 (f1 INTEGER);
  25. ALTER TABLE t1 REPLICA IDENTITY FULL;
  26. INSERT INTO t1 VALUES (1);
  27. CREATE PUBLICATION mz_source FOR ALL TABLES;
  28. > CREATE SOURCE mz_source
  29. FROM POSTGRES CONNECTION pg
  30. (PUBLICATION 'mz_source');
  31. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE t1);
  32. > SELECT COUNT(*) = 1 FROM t1;
  33. true
  34. > SELECT f1 FROM t1;
  35. 1
  36. $ postgres-execute connection=postgres://postgres:postgres@postgres
  37. INSERT INTO t1 VALUES (1), (2);
  38. > SELECT f1 FROM t1 ORDER BY f1 ASC;
  39. 1
  40. 1
  41. 2