test_smoke.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. from textwrap import dedent
  10. from materialize.cloudtest.app.materialize_application import MaterializeApplication
  11. from materialize.cloudtest.util.wait import wait
  12. def test_wait(mz: MaterializeApplication) -> None:
  13. wait(
  14. condition="condition=Ready",
  15. resource="pod",
  16. label="cluster.environmentd.materialize.cloud/cluster-id=u1",
  17. )
  18. def test_sql(mz: MaterializeApplication) -> None:
  19. mz.environmentd.sql("SELECT 1")
  20. one = mz.environmentd.sql_query("SELECT 1")[0][0]
  21. assert int(one) == 1
  22. def test_testdrive(mz: MaterializeApplication) -> None:
  23. mz.testdrive.copy("test/testdrive", "/workdir")
  24. mz.testdrive.run("testdrive/testdrive.td")
  25. mz.testdrive.run(
  26. input=dedent(
  27. """
  28. $ kafka-create-topic topic=test
  29. $ kafka-ingest format=bytes topic=test
  30. ABC
  31. > CREATE TABLE t1 (f1 INTEGER);
  32. > CREATE DEFAULT INDEX ON t1;
  33. > INSERT INTO t1 VALUES (1);
  34. > CREATE CLUSTER c1 REPLICAS (r1 (SIZE '1'), r2 (SIZE '2-2'));
  35. > CREATE CLUSTER c2 SIZE '1', REPLICATION FACTOR 2;
  36. > SET cluster=c1
  37. > CREATE CONNECTION kafka TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT)
  38. > CREATE SOURCE s1
  39. IN CLUSTER c2
  40. FROM KAFKA CONNECTION kafka
  41. (TOPIC 'testdrive-test-${testdrive.seed}');
  42. > CREATE TABLE s1_tbl FROM SOURCE s1 (REFERENCE "testdrive-test-${testdrive.seed}")
  43. FORMAT BYTES
  44. ENVELOPE NONE;
  45. > CREATE MATERIALIZED VIEW v1 AS SELECT COUNT(*) FROM t1;
  46. > SELECT * FROM v1;
  47. 1
  48. > CREATE MATERIALIZED VIEW v2 AS SELECT COUNT(*) FROM s1_tbl;
  49. > SELECT * FROM v2;
  50. 1
  51. > DROP CLUSTER c1 CASCADE;
  52. """
  53. )
  54. )