Skip to content

Commit b87bc4e

Browse files
authored
Merge pull request Azure#4037 from fhljys/fang-datasync
Add Data Sync PowerShell Cmdlets to Azure.SQL
2 parents bbc5924 + cf2c19d commit b87bc4e

File tree

130 files changed

+65192
-10254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+65192
-10254
lines changed

src/ResourceManager/Sql/AzureRM.Sql.psd1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,25 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
166166
'Remove-AzureRmSqlDatabaseFromFailoverGroup',
167167
'Remove-AzureRmSqlDatabaseFailoverGroup',
168168
'Set-AzureRmSqlDatabaseFailoverGroup',
169-
'Switch-AzureRmSqlDatabaseFailoverGroup'
169+
'Switch-AzureRmSqlDatabaseFailoverGroup',
170+
'New-AzureRmSqlSyncGroup',
171+
'Update-AzureRmSqlSyncGroup',
172+
'Get-AzureRmSqlSyncGroup',
173+
'Get-AzureRmSqlSyncGroupLog',
174+
'Remove-AzureRmSqlSyncGroup',
175+
'Update-AzureRmSqlSyncSchema',
176+
'Get-AzureRmSqlSyncSchema',
177+
'Start-AzureRmSqlSyncGroupSync',
178+
'Stop-AzureRmSqlSyncGroupSync',
179+
'New-AzureRmSqlSyncMember',
180+
'Update-AzureRmSqlSyncMember',
181+
'Get-AzureRmSqlSyncMember',
182+
'Remove-AzureRmSqlSyncMember',
183+
'New-AzureRmSqlSyncAgent',
184+
'Get-AzureRmSqlSyncAgent',
185+
'Remove-AzureRmSqlSyncAgent',
186+
'New-AzureRmSqlSyncAgentKey',
187+
'Get-AzureRmSqlSyncAgentLinkedDatabase'
170188

171189
# Variables to export from this module
172190
# VariablesToExport = @()

src/ResourceManager/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Add Data Sync PowerShell Cmdlets to AzureRM.Sql
2122

2223
## Version 3.1.0
2324
* Restore-AzureRmSqlDatabase: Update documentation examples

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
<DependentUpon>Resources.resx</DependentUpon>
212212
</Compile>
213213
<Compile Include="ScenarioTests\ReadScaleCrudTests.cs" />
214+
<Compile Include="ScenarioTests\DataSyncTests.cs" />
214215
<Compile Include="ScenarioTests\RecommendedActionTests.cs" />
215216
<Compile Include="ScenarioTests\DatabaseBackupStretchTests.cs" />
216217
<Compile Include="ScenarioTests\DatabaseCrudStretchTests.cs" />
@@ -226,6 +227,9 @@
226227
<None Include="ScenarioTests\ReadScaleCrudTests.ps1">
227228
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
228229
</None>
230+
<None Include="ScenarioTests\DataSyncTests.ps1">
231+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
232+
</None>
229233
<None Include="ScenarioTests\RecommendedActionTests.ps1">
230234
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
231235
</None>
@@ -632,6 +636,51 @@
632636
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingTextRuleLifecycle.json">
633637
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
634638
</None>
639+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentCreate.json">
640+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
641+
</None>
642+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentKeyCreate.json">
643+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
644+
</None>
645+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentLinkedDatabaseList.json">
646+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
647+
</None>
648+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentRemove.json">
649+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
650+
</None>
651+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentsGetAndList.json">
652+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
653+
</None>
654+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupCreate.json">
655+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
656+
</None>
657+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupsGetAndList.json">
658+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
659+
</None>
660+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupHubSchemaRefreshAndGet.json">
661+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
662+
</None>
663+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupRemove.json">
664+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
665+
</None>
666+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupUpdate.json">
667+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
668+
</None>
669+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberCreate.json">
670+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
671+
</None>
672+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMembersGetAndList.json">
673+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
674+
</None>
675+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberSchemaRefreshAndGet.json">
676+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
677+
</None>
678+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberRemove.json">
679+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
680+
</None>
681+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberUpdate.json">
682+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
683+
</None>
635684
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreate.json">
636685
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
637686
</None>
@@ -843,7 +892,6 @@
843892
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
844893
</None>
845894
</ItemGroup>
846-
<ItemGroup />
847895
<ItemGroup>
848896
<EmbeddedResource Include="Properties\Resources.resx">
849897
<Generator>ResXFileCodeGenerator</Generator>

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/Common.ps1

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,24 @@ function Remove-ResourceGroupForTest ($rg)
356356

