Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resource group based LTR APIs + tests to azure sdk #6957

Merged
merged 7 commits into from
Jul 19, 2019
Merged

Add resource group based LTR APIs + tests to azure sdk #6957

merged 7 commits into from
Jul 19, 2019

Conversation

pixia
Copy link
Contributor

@pixia pixia commented Jul 17, 2019

No description provided.

@jaredmoo
Copy link
Contributor

Let's aim to publish this and #6934 together

// Get the backups under the resource group, server and database. Assert there are no backups returned.
//
IPage<LongTermRetentionBackup> backups = sqlClient.LongTermRetentionBackups.ListByResourceGroupLocation(resourceGroup.Name, server.Location);
Assert.True(backups.Count() == 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you care how many backups are returned? Don't you just want the API to succeed (i.e. not throw)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the checks

string resourceGroupName = "";
string serverName = "";
string databaseName = "";
string locationName = "brazilsouth";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline, added comments and keep the change so test could pass in playback mode

@@ -312,7 +333,7 @@ public void TestLongTermRetentionV2Crud()
//
Microsoft.Azure.Management.Sql.Models.BackupLongTermRetentionPolicy parameters = new Microsoft.Azure.Management.Sql.Models.BackupLongTermRetentionPolicy(weeklyRetention: "P2W");
var policyResult = sqlClient.BackupLongTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, parameters).Result;
sqlClient.GetPutOrPatchOperationResultAsync(policyResult, new Dictionary<string, List<string>>(), CancellationToken.None).Wait();
Assert.Equal(System.Net.HttpStatusCode.OK, policyResult.Response.StatusCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -364,7 +385,7 @@ public void TestLongTermRetentionV2Crud()
//
parameters = new Microsoft.Azure.Management.Sql.Models.BackupLongTermRetentionPolicy(weeklyRetention: "P1W");
policyResult = sqlClient.BackupLongTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, parameters).Result;
sqlClient.GetPutOrPatchOperationResultAsync(policyResult, new Dictionary<string, List<string>>(), CancellationToken.None).Wait();
Assert.Equal(System.Net.HttpStatusCode.OK, policyResult.Response.StatusCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

// Set the weekly retention on the database so that the first backup gets picked up
// Wait about 18 hours until it gets properly copied and you see the backup when run get backups
//
string locationName = "brazilsouth";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clear out the names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline will keep the change

// Verify the backup is gone.
//
backups = sqlClient.LongTermRetentionBackups.ListByResourceGroupDatabase(resourceGroupName, locationName, serverName, databaseName);
Assert.True(backups.Count() == 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Assert.Equal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the check

// Delete the backup.
//
var deleteResult = sqlClient.LongTermRetentionBackups.DeleteByResourceGroupWithHttpMessagesAsync(resourceGroupName, locationName, serverName, databaseName, backup.Name).Result;
Assert.Equal(System.Net.HttpStatusCode.OK, deleteResult.Response.StatusCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you checking statuscode? generate client internals already check the status code. I don't think that this is a detail that you really care about at this layer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just call sqlClient.LongTermRetentionBackups.DeleteByResourceGroup(...) and let the generated SDK do its own validation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, did that

@erich-wang erich-wang self-assigned this Jul 18, 2019
Copy link
Member

@erich-wang erich-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve merge conflicts

@pixia
Copy link
Contributor Author

pixia commented Jul 18, 2019

Done

@erich-wang erich-wang merged commit 9f2816c into Azure:master Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants