Skip to content

Commit

Permalink
Update database role tests to avoid colliding with parallel test runs (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
mikealfare authored Oct 2, 2024
1 parent 2e73254 commit d30670f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/functional/auth_tests/test_database_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d30670f

Please sign in to comment.