Skip to content

Add Data Sync PowerShell Cmdlets to Azure.SQL #4037

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

Merged
merged 28 commits into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fb5e65d
Add Data Sync Legacy SDK
fhljys May 26, 2017
89e2b92
Add Data Sync PowerShell Cmdlets
fhljys May 26, 2017
c1fb0de
Add test cases and session records for Data Sync PowerShell Cmdlets
fhljys May 26, 2017
59a1baf
Update session records, Update test cases, Update help.xml
fhljys May 26, 2017
cf01bba
Update Sync Agent Creation Code and Session Records
May 27, 2017
e467f9c
resolve comments
May 30, 2017
aac3a5c
Resolve comments
May 31, 2017
55aab78
Merge remote-tracking branch 'refs/remotes/upstream/preview'
May 31, 2017
3dc64f8
Update help doc
May 31, 2017
22d6568
Update help doc xml
Jun 1, 2017
7ce9e74
Add alias, make some parameters positional.
Jun 12, 2017
ba7df38
Change DatabaseType to MemberDatabaseType, HubDatabaseCredential to D…
Jun 13, 2017
4330ea3
Add additional parameter set of sync agent resource id and sync datab…
Jun 13, 2017
ebf9782
Update tests and session records
Jun 13, 2017
e7cc67e
Merge remote-tracking branch 'upstream/preview' into fang-datasync
Jun 14, 2017
10a7099
Fix conflict of clientRequestId
Jun 14, 2017
a203f7a
Provide table view for syncGroup, syncMember, syncAgent and linkedDat…
Jun 14, 2017
5848fe7
Revert test framework upgrade
Jun 14, 2017
05bca5f
Merge remote-tracking branch 'refs/remotes/upstream/preview'
Jun 14, 2017
16e0ab7
Resolve comments
Jun 15, 2017
1c859e3
Resolve comments
Jun 15, 2017
d582370
Merge remote-tracking branch 'refs/remotes/upstream/preview'
Jun 15, 2017
2c87d78
Resolve comments --- except remove cmdlets
Jun 18, 2017
2da71b0
Fix remove cmdlets
Jun 18, 2017
1310355
Update session records
Jun 18, 2017
b4c2966
Merge remote-tracking branch 'refs/remotes/upstream/preview'
Jun 18, 2017
9549223
Update changelog
Jun 18, 2017
cf2c19d
Update Remove cmdlets and changelog
Jun 19, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/ResourceManager/Sql/AzureRM.Sql.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,25 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
'Remove-AzureRmSqlDatabaseFromFailoverGroup',
'Remove-AzureRmSqlDatabaseFailoverGroup',
'Set-AzureRmSqlDatabaseFailoverGroup',
'Switch-AzureRmSqlDatabaseFailoverGroup'
'Switch-AzureRmSqlDatabaseFailoverGroup',
'New-AzureRmSqlSyncGroup',
'Set-AzureRmSqlSyncGroup',
'Get-AzureRmSqlSyncGroup',
'Get-AzureRmSqlSyncGroupLog',
'Remove-AzureRmSqlSyncGroup',
'Invoke-AzureRmSqlSyncSchemaRefresh',
Copy link
Member

Choose a reason for hiding this comment

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

See name change below

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

'Get-AzureRmSqlSyncSchema',
'Start-AzureRmSqlSyncGroupSynchronization',
'Stop-AzureRmSqlSyncGroupSynchronization',
'New-AzureRmSqlSyncMember',
'Set-AzureRmSqlSyncMember',
'Get-AzureRmSqlSyncMember',
'Remove-AzureRmSqlSyncMember',
'New-AzureRmSqlSyncAgent',
'Get-AzureRmSqlSyncAgent',
'Remove-AzureRmSqlSyncAgent',
'New-AzureRmSqlSyncAgentKey',
'Get-AzureRmSqlSyncAgentLinkedDatabase'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
75 changes: 66 additions & 9 deletions src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@
<Reference Include="Microsoft.Azure.Test.Framework">
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.6179.26854-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.HttpRecorder">
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.7-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.8.1\lib\net452\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -115,19 +117,23 @@
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.5\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.7\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.5\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.3.0\lib\net452\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.7.1\lib\net452\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -157,8 +163,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -211,6 +219,7 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScenarioTests\ReadScaleCrudTests.cs" />
<Compile Include="ScenarioTests\DataSyncTests.cs" />
<Compile Include="ScenarioTests\RecommendedActionTests.cs" />
<Compile Include="ScenarioTests\DatabaseBackupStretchTests.cs" />
<Compile Include="ScenarioTests\DatabaseCrudStretchTests.cs" />
Expand All @@ -220,12 +229,16 @@
<Compile Include="ScenarioTests\DatabaseReplicationTests.cs" />
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
<None Include="app.config" />
<None Include="ScenarioTests\FailoverGroupTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ReadScaleCrudTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DataSyncTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\RecommendedActionTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -632,6 +645,51 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingTextRuleLifecycle.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentCreate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentKeyCreate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentLinkedDatabaseList.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentRemove.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentsGetAndList.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupCreate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupsGetAndList.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupHubSchemaRefreshAndGet.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupRemove.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupUpdate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberCreate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMembersGetAndList.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberSchemaRefreshAndGet.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberRemove.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberUpdate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -843,7 +901,6 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
67 changes: 64 additions & 3 deletions src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,24 @@ function Remove-ResourceGroupForTest ($rg)

