From d30670f476660d1e75b875fdd8b224353e8618a7 Mon Sep 17 00:00:00 2001 From: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:13:33 -0400 Subject: [PATCH] Update database role tests to avoid colliding with parallel test runs (#1197) * add a unique suffix to the database role to avoid colliding with parallel tests * limit the database role privileges to just the test schema * use the test schema prefix for uniqueness --- tests/functional/auth_tests/test_database_role.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functional/auth_tests/test_database_role.py b/tests/functional/auth_tests/test_database_role.py index f36555e34..c0f93d7d6 100644 --- a/tests/functional/auth_tests/test_database_role.py +++ b/tests/functional/auth_tests/test_database_role.py @@ -42,18 +42,18 @@ def project_config_update(self): return {"models": {"+grants": {"select": [os.getenv("SNOWFLAKE_TEST_ROLE")]}}} @pytest.fixture(scope="class", autouse=True) - def setup(self, project): + def setup(self, project, prefix): """ Create a database role with access to the model we're about to create. The existence of this database role triggered the bug as dbt-snowflake attempts to revoke it if the user also provides a grants config. """ - role = "BLOCKING_DB_ROLE" + role = f"BLOCKING_DB_ROLE_{prefix}" project.run_sql(f"CREATE DATABASE ROLE {role}") sql = f""" GRANT ALL PRIVILEGES ON FUTURE TABLES - IN DATABASE {project.database} + IN SCHEMA {project.test_schema} TO DATABASE ROLE {role} """ project.run_sql(sql)