diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b3e7fe463..f4ac272b26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -183,6 +183,7 @@ jobs: "source-mysql-batch", "source-postgres", "source-postgres-batch", + "source-redshift-batch", "source-sftp", "source-sqlserver", "source-mongodb" diff --git a/source-redshift-batch/Dockerfile b/source-redshift-batch/Dockerfile index 6ea9c9a264..92ed505252 100644 --- a/source-redshift-batch/Dockerfile +++ b/source-redshift-batch/Dockerfile @@ -20,7 +20,9 @@ RUN go install -v github.com/jackc/pgx/v5 # Run tests and build the connector COPY source-redshift-batch ./source-redshift-batch -RUN go test -v ./source-redshift-batch/... +ARG TEST_DATABASE=yes +ENV TEST_DATABASE=$TEST_DATABASE +RUN go test -short -failfast -v ./source-redshift-batch/... RUN go build -o ./connector -v ./source-redshift-batch/... # Runtime Stage diff --git a/source-redshift-batch/docker-compose.yaml b/source-redshift-batch/docker-compose.yaml new file mode 100644 index 0000000000..9b99a6f993 --- /dev/null +++ b/source-redshift-batch/docker-compose.yaml @@ -0,0 +1,30 @@ +services: + db: + image: 'postgres:latest' + command: [ "postgres" ] + ports: + - "5432:5432" + environment: + { + "POSTGRES_DB": "postgres", + "POSTGRES_USER": "postgres", + "POSTGRES_PASSWORD": "postgres" + } + healthcheck: + test: "true" + interval: 3s + networks: + - flow-test + volumes: + - type: bind + source: ./docker-initdb.sh + target: /docker-entrypoint-initdb.d/init-user-db.sh + - postgres_data:/var/lib/postgresql/data + +networks: + flow-test: + name: flow-test + external: true + +volumes: + postgres_data: {} diff --git a/source-redshift-batch/docker-initdb.sh b/source-redshift-batch/docker-initdb.sh new file mode 100755 index 0000000000..ca9a0ab9df --- /dev/null +++ b/source-redshift-batch/docker-initdb.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER flow_capture WITH PASSWORD 'secret1234' REPLICATION; + + CREATE SCHEMA IF NOT EXISTS test; + GRANT USAGE ON SCHEMA test TO flow_capture; + ALTER DEFAULT PRIVILEGES IN SCHEMA test GRANT SELECT ON TABLES to flow_capture; + GRANT SELECT ON ALL TABLES IN SCHEMA test TO flow_capture; + + GRANT CREATE, USAGE ON SCHEMA public TO flow_capture; + + CREATE EXTENSION IF NOT EXISTS citext; +EOSQL diff --git a/source-redshift-batch/main_test.go b/source-redshift-batch/main_test.go index e99b0ac62c..32049d3ec3 100644 --- a/source-redshift-batch/main_test.go +++ b/source-redshift-batch/main_test.go @@ -27,12 +27,12 @@ import ( ) var ( - dbAddress = flag.String("db_address", "default-workgroup.123456789012.us-east-1.redshift-serverless.amazonaws.com:5439", "The database server address to use for tests") - dbName = flag.String("db_name", "dev", "Use the named database for tests") + dbAddress = flag.String("db_address", "localhost:5432", "The database server address to use for tests") + dbName = flag.String("db_name", "postgres", "Use the named database for tests") + dbControlUser = flag.String("db_control_user", "postgres", "The user for test setup/control operations") + dbControlPass = flag.String("db_control_pass", "postgres", "The password the the test setup/control user") dbCaptureUser = flag.String("db_capture_user", "flow_capture", "The user to perform captures as") dbCapturePass = flag.String("db_capture_pass", "secret1234", "The password for the capture user") - dbControlUser = flag.String("db_control_user", "", "The user for test setup/control operations, if different from the capture user") - dbControlPass = flag.String("db_control_pass", "", "The password the the test setup/control user, if different from the capture password") ) func TestMain(m *testing.M) {