<#
.SYNOPSIS
Creates the test environment needed to perform the Sql server CRUD tests
Gets the server credential
#>
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East")
function Get-ServerCredential
{
$serverName = Get-ServerName
$serverLogin = "testusername"
$serverPassword = "t357ingP@s5w0rd!"
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
return $credentials
}

<#
.SYNOPSIS
Creates the test environment needed to perform the Sql server CRUD tests
#>
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East")
{
$serverName = Get-ServerName
$credentials = Get-ServerCredential

$server = New-AzureRmSqlServer -ResourceGroupName $resourceGroup.ResourceGroupName -ServerName $serverName -Location $location -ServerVersion $serverVersion -SqlAdministratorCredentials $credentials
return $server
Expand Down Expand Up @@ -456,4 +466,55 @@ function Get-SqlDatabaseImportExportTestEnvironmentParameters ($testSuffix)
databaseMaxSizeBytes = "5000000";
authType = "Sql";
}
}

<#
.SYNOPSIS
Gets valid sync group name
#>
function Get-SyncGroupName
{
return getAssetName
}

<#
.SYNOPSIS
Gets valid sync member name
#>
function Get-SyncMemberName
{
return getAssetName
}

<#
.SYNOPSIS
Gets valid sync agent name
#>
function Get-SyncAgentName
{
return getAssetName
}

<#
.SYNOPSIS
Gets the values of the parameters used by the sync group tests
#>
function Get-SqlSyncGroupTestEnvironmentParameters ($testSuffix)
{
return @{
intervalInSeconds = 300;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: fix indentation.
method below also

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

conflictResolutionPolicy = "HubWin";
}
}

<#
.SYNOPSIS
Gets the values of the parameters used by the sync member tests
#>
function Get-SqlSyncMemberTestEnvironmentParameters ($testSuffix)
{
return @{
syncDirection = "Bidirectional";
databaseType = "AzureSqlDatabase";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ScenarioTest.SqlTests;
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
{
public class DataSyncTests : SqlTestsBase
{
public DataSyncTests(ITestOutputHelper output) : base(output)
{
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncAgentCreate()
{
RunPowerShellTest("Test-CreateSyncAgent");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncAgentsGetAndList()
{
RunPowerShellTest("Test-GetAndListSyncAgents");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncAgentRemove()
{
RunPowerShellTest("Test-RemoveSyncAgent");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncAgentKeyCreate()
{
RunPowerShellTest("Test-CreateSyncAgentKey");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncAgentLinkedDatabaseList()
{
RunPowerShellTest("Test-listSyncAgentLinkedDatabase");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncGroupCreate()
{
RunPowerShellTest("Test-CreateSyncGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncGroupUpdate()
{
RunPowerShellTest("Test-UpdateSyncGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncGroupsGetAndList()
{
RunPowerShellTest("Test-GetAndListSyncGroups");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncGroupHubSchemaRefreshAndGet()
{
RunPowerShellTest("Test-RefreshAndGetSyncGroupHubSchema");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncGroupRemove()
{
RunPowerShellTest("Test-RemoveSyncGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncMemberCreate()
{
RunPowerShellTest("Test-CreateSyncMember");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncMembersGetAndList()
{
RunPowerShellTest("Test-GetAndListSyncMembers");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncMemberUpdate()
{
RunPowerShellTest("Test-UpdateSyncMember");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncMemberSchemaRefreshAndGet()
{
RunPowerShellTest("Test-RefreshAndGetSyncMemberSchema");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSyncMemberRemove()
{
RunPowerShellTest("Test-RemoveSyncMember");
}
}
}
Loading