Skip to content

Commit

Permalink
adding fixes for gen3-helper-test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseCastle23 committed Jan 15, 2025
1 parent cd71d6f commit 0beb954
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions gen3/bin/db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ gen3_db_namespace() {
#
# Given a gen3 server name, determine the RDS instance id
#
gen3_db_server_rds_id() {
gen3_db_server_aurora_cluster() {
local address
local serverInfo

Expand All @@ -406,7 +406,7 @@ gen3_db_server_rds_id() {
gen3_log_err "unable to determine address for $@"
return 1
fi
aws rds describe-db-instances | jq -e -r --arg address "$address" '.DBInstances[] | select(.Endpoint.Address==$address) | .DBInstanceIdentifier'
aws rds describe-db-instances | jq -e -r --arg address "$address" '.DBInstances[] | select(.Endpoint.Address==$address) | .DBClusterIdentifier'
}

#
Expand All @@ -431,15 +431,15 @@ gen3_db_snapshot_take() {
dryRun=true
fi
local instanceId
if ! instanceId="$(gen3_db_server_rds_id "$serverName")"; then
if ! instanceId="$(gen3_db_server_aurora_cluster "$serverName")"; then
gen3_log_err "failed to find rds instance id for server: $serverName"
return 1
fi
snapshotId="gen3-snapshot-${serverName}-$(date -u +%Y%m%d-%H%M%S)"
if [[ "$dryRun" == true ]]; then
gen3_log_info "dryrun mode - not taking snapshot"
else
aws rds create-db-snapshot --db-snapshot-identifier "$snapshotId" --db-instance-identifier "$instanceId"
aws rds create-db-cluster-snapshot --db-cluster-snapshot-identifier "$snapshotId" --db-cluster-identifier "$instanceId"
fi
}

Expand All @@ -457,11 +457,11 @@ gen3_db_snapshot_list() {
return 1
fi
local instanceId
if ! instanceId="$(gen3_db_server_rds_id "$serverName")"; then
if ! instanceId="$(gen3_db_server_aurora_cluster "$serverName")"; then
gen3_log_err "failed to find rds instance id for server: $serverName"
return 1
fi
aws rds describe-db-snapshots --db-instance-identifier "$instanceId"
aws rds describe-db-cluster-snapshots --db-cluster-identifier "$instanceId"
}


Expand Down
2 changes: 1 addition & 1 deletion gen3/test/dbTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ test_db_snapshot_list() {
local snapshotJson
snapshotJson="$(gen3 db snapshot list server1)"; because $? "gen3 db snapshot list server1 should work"
local snapCount
snapCount="$(jq -e -r '.DBSnapshots | length' <<<"$snapshotJson")";
snapCount="$(jq -e -r '.DBClusterSnapshots | length' <<<"$snapshotJson")";
because $? "snap list json has expected structure"
[[ "$snapCount" =~ ^[0-9]+$ && "$snapCount" -gt 0 ]]; because $? "server1 has at least 1 snapshot"
}
Expand Down

0 comments on commit 0beb954

Please sign in to comment.