server/tests-py: Use markers for backends instead of parameterized tests.

I'm trying to shore up the Python integration tests to make them more reliable. In doing so, I noticed this.

---

It feels a lot more sensible as we never run on more than one backend at a time.

This also removes the `check_file_exists` parameter from the setup functions; it never worked. It was always set to the result of a comparison between a backend name and a function, which was always `False`. Enabling it breaks things.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5254
GitOrigin-RevId: 8718ab21527c2ba0a7205d1c01ebaac1a10be844
This commit is contained in:
Samir Talwar 2022-08-02 21:32:46 +02:00 committed by hasura-bot
parent 6dc1eab513
commit 5df8419a4f
10 changed files with 202 additions and 179 deletions

View File

@ -308,6 +308,30 @@ def pytest_unconfigure(config):
return
config.hge_ctx_gql_server.teardown()
def run_on_current_backend(request: pytest.FixtureRequest):
current_backend = request.config.getoption('--backend')
# Currently, we default all tests to run on Postgres with or without a --backend flag.
# As our test suite develops, we may consider running backend-agnostic tests on all
# backends, unless a specific `--backend` flag is passed.
desired_backends = set(name for marker in request.node.iter_markers('backend') for name in marker.args) or set(['postgres'])
return current_backend in desired_backends
def per_backend_tests_fixture(request: pytest.FixtureRequest):
"""
This fixture ignores backend-specific tests unless the relevant --backend flag has been passed.
"""
if not run_on_current_backend(request):
desired_backends = set(name for marker in request.node.iter_markers('backend') for name in marker.args)
pytest.skip('Skipping test. This test can run on ' + ', '.join(desired_backends) + '.')
@pytest.fixture(scope='class', autouse=True)
def per_backend_test_class(request: pytest.FixtureRequest):
return per_backend_tests_fixture(request)
@pytest.fixture(scope='function', autouse=True)
def per_backend_test_function(request: pytest.FixtureRequest):
return per_backend_tests_fixture(request)
@pytest.fixture(scope='module')
def hge_ctx(request):
config = request.config
@ -470,24 +494,28 @@ def per_class_db_schema_for_mutation_tests(request, hge_ctx):
for filename in ['setup', 'teardown', 'schema_setup', 'schema_teardown', 'pre_setup', 'post_teardown']
]
# only lookup files relevant to the tests being run.
# defaults to postgres file lookup
check_file_exists = hge_ctx.backend == backend
if hge_ctx.is_default_backend:
if setup_metadata_api_version == "v1":
db_context = db_context_with_schema_common(
request, hge_ctx, 'schema_setup_files', 'schema_setup.yaml', 'schema_teardown_files', 'schema_teardown.yaml', check_file_exists
request, hge_ctx,
'schema_setup_files', 'schema_setup.yaml',
'schema_teardown_files', 'schema_teardown.yaml',
)
else:
db_context = db_context_with_schema_common_new (
request, hge_ctx, 'schema_setup_files', setup, 'schema_teardown_files', teardown,
schema_setup, schema_teardown, pre_setup, post_teardown, check_file_exists
db_context = db_context_with_schema_common_new(
request, hge_ctx,
'schema_setup_files', setup,
'schema_teardown_files', teardown,
schema_setup, schema_teardown,
pre_setup, post_teardown,
)
else:
db_context = db_context_with_schema_common_new (
request, hge_ctx, 'schema_setup_files', setup, 'schema_teardown_files', teardown,
schema_setup, schema_teardown, pre_setup, post_teardown, check_file_exists
db_context = db_context_with_schema_common_new(
request, hge_ctx,
'schema_setup_files', setup,
'schema_teardown_files', teardown,
schema_setup, schema_teardown,
pre_setup, post_teardown,
)
yield from db_context
@ -510,30 +538,12 @@ def per_method_db_data_for_mutation_tests(request, hge_ctx, per_class_db_schema_
]
yield from db_context_common(
request, hge_ctx, 'values_setup_files', values_setup,
request, hge_ctx,
'values_setup_files', values_setup,
'values_teardown_files', values_teardown,
False, False, False
skip_setup=False, skip_teardown=False
)
@pytest.fixture(scope='function')
def backend():
"This fixture provides a default `backend` value for the `per_backend_tests` fixture"
return 'postgres'
@pytest.fixture(scope='function', autouse=True)
def per_backend_tests(hge_ctx, backend):
"""
This fixture ignores backend-specific tests unless the relevant --backend flag has been passed.
"""
# Currently, we default all tests to run on Postgres with or without a --backend flag.
# As our test suite develops, we may consider running backend-agnostic tests on all
# backends, unless a specific `--backend` flag is passed.
if not hge_ctx.backend == backend:
pytest.skip(
'Skipping test. Add --backend ' + backend + ' to run backend-specific tests'
)
return
def db_state_context(request, hge_ctx):
# Non-default (Postgres) backend tests expect separate setup and schema_setup
# files for v1/metadata and v2/query requests, respectively.
@ -542,10 +552,6 @@ def db_state_context(request, hge_ctx):
for filename in ['setup', 'teardown', 'schema_setup', 'schema_teardown', 'pre_setup', 'post_teardown']
]
# only lookup files relevant to the tests being run.
# defaults to postgres file lookup
check_file_exists = hge_ctx.backend == backend
# setting the default metadata API version to v1
setup_metadata_api_version = getattr(request.cls, 'setup_metadata_api_version',"v1")
@ -553,64 +559,73 @@ def db_state_context(request, hge_ctx):
if setup_metadata_api_version == "v1":
# setup the metadata and DB schema using the `/v1/query` endpoint
db_context = db_context_with_schema_common(
request, hge_ctx, 'setup_files', 'setup.yaml', 'teardown_files',
'teardown.yaml', check_file_exists )
request, hge_ctx,
'setup_files', 'setup.yaml',
'teardown_files', 'teardown.yaml',
)
elif setup_metadata_api_version == "v2":
# setup the metadata using the "/v1/metadata" and the DB schema using the `/v2/query` endpoints
db_context = db_context_with_schema_common_new (
request, hge_ctx, 'setup_files', setup, 'teardown_files',
teardown, schema_setup, schema_teardown, pre_setup, post_teardown, check_file_exists
db_context = db_context_with_schema_common_new(
request, hge_ctx,
'setup_files', setup,
'teardown_files', teardown,
schema_setup, schema_teardown,
pre_setup, post_teardown,
)
else:
raise NotImplementedError('Invalid API version.')
else:
# setup the metadata using the "/v1/metadata" and the DB schema using the `/v2/query` endpoints
db_context = db_context_with_schema_common_new (
request, hge_ctx, 'setup_files', setup, 'teardown_files',
teardown, schema_setup, schema_teardown, pre_setup, post_teardown, check_file_exists
db_context = db_context_with_schema_common_new(
request, hge_ctx,
'setup_files', setup,
'teardown_files', teardown,
schema_setup, schema_teardown,
pre_setup, post_teardown,
)
yield from db_context
def db_state_context_new(
request, hge_ctx, setup='setup.yaml', teardown='teardown.yaml',
schema_setup='schema_setup.yaml', schema_teardown='schema_teardown.yaml',
pre_setup='pre_setup.yaml', post_teardown='post_teardown.yaml'):
yield from db_context_with_schema_common_new (
request, hge_ctx, 'setup_files', setup, 'teardown_files',
teardown, schema_setup, schema_teardown, pre_setup, post_teardown, True
)
def db_context_with_schema_common(
request, hge_ctx, setup_files_attr, setup_default_file,
teardown_files_attr, teardown_default_file, check_file_exists=True):
request, hge_ctx,
setup_files_attr, setup_default_file,
teardown_files_attr, teardown_default_file,
):
(skip_setup, skip_teardown) = [
request.config.getoption('--' + x)
for x in ['skip-schema-setup', 'skip-schema-teardown']
]
yield from db_context_common(
request, hge_ctx, setup_files_attr, setup_default_file,
request, hge_ctx,
setup_files_attr, setup_default_file,
teardown_files_attr, teardown_default_file,
check_file_exists, skip_setup, skip_teardown
skip_setup, skip_teardown
)
def db_context_with_schema_common_new (
request, hge_ctx, setup_files_attr, setup_default_file,
teardown_files_attr, teardown_default_file, setup_sql_file, teardown_sql_file, pre_setup_file, post_teardown_file, check_file_exists=True):
def db_context_with_schema_common_new(
request, hge_ctx,
setup_files_attr, setup_default_file,
teardown_files_attr, teardown_default_file,
setup_sql_file, teardown_sql_file,
pre_setup_file, post_teardown_file,
):
(skip_setup, skip_teardown) = [
request.config.getoption('--' + x)
for x in ['skip-schema-setup', 'skip-schema-teardown']
]
yield from db_context_common_new (
request, hge_ctx, setup_files_attr, setup_default_file, setup_sql_file,
yield from db_context_common_new(
request, hge_ctx,
setup_files_attr, setup_default_file, setup_sql_file,
teardown_files_attr, teardown_default_file, teardown_sql_file,
pre_setup_file, post_teardown_file,
check_file_exists, skip_setup, skip_teardown
skip_setup, skip_teardown
)
def db_context_common(
request, hge_ctx, setup_files_attr, setup_default_file,
request, hge_ctx,
setup_files_attr, setup_default_file,
teardown_files_attr, teardown_default_file,
check_file_exists=True, skip_setup=True, skip_teardown=True ):
skip_setup=True, skip_teardown=True
):
def get_files(attr, default_file):
files = getattr(request.cls, attr, None)
if not files:
@ -619,17 +634,26 @@ def db_context_common(
setup = get_files(setup_files_attr, setup_default_file)
teardown = get_files(teardown_files_attr, teardown_default_file)
if hge_ctx.is_default_backend:
yield from setup_and_teardown_v1q(request, hge_ctx, setup, teardown, check_file_exists, skip_setup, skip_teardown)
yield from setup_and_teardown_v1q(
request, hge_ctx,
setup, teardown,
skip_setup, skip_teardown
)
else:
yield from setup_and_teardown_v2q(request, hge_ctx, setup, teardown, check_file_exists, skip_setup, skip_teardown)
yield from setup_and_teardown_v2q(
request, hge_ctx,
setup, teardown,
skip_setup, skip_teardown
)
def db_context_common_new(
request, hge_ctx, setup_files_attr, setup_default_file,
setup_default_sql_file,
request, hge_ctx,
setup_files_attr, setup_default_file, setup_default_sql_file,
teardown_files_attr, teardown_default_file, teardown_default_sql_file,
pre_setup_file, post_teardown_file,
check_file_exists=True, skip_setup=True, skip_teardown=True ):
skip_setup=True, skip_teardown=True
):
def get_files(attr, default_file):
files = getattr(request.cls, attr, None)
if not files:
@ -641,17 +665,19 @@ def db_context_common_new(
teardown_default_sql_file = os.path.join(request.cls.dir(), teardown_default_sql_file)
pre_setup_default_file = os.path.join(request.cls.dir(), pre_setup_file)
post_teardown_default_file = os.path.join(request.cls.dir(), post_teardown_file)
yield from setup_and_teardown( request, hge_ctx, setup, teardown,
setup_default_sql_file, teardown_default_sql_file, pre_setup_default_file, post_teardown_default_file,
check_file_exists, skip_setup, skip_teardown)
def setup_and_teardown_v1q(request, hge_ctx, setup_files, teardown_files, check_file_exists=True, skip_setup=False, skip_teardown=False):
def assert_file_exists(f):
assert os.path.isfile(f), 'Could not find file ' + f
if check_file_exists:
for o in [setup_files, teardown_files]:
run_on_elem_or_list(assert_file_exists, o)
yield from setup_and_teardown(
request, hge_ctx,
setup, teardown,
setup_default_sql_file, teardown_default_sql_file,
pre_setup_default_file, post_teardown_default_file,
skip_setup, skip_teardown
)
def setup_and_teardown_v1q(
request, hge_ctx,
setup_files, teardown_files,
skip_setup=False, skip_teardown=False
):
def v1q_f(filepath):
if os.path.isfile(filepath):
return hge_ctx.v1q_f(filepath)
@ -663,13 +689,11 @@ def setup_and_teardown_v1q(request, hge_ctx, setup_files, teardown_files, check_
if request.session.testsfailed > 0 or not skip_teardown:
run_on_elem_or_list(v1q_f, teardown_files)
def setup_and_teardown_v2q(request, hge_ctx, setup_files, teardown_files, check_file_exists=True, skip_setup=False, skip_teardown=False):
def assert_file_exists(f):
assert os.path.isfile(f), 'Could not find file ' + f
if check_file_exists:
for o in [setup_files, teardown_files]:
run_on_elem_or_list(assert_file_exists, o)
def setup_and_teardown_v2q(
request, hge_ctx,
setup_files, teardown_files,
skip_setup=False, skip_teardown=False
):
def v2q_f(filepath):
if os.path.isfile(filepath):
return hge_ctx.v2q_f(filepath)
@ -681,15 +705,13 @@ def setup_and_teardown_v2q(request, hge_ctx, setup_files, teardown_files, check_
if request.session.testsfailed > 0 or not skip_teardown:
run_on_elem_or_list(v2q_f, teardown_files)
def setup_and_teardown(request, hge_ctx, setup_files, teardown_files,
sql_schema_setup_file,sql_schema_teardown_file,
pre_setup_file, post_teardown_file,
check_file_exists=True, skip_setup=False, skip_teardown=False):
def assert_file_exists(f):
assert os.path.isfile(f), 'Could not find file ' + f
if check_file_exists:
for o in [setup_files, teardown_files, sql_schema_setup_file, sql_schema_teardown_file]:
run_on_elem_or_list(assert_file_exists, o)
def setup_and_teardown(
request, hge_ctx,
setup_files, teardown_files,
sql_schema_setup_file, sql_schema_teardown_file,
pre_setup_file, post_teardown_file,
skip_setup=False, skip_teardown=False
):
def v2q_f(f):
if os.path.isfile(f):
try:

View File

@ -5,5 +5,6 @@ norecursedirs = queries webhook test_upgrade
; means we're sure to notice if e.g. a known bug is fixed.
xfail_strict = true
markers =
backend: The backends supported by the test case
skip_server_upgrade_test: Tests with this marker should not be run as part of server upgrade test
allow_server_upgrade_test: Add tests with this marker to server upgrade test, as far as they don't have the skip_server_upgarde_test market

View File

@ -135,7 +135,8 @@ class TestEventCreateAndResetNonDefaultSource:
@classmethod
def dir(cls):
return 'queries/event_triggers/create_and_reset_non_default'
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures("per_method_tests_db_state")
class TestEventCreateAndDeleteMSSQL:
@ -169,7 +170,7 @@ class TestEventCreateAndDeleteMSSQL:
# NOTE: this expects:
# HASURA_GRAPHQL_EVENTS_HTTP_POOL_SIZE=8
# HASURA_GRAPHQL_EVENTS_FETCH_BATCH_SIZE=100 (the default)
@pytest.mark.parametrize("backend", ['mssql','postgres'])
@pytest.mark.backend('mssql','postgres')
@usefixtures("per_method_tests_db_state")
class TestEventFloodPostgresMSSQL(object):
@ -320,7 +321,7 @@ class TestEventDataFormat(object):
update(hge_ctx, table, where_exp, set_exp)
check_event(hge_ctx, evts_webhook, "geojson_all", table, "UPDATE", exp_ev_data)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures("per_class_tests_db_state")
class TestEventDataFormatBigIntMSSQL(object):
@ -356,7 +357,7 @@ class TestEventDataFormatBigIntMSSQL(object):
print("----------- resp ----------\n", resp)
check_event(hge_ctx, evts_webhook, "bigint_all", table, "INSERT", exp_ev_data)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures("per_class_tests_db_state")
class TestEventDataFormatGeoJSONMSSQL(object):
@ -367,7 +368,7 @@ class TestEventDataFormatGeoJSONMSSQL(object):
def test_geojson(self, hge_ctx, evts_webhook):
check_query_f(hge_ctx, self.dir() + '/create_geojson_event_trigger.yaml')
@pytest.mark.parametrize("backend", ['mssql','postgres'])
@pytest.mark.backend('mssql','postgres')
@usefixtures("per_class_tests_db_state")
class TestCreateEventQueryPostgresMSSQL(object):
@ -442,7 +443,7 @@ class TestCreateEventQueryPostgresMSSQL(object):
check_event(hge_ctx, evts_webhook, "measurement_all", table, "INSERT", exp_ev_data)
hge_ctx.v1q_f(self.dir() + '/partition_table_teardown.yaml')
@pytest.mark.parametrize("backend", ['mssql','postgres'])
@pytest.mark.backend('mssql','postgres')
@usefixtures('per_method_tests_db_state')
class TestEventRetryConfPostgresMSSQL(object):
@ -522,7 +523,7 @@ class TestEventRetryConfPostgresMSSQL(object):
except queue.Empty:
pass
@pytest.mark.parametrize("backend", ['mssql','postgres'])
@pytest.mark.backend('mssql','postgres')
@usefixtures('per_method_tests_db_state')
class TestEventHeadersPostgresMSSQL(object):
@ -616,7 +617,7 @@ class TestUpdateEventQuery(object):
check_event(hge_ctx, evts_webhook, "t1_cols", table, "DELETE", exp_ev_data, webhook_path = "/new")
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
class TestUpdateEventQueryMSSQL(object):
@classmethod
@ -745,7 +746,7 @@ class TestDeleteEventQuery(object):
# NOTE: use a bit of a delay here, to catch any stray events generated above
check_event(hge_ctx, evts_webhook, "t1_all", table, "DELETE", exp_ev_data, get_timeout=2)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestDeleteEventQueryMSSQL(object):
@ -848,7 +849,7 @@ class TestEventSelCols:
}
})
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestEventSelColsMSSQL:
@ -966,7 +967,7 @@ class TestEventInsertOnly:
# NOTE: use a bit of a delay here, to catch any stray events generated above
check_event(hge_ctx, evts_webhook, "t1_insert", table, "DELETE", exp_ev_data, get_timeout=2)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestEventInsertOnlyMSSQL:
@ -1007,7 +1008,7 @@ class TestEventInsertOnlyMSSQL:
# NOTE: use a bit of a delay here, to catch any stray events generated above
check_event(hge_ctx, evts_webhook, "t1_insert", table, "DELETE", exp_ev_data, get_timeout=2)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestEventUpdateOnlyMSSQL:
@ -1191,7 +1192,7 @@ class TestEventSelPayload:
}, expected_status_code = 400)
assert resp['code'] == "dependency-error", resp
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestEventSelPayloadMSSQL:
@ -1308,7 +1309,7 @@ class TestWebhookEvent(object):
delete(hge_ctx, table, where_exp)
check_event(hge_ctx, evts_webhook, "t1_all", table, "DELETE", exp_ev_data)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestWebhookEventMSSQL(object):
@ -1380,7 +1381,7 @@ class TestEventWebhookTemplateURL(object):
delete(hge_ctx, table, where_exp)
check_event(hge_ctx, evts_webhook, "t1_all", table, "DELETE", exp_ev_data, webhook_path = '/trigger')
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestEventWebhookTemplateURLMSSQL(object):
@ -1455,7 +1456,7 @@ class TestEventSessionVariables(object):
delete(hge_ctx, table, where_exp)
check_event(hge_ctx, evts_webhook, "t1_all", table, "DELETE", exp_ev_data)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestEventSessionVariablesMSSQL(object):
@ -1532,7 +1533,7 @@ class TestManualEvents(object):
self.test_basic(hge_ctx, evts_webhook)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestManualEventsMSSQL(object):
@ -1565,7 +1566,7 @@ class TestManualEventsMSSQL(object):
self.test_basic(hge_ctx, evts_webhook)
@pytest.mark.parametrize("backend", ['mssql','postgres'])
@pytest.mark.backend('mssql','postgres')
@usefixtures('per_method_tests_db_state')
class TestEventsAsynchronousExecutionPostgresMSSQL(object):
@ -1632,7 +1633,7 @@ class TestEventTransform(object):
removedHeaders=["user-agent"],
webhook_path=expectedPath)
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures("per_method_tests_db_state")
class TestEventTransformMSSQL(object):