357357
<#
358358
.SYNOPSIS
359-
Creates the test environment needed to perform the Sql server CRUD tests
359+
Gets the server credential
360360
#>
361-
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East")
361+
function Get-ServerCredential
362362
{
363-
$serverName = Get-ServerName
364363
$serverLogin = "testusername"
365364
$serverPassword = "t357ingP@s5w0rd!"
366365
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
366+
return $credentials
367+
}
368+
369+
<#
370+
.SYNOPSIS
371+
Creates the test environment needed to perform the Sql server CRUD tests
372+
#>
373+
function Create-ServerForTest ($resourceGroup, $serverVersion = "12.0", $location = "Japan East")
374+
{
375+
$serverName = Get-ServerName
376+
$credentials = Get-ServerCredential
367377

368378
$server = New-AzureRmSqlServer -ResourceGroupName $resourceGroup.ResourceGroupName -ServerName $serverName -Location $location -ServerVersion $serverVersion -SqlAdministratorCredentials $credentials
369379
return $server
@@ -456,4 +466,68 @@ function Get-SqlDatabaseImportExportTestEnvironmentParameters ($testSuffix)
456466
databaseMaxSizeBytes = "5000000";
457467
authType = "Sql";
458468
}
469+
}
470+
471+
<#
472+
.SYNOPSIS
473+
Gets valid sync group name
474+
#>
475+
function Get-SyncGroupName
476+
{
477+
return getAssetName
478+
}
479+
480+
<#
481+
.SYNOPSIS
482+
Gets valid sync member name
483+
#>
484+
function Get-SyncMemberName
485+
{
486+
return getAssetName
487+
}
488+
489+
<#
490+
.SYNOPSIS
491+
Gets valid sync agent name
492+
#>
493+
function Get-SyncAgentName
494+
{
495+
return getAssetName
496+
}
497+
498+
<#
499+
.SYNOPSIS
500+
Gets the values of the parameters used by the sync group tests
501+
#>
502+
function Get-SqlSyncGroupTestEnvironmentParameters ()
503+
{
504+
return @{ intervalInSeconds = 300;
505+
conflictResolutionPolicy = "HubWin";
506+
}
507+
}
508+
509+
<#
510+
.SYNOPSIS
511+
Gets the values of the parameters used by the sync member tests
512+
#>
513+
function Get-SqlSyncMemberTestEnvironmentParameters ()
514+
{
515+
return @{ syncDirection = "Bidirectional";
516+
databaseType = "AzureSqlDatabase";
517+
}
518+
}
519+
520+
<#
521+
.SYNOPSIS
522+
Gets dns name according to environment
523+
#>
524+
function Get-DNSNameBasedOnEnvironment ()
525+
{
526+
$connectingString = [System.Environment]::GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION")
527+
$parsedString = [Microsoft.Azure.Test.TestUtilities]::ParseConnectionString($connectingString)
528+
$environment = $parsedString[[Microsoft.Azure.Test.TestEnvironment]::EnvironmentKey]
529+
if ($environment -eq "Prod"){
530+
return ".database.windows.net"
531+
}
532+
return ".sqltest-eg1.mscds.com"
459533
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ScenarioTest.SqlTests;
16+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Xunit;
19+
using Xunit.Abstractions;
20+
21+
namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
22+
{
23+
public class DataSyncTests : SqlTestsBase
24+
{
25+
public DataSyncTests(ITestOutputHelper output) : base(output)
26+
{
27+
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestSyncAgentCreate()
33+
{
34+
RunPowerShellTest("Test-CreateSyncAgent");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestSyncAgentsGetAndList()
40+
{
41+
RunPowerShellTest("Test-GetAndListSyncAgents");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestSyncAgentRemove()
47+
{
48+
RunPowerShellTest("Test-RemoveSyncAgent");
49+
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestSyncAgentKeyCreate()
54+
{
55+
RunPowerShellTest("Test-CreateSyncAgentKey");
56+
}
57+
58+
[Fact]
59+
[Trait(Category.AcceptanceType, Category.CheckIn)]
60+
public void TestSyncAgentLinkedDatabaseList()
61+
{
62+
RunPowerShellTest("Test-listSyncAgentLinkedDatabase");
63+
}
64+
65+
[Fact]
66+
[Trait(Category.AcceptanceType, Category.CheckIn)]
67+
public void TestSyncGroupCreate()
68+
{
69+
RunPowerShellTest("Test-CreateSyncGroup");
70+
}
71+
72+
[Fact]
73+
[Trait(Category.AcceptanceType, Category.CheckIn)]
74+
public void TestSyncGroupUpdate()
75+
{
76+
RunPowerShellTest("Test-UpdateSyncGroup");
77+
}
78+
79+
[Fact]
80+
[Trait(Category.AcceptanceType, Category.CheckIn)]
81+
public void TestSyncGroupsGetAndList()
82+
{
83+
RunPowerShellTest("Test-GetAndListSyncGroups");
84+
}
85+
86+
[Fact]
87+
[Trait(Category.AcceptanceType, Category.CheckIn)]
88+
public void TestSyncGroupHubSchemaRefreshAndGet()
89+
{
90+
RunPowerShellTest("Test-RefreshAndGetSyncGroupHubSchema");
91+
}
92+
93+
[Fact]
94+
[Trait(Category.AcceptanceType, Category.CheckIn)]
95+
public void TestSyncGroupRemove()
96+
{
97+
RunPowerShellTest("Test-RemoveSyncGroup");
98+
}
99+
100+
[Fact]
101+
[Trait(Category.AcceptanceType, Category.CheckIn)]
102+
public void TestSyncMemberCreate()
103+
{
104+
RunPowerShellTest("Test-CreateSyncMember");
105+
}
106+
107+
[Fact]
108+
[Trait(Category.AcceptanceType, Category.CheckIn)]
109+
public void TestSyncMembersGetAndList()
110+
{
111+
RunPowerShellTest("Test-GetAndListSyncMembers");
112+
}
113+
114+
[Fact]
115+
[Trait(Category.AcceptanceType, Category.CheckIn)]
116+
public void TestSyncMemberUpdate()
117+
{
118+
RunPowerShellTest("Test-UpdateSyncMember");
119+
}
120+
121+
[Fact]
122+
[Trait(Category.AcceptanceType, Category.CheckIn)]
123+
public void TestSyncMemberSchemaRefreshAndGet()
124+
{
125+
RunPowerShellTest("Test-RefreshAndGetSyncMemberSchema");
126+
}
127+
128+
[Fact]
129+
[Trait(Category.AcceptanceType, Category.CheckIn)]
130+
public void TestSyncMemberRemove()
131+
{
132+
RunPowerShellTest("Test-RemoveSyncMember");
133+
}
134+
}
135+
}

0 commit comments

Comments
 (0)