From ef1939e6523d74384c0f66fd241eefff4ca83fb4 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 23 Nov 2020 11:51:00 +0300 Subject: [PATCH 01/15] try emulator on Django tests worker index workers count use one worker credentials relative path try paths try build.sh try build.sh run build chmod don't use worker indexes use sh pipefail pipefail flag o don't cd don't nox log lines don't use count index use python script don't use test utils test instance run test suite don't run emulator fix pb2 types param_types type_pb2 use types module Type module type codes check emulator check emulator don't hide error print emulator don't set unused vars use log log emualtor use git version of package use gut revert use env vars --- .../django_tests_against_emulator.yml | 33 ++++++++++++ .kokoro/build.sh | 2 - build.sh | 51 +++++++++++++++++++ create_test_instance.py | 48 +++++++++++++++++ django_spanner/creation.py | 3 ++ django_spanner/introspection.py | 18 +++---- django_test_suite.sh | 14 ++--- parallelize_tests.go | 14 +---- 8 files changed, 148 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/django_tests_against_emulator.yml create mode 100644 build.sh create mode 100644 create_test_instance.py diff --git a/.github/workflows/django_tests_against_emulator.yml b/.github/workflows/django_tests_against_emulator.yml new file mode 100644 index 0000000000..d8268d4ab0 --- /dev/null +++ b/.github/workflows/django_tests_against_emulator.yml @@ -0,0 +1,33 @@ +on: + push: + branches: + - master + pull_request: +name: Run Django backend tests against emulator +jobs: + system-tests: + runs-on: ubuntu-latest + + services: + emulator: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9010:9010 + - 9020:9020 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Run system tests + run: sh build.sh + env: + SPANNER_EMULATOR_HOST: localhost:9010 + GOOGLE_CLOUD_PROJECT: emulator-test-project + GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE: true + DJANGO_WORKER_INDEX: 0 + DJANGO_WORKER_COUNT: 1 + SPANNER_TEST_INSTANCE: google-cloud-django-backend-tests diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 8d7113079a..976a11d281 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -eo pipefail - cd github/python-spanner-django # Disable buffering, so that the logs stream through. diff --git a/build.sh b/build.sh new file mode 100644 index 0000000000..1a00c6f0d0 --- /dev/null +++ b/build.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Copyright 2020 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 +# +# https://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 -x pipefail + +# Disable buffering, so that the logs stream through. +export PYTHONUNBUFFERED=1 + +# Debug: show build environment +env | grep KOKORO + +# Setup service account credentials. +# export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json + +# Setup project id. +# export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json") + +# Export essential environment variables for Django tests. +export RUNNING_SPANNER_BACKEND_TESTS=1 + +# The emulator is currently unusable for our tests because: +# a) It doesn't support INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE +# b) Cannot accept parameters whose types aren't known, so can't be used for +# Python and other dynamic languages. +# export USE_SPANNER_EMULATOR=0 + +pip3 install . +# Create a unique DJANGO_TESTS_DIR per worker to avoid +# any clashes with configured tests by other workers. +export DJANGO_TESTS_DIR="django_tests_$DJANGO_WORKER_INDEX" +mkdir -p $DJANGO_TESTS_DIR && git clone --depth 1 --single-branch --branch spanner-2.2.x https://github.com/timgraham/django.git $DJANGO_TESTS_DIR/django + +# Install dependencies for Django tests. +sudo apt-get update +apt-get install -y libffi-dev libjpeg-dev zlib1g-dev libmemcached-dev +cd $DJANGO_TESTS_DIR/django && pip3 install -e . && pip3 install -r tests/requirements/py3.txt; cd ../../ + +python create_test_instance.py +bash django_test_suite.sh \ No newline at end of file diff --git a/create_test_instance.py b/create_test_instance.py new file mode 100644 index 0000000000..dca71e8346 --- /dev/null +++ b/create_test_instance.py @@ -0,0 +1,48 @@ +# Copyright 2016 Google LLC All rights reserved. +# +# 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. + +import os + +from google.auth.credentials import AnonymousCredentials +from google.cloud.spanner_v1 import Client + + +INSTANCE_ID = "google-cloud-django-backend-tests" + + +class Config(object): + """Run-time configuration to be modified at set-up. + + This is a mutable stand-in to allow test set-up to modify + global state. + """ + + CLIENT = None + INSTANCE_CONFIG = None + INSTANCE = None + + +emulator_project = os.getenv("GCLOUD_PROJECT", "emulator-test-project") +Config.CLIENT = Client( + project=emulator_project, credentials=AnonymousCredentials() +) + +configs = list(Config.CLIENT.list_instance_configs()) + +Config.INSTANCE_CONFIG = configs[0] +config_name = configs[0].name + +Config.INSTANCE = Config.CLIENT.instance(INSTANCE_ID, config_name) +created_op = Config.INSTANCE.create() +created_op.result(30) # block until completion diff --git a/django_spanner/creation.py b/django_spanner/creation.py index 66bd531170..df0b3432c3 100644 --- a/django_spanner/creation.py +++ b/django_spanner/creation.py @@ -81,6 +81,9 @@ def _create_test_db(self, verbosity, autoclobber, keepdb=False): return test_database_name def _execute_create_test_db(self, cursor, parameters, keepdb=False): + self.log( + "emulator: " + str(self.connection.instance._client._emulator_host) + ) self.connection.instance.database(parameters["dbname"]).create() def _destroy_test_db(self, test_database_name, verbosity): diff --git a/django_spanner/introspection.py b/django_spanner/introspection.py index ab9d29aa3f..2928c84798 100644 --- a/django_spanner/introspection.py +++ b/django_spanner/introspection.py @@ -10,22 +10,22 @@ TableInfo, ) from django.db.models import Index -from google.cloud.spanner_v1.proto import type_pb2 +from google.cloud.spanner_v1 import TypeCode class DatabaseIntrospection(BaseDatabaseIntrospection): data_types_reverse = { - type_pb2.BOOL: "BooleanField", - type_pb2.BYTES: "BinaryField", - type_pb2.DATE: "DateField", - type_pb2.FLOAT64: "FloatField", - type_pb2.INT64: "IntegerField", - type_pb2.STRING: "CharField", - type_pb2.TIMESTAMP: "DateTimeField", + TypeCode.BOOL: "BooleanField", + TypeCode.BYTES: "BinaryField", + TypeCode.DATE: "DateField", + TypeCode.FLOAT64: "FloatField", + TypeCode.INT64: "IntegerField", + TypeCode.STRING: "CharField", + TypeCode.TIMESTAMP: "DateTimeField", } def get_field_type(self, data_type, description): - if data_type == type_pb2.STRING and description.internal_size == "MAX": + if data_type == TypeCode.STRING and description.internal_size == "MAX": return "TextField" return super().get_field_type(data_type, description) diff --git a/django_test_suite.sh b/django_test_suite.sh index e87cd6167f..392ce41fa6 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -15,7 +15,9 @@ TEST_DBNAME=${SPANNER_TEST_DB:-$(python3 -c 'import os, time; print(chr(ord("a") TEST_DBNAME_OTHER="$TEST_DBNAME-ot" TEST_APPS=${DJANGO_TEST_APPS:-basic} INSTANCE=${SPANNER_TEST_INSTANCE:-django-tests} -PROJECT=${PROJECT_ID:-appdev-soda-spanner-staging} +PROJECT=${PROJECT_ID} +SPANNER_EMULATOR_HOST=${SPANNER_EMULATOR_HOST} +GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT} SETTINGS_FILE="$TEST_DBNAME-settings" TESTS_DIR=${DJANGO_TESTS_DIR:-django_tests} @@ -42,15 +44,6 @@ PASSWORD_HASHERS = [ ! } -setup_emulator_if_needed() { - if [[ $SPANNER_EMULATOR_HOST != "" ]] - then - echo "Running the emulator at: $SPANNER_EMULATOR_HOST" - ./emulator_main --host_port "$SPANNER_EMULATOR_HOST" & - SPANNER_INSTANCE=$INSTANCE python3 .kokoro/ensure_instance_exists.py - fi -} - run_django_tests() { cd $TESTS_DIR/django/tests create_settings @@ -58,5 +51,4 @@ run_django_tests() { python3 runtests.py $TEST_APPS --verbosity=2 --noinput --settings $SETTINGS_FILE } -setup_emulator_if_needed run_django_tests diff --git a/parallelize_tests.go b/parallelize_tests.go index 49e6882dc7..c5b7ab52e1 100644 --- a/parallelize_tests.go +++ b/parallelize_tests.go @@ -31,19 +31,10 @@ import ( ) func main() { - workerIndex, err := strconv.ParseInt(os.Getenv("DJANGO_WORKER_INDEX"), 10, 64) - if err != nil { - log.Fatalf("Failed to parse DJANGO_WORKER_INDEX as an integer: %v", err) - } workerCount, err := strconv.ParseInt(os.Getenv("DJANGO_WORKER_COUNT"), 10, 64) if err != nil { log.Fatalf("Failed to parse DJANGO_WORKER_COUNT as an integer: %v", err) } - if workerIndex >= workerCount { - // Re-enable when we figure out how to deal with Cloud Spanner's very low quotas. - fmt.Printf("workerIndex (%d) >= workerCount (%d)", workerIndex, workerCount) - return - } allAppsBlob, err := ioutil.ReadFile("django_test_apps.txt") if err != nil { @@ -51,10 +42,7 @@ func main() { } allApps := strings.Split(string(allAppsBlob), "\n") appsPerWorker := int(math.Ceil(float64(len(allApps)) / float64(workerCount))) - startIndex := int(workerIndex) * appsPerWorker - if startIndex >= len(allApps) { - startIndex = int(workerIndex) - } + startIndex := 0 endIndex := startIndex + appsPerWorker if endIndex >= len(allApps) { endIndex = len(allApps) From fa1ec66196ba931e181ece4ab05aa6ba106dca01 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 11:33:54 +0300 Subject: [PATCH 02/15] pipe logs --- django_test_suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index 392ce41fa6..f317d63f50 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -5,7 +5,7 @@ # license that can be found in the LICENSE file. # exit when any command fails -set -e +set -x pipefail # If no SPANNER_TEST_DB is set, generate a unique one # so that we can have multiple tests running without From f37f47be36a75f552f7cd15dd83b1fcb5067cbfc Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 11:37:44 +0300 Subject: [PATCH 03/15] high verbosity --- django_test_suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index f317d63f50..d3d270eb00 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -48,7 +48,7 @@ run_django_tests() { cd $TESTS_DIR/django/tests create_settings echo -e "\033[32mRunning Django tests: $TEST_APPS\033[00m" - python3 runtests.py $TEST_APPS --verbosity=2 --noinput --settings $SETTINGS_FILE + python3 runtests.py $TEST_APPS --verbosity=3 --noinput --settings $SETTINGS_FILE } run_django_tests From 35f1a404a97ff220f68ba3d9900fdde53e237536 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 11:40:14 +0300 Subject: [PATCH 04/15] traceback --- django_spanner/creation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_spanner/creation.py b/django_spanner/creation.py index df0b3432c3..03ea75a326 100644 --- a/django_spanner/creation.py +++ b/django_spanner/creation.py @@ -51,7 +51,7 @@ def _create_test_db(self, verbosity, autoclobber, keepdb=False): # just return and skip it all. if keepdb: return test_database_name - self.log("Got an error creating the test database: %s" % e) + self.log("Got an error creating the test database: %s" % e.__traceback__) if not autoclobber: confirm = input( "Type 'yes' if you would like to try deleting the test " From 2035c95077da3d2fac2caa5a6a8b3a813fb2c452 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 11:47:05 +0300 Subject: [PATCH 05/15] print traceback --- django_spanner/creation.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django_spanner/creation.py b/django_spanner/creation.py index 03ea75a326..584b5bd438 100644 --- a/django_spanner/creation.py +++ b/django_spanner/creation.py @@ -51,7 +51,13 @@ def _create_test_db(self, verbosity, autoclobber, keepdb=False): # just return and skip it all. if keepdb: return test_database_name - self.log("Got an error creating the test database: %s" % e.__traceback__) + + import traceback + + self.log( + "Got an error creating the test database: %s" + % traceback.print_tb(e.__traceback__) + ) if not autoclobber: confirm = input( "Type 'yes' if you would like to try deleting the test " From 55edda8e41fbb2d99f45aef4417f8fcf365997f5 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 11:58:27 +0300 Subject: [PATCH 06/15] project id --- django_spanner/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django_spanner/base.py b/django_spanner/base.py index 044f8ddd75..2769fe4e1e 100644 --- a/django_spanner/base.py +++ b/django_spanner/base.py @@ -4,6 +4,8 @@ # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd +import sys + from django.db.backends.base.base import BaseDatabaseWrapper from google.cloud import spanner_dbapi as Database, spanner_v1 as spanner @@ -103,7 +105,9 @@ class DatabaseWrapper(BaseDatabaseWrapper): @property def instance(self): - return spanner.Client().instance(self.settings_dict["INSTANCE"]) + return spanner.Client( + project=sys.environ["GOOGLE_CLOUD_PROJECT"] + ).instance(self.settings_dict["INSTANCE"]) @property def _nodb_connection(self): From c0ac7a0988f4205877b69c904dd8fba227f3f498 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:01:45 +0300 Subject: [PATCH 07/15] fix typo --- django_spanner/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_spanner/base.py b/django_spanner/base.py index 2769fe4e1e..a901ecf3b0 100644 --- a/django_spanner/base.py +++ b/django_spanner/base.py @@ -4,7 +4,7 @@ # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd -import sys +import os from django.db.backends.base.base import BaseDatabaseWrapper from google.cloud import spanner_dbapi as Database, spanner_v1 as spanner @@ -106,7 +106,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): @property def instance(self): return spanner.Client( - project=sys.environ["GOOGLE_CLOUD_PROJECT"] + project=os.environ["GOOGLE_CLOUD_PROJECT"] ).instance(self.settings_dict["INSTANCE"]) @property From 79a36e25279158e7226cbb18555794933ff65f06 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:09:56 +0300 Subject: [PATCH 08/15] create instance --- build.sh | 2 +- create_test_instance.py | 30 ++++++------------------------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/build.sh b/build.sh index 1a00c6f0d0..8bcfab564a 100644 --- a/build.sh +++ b/build.sh @@ -47,5 +47,5 @@ sudo apt-get update apt-get install -y libffi-dev libjpeg-dev zlib1g-dev libmemcached-dev cd $DJANGO_TESTS_DIR/django && pip3 install -e . && pip3 install -r tests/requirements/py3.txt; cd ../../ -python create_test_instance.py +python3 create_test_instance.py bash django_test_suite.sh \ No newline at end of file diff --git a/create_test_instance.py b/create_test_instance.py index dca71e8346..f4aada9c12 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -18,31 +18,13 @@ from google.cloud.spanner_v1 import Client -INSTANCE_ID = "google-cloud-django-backend-tests" +emulator_project = os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") +client = Client(project=emulator_project, credentials=AnonymousCredentials()) +configs = list(client.list_instance_configs()) -class Config(object): - """Run-time configuration to be modified at set-up. - - This is a mutable stand-in to allow test set-up to modify - global state. - """ - - CLIENT = None - INSTANCE_CONFIG = None - INSTANCE = None - - -emulator_project = os.getenv("GCLOUD_PROJECT", "emulator-test-project") -Config.CLIENT = Client( - project=emulator_project, credentials=AnonymousCredentials() +instance = client.instance( + "google-cloud-django-backend-tests", configs[0].name ) - -configs = list(Config.CLIENT.list_instance_configs()) - -Config.INSTANCE_CONFIG = configs[0] -config_name = configs[0].name - -Config.INSTANCE = Config.CLIENT.instance(INSTANCE_ID, config_name) -created_op = Config.INSTANCE.create() +created_op = instance.create() created_op.result(30) # block until completion From 6353140fdaf6a256114609c972dce0f06ddd3f11 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:17:33 +0300 Subject: [PATCH 09/15] credentials --- create_test_instance.py | 3 +-- django_spanner/creation.py | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/create_test_instance.py b/create_test_instance.py index f4aada9c12..3d5d8ac60b 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -14,12 +14,11 @@ import os -from google.auth.credentials import AnonymousCredentials from google.cloud.spanner_v1 import Client emulator_project = os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") -client = Client(project=emulator_project, credentials=AnonymousCredentials()) +client = Client(project=emulator_project) configs = list(client.list_instance_configs()) diff --git a/django_spanner/creation.py b/django_spanner/creation.py index 584b5bd438..956fbee17f 100644 --- a/django_spanner/creation.py +++ b/django_spanner/creation.py @@ -52,12 +52,7 @@ def _create_test_db(self, verbosity, autoclobber, keepdb=False): if keepdb: return test_database_name - import traceback - - self.log( - "Got an error creating the test database: %s" - % traceback.print_tb(e.__traceback__) - ) + self.log("Got an error creating the test database: %s" % e) if not autoclobber: confirm = input( "Type 'yes' if you would like to try deleting the test " From b61d2cfd5b8007ae0d7408cab38b21c7f5717f26 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:20:27 +0300 Subject: [PATCH 10/15] create no params --- create_test_instance.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/create_test_instance.py b/create_test_instance.py index 3d5d8ac60b..156a661d1e 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -20,10 +20,6 @@ emulator_project = os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") client = Client(project=emulator_project) -configs = list(client.list_instance_configs()) - -instance = client.instance( - "google-cloud-django-backend-tests", configs[0].name -) +instance = client.instance("google-cloud-django-backend-tests") created_op = instance.create() created_op.result(30) # block until completion From 548f4cc256bf73c4013aebaf2ee2f4570851f674 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:24:03 +0300 Subject: [PATCH 11/15] build verbose --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 8bcfab564a..9ff94f0de4 100644 --- a/build.sh +++ b/build.sh @@ -47,5 +47,5 @@ sudo apt-get update apt-get install -y libffi-dev libjpeg-dev zlib1g-dev libmemcached-dev cd $DJANGO_TESTS_DIR/django && pip3 install -e . && pip3 install -r tests/requirements/py3.txt; cd ../../ -python3 create_test_instance.py +python3 -v create_test_instance.py bash django_test_suite.sh \ No newline at end of file From 7b51f86f7d1a68f87d51d06f0dc1fad26003ee80 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:30:35 +0300 Subject: [PATCH 12/15] log creation --- build.sh | 2 +- create_test_instance.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 9ff94f0de4..8bcfab564a 100644 --- a/build.sh +++ b/build.sh @@ -47,5 +47,5 @@ sudo apt-get update apt-get install -y libffi-dev libjpeg-dev zlib1g-dev libmemcached-dev cd $DJANGO_TESTS_DIR/django && pip3 install -e . && pip3 install -r tests/requirements/py3.txt; cd ../../ -python3 -v create_test_instance.py +python3 create_test_instance.py bash django_test_suite.sh \ No newline at end of file diff --git a/create_test_instance.py b/create_test_instance.py index 156a661d1e..f4c5f042f5 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -17,9 +17,11 @@ from google.cloud.spanner_v1 import Client -emulator_project = os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") -client = Client(project=emulator_project) +client = Client( + project=os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") +) instance = client.instance("google-cloud-django-backend-tests") created_op = instance.create() +print("yeeeeeeeeeeeeeeees") created_op.result(30) # block until completion From 824fd58c614b821f6c1b0f072e5902b7a8908ed1 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:34:09 +0300 Subject: [PATCH 13/15] instance exists --- create_test_instance.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/create_test_instance.py b/create_test_instance.py index f4c5f042f5..252960c8e4 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -23,5 +23,6 @@ instance = client.instance("google-cloud-django-backend-tests") created_op = instance.create() -print("yeeeeeeeeeeeeeeees") created_op.result(30) # block until completion + +print("existssss: ", instance.exists()) From cb1d8407af1dd4141d37072fcd7eab4d269b43c0 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:39:22 +0300 Subject: [PATCH 14/15] project id --- django_spanner/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_spanner/base.py b/django_spanner/base.py index a901ecf3b0..e3fc611ac3 100644 --- a/django_spanner/base.py +++ b/django_spanner/base.py @@ -117,7 +117,7 @@ def _nodb_connection(self): def get_connection_params(self): return { - "project": self.settings_dict["PROJECT"], + "project": os.environ["GOOGLE_CLOUD_PROJECT"], "instance_id": self.settings_dict["INSTANCE"], "database_id": self.settings_dict["NAME"], "user_agent": "django_spanner/2.2.0a1", From 1f4932d97068616939e0ecaa7855198148a6060a Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 26 Nov 2020 12:46:42 +0300 Subject: [PATCH 15/15] update branch --- create_test_instance.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/create_test_instance.py b/create_test_instance.py index 252960c8e4..df59738895 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -24,5 +24,3 @@ instance = client.instance("google-cloud-django-backend-tests") created_op = instance.create() created_op.result(30) # block until completion - -print("existssss: ", instance.exists())