1919
2020import codecs
2121import os
22+ import uuid
2223from typing import List
2324
2425import pytest
@@ -39,15 +40,33 @@ def polaris_host():
3940def polaris_port ():
4041 return int (os .getenv ('POLARIS_PORT' , '8181' ))
4142
43+ @pytest .fixture
44+ def polaris_path_prefix ():
45+ """
46+ Used to provide a path prefix between the port number and the standard polaris endpoint paths.
47+ No leading or trailing /
48+ :return:
49+ """
50+ return os .getenv ('POLARIS_PATH_PREFIX' , '' )
4251
4352@pytest .fixture
44- def polaris_url (polaris_host , polaris_port ):
45- return f"http://{ polaris_host } :{ polaris_port } /api/management/v1"
53+ def polaris_url_scheme ():
54+ """
55+ The URL Schema - either http or https - no : or trailing /
56+ :return:
57+ """
58+ return os .getenv ('POLARIS_URL_SCHEME' , 'http' )
59+
60+ @pytest .fixture
61+ def polaris_url (polaris_url_scheme , polaris_host , polaris_port , polaris_path_prefix ):
62+ polaris_path_prefix = polaris_path_prefix if len (polaris_path_prefix ) == 0 else '/' + polaris_path_prefix
63+ return f"{ polaris_url_scheme } ://{ polaris_host } :{ polaris_port } { polaris_path_prefix } /api/management/v1"
4664
4765
4866@pytest .fixture
49- def polaris_catalog_url (polaris_host , polaris_port ):
50- return f"http://{ polaris_host } :{ polaris_port } /api/catalog"
67+ def polaris_catalog_url (polaris_url_scheme , polaris_host , polaris_port , polaris_path_prefix ):
68+ polaris_path_prefix = polaris_path_prefix if len (polaris_path_prefix ) == 0 else '/' + polaris_path_prefix
69+ return f"{ polaris_url_scheme } ://{ polaris_host } :{ polaris_port } { polaris_path_prefix } /api/catalog"
5170
5271@pytest .fixture
5372def test_bucket ():
@@ -57,6 +76,16 @@ def test_bucket():
5776def aws_role_arn ():
5877 return os .getenv ('AWS_ROLE_ARN' )
5978
79+ @pytest .fixture
80+ def aws_bucket_base_location_prefix ():
81+ """
82+ :return: Base location prefix for tests, excluding leading and trailing '/'
83+ Provides a default if null or empty
84+ """
85+ default_val = 'polaris_test'
86+ bucket_prefix = os .getenv ('AWS_BUCKET_BASE_LOCATION_PREFIX' , default_val )
87+ return default_val if bucket_prefix == '' else bucket_prefix
88+
6089@pytest .fixture
6190def catalog_client (polaris_catalog_url ):
6291 """
@@ -72,13 +101,13 @@ def catalog_client(polaris_catalog_url):
72101
73102
74103@pytest .fixture
75- def snowflake_catalog (root_client , catalog_client , test_bucket , aws_role_arn ):
104+ def snowflake_catalog (root_client , catalog_client , test_bucket , aws_role_arn , aws_bucket_base_location_prefix ):
76105 storage_conf = AwsStorageConfigInfo (storage_type = "S3" ,
77- allowed_locations = [f"s3://{ test_bucket } /polaris_test /" ],
106+ allowed_locations = [f"s3://{ test_bucket } /{ aws_bucket_base_location_prefix } /" ],
78107 role_arn = aws_role_arn )
79- catalog_name = 'snowflake '
108+ catalog_name = f'snowflake_ { str ( uuid . uuid4 ())[ - 10 :] } '
80109 catalog = Catalog (name = catalog_name , type = 'INTERNAL' , properties = {
81- "default-base-location" : f"s3://{ test_bucket } /polaris_test /snowflake_catalog" ,
110+ "default-base-location" : f"s3://{ test_bucket } /{ aws_bucket_base_location_prefix } /snowflake_catalog" ,
82111 "client.credentials-provider" : "software.amazon.awssdk.auth.credentials.SystemPropertyCredentialsProvider"
83112 },
84113 storage_config_info = storage_conf )
0 commit comments