View File

@ -510,7 +510,7 @@ class TestGraphqlUpdatePermissions:
def dir(cls):
return "queries/graphql_mutation/update/permissions"
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@use_mutation_fixtures
class TestGraphqlUpdateBasicMSSQL:
@ -539,7 +539,7 @@ class TestGraphqlUpdateBasicMSSQL:
def dir(cls):
return "queries/graphql_mutation/update/basic"
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@use_mutation_fixtures
class TestGraphqlUpdatePermissionsMSSQL:
@ -594,7 +594,7 @@ class TestGraphqlDeleteBasic:
def dir(cls):
return "queries/graphql_mutation/delete/basic"
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_method_tests_db_state')
class TestGraphqlDeleteBasicMSSQL:
@ -636,7 +636,7 @@ class TestGraphqlDeleteConstraints:
def dir(cls):
return "queries/graphql_mutation/delete/constraints"
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_method_tests_db_state')
class TestGraphqlDeleteConstraintsMSSQL:
@ -689,7 +689,7 @@ class TestGraphqlDeletePermissions:
return "queries/graphql_mutation/delete/permissions"
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_method_tests_db_state')
class TestGraphqlDeletePermissionsMSSQL:
@ -840,7 +840,7 @@ class TestGraphQLMutationTransactions:
def dir(cls):
return 'queries/graphql_mutation/transactions'
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@use_mutation_fixtures
class TestGraphQLInsertMSSQL:
@ -872,7 +872,7 @@ class TestGraphQLInsertMSSQL:
def test_insert_invalid_datetime(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + "/insert_invalid_datetime_mssql.yaml")
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@use_mutation_fixtures
class TestGraphqlInsertPermissionMSSQL:
@ -895,7 +895,7 @@ class TestGraphqlInsertPermissionMSSQL:
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@use_mutation_fixtures
class TestGraphqlInsertIfMatchedMSSQL:

