From a031f354a09852b56457f74d93c303a5a563c95d Mon Sep 17 00:00:00 2001 From: Ilya Gurov Date: Thu, 26 Nov 2020 12:54:40 +0300 Subject: [PATCH 01/31] test: move Django tests to emulator (#27) --- .../django_tests_against_emulator.yml | 33 ++++++++++++ .kokoro/build.sh | 2 - build.sh | 51 +++++++++++++++++++ create_test_instance.py | 26 ++++++++++ django_spanner/base.py | 8 ++- django_spanner/creation.py | 4 ++ django_test_suite.sh | 18 ++----- parallelize_tests.go | 14 +---- 8 files changed, 126 insertions(+), 30 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..8bcfab564a --- /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 ../../ + +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 new file mode 100644 index 0000000000..df59738895 --- /dev/null +++ b/create_test_instance.py @@ -0,0 +1,26 @@ +# 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.cloud.spanner_v1 import Client + + +client = Client( + project=os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") +) + +instance = client.instance("google-cloud-django-backend-tests") +created_op = instance.create() +created_op.result(30) # block until completion diff --git a/django_spanner/base.py b/django_spanner/base.py index 044f8ddd75..e3fc611ac3 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 os + 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=os.environ["GOOGLE_CLOUD_PROJECT"] + ).instance(self.settings_dict["INSTANCE"]) @property def _nodb_connection(self): @@ -113,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", diff --git a/django_spanner/creation.py b/django_spanner/creation.py index 66bd531170..956fbee17f 100644 --- a/django_spanner/creation.py +++ b/django_spanner/creation.py @@ -51,6 +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) if not autoclobber: confirm = input( @@ -81,6 +82,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_test_suite.sh b/django_test_suite.sh index e87cd6167f..d3d270eb00 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 @@ -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,21 +44,11 @@ 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 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 } -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 dc8eeb09844f3a9e33ae6ca812dd902a7ab5e9fa Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 30 Nov 2020 11:38:54 +0300 Subject: [PATCH 02/31] cleanup --- .../django_tests_against_emulator.yml | 2 +- .kokoro/build.sh | 2 + build.sh | 51 ---- django_spanner/creation.py | 4 - django_test_suite.sh | 19 ++ parallelize_tests.go | 288 ------------------ 6 files changed, 22 insertions(+), 344 deletions(-) delete mode 100644 build.sh delete mode 100644 parallelize_tests.go diff --git a/.github/workflows/django_tests_against_emulator.yml b/.github/workflows/django_tests_against_emulator.yml index d8268d4ab0..c49b677f2b 100644 --- a/.github/workflows/django_tests_against_emulator.yml +++ b/.github/workflows/django_tests_against_emulator.yml @@ -23,7 +23,7 @@ jobs: with: python-version: 3.8 - name: Run system tests - run: sh build.sh + run: sh django_test_suite.sh env: SPANNER_EMULATOR_HOST: localhost:9010 GOOGLE_CLOUD_PROJECT: emulator-test-project diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 976a11d281..8d7113079a 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -13,6 +13,8 @@ # 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 deleted file mode 100644 index 8bcfab564a..0000000000 --- a/build.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/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 ../../ - -python3 create_test_instance.py -bash django_test_suite.sh \ No newline at end of file diff --git a/django_spanner/creation.py b/django_spanner/creation.py index 956fbee17f..66bd531170 100644 --- a/django_spanner/creation.py +++ b/django_spanner/creation.py @@ -51,7 +51,6 @@ 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) if not autoclobber: confirm = input( @@ -82,9 +81,6 @@ 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_test_suite.sh b/django_test_suite.sh index d3d270eb00..894e62b2b4 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -7,6 +7,25 @@ # exit when any command fails set -x pipefail +# Disable buffering, so that the logs stream through. +export PYTHONUNBUFFERED=1 + +# Export essential environment variables for Django tests. +export RUNNING_SPANNER_BACKEND_TESTS=1 + +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 ../../ + +python3 create_test_instance.py + # If no SPANNER_TEST_DB is set, generate a unique one # so that we can have multiple tests running without # conflicting which changes and constraints. We'll always diff --git a/parallelize_tests.go b/parallelize_tests.go deleted file mode 100644 index c5b7ab52e1..0000000000 --- a/parallelize_tests.go +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2020 Google LLC. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -package main - -import ( - "context" - "crypto/sha256" - "errors" - "fmt" - "io/ioutil" - "log" - "math" - "math/rand" - "os" - "os/exec" - "os/signal" - "runtime" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" - - "cloud.google.com/go/compute/metadata" - instance "cloud.google.com/go/spanner/admin/instance/apiv1" - instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" -) - -func main() { - 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) - } - - allAppsBlob, err := ioutil.ReadFile("django_test_apps.txt") - if err != nil { - panic(err) - } - allApps := strings.Split(string(allAppsBlob), "\n") - appsPerWorker := int(math.Ceil(float64(len(allApps)) / float64(workerCount))) - startIndex := 0 - endIndex := startIndex + appsPerWorker - if endIndex >= len(allApps) { - endIndex = len(allApps) - } - testApps := allApps[startIndex:endIndex] - println("startIndex:", startIndex, "endIndex:", endIndex, "totalApps", len(testApps)) - if len(testApps) == 0 { - panic("No DJANGO_TEST_APPS passed in") - } - - // Seeding the random generator only using time.Now() as that's sufficient - // just to add jitter and reduce resource exhaustion limits. - rng := rand.New(rand.NewSource(time.Now().UnixNano())) - rng.Shuffle(len(testApps), func(i, j int) { - testApps[i], testApps[j] = testApps[j], testApps[i] - }) - - // Create a unique instance for this worker to circumvent quota limits; to upto 56 seconds. - createInstanceThrottle := time.Millisecond * time.Duration(417+rng.Intn(54937)) - fmt.Printf("createInstance: throttling by sleeping for %s\n", createInstanceThrottle) - time.Sleep(createInstanceThrottle) - instanceName, deleteInstance, err := createInstance() - if err != nil { - panic(err) - } - defer deleteInstance() - fmt.Printf("Spanner instance: %q\n", instanceName) - - shutdownCtx, cancel := context.WithCancel(context.Background()) - defer cancel() - - exitCode := int32(0) - var wg sync.WaitGroup - defer func() { - wg.Wait() - cancel() - deleteInstance() - os.Exit(int(exitCode)) - }() - - // Gracefully shutdown on Ctrl+C. - sigCh := make(chan os.Signal) - signal.Notify(sigCh, os.Interrupt) - go func() { - <-sigCh - cancel() - wg.Wait() - deleteInstance() - }() - - nProcs := runtime.GOMAXPROCS(0) - println("GOMAXPROCS:", nProcs) - - // The number of Django apps to run per goroutine. - nAppsPerG := 3 - - if len(testApps) <= nProcs || len(testApps) <= nAppsPerG { - // We can evenly spread each app per P. - nAppsPerG = 1 - } else { - nAppsPerG = len(testApps) / (nAppsPerG * nProcs) - } - if nAppsPerG == 0 { - nAppsPerG = 2 - } - - println("apps per G: ", nAppsPerG) - - emulatorPortIds := int(0) - envUseEmulator := os.Getenv("USE_SPANNER_EMULATOR") - useEmulator := envUseEmulator != "0" && envUseEmulator != "" - genEmulatorHost := func() string { - if !useEmulator { - return "" - } - emulatorPortIds++ - return fmt.Sprintf("localhost:%d", 9010+emulatorPortIds) - } - - sema := make(chan bool, nProcs) - // Now run the tests in parallel. - for i := 0; i < len(testApps); i += nAppsPerG { - apps := testApps[i : i+nAppsPerG] - if len(apps) == 0 { - continue - } - - select { - case <-shutdownCtx.Done(): - // No more spawning goroutines, the test has been cancelled. - return - - case sema <- true: - // Proceed normally. - wg.Add(1) - } - - go func(wg *sync.WaitGroup, apps []string) { - defer func() { - if r := recover(); r != nil { - // Recover to ensure that other tests can - // proceed regardless of any goroutine panic. - fmt.Printf("\033[31m%v\033[00m\n", r) - atomic.StoreInt32(&exitCode, -1) - } - - wg.Done() - - select { - case <-sema: - case <-shutdownCtx.Done(): - } - }() - - var throttle time.Duration - if !useEmulator { - // Artificially add a wait time so as to ensure that we don't - // violate Cloud Spanner's 5QPs averaged over 100 seconds. - // Here our throttle will be in the range: - // [1, 6 * (100sec / 5QPs)] aka [1s, 120sec] - // to try to introduce variability. - throttle = (time.Millisecond * time.Duration(rng.Intn(937))) + (time.Second * time.Duration(1+rng.Intn(int(6*100/5.0)))) - fmt.Printf("Throttling by sleeping for %s\n", throttle) - } - - select { - case <-shutdownCtx.Done(): - println("Canceled so returning ASAP") - return - case <-time.After(throttle): - } - - if err := runTests(shutdownCtx, instanceName, apps, "django_test_suite.sh", genEmulatorHost); err != nil { - panic(err) - } - }(&wg, apps) - - // Add as much jitter as possible. - <-time.After(871 * time.Millisecond) - } -} - -func runTests(ctx context.Context, instanceName string, djangoApps []string, testSuiteScriptPath string, genEmulatorHost func() string) error { - if len(djangoApps) == 0 { - return errors.New("Expected at least one app") - } - - cmd := exec.CommandContext(ctx, "bash", testSuiteScriptPath) - cmd.Env = append(os.Environ(), `DJANGO_TEST_APPS=`+strings.Join(djangoApps, " ")+``) - cmd.Env = append(cmd.Env, "SPANNER_TEST_INSTANCE="+instanceName) - if emulatorHost := genEmulatorHost(); emulatorHost != "" { - cmd.Env = append(cmd.Env, "SPANNER_EMULATOR_HOST="+emulatorHost) - } - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - return cmd.Run() -} - -func createInstance() (name string, done func(), xerr error) { - ctx := context.Background() - client, err := instance.NewInstanceAdminClient(ctx) - if err != nil { - xerr = err - return - } - - h := sha256.New() - fmt.Fprintf(h, "%s", time.Now()) - hs := fmt.Sprintf("%x", h.Sum(nil)) - displayName := fmt.Sprintf("django-%s", hs[:12]) - - projectID := strings.TrimSpace(os.Getenv("PROJECT_ID")) - if projectID == "" { - xerr = errors.New(`"PROJECT_ID" must be set in your environment`) - return - } - projectPrefix := "projects/" + projectID - instanceName := projectPrefix + "/instances/" + displayName - instanceConfig := projectPrefix + "/instanceConfigs/regional-" + findRegion() - req := &instancepb.CreateInstanceRequest{ - Parent: projectPrefix, - InstanceId: displayName, - Instance: &instancepb.Instance{ - Name: instanceName, - DisplayName: displayName, - NodeCount: 1, - Config: instanceConfig, - }, - } - - op, err := client.CreateInstance(ctx, req) - if err != nil { - xerr = err - return - } - - res, err := op.Wait(context.Background()) - if err != nil { - xerr = err - return - } - // Double check that the instance was actually - // created as we wanted and that its state is READY! - retrieved, err := client.GetInstance(ctx, &instancepb.GetInstanceRequest{ - Name: res.Name, - }) - if err != nil { - xerr = err - return - } - if g, w := retrieved.GetState(), instancepb.Instance_READY; g != w { - xerr = fmt.Errorf("invalid state of instance:: got %s, want %s", g, w) - } - - // The short name of reference for the Spanner instance, and not its InstanceName. - name = retrieved.DisplayName - deletionName := retrieved.Name - var doneOnce sync.Once - done = func() { - doneOnce.Do(func() { - if err := client.DeleteInstance(ctx, &instancepb.DeleteInstanceRequest{Name: deletionName}); err == nil { - fmt.Printf("Deleted instance: %q\n", name) - } else { - fmt.Printf("Failed to delete instance: %q ==> %v\n", name, err) - } - }) - } - return -} - -func findRegion() string { - zone := "us-central1-b" - if metadata.OnGCE() { - foundZone, err := metadata.Zone() - if err == nil { - zone = foundZone - } - } - // There is no metadata API to retrieve the region from the zone, - // so we have to improvise and trim off the last '-' e.g. - // with a zone of "us-central1-b", the region will be "us-central". - return zone[:strings.LastIndex(zone, "-")] -} From b9f35dea9577aadb3e77d2b67464557875d25d8e Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Tue, 1 Dec 2020 12:22:08 +0300 Subject: [PATCH 03/31] rename checks --- .github/workflows/django_tests_against_emulator.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/django_tests_against_emulator.yml b/.github/workflows/django_tests_against_emulator.yml index c49b677f2b..462f5e427d 100644 --- a/.github/workflows/django_tests_against_emulator.yml +++ b/.github/workflows/django_tests_against_emulator.yml @@ -3,7 +3,7 @@ on: branches: - master pull_request: -name: Run Django backend tests against emulator +name: django-tests jobs: system-tests: runs-on: ubuntu-latest @@ -22,7 +22,7 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.8 - - name: Run system tests + - name: Run Django tests run: sh django_test_suite.sh env: SPANNER_EMULATOR_HOST: localhost:9010 From 1e2f9f4ef92f09a0a18d4bff1cd9155db45358df Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 3 Dec 2020 11:55:22 +0300 Subject: [PATCH 04/31] install from git --- django_test_suite.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django_test_suite.sh b/django_test_suite.sh index 894e62b2b4..d5784eeea0 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -14,6 +14,9 @@ export PYTHONUNBUFFERED=1 export RUNNING_SPANNER_BACKEND_TESTS=1 pip3 install . +pip3 uninstall -y google-cloud-spanner +pip3 install -e 'git+https://github.com/q-logic/python-spanner.git@autocommit_change#egg=google-cloud-spanner' + # 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" From 0cd10222ce9ebe8642ce1b2f8c81f5068f7fdd54 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 3 Dec 2020 12:43:45 +0300 Subject: [PATCH 05/31] re-run --- django_test_suite.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index d5784eeea0..b751da0f4e 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -7,12 +7,12 @@ # exit when any command fails set -x pipefail -# Disable buffering, so that the logs stream through. -export PYTHONUNBUFFERED=1 - # Export essential environment variables for Django tests. export RUNNING_SPANNER_BACKEND_TESTS=1 +# Disable buffering, so that the logs stream through. +export PYTHONUNBUFFERED=1 + pip3 install . pip3 uninstall -y google-cloud-spanner pip3 install -e 'git+https://github.com/q-logic/python-spanner.git@autocommit_change#egg=google-cloud-spanner' From ca44c2296244ee01dacde4b30ffd955e40e051b6 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Thu, 3 Dec 2020 13:29:04 +0300 Subject: [PATCH 06/31] re-run --- django_test_suite.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index b751da0f4e..d5784eeea0 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -7,12 +7,12 @@ # exit when any command fails set -x pipefail -# Export essential environment variables for Django tests. -export RUNNING_SPANNER_BACKEND_TESTS=1 - # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 +# Export essential environment variables for Django tests. +export RUNNING_SPANNER_BACKEND_TESTS=1 + pip3 install . pip3 uninstall -y google-cloud-spanner pip3 install -e 'git+https://github.com/q-logic/python-spanner.git@autocommit_change#egg=google-cloud-spanner' From 53d151fdfb6a1f11e158b04e35133e9e8f8d58b6 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 4 Dec 2020 10:35:02 +0300 Subject: [PATCH 07/31] re-run --- 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 d5784eeea0..89187af7d3 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -12,8 +12,8 @@ export PYTHONUNBUFFERED=1 # Export essential environment variables for Django tests. export RUNNING_SPANNER_BACKEND_TESTS=1 - pip3 install . + pip3 uninstall -y google-cloud-spanner pip3 install -e 'git+https://github.com/q-logic/python-spanner.git@autocommit_change#egg=google-cloud-spanner' From c5692938185a5e0ab21449ae63e45752487da34a Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 4 Dec 2020 10:54:32 +0300 Subject: [PATCH 08/31] delete compiler --- django_spanner/compiler.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/django_spanner/compiler.py b/django_spanner/compiler.py index 61d980a6f3..a497b7b913 100644 --- a/django_spanner/compiler.py +++ b/django_spanner/compiler.py @@ -101,7 +101,16 @@ class SQLInsertCompiler(BaseSQLInsertCompiler, SQLCompiler): class SQLDeleteCompiler(BaseSQLDeleteCompiler, SQLCompiler): - pass + def _as_sql(self, query): + result = [ + "DELETE FROM %s" % self.quote_name_unless_alias(query.base_table) + ] + where, params = self.compile(query.where) + if where: + result.append("WHERE %s" % where) + else: + result.append("WHERE 1=1") + return " ".join(result), tuple(params) class SQLUpdateCompiler(BaseSQLUpdateCompiler, SQLCompiler): From 6150e1c32daa28ea4c294de24c7e7afa9b84aeef Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 4 Dec 2020 11:05:39 +0300 Subject: [PATCH 09/31] re-run --- django_spanner/compiler.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/django_spanner/compiler.py b/django_spanner/compiler.py index a497b7b913..067649dd8d 100644 --- a/django_spanner/compiler.py +++ b/django_spanner/compiler.py @@ -101,16 +101,11 @@ class SQLInsertCompiler(BaseSQLInsertCompiler, SQLCompiler): class SQLDeleteCompiler(BaseSQLDeleteCompiler, SQLCompiler): - def _as_sql(self, query): - result = [ - "DELETE FROM %s" % self.quote_name_unless_alias(query.base_table) - ] - where, params = self.compile(query.where) - if where: - result.append("WHERE %s" % where) - else: - result.append("WHERE 1=1") - return " ".join(result), tuple(params) + def as_sql(self): + query = super().as_sql() + if not self.where: + query += "WHERE 1=1" + return query class SQLUpdateCompiler(BaseSQLUpdateCompiler, SQLCompiler): From 1d85f8072e6aebbb8fbedaf578879602fcd36a22 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 4 Dec 2020 11:08:32 +0300 Subject: [PATCH 10/31] don't change delete compiler --- django_spanner/compiler.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/django_spanner/compiler.py b/django_spanner/compiler.py index 067649dd8d..61d980a6f3 100644 --- a/django_spanner/compiler.py +++ b/django_spanner/compiler.py @@ -101,11 +101,7 @@ class SQLInsertCompiler(BaseSQLInsertCompiler, SQLCompiler): class SQLDeleteCompiler(BaseSQLDeleteCompiler, SQLCompiler): - def as_sql(self): - query = super().as_sql() - if not self.where: - query += "WHERE 1=1" - return query + pass class SQLUpdateCompiler(BaseSQLUpdateCompiler, SQLCompiler): From cfbcd34468316e7c165f7db5dc547a3c63e9d639 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 4 Dec 2020 12:11:06 +0300 Subject: [PATCH 11/31] re-run --- 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 89187af7d3..d5784eeea0 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -12,8 +12,8 @@ export PYTHONUNBUFFERED=1 # Export essential environment variables for Django tests. export RUNNING_SPANNER_BACKEND_TESTS=1 -pip3 install . +pip3 install . pip3 uninstall -y google-cloud-spanner pip3 install -e 'git+https://github.com/q-logic/python-spanner.git@autocommit_change#egg=google-cloud-spanner' From 6e408efd9b40f80b5c4ebe248495bb363d23b9c0 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 4 Dec 2020 13:32:10 +0300 Subject: [PATCH 12/31] revert debug changes --- django_test_suite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index d5784eeea0..3f9c9d8d39 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 -x pipefail +set -e # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 @@ -70,7 +70,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=3 --noinput --settings $SETTINGS_FILE + python3 runtests.py $TEST_APPS --verbosity=2 --noinput --settings $SETTINGS_FILE } run_django_tests From 1dbc429a00326c9f1a715c8b21e93f6e87e9a6b7 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 4 Dec 2020 13:37:48 +0300 Subject: [PATCH 13/31] re-run --- django_test_suite.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index 3f9c9d8d39..39cf902f21 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -4,8 +4,7 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -# exit when any command fails -set -e +set -x pipefail # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 From 4a2397326d5d588984e0df14ad523cb64118a303 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 7 Dec 2020 11:27:34 +0300 Subject: [PATCH 14/31] re-run --- .../django_tests_against_emulator.yml | 1 + django_spanner/features.py | 16 +++++-------- django_test_suite.sh | 24 ++++++++----------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/workflows/django_tests_against_emulator.yml b/.github/workflows/django_tests_against_emulator.yml index 462f5e427d..f8b7fc7d1d 100644 --- a/.github/workflows/django_tests_against_emulator.yml +++ b/.github/workflows/django_tests_against_emulator.yml @@ -28,6 +28,7 @@ jobs: SPANNER_EMULATOR_HOST: localhost:9010 GOOGLE_CLOUD_PROJECT: emulator-test-project GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE: true + RUNNING_SPANNER_BACKEND_TESTS: 1 DJANGO_WORKER_INDEX: 0 DJANGO_WORKER_COUNT: 1 SPANNER_TEST_INSTANCE: google-cloud-django-backend-tests diff --git a/django_spanner/features.py b/django_spanner/features.py index 771dd0b939..7ac4903ac0 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -326,17 +326,13 @@ class DatabaseFeatures(BaseDatabaseFeatures): "model_formsets.tests.ModelFormsetTest.test_prevent_change_outer_model_and_create_invalid_data", "model_formsets_regress.tests.FormfieldShouldDeleteFormTests.test_no_delete", "model_formsets_regress.tests.FormsetTests.test_extraneous_query_is_not_run", + # os.chmod() doesn't work on Kokoro? + "file_uploads.tests.DirectoryCreationTests.test_readonly_root", + # Tests that sometimes fail on Kokoro for unknown reasons. + "contenttypes_tests.test_models.ContentTypesTests.test_cache_not_shared_between_managers", + "migration_test_data_persistence.tests.MigrationDataNormalPersistenceTestCase.test_persistence", + "servers.test_liveserverthread.LiveServerThreadTest.test_closes_connections", ) - # Kokoro-specific skips. - if os.environ.get("KOKORO_JOB_NAME"): - skip_tests += ( - # os.chmod() doesn't work on Kokoro? - "file_uploads.tests.DirectoryCreationTests.test_readonly_root", - # Tests that sometimes fail on Kokoro for unknown reasons. - "contenttypes_tests.test_models.ContentTypesTests.test_cache_not_shared_between_managers", - "migration_test_data_persistence.tests.MigrationDataNormalPersistenceTestCase.test_persistence", - "servers.test_liveserverthread.LiveServerThreadTest.test_closes_connections", - ) if os.environ.get("SPANNER_EMULATOR_HOST", None): # Some code isn't yet supported by the Spanner emulator. diff --git a/django_test_suite.sh b/django_test_suite.sh index 39cf902f21..77d1953efb 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -9,21 +9,22 @@ set -x pipefail # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 -# Export essential environment variables for Django tests. -export RUNNING_SPANNER_BACKEND_TESTS=1 +sudo apt-get update -y +sudo apt-get install -y libmemcached-dev pip3 install . pip3 uninstall -y google-cloud-spanner +pip3 uninstall -y django-google-spanner pip3 install -e 'git+https://github.com/q-logic/python-spanner.git@autocommit_change#egg=google-cloud-spanner' +pip3 install -e 'git+https://github.com/q-logic/python-spanner-django.git@dj_tests_against_emulator#egg=django-google-spanner' -# 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" +export DJANGO_TESTS_DIR="django_tests_dir" 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 +sudo apt-get install -y libffi-dev libjpeg-dev zlib1g-devel + cd $DJANGO_TESTS_DIR/django && pip3 install -e . && pip3 install -r tests/requirements/py3.txt; cd ../../ python3 create_test_instance.py @@ -65,11 +66,6 @@ PASSWORD_HASHERS = [ ! } -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 -} - -run_django_tests +cd $TESTS_DIR/django/tests +create_settings +python3 runtests.py admin_changelist admin_docs admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress many_to_many many_to_one many_to_one_null max_lengths migrate_signals migrations migration_test_data_persistence modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation view_tests --verbosity=3 --noinput --settings $SETTINGS_FILE From 45fd22f8ff6dbc0bd618064832f69af47b2f3eab Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 7 Dec 2020 15:58:30 +0300 Subject: [PATCH 15/31] 900 --- django_spanner/features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_spanner/features.py b/django_spanner/features.py index 7ac4903ac0..4a01c919ab 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -21,7 +21,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): # Spanner uses REGEXP_CONTAINS which is case-sensitive. has_case_insensitive_like = False # https://cloud.google.com/spanner/quotas#query_limits - max_query_params = 950 + max_query_params = 900 supports_foreign_keys = False supports_ignore_conflicts = False supports_partial_indexes = False From 9dc1c135d5726761644e1f177d2cf91895377e66 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 7 Dec 2020 16:39:10 +0300 Subject: [PATCH 16/31] re-run --- django_test_suite.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index 77d1953efb..f23328d380 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -6,12 +6,12 @@ set -x pipefail -# Disable buffering, so that the logs stream through. -export PYTHONUNBUFFERED=1 - sudo apt-get update -y sudo apt-get install -y libmemcached-dev +# Disable buffering, so that the logs stream through. +export PYTHONUNBUFFERED=1 + pip3 install . pip3 uninstall -y google-cloud-spanner pip3 uninstall -y django-google-spanner From 3b5cef240e18836a5a2849f6c1ad32ac83c89720 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 7 Dec 2020 17:08:56 +0300 Subject: [PATCH 17/31] try splitting tests --- django_test_suite.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index f23328d380..e0351efff7 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -68,4 +68,5 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings -python3 runtests.py admin_changelist admin_docs admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress many_to_many many_to_one many_to_one_null max_lengths migrate_signals migrations migration_test_data_persistence modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation view_tests --verbosity=3 --noinput --settings $SETTINGS_FILE +python3 runtests.py max_lengths migrate_signals migrations migration_test_data_persistence modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE +python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From 70e2e77a27a40a588a0574a8ad3ed67bfd31551a Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 7 Dec 2020 17:19:41 +0300 Subject: [PATCH 18/31] more splits --- django_test_suite.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index e0351efff7..a81fcf7bc7 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -68,5 +68,7 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings -python3 runtests.py max_lengths migrate_signals migrations migration_test_data_persistence modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE -python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE +python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE +python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE +python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From 00f42f002f959544ef4dd6bb793a08097671155d Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Tue, 8 Dec 2020 10:39:42 +0300 Subject: [PATCH 19/31] parallel --- django_test_suite.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index a81fcf7bc7..5c3fc4a17f 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -68,7 +68,7 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings -python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE -python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE -python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE +python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & +python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & +python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From 9dee14b0eaebb403c6418146d8858615e70846dd Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Wed, 9 Dec 2020 11:03:38 +0300 Subject: [PATCH 20/31] use several emulator --- .../workflows/django_tests_against_emulator.yml | 15 +++++++++++++-- django_test_suite.sh | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/django_tests_against_emulator.yml b/.github/workflows/django_tests_against_emulator.yml index f8b7fc7d1d..c4e41eab0d 100644 --- a/.github/workflows/django_tests_against_emulator.yml +++ b/.github/workflows/django_tests_against_emulator.yml @@ -9,11 +9,22 @@ jobs: runs-on: ubuntu-latest services: - emulator: + emulator-0: image: gcr.io/cloud-spanner-emulator/emulator:latest ports: - 9010:9010 - - 9020:9020 + emulator-1: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9011:9010 + emulator-2: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9012:9010 + emulator-3: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9013:9010 steps: - name: Checkout code diff --git a/django_test_suite.sh b/django_test_suite.sh index 5c3fc4a17f..a2057ba24a 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -68,7 +68,7 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings -python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & -python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & -python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & -python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9011 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9013 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From c1ac8159d06170d2a6656fd0709f9c951fce25cc Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Wed, 9 Dec 2020 11:24:57 +0300 Subject: [PATCH 21/31] create instance in every thread --- django_test_suite.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index a2057ba24a..a391dbc71c 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -27,7 +27,10 @@ sudo apt-get install -y libffi-dev libjpeg-dev zlib1g-devel cd $DJANGO_TESTS_DIR/django && pip3 install -e . && pip3 install -r tests/requirements/py3.txt; cd ../../ -python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9010 python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9011 python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9012 python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9013 python3 create_test_instance.py # If no SPANNER_TEST_DB is set, generate a unique one # so that we can have multiple tests running without @@ -68,6 +71,7 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings + SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9011 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & From e7a3aac911b5d3dc5f27976e87a438ef7d9e822b Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Wed, 9 Dec 2020 21:53:36 +0300 Subject: [PATCH 22/31] use 8 threads --- .../django_tests_against_emulator.yml | 16 ++++++++++++++++ django_test_suite.sh | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/django_tests_against_emulator.yml b/.github/workflows/django_tests_against_emulator.yml index c4e41eab0d..c52a4e8b58 100644 --- a/.github/workflows/django_tests_against_emulator.yml +++ b/.github/workflows/django_tests_against_emulator.yml @@ -25,6 +25,22 @@ jobs: image: gcr.io/cloud-spanner-emulator/emulator:latest ports: - 9013:9010 + emulator-4: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9014:9010 + emulator-5: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9015:9010 + emulator-6: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9016:9010 + emulator-7: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9017:9010 steps: - name: Checkout code diff --git a/django_test_suite.sh b/django_test_suite.sh index a391dbc71c..7ac99bfcbe 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -31,6 +31,10 @@ SPANNER_EMULATOR_HOST=localhost:9010 python3 create_test_instance.py SPANNER_EMULATOR_HOST=localhost:9011 python3 create_test_instance.py SPANNER_EMULATOR_HOST=localhost:9012 python3 create_test_instance.py SPANNER_EMULATOR_HOST=localhost:9013 python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9014 python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9015 python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9016 python3 create_test_instance.py +SPANNER_EMULATOR_HOST=localhost:9017 python3 create_test_instance.py # If no SPANNER_TEST_DB is set, generate a unique one # so that we can have multiple tests running without @@ -72,7 +76,14 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings -SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9011 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9013 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9011 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & + +SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9013 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & + +SPANNER_EMULATOR_HOST=localhost:9014 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9015 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & + +SPANNER_EMULATOR_HOST=localhost:9016 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9017 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From 4c9daf2c48444f7fcead52aa4fa586a820051cc6 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 11 Dec 2020 10:52:46 +0300 Subject: [PATCH 23/31] skip tests, which are using unsupported types --- django_spanner/features.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/django_spanner/features.py b/django_spanner/features.py index 4a01c919ab..8271d090e5 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -1102,8 +1102,27 @@ class DatabaseFeatures(BaseDatabaseFeatures): "expressions.tests.ValueTests.test_update_TimeField_using_Value", # noqa "expressions.tests.ValueTests.test_update_UUIDField_using_Value", # noqa "fixtures.tests.FixtureLoadingTests.test_loaddata_error_message", # noqa + "fixtures.tests.FixtureTransactionTests.test_format_discovery", # noqa "fixtures.tests.ForwardReferenceTests.test_forward_reference_fk", # noqa "fixtures.tests.ForwardReferenceTests.test_forward_reference_m2m", # noqa + "flatpages_tests.test_csrf.FlatpageCSRFTests.test_view_authenticated_flatpage", # noqa + "flatpages_tests.test_middleware.FlatpageMiddlewareTests.test_fallback_authenticated_flatpage", # noqa + "flatpages_tests.test_middleware.FlatpageMiddlewareTests.test_view_authenticated_flatpage", # noqa + "flatpages_tests.test_templatetags.FlatpageTemplateTagTests.test_get_flatpages_tag_for_user", # noqa + "flatpages_tests.test_templatetags.FlatpageTemplateTagTests.test_get_flatpages_with_prefix_for_user", # noqa + "flatpages_tests.test_views.FlatpageViewTests.test_view_authenticated_flatpage", # noqa + "generic_inline_admin.tests.GenericAdminViewTest.test_basic_add_GET", # noqa + "generic_inline_admin.tests.GenericAdminViewTest.test_basic_add_POST", # noqa + "generic_inline_admin.tests.GenericAdminViewTest.test_basic_edit_GET", # noqa + "generic_inline_admin.tests.GenericAdminViewTest.test_basic_edit_POST", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.testMaxNumParam ", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_extra_param", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_get_max_num", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_get_min_num", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_min_num_param", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_no_param", # noqa + "generic_inline_admin.tests.GenericInlineAdminWithUniqueTogetherTest.test_add", # noqa + "generic_inline_admin.tests.GenericInlineAdminWithUniqueTogetherTest.test_delete", # noqa "get_or_create.tests.GetOrCreateTests.test_get_or_create_invalid_params", # noqa "get_or_create.tests.GetOrCreateTestsWithManualPKs.test_create_with_duplicate_primary_key", # noqa "get_or_create.tests.GetOrCreateTestsWithManualPKs.test_get_or_create_raises_IntegrityError_plus_traceback", # noqa From 93eb7faaf2ff7390fd97001317bf88cb341e3376 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 11 Dec 2020 10:56:23 +0300 Subject: [PATCH 24/31] re-run --- django_test_suite.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index 7ac99bfcbe..a05ef0d57e 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -78,12 +78,9 @@ create_settings SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9011 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & - SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9013 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & - SPANNER_EMULATOR_HOST=localhost:9014 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9015 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & - SPANNER_EMULATOR_HOST=localhost:9016 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress --verbosity=3 --noinput --settings $SETTINGS_FILE SPANNER_EMULATOR_HOST=localhost:9017 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From e7e89fd6cb479c78447f5e023a0b3fafeade11f7 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Fri, 11 Dec 2020 11:00:16 +0300 Subject: [PATCH 25/31] fix typo --- django_spanner/features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_spanner/features.py b/django_spanner/features.py index 8271d090e5..7b308cc539 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -1115,7 +1115,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): "generic_inline_admin.tests.GenericAdminViewTest.test_basic_add_POST", # noqa "generic_inline_admin.tests.GenericAdminViewTest.test_basic_edit_GET", # noqa "generic_inline_admin.tests.GenericAdminViewTest.test_basic_edit_POST", # noqa - "generic_inline_admin.tests.GenericInlineAdminParametersTest.testMaxNumParam ", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.testMaxNumParam", # noqa "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_extra_param", # noqa "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_get_max_num", # noqa "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_get_min_num", # noqa From eaf53745708155cf7038530b44fefb8c934cad1e Mon Sep 17 00:00:00 2001 From: Chris Kleinknecht Date: Fri, 11 Dec 2020 16:01:47 -0800 Subject: [PATCH 26/31] Fix typos in test runner script --- django_test_suite.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index a05ef0d57e..c781563225 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -77,10 +77,10 @@ cd $TESTS_DIR/django/tests create_settings SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9011 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9011 python3 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9013 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9013 python3 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9014 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9015 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9015 python3 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & SPANNER_EMULATOR_HOST=localhost:9016 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress --verbosity=3 --noinput --settings $SETTINGS_FILE -SPANNER_EMULATOR_HOST=localhost:9017 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9017 python3 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From 1c35b27ab7bdb3235b30d2507be29d504d4c08d3 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 14 Dec 2020 11:56:15 +0300 Subject: [PATCH 27/31] use unique instance names --- create_test_instance.py | 3 ++- django_spanner/features.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/create_test_instance.py b/create_test_instance.py index df59738895..ffd0c41992 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -13,6 +13,7 @@ # limitations under the License. import os +import uuid from google.cloud.spanner_v1 import Client @@ -21,6 +22,6 @@ project=os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") ) -instance = client.instance("google-cloud-django-backend-tests") +instance = client.instance("django-backend-tests-" + uuid.uuid4().hex[:10]) created_op = instance.create() created_op.result(30) # block until completion diff --git a/django_spanner/features.py b/django_spanner/features.py index 7b308cc539..cbb365ac67 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -1116,6 +1116,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): "generic_inline_admin.tests.GenericAdminViewTest.test_basic_edit_GET", # noqa "generic_inline_admin.tests.GenericAdminViewTest.test_basic_edit_POST", # noqa "generic_inline_admin.tests.GenericInlineAdminParametersTest.testMaxNumParam", # noqa + "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_get_extra", # noqa "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_extra_param", # noqa "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_get_max_num", # noqa "generic_inline_admin.tests.GenericInlineAdminParametersTest.test_get_min_num", # noqa From 898993965bfa1b0bea538cb8dcac9949beb72eaf Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 14 Dec 2020 12:00:30 +0300 Subject: [PATCH 28/31] revert --- create_test_instance.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/create_test_instance.py b/create_test_instance.py index ffd0c41992..df59738895 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -13,7 +13,6 @@ # limitations under the License. import os -import uuid from google.cloud.spanner_v1 import Client @@ -22,6 +21,6 @@ project=os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") ) -instance = client.instance("django-backend-tests-" + uuid.uuid4().hex[:10]) +instance = client.instance("google-cloud-django-backend-tests") created_op = instance.create() created_op.result(30) # block until completion From 3c4c46886f70d30994f5ae00619212a429163f91 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 14 Dec 2020 12:04:17 +0300 Subject: [PATCH 29/31] separate instances --- create_test_instance.py | 5 ++++- django_test_suite.sh | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/create_test_instance.py b/create_test_instance.py index df59738895..f546c4dcd6 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -21,6 +21,9 @@ project=os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") ) -instance = client.instance("google-cloud-django-backend-tests") +instance = client.instance( + "google-cloud-django-backend-tests-" + + os.environ["SPANNER_EMULATOR_HOST"][-1] +) created_op = instance.create() created_op.result(30) # block until completion diff --git a/django_test_suite.sh b/django_test_suite.sh index c781563225..76dac38a31 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -76,11 +76,11 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings -SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9011 python3 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9013 python3 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9014 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9015 python3 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9016 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress --verbosity=3 --noinput --settings $SETTINGS_FILE -SPANNER_EMULATOR_HOST=localhost:9017 python3 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9010 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-0 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9011 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-1 python3 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9012 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-2 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9013 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-3 python3 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9014 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-4 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9015 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-5 python3 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9016 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-6 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9017 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-7 python3 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE From 82855cb61bf656edf47ec14374f78a08a860b2ed Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 14 Dec 2020 12:14:36 +0300 Subject: [PATCH 30/31] re-run --- django_test_suite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index 76dac38a31..2d7e39cbc3 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -43,7 +43,7 @@ SPANNER_EMULATOR_HOST=localhost:9017 python3 create_test_instance.py TEST_DBNAME=${SPANNER_TEST_DB:-$(python3 -c 'import os, time; print(chr(ord("a") + time.time_ns() % 26)+os.urandom(10).hex())')} TEST_DBNAME_OTHER="$TEST_DBNAME-ot" TEST_APPS=${DJANGO_TEST_APPS:-basic} -INSTANCE=${SPANNER_TEST_INSTANCE:-django-tests} +INSTANCE=${SPANNER_TEST_INSTANCE} PROJECT=${PROJECT_ID} SPANNER_EMULATOR_HOST=${SPANNER_EMULATOR_HOST} GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT} @@ -62,7 +62,7 @@ DATABASES = { 'other': { 'ENGINE': 'django_spanner', 'PROJECT': "$PROJECT", - 'INSTANCE': "$INSTANCE", + 'INSTANCE': "$SPANNER_TEST_INSTANCE", 'NAME': "$TEST_DBNAME_OTHER", }, } From 548a53263bb346d441d1e6a73a44cb3a97ccd966 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Mon, 14 Dec 2020 12:20:40 +0300 Subject: [PATCH 31/31] revert --- create_test_instance.py | 5 +---- django_test_suite.sh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/create_test_instance.py b/create_test_instance.py index f546c4dcd6..df59738895 100644 --- a/create_test_instance.py +++ b/create_test_instance.py @@ -21,9 +21,6 @@ project=os.getenv("GOOGLE_CLOUD_PROJECT", "emulator-test-project") ) -instance = client.instance( - "google-cloud-django-backend-tests-" - + os.environ["SPANNER_EMULATOR_HOST"][-1] -) +instance = client.instance("google-cloud-django-backend-tests") created_op = instance.create() created_op.result(30) # block until completion diff --git a/django_test_suite.sh b/django_test_suite.sh index 2d7e39cbc3..c781563225 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -43,7 +43,7 @@ SPANNER_EMULATOR_HOST=localhost:9017 python3 create_test_instance.py TEST_DBNAME=${SPANNER_TEST_DB:-$(python3 -c 'import os, time; print(chr(ord("a") + time.time_ns() % 26)+os.urandom(10).hex())')} TEST_DBNAME_OTHER="$TEST_DBNAME-ot" TEST_APPS=${DJANGO_TEST_APPS:-basic} -INSTANCE=${SPANNER_TEST_INSTANCE} +INSTANCE=${SPANNER_TEST_INSTANCE:-django-tests} PROJECT=${PROJECT_ID} SPANNER_EMULATOR_HOST=${SPANNER_EMULATOR_HOST} GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT} @@ -62,7 +62,7 @@ DATABASES = { 'other': { 'ENGINE': 'django_spanner', 'PROJECT': "$PROJECT", - 'INSTANCE': "$SPANNER_TEST_INSTANCE", + 'INSTANCE': "$INSTANCE", 'NAME': "$TEST_DBNAME_OTHER", }, } @@ -76,11 +76,11 @@ PASSWORD_HASHERS = [ cd $TESTS_DIR/django/tests create_settings -SPANNER_EMULATOR_HOST=localhost:9010 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-0 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9011 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-1 python3 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9012 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-2 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9013 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-3 python3 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9014 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-4 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9015 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-5 python3 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & -SPANNER_EMULATOR_HOST=localhost:9016 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-6 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress --verbosity=3 --noinput --settings $SETTINGS_FILE -SPANNER_EMULATOR_HOST=localhost:9017 SPANNER_TEST_INSTANCE=google-cloud-django-backend-tests-7 python3 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9010 python3 runtests.py modeladmin model_fields model_forms model_formsets model_formsets_regress model_indexes model_inheritance model_inheritance_regress model_options model_package model_regress multiple_database --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9011 python3 mutually_referential nested_foreign_keys null_fk null_fk_ordering null_queries one_to_one ordering order_with_respect_to or_lookups prefetch_related proxy_model_inheritance proxy_models queries queryset_pickle raw_query redirects_tests reserved_names reverse_lookup save_delete_hooks schema --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9012 python3 runtests.py migration_test_data_persistence max_lengths migrate_signals migrations select_for_update select_related select_related_onetoone select_related_regress serializers servers sessions_tests signals --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9013 python3 sitemaps_tests sites_framework sites_tests string_lookup syndication_tests test_client test_client_regress test_runner test_utils timezones transaction_hooks transactions unmanaged_models update update_only_fields validation admin_changelist admin_docs view_tests many_to_many many_to_one many_to_one_null --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9014 python3 runtests.py admin_filters admin_inlines admin_ordering admin_utils admin_views aggregation aggregation_regress annotations auth_tests backends basic bulk_create cache choices constraints contenttypes_tests --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9015 python3 custom_columns custom_lookups custom_managers custom_methods custom_pk datatypes dates datetimes db_functions defer defer_regress delete delete_regress distinct_on_fields empty expressions expressions_case expressions_window extra_regress field_defaults file_storage file_uploads filtered_relation --verbosity=3 --noinput --settings $SETTINGS_FILE & +SPANNER_EMULATOR_HOST=localhost:9016 python3 runtests.py fixtures fixtures_model_package fixtures_regress flatpages_tests force_insert_update foreign_object forms_tests from_db_value generic_inline_admin generic_relations generic_relations_regress --verbosity=3 --noinput --settings $SETTINGS_FILE +SPANNER_EMULATOR_HOST=localhost:9017 python3 generic_views get_earliest_or_latest get_object_or_404 get_or_create i18n indexes inline_formsets inspectdb introspection invalid_models_tests known_related_objects lookup m2m_and_m2o m2m_intermediary m2m_multiple m2m_recursive m2m_regress m2m_signals m2m_through m2m_through_regress m2o_recursive managers_regress --verbosity=3 --noinput --settings $SETTINGS_FILE