mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
6ed9f36125
These tests are intended to catch issues in upgrading HGE. However: * the tests are very convoluted and hard to understand, * we can only run a small subset of Python tests that don't mutate any data or metadata, and * I have never seen them fail for a legitimate reason, but I've seen a lot of flakes. While we do believe it's important to test that upgrades don't break the stored introspection, these tests don't seem to be doing that any more. I humbly request that we delete them now and either (a) figure out how to test this properly, or (b) just wait for v3, which does away with reintrospecting on server startup entirely. [NDAT-259]: https://hasurahq.atlassian.net/browse/NDAT-259?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8844 GitOrigin-RevId: 528bc632fce377b7eff2026b832bd58586ac5a0b
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
import pytest
|
|
import sqlalchemy
|
|
|
|
from context import HGECtx
|
|
import fixtures.postgres
|
|
from validate import check_query_f
|
|
|
|
usefixtures = pytest.mark.usefixtures
|
|
|
|
@pytest.mark.parametrize('transport', ['http', 'websocket'])
|
|
@pytest.mark.backend('postgres', 'citus')
|
|
@pytest.mark.admin_secret
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_ADMIN_INTERNAL_ERRORS', 'false')
|
|
@usefixtures('setup_schema_externally')
|
|
class TestGraphQLOnReadOnlySource:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return 'queries/graphql_query/read_only_source'
|
|
|
|
setup_metadata_api_version = 'v2'
|
|
|
|
def test_query_aves(self, hge_ctx, transport):
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_aves.yaml', transport)
|
|
|
|
# graphql-engine's websocket response is different than in http on execution
|
|
# errors; so this test is run only on http
|
|
def test_mutation_aves(self, hge_ctx, transport):
|
|
if transport != 'http':
|
|
pytest.skip('This test should only run over HTTP.')
|
|
check_query_f(hge_ctx, self.dir() + '/update_query_aves.yaml', transport)
|
|
|
|
|
|
# As this is a read-only test, we can't create the schema/tables as part of the
|
|
# HGE metadata. Hence, we create it as a separate fixture, where we execute the
|
|
# DDLs directly on the database.
|
|
@pytest.fixture(scope='class')
|
|
def setup_schema_externally(
|
|
owner_engine: sqlalchemy.engine.Engine,
|
|
hge_ctx: HGECtx,
|
|
add_source,
|
|
):
|
|
source = 'read_only'
|
|
backend = add_source(source, read_only = True)
|
|
|
|
with fixtures.postgres.switch_schema(owner_engine, backend.name).connect() as connection:
|
|
connection.execute("CREATE TABLE aves (id serial PRIMARY KEY, name TEXT)")
|
|
connection.execute("INSERT INTO aves (name) VALUES ('Booted Eagle'), ('Hooded Merganser')")
|
|
|
|
hge_ctx.v1metadataq({
|
|
'type': 'pg_track_table',
|
|
'args': {
|
|
'source': source,
|
|
'table': {
|
|
'name': 'aves',
|
|
},
|
|
},
|
|
})
|