Skip to content

Commit 2312206

Browse files
authored
SNOW-1891120: Use static names for test integrations (#2934)
1 parent da41fac commit 2312206

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

tests/integ/conftest.py

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,45 +68,45 @@ def set_up_external_access_integration_resources(
6868
# prepare external access resource
6969
session.sql(
7070
f"""
71-
CREATE OR REPLACE NETWORK RULE {rule1}
71+
CREATE IF NOT EXISTS NETWORK RULE {rule1}
7272
MODE = EGRESS
7373
TYPE = HOST_PORT
7474
VALUE_LIST = ('www.google.com');
7575
"""
7676
).collect()
7777
session.sql(
7878
f"""
79-
CREATE OR REPLACE NETWORK RULE {rule2}
79+
CREATE IF NOT EXISTS NETWORK RULE {rule2}
8080
MODE = EGRESS
8181
TYPE = HOST_PORT
8282
VALUE_LIST = ('www.microsoft.com');
8383
"""
8484
).collect()
8585
session.sql(
8686
f"""
87-
CREATE OR REPLACE SECRET {key1}
87+
CREATE IF NOT EXISTS SECRET {key1}
8888
TYPE = GENERIC_STRING
8989
SECRET_STRING = 'replace-with-your-api-key';
9090
"""
9191
).collect()
9292
session.sql(
9393
f"""
94-
CREATE OR REPLACE SECRET {key2}
94+
CREATE IF NOT EXISTS SECRET {key2}
9595
TYPE = GENERIC_STRING
9696
SECRET_STRING = 'replace-with-your-api-key_2';
9797
"""
9898
).collect()
9999
session.sql(
100100
f"""
101-
CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION {integration1}
101+
CREATE IF NOT EXISTS EXTERNAL ACCESS INTEGRATION {integration1}
102102
ALLOWED_NETWORK_RULES = ({rule1})
103103
ALLOWED_AUTHENTICATION_SECRETS = ({key1})
104104
ENABLED = true;
105105
"""
106106
).collect()
107107
session.sql(
108108
f"""
109-
CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION {integration2}
109+
CREATE IF NOT EXISTS EXTERNAL ACCESS INTEGRATION {integration2}
110110
ALLOWED_NETWORK_RULES = ({rule2})
111111
ALLOWED_AUTHENTICATION_SECRETS = ({key2})
112112
ENABLED = true;
@@ -124,15 +124,7 @@ def set_up_external_access_integration_resources(
124124
pass
125125

126126

127-
def clean_up_external_access_integration_resources(
128-
session, rule1, rule2, key1, key2, integration1, integration2
129-
):
130-
session.sql(f"drop network rule if exists {rule1}").collect()
131-
session.sql(f"drop network rule if exists {rule2}").collect()
132-
session.sql(f"drop secret if exists {key1}").collect()
133-
session.sql(f"drop secret if exists {key2}").collect()
134-
session.sql(f"drop integration if exists {integration1}").collect()
135-
session.sql(f"drop integration if exists {integration2}").collect()
127+
def clean_up_external_access_integration_resources():
136128
CONNECTION_PARAMETERS.pop("external_access_rule1", None)
137129
CONNECTION_PARAMETERS.pop("external_access_rule2", None)
138130
CONNECTION_PARAMETERS.pop("external_access_key1", None)
@@ -232,12 +224,12 @@ def session(
232224
unparser_jar,
233225
):
234226
set_ast_state(AstFlagSource.TEST, ast_enabled)
235-
rule1 = f"rule1{Utils.random_alphanumeric_str(10)}"
236-
rule2 = f"rule2{Utils.random_alphanumeric_str(10)}"
237-
key1 = f"key1{Utils.random_alphanumeric_str(10)}"
238-
key2 = f"key2{Utils.random_alphanumeric_str(10)}"
239-
integration1 = f"integration1_{Utils.random_alphanumeric_str(10)}"
240-
integration2 = f"integration2_{Utils.random_alphanumeric_str(10)}"
227+
rule1 = "snowpark_python_test_rule1"
228+
rule2 = "snowpark_python_test_rule2"
229+
key1 = "snowpark_python_test_key1"
230+
key2 = "snowpark_python_test_key2"
231+
integration1 = "snowpark_python_test_integration1"
232+
integration2 = "snowpark_python_test_integration2"
241233

242234
session = (
243235
Session.builder.configs(db_parameters)
@@ -266,9 +258,7 @@ def session(
266258
close_full_ast_validation_mode(full_ast_validation_listener)
267259

268260
if RUNNING_ON_GH and not local_testing_mode:
269-
clean_up_external_access_integration_resources(
270-
session, rule1, rule2, key1, key2, integration1, integration2
271-
)
261+
clean_up_external_access_integration_resources()
272262
session.close()
273263

274264

@@ -280,12 +270,12 @@ def profiler_session(
280270
local_testing_mode,
281271
cte_optimization_enabled,
282272
):
283-
rule1 = f"rule1{Utils.random_alphanumeric_str(10)}"
284-
rule2 = f"rule2{Utils.random_alphanumeric_str(10)}"
285-
key1 = f"key1{Utils.random_alphanumeric_str(10)}"
286-
key2 = f"key2{Utils.random_alphanumeric_str(10)}"
287-
integration1 = f"integration1_{Utils.random_alphanumeric_str(10)}"
288-
integration2 = f"integration2_{Utils.random_alphanumeric_str(10)}"
273+
rule1 = "snowpark_python_profiler_test_rule1"
274+
rule2 = "snowpark_python_profiler_test_rule2"
275+
key1 = "snowpark_python_profiler_test_key1"
276+
key2 = "snowpark_python_profiler_test_key2"
277+
integration1 = "snowpark_python_profiler_test_integration1"
278+
integration2 = "snowpark_python_profiler_test_integration2"
289279
session = (
290280
Session.builder.configs(db_parameters)
291281
.config("local_testing", local_testing_mode)
@@ -301,9 +291,7 @@ def profiler_session(
301291
yield session
302292
finally:
303293
if RUNNING_ON_GH and not local_testing_mode:
304-
clean_up_external_access_integration_resources(
305-
session, rule1, rule2, key1, key2, integration1, integration2
306-
)
294+
clean_up_external_access_integration_resources()
307295
session.close()
308296

309297

0 commit comments

Comments
 (0)