View File

@ -26,7 +26,7 @@ class TestGraphQLEmpty:
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['bigquery'])
@pytest.mark.backend('bigquery')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBasicBigquery:
@ -105,7 +105,7 @@ class TestGraphQLQueryBasicBigquery:
return 'queries/graphql_query/bigquery'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['bigquery'])
@pytest.mark.backend('bigquery')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpSearchBigquery:
@ -120,7 +120,7 @@ class TestGraphQLQueryBoolExpSearchBigquery:
return 'queries/graphql_query/boolexp/search'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['citus', 'mssql', 'postgres'])
@pytest.mark.backend('citus', 'mssql', 'postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBasicPostgresMSSQLCitus:
@ -135,7 +135,7 @@ class TestGraphQLQueryBasicPostgresMSSQLCitus:
return 'queries/graphql_query/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBasicMSSQL:
@ -163,7 +163,7 @@ class TestGraphQLQueryBasicMSSQL:
return 'queries/graphql_query/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['postgres'])
@pytest.mark.backend('postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBasicPostgres:
# Can't run server upgrade tests, as this test has a schema change
@ -209,7 +209,7 @@ class TestGraphQLQueryBasicPostgres:
return 'queries/graphql_query/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['citus'])
@pytest.mark.backend('citus')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBasicCitus:
def test_nested_select_with_foreign_key_alter(self, hge_ctx, transport):
@ -246,7 +246,7 @@ class TestGraphQLQueryBasicCitus:
return 'queries/graphql_query/citus'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['citus', 'postgres'])
@pytest.mark.backend('citus', 'postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryFragmentsPostgresCitus:
@ -291,7 +291,7 @@ class TestGraphQLQueryAgg:
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['mssql', 'postgres'])
@pytest.mark.backend('mssql', 'postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryAggPermPostgresMSSQL:
@ -318,7 +318,7 @@ class TestGraphQLQueryAggPermPostgresMSSQL:
return 'queries/graphql_query/agg_perm'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['postgres'])
@pytest.mark.backend('postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryAggPermPostgres:
# This test should be part of TestGraphQLQueryAggPermCommon and it is not because of
@ -383,7 +383,7 @@ class TestGraphQLQueryOffsets:
return 'queries/graphql_query/offset'
@pytest.mark.parametrize("transport", ['http', 'websocket', 'subscription'])
@pytest.mark.parametrize("backend", ['mssql', 'postgres'])
@pytest.mark.backend('mssql', 'postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpBasicPostgresMSSQL:
def test_order_delivered_at_is_null(self, hge_ctx, transport):
@ -430,7 +430,7 @@ class TestGraphQLQueryBoolExpBasicPostgresMSSQL:
return 'queries/graphql_query/boolexp/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['postgres'])
@pytest.mark.backend('postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpBasicPostgres:
def test_author_article_operator_ne_not_found_err(self, hge_ctx, transport):
@ -465,7 +465,7 @@ class TestGraphQLQueryBoolExpBasicPostgres:
return 'queries/graphql_query/boolexp/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpBasicMSSQL:
def test_author_article_operator_ne_not_found_err(self, hge_ctx, transport):
@ -656,8 +656,8 @@ class TestGraphQLInheritedRolesPostgres:
check_query_f(hge_ctx, self.dir() + '/inherited_role_with_some_roles_having_no_permissions.yaml')
@pytest.mark.parametrize('transport', ['http', 'websocket'])
@pytest.mark.parametrize('backend', ['mssql'])
@usefixtures('per_backend_tests', 'per_class_tests_db_state')
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestGraphQLInheritedRolesMSSQL:
@classmethod
@ -671,7 +671,7 @@ class TestGraphQLInheritedRolesMSSQL:
check_query_f(hge_ctx, self.dir() + '/inherited_role_with_some_roles_having_no_permissions.yaml')
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['postgres'])
@pytest.mark.backend('postgres')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpSearchPostgres:
@ -713,7 +713,7 @@ class TestGraphQLQueryBoolExpSearchPostgres:
return 'queries/graphql_query/boolexp/search'
@pytest.mark.parametrize("transport", ['http', 'websocket', 'subscription'])
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpSearchMSSQL:
@ -1078,20 +1078,20 @@ class TestGraphQLExplainPostgresMSSQL:
def dir(cls):
return 'queries/explain'
def test_simple_query_as_admin(self, hge_ctx, backend):
def test_simple_query_as_admin(self, hge_ctx):
q = {"query": {"query": "query abc { __typename }", "operationName": "abc"}}
hge_ctx.v1GraphqlExplain(q)
def test_simple_query_as_user(self, hge_ctx, backend):
def test_simple_query_as_user(self, hge_ctx):
q = {"query": {"query": "query abc { __typename }", "operationName": "abc"}}
hge_ctx.v1GraphqlExplain(q, {"x-hasura-role": "random_user"}, expected_status_code = 400)
@pytest.mark.parametrize("backend", ['postgres', 'mssql'])
def test_simple_query(self, hge_ctx, backend):
@pytest.mark.backend('postgres', 'mssql')
def test_simple_query(self, hge_ctx):
self.with_admin_secret("query", hge_ctx, self.dir() + hge_ctx.backend_suffix('/simple_query') + ".yaml")
@pytest.mark.parametrize("backend", ['postgres', 'mssql'])
def test_permissions_query(self, hge_ctx, backend):
@pytest.mark.backend('postgres', 'mssql')
def test_permissions_query(self, hge_ctx):
self.with_admin_secret("query", hge_ctx, self.dir() + hge_ctx.backend_suffix('/permissions_query') + ".yaml")
def test_limit_query(self, hge_ctx):
@ -1113,20 +1113,19 @@ class TestGraphQLExplainPostgresMSSQL:
def test_orderby_array_relationship_query(self, hge_ctx):
self.with_admin_secret("query", hge_ctx, self.dir() + '/orderby_array_relationship_query.yaml')
@pytest.mark.parametrize("backend", ['postgres', 'mssql'])
def test_documented_query(self, hge_ctx, backend):
@pytest.mark.backend('postgres', 'mssql')
def test_documented_query(self, hge_ctx):
self.with_admin_secret("query", hge_ctx, self.dir() + hge_ctx.backend_suffix('/docs_query') + ".yaml")
@pytest.mark.parametrize("backend", ['postgres', 'mssql'])
def test_documented_subscription(self, hge_ctx, backend):
@pytest.mark.backend('postgres', 'mssql')
def test_documented_subscription(self, hge_ctx):
self.with_admin_secret("subscription", hge_ctx, self.dir() + hge_ctx.backend_suffix('/docs_subscription') + ".yaml")
@pytest.mark.parametrize("backend", ['bigquery'])
def test_array_relationship_orderby(self, hge_ctx, backend):
@pytest.mark.backend('bigquery')
def test_array_relationship_orderby(self, hge_ctx):
self.with_admin_secret("query", hge_ctx, self.dir() + hge_ctx.backend_suffix('/author_articles_orderby') + ".yaml")
def with_admin_secret(self, explain_query_type, hge_ctx, f, hdrs=None, req_st=200):
overwrite_expectations = PytestConf.config.getoption("--accept")
conf = get_conf_f(f)
@ -1350,7 +1349,7 @@ class TestGraphQLQueryBoolExpLtree:
return 'queries/graphql_query/boolexp/ltree'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpSpatialMSSQL:
@pytest.mark.skip_server_upgrade_test
@ -1401,7 +1400,7 @@ class TestGraphQLQueryBoolExpSpatialMSSQL:
return 'queries/graphql_query/boolexp/spatial'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['bigquery'])
@pytest.mark.backend('bigquery')
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpSpatialBigquery:
def test_select_spatial_bigquery_types(self, hge_ctx, transport):

View File

@ -13,8 +13,8 @@ if not PytestConf.config.getoption('--test-read-only-source'):
allow_module_level=True)
@pytest.mark.parametrize('transport', ['http', 'websocket'])
@pytest.mark.parametrize('backend', ['postgres', 'citus'])
#@pytest.mark.parametrize('backend', ['citus', 'mssql', 'postgres'])
@pytest.mark.backend('postgres', 'citus')
#@pytest.mark.backend('citus', 'mssql', 'postgres')
@usefixtures('setup_schema_externally', 'per_class_tests_db_state')
class TestGraphQLOnReadOnlySource:

View File

@ -598,7 +598,7 @@ class TestMetadataOrder:
assert export_resp['resource_version'] == export_resp_1['resource_version']
@pytest.mark.parametrize("backend", ['citus', 'mssql', 'postgres', 'bigquery'])
@pytest.mark.backend('citus', 'mssql', 'postgres', 'bigquery')
@usefixtures('per_class_tests_db_state')
class TestSetTableCustomizationPostgresMSSQLCitusBigquery:
@ -609,7 +609,7 @@ class TestSetTableCustomizationPostgresMSSQLCitusBigquery:
def test_set_table_customization(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + hge_ctx.backend_suffix('/set_table_customization') + '.yaml')
@pytest.mark.parametrize("backend", ['bigquery'])
@pytest.mark.backend('bigquery')
@usefixtures('per_method_tests_db_state')
class TestMetadataBigquery:

View File

@ -29,7 +29,7 @@ class TestNamingConventions:
def test_type_and_field_names_with_prefix_and_suffix(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_with_prefix_and_suffix.yaml')
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
class TestNamingConventionsFailure:
@classmethod
def dir(cls):

View File

@ -104,7 +104,7 @@ class TestSubscriptionCtrl(object):
with pytest.raises(queue.Empty):
ev = ws_client.get_ws_event(3)
@pytest.mark.parametrize("backend", ['mssql', 'postgres'])
@pytest.mark.backend('mssql', 'postgres')
@usefixtures('per_class_tests_db_state', 'ws_conn_init')
class TestSubscriptionBasic:
@classmethod
@ -615,7 +615,7 @@ class TestSubscriptionLiveQueriesForGraphQLWS:
ws_client_graphql_ws.send(frame)
ws_client_graphql_ws.clear_queue()
@pytest.mark.parametrize("backend", ['mssql', 'postgres'])
@pytest.mark.backend('mssql', 'postgres')
@usefixtures('per_class_tests_db_state')
class TestSubscriptionMultiplexingPostgresMSSQL:
@ -669,7 +669,7 @@ class TestSubscriptionMultiplexingPostgres:
response = get_explain_graphql_query_response(hge_ctx, config['query'], config['variables'], {})
assert response["variables"]["synthetic"] == ['{1,2,3}'], response["variables"]
@pytest.mark.parametrize("backend", ['postgres'])
@pytest.mark.backend('postgres')
@usefixtures('per_class_tests_db_state', 'ws_conn_init')
class TestSubscriptionUDFWithSessionArg:
"""
@ -700,7 +700,7 @@ class TestSubscriptionUDFWithSessionArg:
assert ev['type'] == 'data', ev
assert ev['payload']['data'] == {'me': [{'id': '42', 'name': 'Charlie'}]}, ev['payload']['data']
@pytest.mark.parametrize("backend", ['mssql', 'postgres'])
@pytest.mark.backend('mssql', 'postgres')
@usefixtures('per_class_tests_db_state', 'ws_conn_init')
class TestSubscriptionCustomizedSourceMSSQLPostgres:
@classmethod
@ -776,7 +776,7 @@ class TestSubscriptionCustomizedSourceMSSQLPostgres:
assert ev['type'] == 'error' and ev['id'] == '2', ev
assert ev['payload']['errors'] == [OrderedDict([('extensions', OrderedDict([('path', '$'), ('code', 'validation-failed')])), ('message', 'subscriptions must select one top level field')])], ev
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state', 'ws_conn_init')
class TestSubscriptionMSSQLChunkedResults:
@classmethod

View File

@ -24,50 +24,50 @@ class TestV2SelectBasic: # Basic RQL Tests on v2/query
# def test_select_query_author_with_user_role_failure(self, hge_ctx):
# check_query_f(hge_ctx, self.dir() + '/select_article_role_error.yaml')
@pytest.mark.parametrize("backend", ['mssql'])
@pytest.mark.backend('mssql')
@usefixtures('per_class_tests_db_state')
class TestRunSQLMSSQL:
def test_drop_article_table_without_cascade(self, hge_ctx, backend):
def test_drop_article_table_without_cascade(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/drop_article_table_without_cascade.yaml')
def test_drop_article_table_with_cascade(self, hge_ctx, backend):
def test_drop_article_table_with_cascade(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/drop_article_table_with_cascade.yaml')
def test_create_author_table_fail(self, hge_ctx, backend):
def test_create_author_table_fail(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/create_author_table_fail.yaml')
def test_invalid_sql_query(self, hge_ctx, backend):
def test_invalid_sql_query(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/invalid_sql_query.yaml')
def test_select_query(self, hge_ctx, backend):
def test_select_query(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_select_query_mssql.yaml')
def test_drop_table(self, hge_ctx, backend):
def test_drop_table(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_drop_table_mssql.yaml')
def test_rename_table(self, hge_ctx, backend):
def test_rename_table(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_rename_table_mssql.yaml')
def test_drop_column(self, hge_ctx, backend):
def test_drop_column(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_drop_column_mssql.yaml')
def test_add_column(self, hge_ctx, backend):
def test_add_column(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_add_column_mssql.yaml')
def test_rename_column(self, hge_ctx, backend):
def test_rename_column(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_rename_column_mssql.yaml')
def test_select_query_fail(self, hge_ctx, backend):
def test_select_query_fail(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_select_query_fail.yaml')
def test_add_column_fail(self, hge_ctx, backend):
def test_add_column_fail(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_add_column_fail.yaml')
def test_drop_column_fail(self, hge_ctx, backend):
def test_drop_column_fail(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/sql_drop_column_fail.yaml')
def test_create_index_fail(self, hge_ctx, backend):
def test_create_index_fail(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/create_index_fail.yaml')
@classmethod