Skip to content

Commit

Permalink
fixing bug to allow replay to connect to multiple databases and lowering
Browse files Browse the repository at this point in the history
numpy version
  • Loading branch information
Devanathan Sabapathy committed Jul 5, 2024
1 parent 616b5cd commit a36d695
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/replay/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def get_connection_credentials(self, username, database=None, skip_cache=False):
cluster_host = cluster_endpoint.split(":")[0]

cluster_port = cluster_endpoint_split[5].split("/")[0][4:]
database = cluster_endpoint_split[5].split("/")[1]
if database == None:
database = cluster_endpoint_split[5].split("/")[1]

additional_args = {}
if os.environ.get("ENDPOINT_URL"):
Expand Down
24 changes: 24 additions & 0 deletions core/tests/test_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,30 @@ def test_get_connection_credentials_provisioned_from_redshift_api(
"database": "dev",
},
)

@patch("core.replay.prep.redshift_get_cluster_credentials")
def test_get_connection_credentials_for_database_not_being_none(self, mock_get_cluster_creds):
mock_get_cluster_creds.return_value = {"DbUser": "testAdmin", "DbPassword": "testPassword"}
prep = ReplayPrep(
{
"target_cluster_endpoint": "test.111222333222.us-east-1.redshift.amazonaws.com:5439/dev",
"odbc_driver": "test",
"nlb_nat_dns": None,
"target_cluster_region": "us-east-1",
}
)

result = prep.get_connection_credentials("testUsername","tcpds_100g")
self.assertEqual(
result["psql"],
{
"username": "testAdmin",
"password": "testPassword",
"host": "test.111222333222.us-east-1.redshift.amazonaws.com",
"port": "5439",
"database": "tcpds_100g",
},
)


class TestCorrelateTransactionsWithConnections(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ botocore==1.27.24
Flask==2.2.5
matplotlib==3.5.2
moto==3.1.16
numpy
numpy==1.26.4
pandas
python-dateutil==2.8.1
PyYAML==6.0
Expand Down

0 comments on commit a36d695

Please sign in to comment.