Skip to content

Commit 0583b07

Browse files
author
ling_aws
committed
Fixing failing tests after merge for pull request #162 from GuodongB/main
1 parent 68c6d85 commit 0583b07

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ __pycache__/
1717
.Python
1818
build/
1919
develop-eggs/
20-
dist/
2120
downloads/
2221
eggs/
2322
.eggs/
@@ -173,4 +172,9 @@ statements_to_be_avoided.txt
173172

174173
core/*/logs/*
175174
tools/*/logs/*
176-
tools/*/tests/logs/*
175+
tools/*/tests/logs/*
176+
177+
.python-version
178+
testDrive*/
179+
testDrive*
180+
/testDrive*/

common/util.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
r"(.+)\.(.+)\.(.+).redshift-serverless(-dev)?\.amazonaws\.com:[0-9]{4,5}\/(.)+"
1414
)
1515

16-
1716
def db_connect(
1817
interface="psql",
1918
host=None,
@@ -126,7 +125,6 @@ def cluster_dict(endpoint, is_serverless=False, start_time=None, end_time=None):
126125

127126
return cluster
128127

129-
130128
def bucket_dict(bucket_url):
131129
bucket, path = None, None
132130
try:
@@ -146,7 +144,6 @@ def bucket_dict(bucket_url):
146144
path = ""
147145
return {"url": bucket_url, "bucket_name": bucket, "prefix": path}
148146

149-
150147
def matches_filters(obj, filters):
151148
"""Check if the object matches the filters. The object just needs to
152149
provide a supported_filters() function. This also assumes filters has already
@@ -171,23 +168,26 @@ def matches_filters(obj, filters):
171168
else:
172169
return False
173170

174-
175171
def get_connection_key(database_name, username, pid):
176172
return f"{database_name}_{username}_{pid}"
177173

178-
179174
def is_serverless(config):
180-
if ".com.cn" in config["target_cluster_endpoint"] and len(config["target_cluster_endpoint"].split(".")) == 7:
181-
serverless_cluster_endpoint_pattern = (r"(.+)\.(.+)\.(.+).redshift-serverless(-dev)?\.amazonaws\.com\.cn:[0-9]{4,5}\/(.)+")
182-
return bool(
183-
re.fullmatch(serverless_cluster_endpoint_pattern, config["target_cluster_endpoint"])
184-
)
185-
175+
endpoint = config["target_cluster_endpoint"]
176+
177+
# Determine the domain suffix based on region
178+
if ".com.cn" in endpoint and len(endpoint.split(".")) == 7:
179+
domain_suffix = "amazonaws.com.cn"
180+
else:
181+
domain_suffix = "amazonaws.com"
182+
183+
# Build the pattern dynamically
184+
pattern = rf"(.+)\.(.+)\.(.+).redshift-serverless(-dev)?\.{domain_suffix}:[0-9]{{4,5}}\/(.)+"
185+
186+
return bool(re.fullmatch(pattern, endpoint))
186187

187188
def current_offset_ms(ref_time):
188189
return (datetime.datetime.now(tz=datetime.timezone.utc) - ref_time).total_seconds() * 1000.0
189190

190-
191191
# exception thrown if credentials can't be retrieved
192192
class CredentialsException(Exception):
193193
pass

0 commit comments

Comments
 (0)