Skip to content

Conversation

@btasdoven
Copy link
Contributor

@btasdoven btasdoven commented May 2, 2017

Adding Failover Groups operations to Microsoft.Sql provider with their tests, and reflecting the API changes in our swagger file.

This is a breaking change in terms of Failover Groups APIs; however, this should not be an issue since the feature has not gone public.

Description


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as a link to the swagger spec, used to generate the code.
  • The project.json and AssemblyInfo.cs files have been updated with the new version of the SDK.

@azuresdkci
Copy link
Contributor

Can one of the admins verify this patch?

1 similar comment
@azuresdkci
Copy link
Contributor

Can one of the admins verify this patch?

@msftclas
Copy link

msftclas commented May 2, 2017

@btasdoven,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@btasdoven btasdoven requested review from jaredmoo, nathannfan and shahabhijeet and removed request for nathannfan May 2, 2017 22:05
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 201 && (int)_statusCode != 202)
if ((int)_statusCode != 200 && (int)_statusCode != 202)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to reviewers: Swagger change was Azure/azure-rest-api-specs#1166

{
ReadOnlyEndpoint = new FailoverGroupReadOnlyEndpoint()
{
FailoverPolicy = "Disabled",
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to write ReadOnlyEndpointFailoverPolicy.Disabled. (How do I know? see https://github.com/Azure/azure-rest-api-specs/blob/master/arm-sql/2015-05-01-preview/swagger/failoverGroups.json#L490 )

},
ReadWriteEndpoint = new FailoverGroupReadWriteEndpoint()
{
FailoverPolicy = "Automatic",
Copy link
Contributor

Choose a reason for hiding this comment

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

Use ReadWriteEndpointFailoverPolicy.Automatic

}

[Fact]
public void TestUpdateFailoverGroup()
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a bit repetitive, could this be part of the above test case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or could you at least factor out the common setup code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Combined the test cases into one.

var targetDatabase = sqlClient.Databases.Get(resourceGroup.Name, partnerServer.Name, databaseName);
Assert.NotNull(sourceDatabase.FailoverGroupId);
Assert.NotNull(targetDatabase.FailoverGroupId);

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you have a test where you call Failover? Seems like an important scenario for FailoverGroups ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't have to be a separate test, could be part of this or the other one. As long as it's covered somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense :) Added failover operation as part of the test case.

{
public class FailoverGroupCrudScenarioTests
{
public static string DefaultPrimaryLocation
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add these to SqlManagementTestUtilities?

I'm guessing they're for stage, maybe make them DefaultStageLocation and DefaultStageSecondaryLocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, they are for Stage. Moved them to SqlManagementTestUtilities.

}
}

private Server CreateServer(SqlManagementClient sqlClient, ResourceGroup resourceGroup, string serverPrefix, string location)
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be useful in SqlManagementTestUtilities as well, could you put it there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}

private Server CreateServer(SqlManagementClient sqlClient, ResourceGroup resourceGroup, string serverPrefix, string location)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also move this to SqlManagementTestUtilities?

//
var failoverGroupOnSecondary = sqlClient.FailoverGroups.Get(resourceGroup.Name, sourceServer.Name, failoverGroupName);
Assert.Equal(FailoverGroupReplicationRole.Secondary, failoverGroupOnSecondary.ReplicationRole);
Assert.Equal(FailoverGroupReplicationRole.Primary, failoverGroupOnSecondary.PartnerServers.First().ReplicationRole);
Copy link
Contributor

Choose a reason for hiding this comment

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

Beautiful. 💯

Copy link
Contributor

@shahabhijeet shahabhijeet left a comment

Choose a reason for hiding this comment

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

I don't see any change in version.
Will need changes to csproj and assemblyinfo files related to versions.

@shahabhijeet
Copy link
Contributor

@azuresdkci add to whitelist

@btasdoven
Copy link
Contributor Author

@shahabhijeet, do you have any other comments?

@shahabhijeet shahabhijeet merged commit 8732434 into Azure:vs17Dev May 9, 2017
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.

6 participants