From 12316b493ca0c1e453f7b49bca99b4101e41fa2c Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Wed, 29 Jun 2022 16:17:01 +0530 Subject: [PATCH 01/10] changes for testing in postgres --- tests/system/conftest.py | 41 ++++++++++++++++++------ tests/system/test_backup_api.py | 30 +++++++++++++----- tests/system/test_database_api.py | 2 ++ tests/system/test_session_api.py | 52 ++++++++++++++++++++++++------- 4 files changed, 97 insertions(+), 28 deletions(-) diff --git a/tests/system/conftest.py b/tests/system/conftest.py index b7004fa274..8432c78db9 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -57,6 +57,14 @@ def not_postgres(database_dialect): ) +@pytest.fixture(scope="session") +def not_google_standard_sql(database_dialect): + if database_dialect == DatabaseDialect.GOOGLE_STANDARD_SQL: + pytest.skip( + f"{_helpers.DATABASE_DIALECT_ENVVAR} set to GOOGLE_STANDARD_SQL in environment." + ) + + @pytest.fixture(scope="session") def database_dialect(): return ( @@ -77,7 +85,9 @@ def spanner_client(): credentials=credentials, ) else: - return spanner_v1.Client() # use google.auth.default credentials + return spanner_v1.Client( + client_options={"api_endpoint": "staging-wrenchworks.sandbox.googleapis.com"} + ) # use google.auth.default credentials @pytest.fixture(scope="session") @@ -169,14 +179,27 @@ def shared_instance( def shared_database(shared_instance, database_operation_timeout, database_dialect): database_name = _helpers.unique_id("test_database") pool = spanner_v1.BurstyPool(labels={"testcase": "database_api"}) - database = shared_instance.database( - database_name, - ddl_statements=_helpers.DDL_STATEMENTS, - pool=pool, - database_dialect=database_dialect, - ) - operation = database.create() - operation.result(database_operation_timeout) # raises on failure / timeout. + if(database_dialect == DatabaseDialect.POSTGRESQL): + database = shared_instance.database( + database_name, + pool=pool, + database_dialect=database_dialect, + ) + operation = database.create() + operation.result(database_operation_timeout) # raises on failure / timeout. + + operation = database.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS) + operation.result(database_operation_timeout) # raises on failure / timeout. + + else: + database = shared_instance.database( + database_name, + ddl_statements=_helpers.DDL_STATEMENTS, + pool=pool, + database_dialect=database_dialect, + ) + operation = database.create() + operation.result(database_operation_timeout) # raises on failure / timeout. yield database diff --git a/tests/system/test_backup_api.py b/tests/system/test_backup_api.py index bfcd635e8d..3a72c1a8ea 100644 --- a/tests/system/test_backup_api.py +++ b/tests/system/test_backup_api.py @@ -14,6 +14,7 @@ import datetime import time +from google.cloud.spanner_admin_database_v1.types.common import DatabaseDialect import pytest @@ -96,14 +97,27 @@ def database_version_time(shared_database): def second_database(shared_instance, database_operation_timeout, database_dialect): database_name = _helpers.unique_id("test_database2") pool = spanner_v1.BurstyPool(labels={"testcase": "database_api"}) - database = shared_instance.database( - database_name, - ddl_statements=_helpers.DDL_STATEMENTS, - pool=pool, - database_dialect=database_dialect, - ) - operation = database.create() - operation.result(database_operation_timeout) # raises on failure / timeout. + if(database_dialect == DatabaseDialect.POSTGRESQL): + database = shared_instance.database( + database_name, + pool=pool, + database_dialect=database_dialect, + ) + operation = database.create() + operation.result(database_operation_timeout) # raises on failure / timeout. + + operation = database.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS) + operation.result(database_operation_timeout) # raises on failure / timeout. + + else: + database = shared_instance.database( + database_name, + ddl_statements=_helpers.DDL_STATEMENTS, + pool=pool, + database_dialect=database_dialect, + ) + operation = database.create() + operation.result(database_operation_timeout) # raises on failure / timeout. yield database diff --git a/tests/system/test_database_api.py b/tests/system/test_database_api.py index 1d21a77498..e9e6c69287 100644 --- a/tests/system/test_database_api.py +++ b/tests/system/test_database_api.py @@ -129,6 +129,7 @@ def test_create_database_pitr_success( def test_create_database_with_default_leader_success( not_emulator, # Default leader setting not supported by the emulator + not_postgres, multiregion_instance, databases_to_delete, ): @@ -270,6 +271,7 @@ def test_update_ddl_w_pitr_success( def test_update_ddl_w_default_leader_success( not_emulator, + not_postgres, multiregion_instance, databases_to_delete, ): diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py index f211577abd..6cf096c44a 100644 --- a/tests/system/test_session_api.py +++ b/tests/system/test_session_api.py @@ -200,13 +200,29 @@ def sessions_database(shared_instance, database_operation_timeout, database_dialect): database_name = _helpers.unique_id("test_sessions", separator="_") pool = spanner_v1.BurstyPool(labels={"testcase": "session_api"}) - sessions_database = shared_instance.database( + + if(database_dialect == DatabaseDialect.POSTGRESQL): + sessions_database = shared_instance.database( + database_name, + pool=pool, + database_dialect=database_dialect, + ) + + operation = sessions_database.create() + operation.result(database_operation_timeout) + + operation = sessions_database.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS) + operation.result(database_operation_timeout) + + else: + sessions_database = shared_instance.database( database_name, ddl_statements=_helpers.DDL_STATEMENTS, pool=pool, - ) - operation = sessions_database.create() - operation.result(database_operation_timeout) # raises on failure / timeout. + ) + + operation = sessions_database.create() + operation.result(database_operation_timeout) _helpers.retry_has_all_dll(sessions_database.reload)() # Some tests expect there to be a session present in the pool. @@ -1322,16 +1338,30 @@ def test_read_w_index( # Create an alternate dataase w/ index. extra_ddl = ["CREATE INDEX contacts_by_last_name ON contacts(last_name)"] pool = spanner_v1.BurstyPool(labels={"testcase": "read_w_index"}) - temp_db = shared_instance.database( + + if(database_dialect == DatabaseDialect.POSTGRESQL): + temp_db = shared_instance.database( _helpers.unique_id("test_read", separator="_"), - ddl_statements=_helpers.DDL_STATEMENTS + extra_ddl, pool=pool, database_dialect=database_dialect, ) - operation = temp_db.create() - databases_to_delete.append(temp_db) - operation.result(database_operation_timeout) # raises on failure / timeout. + operation = temp_db.create() + operation.result(database_operation_timeout) + operation = temp_db.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS + extra_ddl,) + operation.result(database_operation_timeout) + + else: + temp_db = shared_instance.database( + _helpers.unique_id("test_read", separator="_"), + ddl_statements=_helpers.DDL_STATEMENTS + extra_ddl, + pool=pool, + database_dialect=database_dialect, + ) + operation = temp_db.create() + operation.result(database_operation_timeout) # raises on failure / timeout. + + databases_to_delete.append(temp_db) committed = _set_up_table(temp_db, row_count) with temp_db.snapshot(read_timestamp=committed) as snapshot: @@ -2040,7 +2070,7 @@ def test_execute_sql_w_date_bindings(sessions_database, not_postgres, database_d def test_execute_sql_w_numeric_bindings( - not_emulator, not_postgres, sessions_database, database_dialect + not_emulator, sessions_database, database_dialect ): if database_dialect == DatabaseDialect.POSTGRESQL: _bind_test_helper( @@ -2060,7 +2090,7 @@ def test_execute_sql_w_numeric_bindings( ) -def test_execute_sql_w_json_bindings(not_emulator, sessions_database, database_dialect): +def test_execute_sql_w_json_bindings(not_emulator, not_postgres, sessions_database, database_dialect): _bind_test_helper( sessions_database, database_dialect, From 2dfd9878a66d8ad2c029361a3fabfc8bc43fd01f Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Wed, 29 Jun 2022 18:43:02 +0530 Subject: [PATCH 02/10] parametrized testing --- noxfile.py | 5 ++++- tests/system/conftest.py | 14 +++++++------ tests/system/test_backup_api.py | 10 ++++----- tests/system/test_session_api.py | 36 ++++++++++++++++++-------------- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/noxfile.py b/noxfile.py index 265933acd7..2cca2f89da 100644 --- a/noxfile.py +++ b/noxfile.py @@ -238,7 +238,8 @@ def install_systemtest_dependencies(session, *constraints): @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) -def system(session): +@nox.parametrize("database_dialect", ["GOOGLE_STANDARD_SQL", "POSTGRESQL"]) +def system(session, database_dialect): """Run the system test suite.""" constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" @@ -277,6 +278,7 @@ def system(session): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_path, *session.posargs, + env={"SPANNER_DATABASE_DIALECT": database_dialect}, ) if system_test_folder_exists: session.run( @@ -285,6 +287,7 @@ def system(session): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_folder_path, *session.posargs, + env={"SPANNER_DATABASE_DIALECT": database_dialect}, ) diff --git a/tests/system/conftest.py b/tests/system/conftest.py index 8432c78db9..26404ef346 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -86,7 +86,9 @@ def spanner_client(): ) else: return spanner_v1.Client( - client_options={"api_endpoint": "staging-wrenchworks.sandbox.googleapis.com"} + client_options={ + "api_endpoint": "staging-wrenchworks.sandbox.googleapis.com" + } ) # use google.auth.default credentials @@ -179,19 +181,19 @@ def shared_instance( def shared_database(shared_instance, database_operation_timeout, database_dialect): database_name = _helpers.unique_id("test_database") pool = spanner_v1.BurstyPool(labels={"testcase": "database_api"}) - if(database_dialect == DatabaseDialect.POSTGRESQL): + if database_dialect == DatabaseDialect.POSTGRESQL: database = shared_instance.database( database_name, pool=pool, database_dialect=database_dialect, ) operation = database.create() - operation.result(database_operation_timeout) # raises on failure / timeout. + operation.result(database_operation_timeout) # raises on failure / timeout. operation = database.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS) - operation.result(database_operation_timeout) # raises on failure / timeout. + operation.result(database_operation_timeout) # raises on failure / timeout. - else: + else: database = shared_instance.database( database_name, ddl_statements=_helpers.DDL_STATEMENTS, @@ -199,7 +201,7 @@ def shared_database(shared_instance, database_operation_timeout, database_dialec database_dialect=database_dialect, ) operation = database.create() - operation.result(database_operation_timeout) # raises on failure / timeout. + operation.result(database_operation_timeout) # raises on failure / timeout. yield database diff --git a/tests/system/test_backup_api.py b/tests/system/test_backup_api.py index 3a72c1a8ea..dc80653786 100644 --- a/tests/system/test_backup_api.py +++ b/tests/system/test_backup_api.py @@ -97,19 +97,19 @@ def database_version_time(shared_database): def second_database(shared_instance, database_operation_timeout, database_dialect): database_name = _helpers.unique_id("test_database2") pool = spanner_v1.BurstyPool(labels={"testcase": "database_api"}) - if(database_dialect == DatabaseDialect.POSTGRESQL): + if database_dialect == DatabaseDialect.POSTGRESQL: database = shared_instance.database( database_name, pool=pool, database_dialect=database_dialect, ) operation = database.create() - operation.result(database_operation_timeout) # raises on failure / timeout. + operation.result(database_operation_timeout) # raises on failure / timeout. operation = database.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS) - operation.result(database_operation_timeout) # raises on failure / timeout. + operation.result(database_operation_timeout) # raises on failure / timeout. - else: + else: database = shared_instance.database( database_name, ddl_statements=_helpers.DDL_STATEMENTS, @@ -117,7 +117,7 @@ def second_database(shared_instance, database_operation_timeout, database_dialec database_dialect=database_dialect, ) operation = database.create() - operation.result(database_operation_timeout) # raises on failure / timeout. + operation.result(database_operation_timeout) # raises on failure / timeout. yield database diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py index 6cf096c44a..13c3e246ed 100644 --- a/tests/system/test_session_api.py +++ b/tests/system/test_session_api.py @@ -201,11 +201,11 @@ def sessions_database(shared_instance, database_operation_timeout, database_dial database_name = _helpers.unique_id("test_sessions", separator="_") pool = spanner_v1.BurstyPool(labels={"testcase": "session_api"}) - if(database_dialect == DatabaseDialect.POSTGRESQL): + if database_dialect == DatabaseDialect.POSTGRESQL: sessions_database = shared_instance.database( - database_name, - pool=pool, - database_dialect=database_dialect, + database_name, + pool=pool, + database_dialect=database_dialect, ) operation = sessions_database.create() @@ -213,12 +213,12 @@ def sessions_database(shared_instance, database_operation_timeout, database_dial operation = sessions_database.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS) operation.result(database_operation_timeout) - + else: sessions_database = shared_instance.database( - database_name, - ddl_statements=_helpers.DDL_STATEMENTS, - pool=pool, + database_name, + ddl_statements=_helpers.DDL_STATEMENTS, + pool=pool, ) operation = sessions_database.create() @@ -1339,19 +1339,21 @@ def test_read_w_index( extra_ddl = ["CREATE INDEX contacts_by_last_name ON contacts(last_name)"] pool = spanner_v1.BurstyPool(labels={"testcase": "read_w_index"}) - if(database_dialect == DatabaseDialect.POSTGRESQL): + if database_dialect == DatabaseDialect.POSTGRESQL: temp_db = shared_instance.database( - _helpers.unique_id("test_read", separator="_"), - pool=pool, - database_dialect=database_dialect, - ) + _helpers.unique_id("test_read", separator="_"), + pool=pool, + database_dialect=database_dialect, + ) operation = temp_db.create() operation.result(database_operation_timeout) - operation = temp_db.update_ddl(ddl_statements=_helpers.DDL_STATEMENTS + extra_ddl,) + operation = temp_db.update_ddl( + ddl_statements=_helpers.DDL_STATEMENTS + extra_ddl, + ) operation.result(database_operation_timeout) - else: + else: temp_db = shared_instance.database( _helpers.unique_id("test_read", separator="_"), ddl_statements=_helpers.DDL_STATEMENTS + extra_ddl, @@ -2090,7 +2092,9 @@ def test_execute_sql_w_numeric_bindings( ) -def test_execute_sql_w_json_bindings(not_emulator, not_postgres, sessions_database, database_dialect): +def test_execute_sql_w_json_bindings( + not_emulator, not_postgres, sessions_database, database_dialect +): _bind_test_helper( sessions_database, database_dialect, From 51396d7ba9937fbd74fd137dd4be13cd3710dff8 Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Wed, 29 Jun 2022 18:54:06 +0530 Subject: [PATCH 03/10] parametrized testing --- noxfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/noxfile.py b/noxfile.py index 2cca2f89da..50f51683e4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -270,6 +270,10 @@ def system(session, database_dialect): install_systemtest_dependencies(session, "-c", constraints_path) + # If POSTGRESQL tests and Emulator, skip the tests + if(os.environ.get("SPANNER_EMULATOR_HOST")): + session.skip("Postgresql is not supported by Emulator yet.") + # Run py.test against the system tests. if system_test_exists: session.run( From b286389cb668e8df4ff6d4a1dab952b2ba4b7701 Mon Sep 17 00:00:00 2001 From: ansh0l Date: Wed, 29 Jun 2022 11:57:03 +0530 Subject: [PATCH 04/10] chore: correct skip backup tests env variable (#753) --- noxfile.py | 4 ++-- tests/system/_helpers.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index 50f51683e4..c0b5546729 100644 --- a/noxfile.py +++ b/noxfile.py @@ -271,9 +271,9 @@ def system(session, database_dialect): install_systemtest_dependencies(session, "-c", constraints_path) # If POSTGRESQL tests and Emulator, skip the tests - if(os.environ.get("SPANNER_EMULATOR_HOST")): + if os.environ.get("SPANNER_EMULATOR_HOST") and database_dialect == "POSTGRESQL": session.skip("Postgresql is not supported by Emulator yet.") - + # Run py.test against the system tests. if system_test_exists: session.run( diff --git a/tests/system/_helpers.py b/tests/system/_helpers.py index 0cb00b15ff..51a6d773c4 100644 --- a/tests/system/_helpers.py +++ b/tests/system/_helpers.py @@ -31,7 +31,7 @@ INSTANCE_ID = os.environ.get(INSTANCE_ID_ENVVAR, INSTANCE_ID_DEFAULT) SKIP_BACKUP_TESTS_ENVVAR = "SKIP_BACKUP_TESTS" -SKIP_BACKUP_TESTS = True # os.getenv(SKIP_BACKUP_TESTS_ENVVAR) == True +SKIP_BACKUP_TESTS = os.getenv(SKIP_BACKUP_TESTS_ENVVAR) is not None INSTANCE_OPERATION_TIMEOUT_IN_SECONDS = int( os.getenv("SPANNER_INSTANCE_OPERATION_TIMEOUT_IN_SECONDS", 560) From 85c346076f9bbd93fa93d902902e1dd2b7f13ff1 Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Thu, 30 Jun 2022 11:13:49 +0530 Subject: [PATCH 05/10] increasing timeout --- tests/system/_helpers.py | 2 +- tests/system/conftest.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/system/_helpers.py b/tests/system/_helpers.py index 51a6d773c4..fba1f1a5a5 100644 --- a/tests/system/_helpers.py +++ b/tests/system/_helpers.py @@ -117,7 +117,7 @@ def scrub_instance_ignore_not_found(to_scrub): def cleanup_old_instances(spanner_client): - cutoff = int(time.time()) - 2 * 60 * 60 # two hour ago + cutoff = int(time.time()) - 3 * 60 * 60 # three hour ago instance_filter = "labels.python-spanner-systests:true" for instance_pb in spanner_client.list_instances(filter_=instance_filter): diff --git a/tests/system/conftest.py b/tests/system/conftest.py index 26404ef346..3d6706b582 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -85,11 +85,7 @@ def spanner_client(): credentials=credentials, ) else: - return spanner_v1.Client( - client_options={ - "api_endpoint": "staging-wrenchworks.sandbox.googleapis.com" - } - ) # use google.auth.default credentials + return spanner_v1.Client() # use google.auth.default credentials @pytest.fixture(scope="session") From ae49fde208cc2f3a29192d0650c36240e8fdb0c7 Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Fri, 1 Jul 2022 12:14:46 +0530 Subject: [PATCH 06/10] splitting tests --- .kokoro/build.sh | 2 ++ .../presubmit/system-3.8-google-standard-sql.cfg | 13 +++++++++++++ .../{system-3.8.cfg => system-3.8-postgres.cfg} | 6 ++++++ noxfile.py | 10 ++++------ 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 .kokoro/presubmit/system-3.8-google-standard-sql.cfg rename .kokoro/presubmit/{system-3.8.cfg => system-3.8-postgres.cfg} (60%) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 562b42b844..7dc87d1ee2 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -55,6 +55,8 @@ fi # If NOX_SESSION is set, it only runs the specified session, # otherwise run all the sessions. +if [[ -n "${SPANNER_DATABASE_DIALECT:-}" ]]; then + export SPANNER_DATABASE_DIALECT = ${SPANNER_DATABASE_DIALECT:-} if [[ -n "${NOX_SESSION:-}" ]]; then python3 -m nox -s ${NOX_SESSION:-} else diff --git a/.kokoro/presubmit/system-3.8-google-standard-sql.cfg b/.kokoro/presubmit/system-3.8-google-standard-sql.cfg new file mode 100644 index 0000000000..884dbe8ebc --- /dev/null +++ b/.kokoro/presubmit/system-3.8-google-standard-sql.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Only run this nox session. +env_vars: { + key: "NOX_SESSION" + value: "system-3.8" +} + +# Run for google standard sql +env_vars: { + key: "SPANNER_DATABASE_DIALECT" + value: "GOOGLE_STANDARD_SQL" +} \ No newline at end of file diff --git a/.kokoro/presubmit/system-3.8.cfg b/.kokoro/presubmit/system-3.8-postgres.cfg similarity index 60% rename from .kokoro/presubmit/system-3.8.cfg rename to .kokoro/presubmit/system-3.8-postgres.cfg index f4bcee3db0..e7721abdad 100644 --- a/.kokoro/presubmit/system-3.8.cfg +++ b/.kokoro/presubmit/system-3.8-postgres.cfg @@ -4,4 +4,10 @@ env_vars: { key: "NOX_SESSION" value: "system-3.8" +} + +# Run for postgres +env_vars: { + key: "SPANNER_DATABASE_DIALECT" + value: "POSTGRESQL" } \ No newline at end of file diff --git a/noxfile.py b/noxfile.py index c0b5546729..ca53a6c7ad 100644 --- a/noxfile.py +++ b/noxfile.py @@ -238,8 +238,7 @@ def install_systemtest_dependencies(session, *constraints): @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) -@nox.parametrize("database_dialect", ["GOOGLE_STANDARD_SQL", "POSTGRESQL"]) -def system(session, database_dialect): +def system(session): """Run the system test suite.""" constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" @@ -247,6 +246,9 @@ def system(session, database_dialect): system_test_path = os.path.join("tests", "system.py") system_test_folder_path = os.path.join("tests", "system") + # If POSTGRESQL tests and Emulator, skip the tests + if os.environ.get("SPANNER_EMULATOR_HOST") and os.environ.get("SPANNER_DATABASE_DIALECT") == "POSTGRESQL": + session.skip("Postgresql is not supported by Emulator yet.") # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": session.skip("RUN_SYSTEM_TESTS is set to false, skipping") @@ -270,10 +272,6 @@ def system(session, database_dialect): install_systemtest_dependencies(session, "-c", constraints_path) - # If POSTGRESQL tests and Emulator, skip the tests - if os.environ.get("SPANNER_EMULATOR_HOST") and database_dialect == "POSTGRESQL": - session.skip("Postgresql is not supported by Emulator yet.") - # Run py.test against the system tests. if system_test_exists: session.run( From 63064c742d5c3cd4d79c592e07a14abc35c10bce Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Fri, 1 Jul 2022 15:49:00 +0530 Subject: [PATCH 07/10] changes as per review --- .kokoro/build.sh | 2 ++ noxfile.py | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 7dc87d1ee2..198ecc324b 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -57,6 +57,8 @@ fi # otherwise run all the sessions. if [[ -n "${SPANNER_DATABASE_DIALECT:-}" ]]; then export SPANNER_DATABASE_DIALECT = ${SPANNER_DATABASE_DIALECT:-} +fi + if [[ -n "${NOX_SESSION:-}" ]]; then python3 -m nox -s ${NOX_SESSION:-} else diff --git a/noxfile.py b/noxfile.py index ca53a6c7ad..71dd1fcf55 100644 --- a/noxfile.py +++ b/noxfile.py @@ -280,7 +280,6 @@ def system(session): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_path, *session.posargs, - env={"SPANNER_DATABASE_DIALECT": database_dialect}, ) if system_test_folder_exists: session.run( @@ -289,7 +288,6 @@ def system(session): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_folder_path, *session.posargs, - env={"SPANNER_DATABASE_DIALECT": database_dialect}, ) From b7ff8fc776a80f14633f5398b026c35b01208119 Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Mon, 4 Jul 2022 12:17:28 +0530 Subject: [PATCH 08/10] Revert "changes as per review" This reverts commit 63064c742d5c3cd4d79c592e07a14abc35c10bce. --- .kokoro/build.sh | 2 -- noxfile.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 198ecc324b..7dc87d1ee2 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -57,8 +57,6 @@ fi # otherwise run all the sessions. if [[ -n "${SPANNER_DATABASE_DIALECT:-}" ]]; then export SPANNER_DATABASE_DIALECT = ${SPANNER_DATABASE_DIALECT:-} -fi - if [[ -n "${NOX_SESSION:-}" ]]; then python3 -m nox -s ${NOX_SESSION:-} else diff --git a/noxfile.py b/noxfile.py index 71dd1fcf55..ca53a6c7ad 100644 --- a/noxfile.py +++ b/noxfile.py @@ -280,6 +280,7 @@ def system(session): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_path, *session.posargs, + env={"SPANNER_DATABASE_DIALECT": database_dialect}, ) if system_test_folder_exists: session.run( @@ -288,6 +289,7 @@ def system(session): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_folder_path, *session.posargs, + env={"SPANNER_DATABASE_DIALECT": database_dialect}, ) From f979d31d099f094b975ce113df5d07a61c67f90c Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Mon, 4 Jul 2022 12:17:30 +0530 Subject: [PATCH 09/10] Revert "splitting tests" This reverts commit ae49fde208cc2f3a29192d0650c36240e8fdb0c7. --- .kokoro/build.sh | 2 -- .../presubmit/system-3.8-google-standard-sql.cfg | 13 ------------- .../{system-3.8-postgres.cfg => system-3.8.cfg} | 6 ------ noxfile.py | 10 ++++++---- 4 files changed, 6 insertions(+), 25 deletions(-) delete mode 100644 .kokoro/presubmit/system-3.8-google-standard-sql.cfg rename .kokoro/presubmit/{system-3.8-postgres.cfg => system-3.8.cfg} (60%) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 7dc87d1ee2..562b42b844 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -55,8 +55,6 @@ fi # If NOX_SESSION is set, it only runs the specified session, # otherwise run all the sessions. -if [[ -n "${SPANNER_DATABASE_DIALECT:-}" ]]; then - export SPANNER_DATABASE_DIALECT = ${SPANNER_DATABASE_DIALECT:-} if [[ -n "${NOX_SESSION:-}" ]]; then python3 -m nox -s ${NOX_SESSION:-} else diff --git a/.kokoro/presubmit/system-3.8-google-standard-sql.cfg b/.kokoro/presubmit/system-3.8-google-standard-sql.cfg deleted file mode 100644 index 884dbe8ebc..0000000000 --- a/.kokoro/presubmit/system-3.8-google-standard-sql.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Only run this nox session. -env_vars: { - key: "NOX_SESSION" - value: "system-3.8" -} - -# Run for google standard sql -env_vars: { - key: "SPANNER_DATABASE_DIALECT" - value: "GOOGLE_STANDARD_SQL" -} \ No newline at end of file diff --git a/.kokoro/presubmit/system-3.8-postgres.cfg b/.kokoro/presubmit/system-3.8.cfg similarity index 60% rename from .kokoro/presubmit/system-3.8-postgres.cfg rename to .kokoro/presubmit/system-3.8.cfg index e7721abdad..f4bcee3db0 100644 --- a/.kokoro/presubmit/system-3.8-postgres.cfg +++ b/.kokoro/presubmit/system-3.8.cfg @@ -4,10 +4,4 @@ env_vars: { key: "NOX_SESSION" value: "system-3.8" -} - -# Run for postgres -env_vars: { - key: "SPANNER_DATABASE_DIALECT" - value: "POSTGRESQL" } \ No newline at end of file diff --git a/noxfile.py b/noxfile.py index ca53a6c7ad..c0b5546729 100644 --- a/noxfile.py +++ b/noxfile.py @@ -238,7 +238,8 @@ def install_systemtest_dependencies(session, *constraints): @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) -def system(session): +@nox.parametrize("database_dialect", ["GOOGLE_STANDARD_SQL", "POSTGRESQL"]) +def system(session, database_dialect): """Run the system test suite.""" constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" @@ -246,9 +247,6 @@ def system(session): system_test_path = os.path.join("tests", "system.py") system_test_folder_path = os.path.join("tests", "system") - # If POSTGRESQL tests and Emulator, skip the tests - if os.environ.get("SPANNER_EMULATOR_HOST") and os.environ.get("SPANNER_DATABASE_DIALECT") == "POSTGRESQL": - session.skip("Postgresql is not supported by Emulator yet.") # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": session.skip("RUN_SYSTEM_TESTS is set to false, skipping") @@ -272,6 +270,10 @@ def system(session): install_systemtest_dependencies(session, "-c", constraints_path) + # If POSTGRESQL tests and Emulator, skip the tests + if os.environ.get("SPANNER_EMULATOR_HOST") and database_dialect == "POSTGRESQL": + session.skip("Postgresql is not supported by Emulator yet.") + # Run py.test against the system tests. if system_test_exists: session.run( From e91f8fd89c4117b60a252a309b2c8250998c88c4 Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Mon, 4 Jul 2022 12:20:24 +0530 Subject: [PATCH 10/10] skipping backup testing --- noxfile.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index c0b5546729..42151a22f9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -257,6 +257,9 @@ def system(session, database_dialect): session.skip( "Credentials or emulator host must be set via environment variable" ) + # If POSTGRESQL tests and Emulator, skip the tests + if os.environ.get("SPANNER_EMULATOR_HOST") and database_dialect == "POSTGRESQL": + session.skip("Postgresql is not supported by Emulator yet.") # Install pyopenssl for mTLS testing. if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": @@ -270,10 +273,6 @@ def system(session, database_dialect): install_systemtest_dependencies(session, "-c", constraints_path) - # If POSTGRESQL tests and Emulator, skip the tests - if os.environ.get("SPANNER_EMULATOR_HOST") and database_dialect == "POSTGRESQL": - session.skip("Postgresql is not supported by Emulator yet.") - # Run py.test against the system tests. if system_test_exists: session.run( @@ -282,7 +281,10 @@ def system(session, database_dialect): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_path, *session.posargs, - env={"SPANNER_DATABASE_DIALECT": database_dialect}, + env={ + "SPANNER_DATABASE_DIALECT": database_dialect, + "SKIP_BACKUP_TESTS": "true", + }, ) if system_test_folder_exists: session.run( @@ -291,7 +293,10 @@ def system(session, database_dialect): f"--junitxml=system_{session.python}_sponge_log.xml", system_test_folder_path, *session.posargs, - env={"SPANNER_DATABASE_DIALECT": database_dialect}, + env={ + "SPANNER_DATABASE_DIALECT": database_dialect, + "SKIP_BACKUP_TESTS": "true", + }, )