Exemplo n.º 1
0
def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
    parser.add_argument(
        "filter",
        nargs="*",
        default=["*.td"],
        help="limit to only the files matching filter",
    )
    args = parser.parse_args()

    c.up("materialized", "test-certs", "testdrive", "postgres")
    c.wait_for_materialized()
    c.wait_for_postgres()
    c.run("testdrive", *args.filter)
Exemplo n.º 2
0
def setup(c: Composition) -> None:
    c.up("testdrive", persistent=True)

    c.start_and_wait_for_tcp(
        services=["redpanda", "postgres-backend", "postgres-source", "debezium"]
    )
    for postgres in ["postgres-backend", "postgres-source"]:
        c.wait_for_postgres(service=postgres)

    c.sql(
        sql=f"""
       CREATE SCHEMA IF NOT EXISTS consensus;
       CREATE SCHEMA IF NOT EXISTS storage;
       CREATE SCHEMA IF NOT EXISTS adapter;
    """,
        service="postgres-backend",
        user="******",
        password="******",
    )
Exemplo n.º 3
0
def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
    parser.add_argument(
        "filter",
        nargs="*",
        default=["*.td"],
        help="limit to only the files matching filter",
    )
    args = parser.parse_args()

    ssl_ca = c.run("test-certs", "cat", "/secrets/ca.crt", capture=True).stdout
    ssl_cert = c.run("test-certs",
                     "cat",
                     "/secrets/certuser.crt",
                     capture=True).stdout
    ssl_key = c.run("test-certs", "cat", "/secrets/certuser.key",
                    capture=True).stdout
    ssl_wrong_cert = c.run("test-certs",
                           "cat",
                           "/secrets/postgres.crt",
                           capture=True).stdout
    ssl_wrong_key = c.run("test-certs",
                          "cat",
                          "/secrets/postgres.key",
                          capture=True).stdout

    c.up("materialized", "test-certs", "testdrive", "postgres")
    c.wait_for_materialized()
    c.wait_for_postgres()
    c.run(
        "testdrive",
        f"--var=ssl-ca={ssl_ca}",
        f"--var=ssl-cert={ssl_cert}",
        f"--var=ssl-key={ssl_key}",
        f"--var=ssl-wrong-cert={ssl_wrong_cert}",
        f"--var=ssl-wrong-key={ssl_wrong_key}",
        *args.filter,
    )
Exemplo n.º 4
0
def workflow_stash(c: Composition) -> None:
    c.rm(
        "testdrive",
        "materialized",
        stop=True,
        destroy_volumes=True,
    )
    c.rm_volumes("mzdata", "pgdata", force=True)

    materialized = Materialized(options=[
        "--adapter-stash-url", "postgres://*****:*****@postgres"
    ], )
    postgres = Postgres(image="postgres:14.4")

    with c.override(materialized, postgres):
        c.up("postgres")
        c.wait_for_postgres()
        c.start_and_wait_for_tcp(services=["materialized"])
        c.wait_for_materialized("materialized")

        c.sql("CREATE TABLE a (i INT)")

        c.stop("postgres")
        c.up("postgres")
        c.wait_for_postgres()

        c.sql("CREATE TABLE b (i INT)")

        c.rm("postgres", stop=True, destroy_volumes=True)
        c.up("postgres")
        c.wait_for_postgres()

        # Postgres cleared its database, so this should fail.
        try:
            c.sql("CREATE TABLE c (i INT)")
            raise Exception("expected unreachable")
        except Exception as e:
            # Depending on timing, either of these errors can occur. The stash error comes
            # from the stash complaining. The network error comes from pg8000 complaining
            # because materialize panic'd.
            if "stash error: postgres: db error" not in str(
                    e) and "network error" not in str(e):
                raise e
Exemplo n.º 5
0
def restart_pg(c: Composition) -> None:
    c.kill("postgres")
    c.up("postgres")
    c.wait_for_postgres()
Exemplo n.º 6
0
 def execute(self, c: Composition) -> None:
     c.kill("postgres-source")
     c.up("postgres-source")
     c.wait_for_postgres(service="postgres-source")
Exemplo n.º 7
0
def run_sqllogictest(c: Composition, command: str) -> None:
    c.up("postgres")
    c.wait_for_postgres(dbname="postgres")
    c.run("sqllogictest-svc", command)