From 9b42fb05de7b04e0cbb5dfe87048b11f2e9179ee Mon Sep 17 00:00:00 2001 From: Noel Kwan <47273164+kwannoel@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:49:50 +0800 Subject: [PATCH] test: refactor pg tvf tests into inline tests (#19004) --- ci/docker-compose.yml | 1 + ci/scripts/e2e-source-test.sh | 3 --- ci/workflows/pull-request.yml | 2 +- .../tvf/postgres_query.slt | 11 ++++++++--- risedev.yml | 6 ++++++ src/risedevtool/src/risedev_env.rs | 2 +- 6 files changed, 17 insertions(+), 8 deletions(-) rename e2e_test/{source_legacy => source_inline}/tvf/postgres_query.slt (85%) diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml index d89459bc02865..e185f8a93c384 100644 --- a/ci/docker-compose.yml +++ b/ci/docker-compose.yml @@ -1,4 +1,5 @@ services: + # TODO: Rename this to `postgres` db: image: postgres:15-alpine environment: diff --git a/ci/scripts/e2e-source-test.sh b/ci/scripts/e2e-source-test.sh index c684491685526..4491db5633ea8 100755 --- a/ci/scripts/e2e-source-test.sh +++ b/ci/scripts/e2e-source-test.sh @@ -139,9 +139,6 @@ risedev slt './e2e_test/source_legacy/cdc/cdc.check_new_rows.slt' # drop relations risedev slt './e2e_test/source_legacy/cdc/cdc_share_stream_drop.slt' -echo "--- postgres_query tvf test" -risedev slt './e2e_test/source_legacy/tvf/postgres_query.slt' - echo "--- Kill cluster" risedev ci-kill export RISINGWAVE_CI=true diff --git a/ci/workflows/pull-request.yml b/ci/workflows/pull-request.yml index a2f926e9389d6..9ed1237774eeb 100644 --- a/ci/workflows/pull-request.yml +++ b/ci/workflows/pull-request.yml @@ -201,7 +201,7 @@ steps: mount-buildkite-agent: true upload-container-logs: always - ./ci/plugins/upload-failure-logs - timeout_in_minutes: 18 + timeout_in_minutes: 20 retry: *auto-retry - label: "end-to-end sink test" diff --git a/e2e_test/source_legacy/tvf/postgres_query.slt b/e2e_test/source_inline/tvf/postgres_query.slt similarity index 85% rename from e2e_test/source_legacy/tvf/postgres_query.slt rename to e2e_test/source_inline/tvf/postgres_query.slt index 0ce577535b923..88e508e442474 100644 --- a/e2e_test/source_legacy/tvf/postgres_query.slt +++ b/e2e_test/source_inline/tvf/postgres_query.slt @@ -1,5 +1,10 @@ +control substitution on + +system ok +PGDATABASE=source_test createdb + system ok -PGHOST=db PGPORT=5432 PGUSER=postgres PGPASSWORD=postgres PGDATABASE=cdc_test psql -c " +PGDATABASE=source_test psql -c " CREATE TABLE test ( id bigint primary key, v1 bool, @@ -21,12 +26,12 @@ CREATE TABLE test ( );" system ok -PGHOST=db PGPORT=5432 PGUSER=postgres PGPASSWORD=postgres PGDATABASE=cdc_test psql -c " +PGDATABASE=source_test psql -c " INSERT INTO test SELECT generate_series(1, 100), true, 1, 1, 1, 1.0, 1.0, 1.0, '2021-01-01', '00:00:00', '2021-01-01 00:00:00', '2021-01-01 00:00:00 pst', 'text', 'varchar', '1 day', '{}', '\x01'; " query II -select * from postgres_query('db', '5432', 'postgres', 'postgres', 'cdc_test', 'select * from test where id > 90;'); +select * from postgres_query('$PGHOST', '$PGPORT', '$PGUSER', '$PGPASSWORD', 'source_test', 'select * from test where id > 90;'); ---- 91 t 1 1 1 1 1 1.0 2021-01-01 00:00:00 2021-01-01 00:00:00 2021-01-01 08:00:00+00:00 text varchar 1 day {} \x01 92 t 1 1 1 1 1 1.0 2021-01-01 00:00:00 2021-01-01 00:00:00 2021-01-01 08:00:00+00:00 text varchar 1 day {} \x01 diff --git a/risedev.yml b/risedev.yml index dd3f69a1acf62..82ce9ac3d72f2 100644 --- a/risedev.yml +++ b/risedev.yml @@ -870,6 +870,12 @@ profile: user: root password: 123456 user-managed: true + - use: postgres + port: 5432 + address: db + user: postgres + password: postgres + user-managed: true ci-redis: config-path: src/config/ci.toml diff --git a/src/risedevtool/src/risedev_env.rs b/src/risedevtool/src/risedev_env.rs index 4860d30e01485..5d7c113b6bc30 100644 --- a/src/risedevtool/src/risedev_env.rs +++ b/src/risedevtool/src/risedev_env.rs @@ -105,7 +105,7 @@ pub fn generate_risedev_env(services: &Vec) -> String { writeln!(env, r#"PUBSUB_EMULATOR_HOST="{address}:{port}""#,).unwrap(); writeln!(env, r#"RISEDEV_PUBSUB_WITH_OPTIONS_COMMON="connector='google_pubsub',pubsub.emulator_host='{address}:{port}'""#,).unwrap(); } - ServiceConfig::Postgres(c) if c.application != Application::Metastore => { + ServiceConfig::Postgres(c) => { let host = &c.address; let port = &c.port; let user = &c.user;