From 61cedf063a11e668c6df38d8bac43b03162210c7 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Mon, 8 Apr 2024 10:54:33 +0100 Subject: [PATCH 1/4] test: Fix SA engine check --- tests/integration/dbapi/async/V2/test_system_engine_async.py | 5 ++--- tests/integration/dbapi/sync/V2/test_system_engine.py | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/dbapi/async/V2/test_system_engine_async.py b/tests/integration/dbapi/async/V2/test_system_engine_async.py index cbb92a7544..5ce0b6d49d 100644 --- a/tests/integration/dbapi/async/V2/test_system_engine_async.py +++ b/tests/integration/dbapi/async/V2/test_system_engine_async.py @@ -48,10 +48,9 @@ async def test_system_engine( if connection_system_engine.database: await c.execute("show tables") - await c.execute( - "create table if not exists test_async(id int) primary index id" - ) with raises(OperationalError): + # Either one or another query fails if we're not on a user engine + await c.execute("create table if not exists test_async(id int)") await c.execute("insert into test values (1)") else: await c.execute("show databases") diff --git a/tests/integration/dbapi/sync/V2/test_system_engine.py b/tests/integration/dbapi/sync/V2/test_system_engine.py index 8b535cbd26..6127bb93ec 100644 --- a/tests/integration/dbapi/sync/V2/test_system_engine.py +++ b/tests/integration/dbapi/sync/V2/test_system_engine.py @@ -48,8 +48,9 @@ def test_system_engine( if connection_system_engine.database: c.execute("show tables") - c.execute("create table if not exists test_sync(id int) primary index id") with raises(OperationalError): + # Either one or another query fails if we're not on a user engine + c.execute("create table if not exists test_sync(id int)") c.execute("insert into test values (1)") else: c.execute("show databases") From 70e71d15bcf2e45950a74c6ad452a66b5e3d23d0 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Mon, 8 Apr 2024 13:31:06 +0100 Subject: [PATCH 2/4] fix conftest --- tests/integration/dbapi/async/V2/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/dbapi/async/V2/conftest.py b/tests/integration/dbapi/async/V2/conftest.py index f96ef7826e..725e29f24a 100644 --- a/tests/integration/dbapi/async/V2/conftest.py +++ b/tests/integration/dbapi/async/V2/conftest.py @@ -124,7 +124,7 @@ async def service_account_no_user( with connection_system_engine_no_db.cursor() as cursor: await cursor.execute( f'CREATE SERVICE ACCOUNT "{sa_account_name}" ' - 'WITH DESCRIPTION = "Ecosytem test with no user"' + "WITH DESCRIPTION = 'Ecosytem test with no user'" ) await cursor.execute(f"CALL fb_GENERATESERVICEACCOUNTKEY('{sa_account_name}')") # service_account_name, service_account_id, secret From 18ad091b40926a3ff0fdd293f3b6089fa3369767 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Mon, 8 Apr 2024 15:10:34 +0100 Subject: [PATCH 3/4] Fix table name --- tests/integration/dbapi/async/V2/test_system_engine_async.py | 2 +- tests/integration/dbapi/sync/V2/test_system_engine.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/dbapi/async/V2/test_system_engine_async.py b/tests/integration/dbapi/async/V2/test_system_engine_async.py index 5ce0b6d49d..1c68e23e6a 100644 --- a/tests/integration/dbapi/async/V2/test_system_engine_async.py +++ b/tests/integration/dbapi/async/V2/test_system_engine_async.py @@ -51,7 +51,7 @@ async def test_system_engine( with raises(OperationalError): # Either one or another query fails if we're not on a user engine await c.execute("create table if not exists test_async(id int)") - await c.execute("insert into test values (1)") + await c.execute("insert into test_async values (1)") else: await c.execute("show databases") with raises(OperationalError): diff --git a/tests/integration/dbapi/sync/V2/test_system_engine.py b/tests/integration/dbapi/sync/V2/test_system_engine.py index 6127bb93ec..ea91cbf95d 100644 --- a/tests/integration/dbapi/sync/V2/test_system_engine.py +++ b/tests/integration/dbapi/sync/V2/test_system_engine.py @@ -51,7 +51,7 @@ def test_system_engine( with raises(OperationalError): # Either one or another query fails if we're not on a user engine c.execute("create table if not exists test_sync(id int)") - c.execute("insert into test values (1)") + c.execute("insert into test_sync values (1)") else: c.execute("show databases") with raises(OperationalError): From ef79b468f5344c8ffa0c55b65aee93439e3223b7 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Mon, 8 Apr 2024 15:40:53 +0100 Subject: [PATCH 4/4] add error text check --- .../dbapi/async/V2/test_system_engine_async.py | 8 +++++++- tests/integration/dbapi/sync/V2/test_system_engine.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/integration/dbapi/async/V2/test_system_engine_async.py b/tests/integration/dbapi/async/V2/test_system_engine_async.py index 1c68e23e6a..06f35d4bc3 100644 --- a/tests/integration/dbapi/async/V2/test_system_engine_async.py +++ b/tests/integration/dbapi/async/V2/test_system_engine_async.py @@ -1,3 +1,4 @@ +import re from typing import List from pytest import raises @@ -7,6 +8,10 @@ from firebolt.utils.exception import OperationalError from tests.integration.dbapi.utils import assert_deep_eq +system_error_pattern = re.compile( + r"system engine doesn't support .* statements. Run this statement on a user engine." +) + async def test_system_engine( connection_system_engine: Connection, @@ -48,10 +53,11 @@ async def test_system_engine( if connection_system_engine.database: await c.execute("show tables") - with raises(OperationalError): + with raises(OperationalError) as e: # Either one or another query fails if we're not on a user engine await c.execute("create table if not exists test_async(id int)") await c.execute("insert into test_async values (1)") + assert system_error_pattern.search(str(e.value)), "Invalid error message" else: await c.execute("show databases") with raises(OperationalError): diff --git a/tests/integration/dbapi/sync/V2/test_system_engine.py b/tests/integration/dbapi/sync/V2/test_system_engine.py index ea91cbf95d..d8b84c71b8 100644 --- a/tests/integration/dbapi/sync/V2/test_system_engine.py +++ b/tests/integration/dbapi/sync/V2/test_system_engine.py @@ -1,3 +1,4 @@ +import re from typing import List from pytest import raises @@ -7,6 +8,10 @@ from firebolt.utils.exception import OperationalError from tests.integration.dbapi.utils import assert_deep_eq +system_error_pattern = re.compile( + r"system engine doesn't support .* statements. Run this statement on a user engine." +) + def test_system_engine( connection_system_engine: Connection, @@ -48,10 +53,11 @@ def test_system_engine( if connection_system_engine.database: c.execute("show tables") - with raises(OperationalError): + with raises(OperationalError) as e: # Either one or another query fails if we're not on a user engine c.execute("create table if not exists test_sync(id int)") c.execute("insert into test_sync values (1)") + assert system_error_pattern.search(str(e.value)), "Invalid error message" else: c.execute("show databases") with raises(OperationalError):