RDS: add SourceType field for response (#6306)
This commit is contained in:
parent
9d8d166571
commit
ebe48e7443
@ -1136,6 +1136,9 @@ class ExportTask(BaseModel):
|
||||
|
||||
self.status = "complete"
|
||||
self.created_at = iso_8601_datetime_with_milliseconds(datetime.datetime.now())
|
||||
self.source_type = (
|
||||
"SNAPSHOT" if type(snapshot) is DatabaseSnapshot else "CLUSTER"
|
||||
)
|
||||
|
||||
def to_xml(self) -> str:
|
||||
template = Template(
|
||||
@ -1161,6 +1164,7 @@ class ExportTask(BaseModel):
|
||||
<TotalExtractedDataInGB>{{ 1 }}</TotalExtractedDataInGB>
|
||||
<FailureCause></FailureCause>
|
||||
<WarningMessage></WarningMessage>
|
||||
<SourceType>{{ task.source_type }}</SourceType>
|
||||
"""
|
||||
)
|
||||
return template.render(task=self, snapshot=self.snapshot)
|
||||
|
@ -25,6 +25,30 @@ def _prepare_db_snapshot(client, snapshot_name="snapshot-1"):
|
||||
return resp["DBSnapshot"]["DBSnapshotArn"]
|
||||
|
||||
|
||||
def _prepare_db_cluster_snapshot(client, snapshot_name="cluster-snapshot-1"):
|
||||
db_cluster_identifier = "db-cluster-primary-1"
|
||||
client.create_db_cluster(
|
||||
AvailabilityZones=[
|
||||
"us-west-2",
|
||||
],
|
||||
BackupRetentionPeriod=1,
|
||||
DBClusterIdentifier=db_cluster_identifier,
|
||||
DBClusterParameterGroupName="db-cluster-primary-1-group",
|
||||
DatabaseName="staging-postgres",
|
||||
Engine="postgres",
|
||||
EngineVersion="5.6.10a",
|
||||
MasterUserPassword="hunterxhunder",
|
||||
MasterUsername="root",
|
||||
Port=3306,
|
||||
StorageEncrypted=True,
|
||||
)
|
||||
resp = client.create_db_cluster_snapshot(
|
||||
DBClusterSnapshotIdentifier=snapshot_name,
|
||||
DBClusterIdentifier=db_cluster_identifier,
|
||||
)
|
||||
return resp["DBClusterSnapshot"]["DBClusterSnapshotArn"]
|
||||
|
||||
|
||||
@mock_rds
|
||||
def test_start_export_task_fails_unknown_snapshot():
|
||||
client = boto3.client("rds", region_name="us-west-2")
|
||||
@ -44,7 +68,7 @@ def test_start_export_task_fails_unknown_snapshot():
|
||||
|
||||
|
||||
@mock_rds
|
||||
def test_start_export_task():
|
||||
def test_start_export_task_db():
|
||||
client = boto3.client("rds", region_name="us-west-2")
|
||||
source_arn = _prepare_db_snapshot(client)
|
||||
|
||||
@ -67,6 +91,34 @@ def test_start_export_task():
|
||||
"arn:aws:kms:::key/0ea3fef3-80a7-4778-9d8c-1c0c6EXAMPLE"
|
||||
)
|
||||
export["ExportOnly"].should.equal(["schema.table"])
|
||||
export["SourceType"].should.equal("SNAPSHOT")
|
||||
|
||||
|
||||
@mock_rds
|
||||
def test_start_export_task_db_cluster():
|
||||
client = boto3.client("rds", region_name="us-west-2")
|
||||
source_arn = _prepare_db_cluster_snapshot(client)
|
||||
|
||||
export = client.start_export_task(
|
||||
ExportTaskIdentifier="export-snapshot-1",
|
||||
SourceArn=source_arn,
|
||||
S3BucketName="export-bucket",
|
||||
S3Prefix="snaps/",
|
||||
IamRoleArn="arn:aws:iam:::role/export-role",
|
||||
KmsKeyId="arn:aws:kms:::key/0ea3fef3-80a7-4778-9d8c-1c0c6EXAMPLE",
|
||||
ExportOnly=["schema.table"],
|
||||
)
|
||||
|
||||
export["ExportTaskIdentifier"].should.equal("export-snapshot-1")
|
||||
export["SourceArn"].should.equal(source_arn)
|
||||
export["S3Bucket"].should.equal("export-bucket")
|
||||
export["S3Prefix"].should.equal("snaps/")
|
||||
export["IamRoleArn"].should.equal("arn:aws:iam:::role/export-role")
|
||||
export["KmsKeyId"].should.equal(
|
||||
"arn:aws:kms:::key/0ea3fef3-80a7-4778-9d8c-1c0c6EXAMPLE"
|
||||
)
|
||||
export["ExportOnly"].should.equal(["schema.table"])
|
||||
export["SourceType"].should.equal("CLUSTER")
|
||||
|
||||
|
||||
@mock_rds
|
||||
|
Loading…
Reference in New Issue
Block a user