From 7a9bc08db70575fe97b7919c645d68412e238bb9 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Thu, 6 Jun 2024 13:18:08 -0400 Subject: [PATCH 1/4] update emulator scripts to use fdc emulator v1.2.0 --- firebase-dataconnect/emulator/emulator.sh | 10 ++++-- .../emulator/emulator_noauth.sh | 32 ------------------- .../emulator/postgres_dbinit.sh | 30 ----------------- .../emulator/start_postgres_pod.sh | 1 - 4 files changed, 7 insertions(+), 66 deletions(-) delete mode 100755 firebase-dataconnect/emulator/emulator_noauth.sh delete mode 100755 firebase-dataconnect/emulator/postgres_dbinit.sh diff --git a/firebase-dataconnect/emulator/emulator.sh b/firebase-dataconnect/emulator/emulator.sh index 8300ec940d7..65778b08be1 100755 --- a/firebase-dataconnect/emulator/emulator.sh +++ b/firebase-dataconnect/emulator/emulator.sh @@ -16,12 +16,16 @@ set -euo pipefail +readonly SELF_DIR="$(dirname "$0")" +export DATACONNECT_EMULATOR_BINARY_PATH="${SELF_DIR}/cli_wrapper.sh" + readonly FIREBASE_ARGS=( - firebase emulators:exec - --only auth + firebase + emulators:start + --only auth,dataconnect --project prjh5zbv64sv6 - ./emulator_noauth.sh ) +echo "[$0] Set environment variable DATACONNECT_EMULATOR_BINARY_PATH=${DATACONNECT_EMULATOR_BINARY_PATH}" echo "[$0] Running command: ${FIREBASE_ARGS[*]}" exec "${FIREBASE_ARGS[@]}" diff --git a/firebase-dataconnect/emulator/emulator_noauth.sh b/firebase-dataconnect/emulator/emulator_noauth.sh deleted file mode 100755 index f7448c8d26d..00000000000 --- a/firebase-dataconnect/emulator/emulator_noauth.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -euo pipefail - -readonly CLI_ARGS=( - ./cli - -logbuflevel=-1 - -logtostderr - -v=9 - dev - -listen=127.0.0.1:9399 - -service_location=us-central1 - -config_dir=dataconnect - -local_connection_string='postgresql://postgres:postgres@localhost:5432?sslmode=disable' -) - -echo "[$0] Running command: ${CLI_ARGS[*]}" -exec "${CLI_ARGS[@]}" diff --git a/firebase-dataconnect/emulator/postgres_dbinit.sh b/firebase-dataconnect/emulator/postgres_dbinit.sh deleted file mode 100755 index acfc221abd0..00000000000 --- a/firebase-dataconnect/emulator/postgres_dbinit.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script is mounted in the postgresql container such that it will be run -# on a fresh instance. Specifically, this will create the database that that the -# dataconnect emulator expects to exist. -# See https://hub.docker.com/_/postgres for details, especially the -# "Initialization Scripts" section. - -set -xev - -echo "POSTGRES_USER=$POSTGRES_USER" - -psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL - CREATE DATABASE "dba6g7djscd5"; - GRANT ALL PRIVILEGES ON DATABASE "dba6g7djscd5" TO $POSTGRES_USER; -EOSQL diff --git a/firebase-dataconnect/emulator/start_postgres_pod.sh b/firebase-dataconnect/emulator/start_postgres_pod.sh index d5b241cab49..31b96d85e1e 100755 --- a/firebase-dataconnect/emulator/start_postgres_pod.sh +++ b/firebase-dataconnect/emulator/start_postgres_pod.sh @@ -38,7 +38,6 @@ podman \ --rm \ --pod dataconnect_postgres \ -e POSTGRES_HOST_AUTH_METHOD=trust \ - --mount "type=bind,ro,src=${SCRIPT_DIR}/postgres_dbinit.sh,dst=/docker-entrypoint-initdb.d/postgres_dbinit.sh" \ --mount "type=volume,src=dataconnect_pgdata,dst=/var/lib/postgresql/data" \ docker.io/library/postgres:15 From 02f469a1cc22e6a9f8f77f1a38ceadac755e000c Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Thu, 6 Jun 2024 13:56:55 -0400 Subject: [PATCH 2/4] work --- firebase-dataconnect/emulator/.gitignore | 3 +- firebase-dataconnect/emulator/cli_wrapper.sh | 33 ++++++++++++++++++++ firebase-dataconnect/emulator/emulator.sh | 3 ++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 firebase-dataconnect/emulator/cli_wrapper.sh diff --git a/firebase-dataconnect/emulator/.gitignore b/firebase-dataconnect/emulator/.gitignore index 685453a3db9..97a9ae2c15d 100644 --- a/firebase-dataconnect/emulator/.gitignore +++ b/firebase-dataconnect/emulator/.gitignore @@ -1,7 +1,8 @@ .dataconnect/ -/cli* +/cli /*.tools.json /firebase-debug.log /.firebase/ /ui-debug.log /dataconnect-debug.log +/cli_wrapper.sh.log.txt diff --git a/firebase-dataconnect/emulator/cli_wrapper.sh b/firebase-dataconnect/emulator/cli_wrapper.sh new file mode 100755 index 00000000000..34b0942d29b --- /dev/null +++ b/firebase-dataconnect/emulator/cli_wrapper.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Set the DATACONNECT_EMULATOR_BINARY_PATH environment variable to point to this file. +# Then run: firebase emulators:start --only dataconnect + +set -euo pipefail + +readonly SELF_DIR="$(dirname "$0")" +readonly LOG_FILE="${SELF_DIR}/cli_wrapper.sh.log.txt" +readonly CLI_BINARY="${SELF_DIR}/cli" + +readonly args=( + "${CLI_BINARY}" + "-logtostderr" + "$@" +) + +echo "$(date) pid=$$ ${args[*]}" >>"${LOG_FILE}" +exec "${args[@]}" diff --git a/firebase-dataconnect/emulator/emulator.sh b/firebase-dataconnect/emulator/emulator.sh index 65778b08be1..b1f5382f117 100755 --- a/firebase-dataconnect/emulator/emulator.sh +++ b/firebase-dataconnect/emulator/emulator.sh @@ -16,11 +16,14 @@ set -euo pipefail +echo "[$0] PID=$$" + readonly SELF_DIR="$(dirname "$0")" export DATACONNECT_EMULATOR_BINARY_PATH="${SELF_DIR}/cli_wrapper.sh" readonly FIREBASE_ARGS=( firebase + --debug emulators:start --only auth,dataconnect --project prjh5zbv64sv6 From 082f2ffcea7536cbb42f950420a9807b36d59810 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Thu, 6 Jun 2024 14:52:56 -0400 Subject: [PATCH 3/4] firebase.json: add dataconnect port 9399 --- firebase-dataconnect/emulator/firebase.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/firebase-dataconnect/emulator/firebase.json b/firebase-dataconnect/emulator/firebase.json index af9196c29dc..cab6f077650 100644 --- a/firebase-dataconnect/emulator/firebase.json +++ b/firebase-dataconnect/emulator/firebase.json @@ -10,6 +10,9 @@ "ui": { "enabled": true }, - "singleProjectMode": true + "singleProjectMode": true, + "dataconnect": { + "port": 9399 + } } } From 997c40ec0d8441e6165e69faf1f99e7bf9a65f04 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Thu, 6 Jun 2024 14:54:52 -0400 Subject: [PATCH 4/4] start_postgres_pod.sh: update comment --- firebase-dataconnect/emulator/start_postgres_pod.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firebase-dataconnect/emulator/start_postgres_pod.sh b/firebase-dataconnect/emulator/start_postgres_pod.sh index 31b96d85e1e..f0731967c26 100755 --- a/firebase-dataconnect/emulator/start_postgres_pod.sh +++ b/firebase-dataconnect/emulator/start_postgres_pod.sh @@ -76,7 +76,7 @@ To delete the postgresql database, run To delete the containers, run podman pod rm --force dataconnect_postgres -When running the Firebase Data Connect emulator, specify this argument to use this postgresql -or set "localConnectionString" in .firebaserc: - -local_connection_string='postgresql://postgres:postgres@localhost:5432?sslmode=disable' +When running the Firebase Data Connect emulator, use this postgresql connection string +in .firebaserc: + postgresql://postgres:postgres@localhost:5432?sslmode=disable EOF