Repository: risingwavelabs/risingwave
File: ci/scripts/e2e-sink-test.sh (Shell)

Code before:
# Use ci-inline-source-test since it will configure ports, db, host etc... env vars via risedev-env.
# These are required for cli tools like psql have env vars correctly configured.
risedev ci-start ci-inline-source-test

echo "--- check connectivity for postgres"
PGPASSWORD='post\tgres' psql -h db -U postgres -d postgres -p 5432 -c "SELECT 1;"

echo "--- dumping risedev-env"
echo "risedev-env:"
risedev show-risedev-env

# MUST use risedev slt, not sqllogictest, else env var not loaded and test fails.
echo "--- testing postgres_sink"
risedev slt './e2e_test/sink/postgres_sink.slt'

echo "--- testing common sinks"
risedev slt './e2e_test/sink/append_only_sink.slt'
risedev slt './e2e_test/sink/create_sink_as.slt'
risedev slt './e2e_test/sink/blackhole_sink.slt'
risedev slt './e2e_test/sink/remote/types.slt'
risedev slt './e2e_test/sink/sink_into_table/*.slt'
risedev slt './e2e_test/sink/file_sink.slt'
risedev slt './e2e_test/sink/license.slt'
risedev slt './e2e_test/sink/rate_limit.slt'
risedev slt './e2e_test/sink/auto_schema_change.slt'
risedev slt 'e2e_test/sink/kafka/test_bytes_format.slt'
risedev slt './e2e_test/sink/sink_vector_columns.slt'
risedev slt './e2e_test/sink/force_compaction_sink.slt'
sleep 1

echo "--- preparing postgresql"
prepare_pg

echo "--- testing remote sinks"

# check sink destination postgres
risedev slt './e2e_test/sink/remote/jdbc.load.slt'
sleep 1
SLT_PASSWORD=$PGPASSWORD sqllogictest -h db -p 5432 -d test './e2e_test/sink/remote/jdbc.check.pg.slt' --label 'jdbc'
sleep 1

# check sink destination mysql using shell
diff -u ./e2e_test/sink/remote/mysql_expected_result_0.tsv \
<(mysql --host=mysql --port=3306 -u root -p123456 -s -N -r test -e "SELECT * FROM test.t_remote_0 ORDER BY id")
if [ $? -eq 0 ]; then
  echo "mysql sink check 0 passed"
else
  echo "The output is not as expected."
  exit 1
fi


Review comment (suggestion):
Maybe this shall be added here instead (and I am wondering whether we can make it a wildcard - not required in this PR):
https://github.com/risingwavelabs/risingwave/blob/7692aa89c56c0236613b4d57e3d3da28170837a9/ci/scripts/e2e-kafka-sink-test.sh#L149-L163

Code after:
# Use ci-inline-source-test since it will configure ports, db, host etc... env vars via risedev-env.
# These are required for cli tools like psql have env vars correctly configured.
risedev ci-start ci-inline-source-test

echo "--- check connectivity for postgres"
PGPASSWORD='post\tgres' psql -h db -U postgres -d postgres -p 5432 -c "SELECT 1;"

echo "--- dumping risedev-env"
echo "risedev-env:"
risedev show-risedev-env

# MUST use risedev slt, not sqllogictest, else env var not loaded and test fails.
echo "--- testing postgres_sink"
risedev slt './e2e_test/sink/postgres_sink.slt'

echo "--- testing common sinks"
risedev slt './e2e_test/sink/append_only_sink.slt'
risedev slt './e2e_test/sink/create_sink_as.slt'
risedev slt './e2e_test/sink/blackhole_sink.slt'
risedev slt './e2e_test/sink/remote/types.slt'
risedev slt './e2e_test/sink/sink_into_table/*.slt'
risedev slt './e2e_test/sink/file_sink.slt'
risedev slt './e2e_test/sink/license.slt'
risedev slt './e2e_test/sink/rate_limit.slt'
risedev slt './e2e_test/sink/auto_schema_change.slt'
risedev slt './e2e_test/sink/sink_vector_columns.slt'
risedev slt './e2e_test/sink/force_compaction_sink.slt'
sleep 1

echo "--- preparing postgresql"
prepare_pg

echo "--- testing remote sinks"

# check sink destination postgres
risedev slt './e2e_test/sink/remote/jdbc.load.slt'
sleep 1
SLT_PASSWORD=$PGPASSWORD sqllogictest -h db -p 5432 -d test './e2e_test/sink/remote/jdbc.check.pg.slt' --label 'jdbc'
sleep 1

# check sink destination mysql using shell
diff -u ./e2e_test/sink/remote/mysql_expected_result_0.tsv \
<(mysql --host=mysql --port=3306 -u root -p123456 -s -N -r test -e "SELECT * FROM test.t_remote_0 ORDER BY id")
if [ $? -eq 0 ]; then
  echo "mysql sink check 0 passed"
else
  echo "The output is not as expected."
  exit 1
fi

diff -u ./e2e_test/sink/remote/mysql_expected_result_1.tsv \