src/accounts/accounts-db/k8s/components/init-db-job/init-db-job.yaml [30:76]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    TEST_SQL_SCRIPT="/scripts/1-load-testdata.sh"

    HOST=${1:-'127.0.0.1'}
    PORT=${2:-'5432'}
    DB_NAME=${3:-'default'}

    # Initial wait for cloud-sql-proxy
    sleep 20

    while [ $COUNTER -lt 10 ]; do
        let COUNTER=$COUNTER+1

        echo "Attempt # ${COUNTER}: Checking connectivity to ${HOST}:${PORT}/${DB_NAME}..."
        pg_isready --host=${HOST} --port=${PORT} --dbname=${DB_NAME}

        if [ $? -gt 0 ]; then
            echo "Attempt # ${COUNTER}: Database is not ready, trying again in ${SLEEP_TIME} seconds"
            sleep $SLEEP_TIME
        else
            echo "Database is ready to connect"
            let DB_READY=1
            break
        fi
    done

    if [ "${DB_READY}" -eq 1 ]; then
        echo "Running initialization script"
        psql --host=${HOST} --port=${PORT} --dbname=${DB_NAME} -f ${INIT_SQL_SCRIPT}
        if [ $? -gt 0 ]; then
            echo "Problems running the initialization script"
            ERROR=$((ERROR+1))
        else
            echo "Run Test Data"
            . ${TEST_SQL_SCRIPT}
            if [ $? -gt 0 ]; then
              echo "Problems running the test data script"
              ERROR=$((ERROR+1))
            fi
        fi
    else
        echo "Failed to connect to the database"
        ERROR=$((ERROR+1))
    fi

    wget --post-data '' http://127.0.0.1:9091/quitquitquit 2>&1

    return ${ERROR}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/ledger/ledger-db/k8s/components/init-db-job/init-db-job.yaml [30:76]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    TEST_SQL_SCRIPT="/scripts/1-load-testdata.sh"

    HOST=${1:-'127.0.0.1'}
    PORT=${2:-'5432'}
    DB_NAME=${3:-'default'}

    # Initial wait for cloud-sql-proxy
    sleep 20

    while [ $COUNTER -lt 10 ]; do
        let COUNTER=$COUNTER+1

        echo "Attempt # ${COUNTER}: Checking connectivity to ${HOST}:${PORT}/${DB_NAME}..."
        pg_isready --host=${HOST} --port=${PORT} --dbname=${DB_NAME}

        if [ $? -gt 0 ]; then
            echo "Attempt # ${COUNTER}: Database is not ready, trying again in ${SLEEP_TIME} seconds"
            sleep $SLEEP_TIME
        else
            echo "Database is ready to connect"
            let DB_READY=1
            break
        fi
    done

    if [ "${DB_READY}" -eq 1 ]; then
        echo "Running initialization script"
        psql --host=${HOST} --port=${PORT} --dbname=${DB_NAME} -f ${INIT_SQL_SCRIPT}
        if [ $? -gt 0 ]; then
            echo "Problems running the initialization script"
            ERROR=$((ERROR+1))
        else
            echo "Run Test Data"
            . ${TEST_SQL_SCRIPT}
            if [ $? -gt 0 ]; then
              echo "Problems running the test data script"
              ERROR=$((ERROR+1))
            fi
        fi
    else
        echo "Failed to connect to the database"
        ERROR=$((ERROR+1))
    fi

    wget --post-data '' http://127.0.0.1:9091/quitquitquit 2>&1

    return ${ERROR}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



