mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
f8e133070b
* run basic tests after upgrade * terminate before specifying file in pytest cmd * Move fixture definitions out of test classes Previously we had abstract classes with the fixtures defined in them. The test classes then inherits these super classes. This is creating inheritence problems, especially when you want to just inherit the tests in class, but not the fixtures. We have now moved all those fixture definitions outside of the class (in conftest.py). These fixtures are now used by the test classes when and where they are required. * Run pytests on server upgrade Server upgrade tests are run by 1) Run pytest with schema/metadata setup but do not do schema/metadata teardown 2) Upgrade the server 3) Run pytest using the above schema and teardown at the end of the tests 4) Cleanup hasura metadata and start again with next set of tests We have added options --skip-schema-setup and --skip-schema-teardown to help running server upgrade tests. While running the tests, we noticed that error codes and messages for some of the tests have changed. So we have added another option to pytest `--avoid-error-message-checks`. If this flag is set, and if comparing expected and response message fails, and if the expected response has an error message, Pytest will throw warnings instead of an error. * Use marks to specify server-upgrade tests Not all tests can be run as serve upgrade tests, particularly those which themselves change the schema. We introduce two pytest markers. Marker allow_server_upgrade_test will add the test into the list of server upgrade tests that can be run. skip_server_upgrade_test removes it from the list. With this we have added tests for queries, mutations, and selected event trigger and remote schema tests to the list of server upgrade tests. * Remove components not needed anymore * Install curl * Fix error in query validation * Fix error in test_v1_queries.py * install procps for server upgrade tests * Use postgres image which has postgis installed * set pager off with psql * quote the bash variable WORKTREE_DIR Co-authored-by: nizar-m <19857260+nizar-m@users.noreply.github.com> Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import pytest
|
|
import ruamel.yaml as yaml
|
|
import os
|
|
|
|
resp_pg_version_map = {
|
|
'9_5': 'response_9',
|
|
'9_6': 'response_9',
|
|
'10': 'response_10_11',
|
|
'11': 'response_10_11',
|
|
'12': 'response_10_11',
|
|
'latest': 'response_10_11'
|
|
}
|
|
|
|
@pytest.mark.usefixtures('per_method_tests_db_state')
|
|
class TestPGDump:
|
|
|
|
def test_pg_dump_for_public_schema(self, hge_ctx):
|
|
query_file = self.dir() + '/pg_dump_public.yaml'
|
|
PG_VERSION = os.getenv('PG_VERSION', 'latest')
|
|
with open(query_file, 'r') as stream:
|
|
q = yaml.safe_load(stream)
|
|
headers = {}
|
|
if hge_ctx.hge_key is not None:
|
|
headers['x-hasura-admin-secret'] = hge_ctx.hge_key
|
|
resp = hge_ctx.http.post(hge_ctx.hge_url + q['url'], json=q['query'], headers=headers)
|
|
body = resp.text
|
|
assert resp.status_code == q['status']
|
|
print(body)
|
|
print(q[resp_pg_version_map[PG_VERSION]])
|
|
assert body == q[resp_pg_version_map[PG_VERSION]]
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "pgdump"
|