Skip to content

Commit c1fb0de

Browse files
committed
Add test cases and session records for Data Sync PowerShell Cmdlets
1 parent 89e2b92 commit c1fb0de

23 files changed

+36652
-17
lines changed

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

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@
9191
<Reference Include="Microsoft.Azure.Test.Framework">
9292
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.6179.26854-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
9393
</Reference>
94-
<Reference Include="Microsoft.Azure.Test.HttpRecorder">
95-
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.7-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
94+
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
95+
<SpecificVersion>False</SpecificVersion>
96+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.8.1\lib\net452\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
97+
<Private>True</Private>
9698
</Reference>
9799
<Reference Include="Microsoft.Data.Edm">
98100
<SpecificVersion>False</SpecificVersion>
@@ -115,19 +117,23 @@
115117
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
116118
</Reference>
117119
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
118-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.5\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
120+
<SpecificVersion>False</SpecificVersion>
121+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.7\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
119122
<Private>True</Private>
120123
</Reference>
121124
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
122125
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.5\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
123126
<Private>True</Private>
124127
</Reference>
125128
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
126-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
129+
<SpecificVersion>False</SpecificVersion>
130+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.3.0\lib\net452\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
127131
<Private>True</Private>
128132
</Reference>
129-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
130-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
133+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
134+
<SpecificVersion>False</SpecificVersion>
135+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.7.1\lib\net452\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
136+
<Private>True</Private>
131137
</Reference>
132138
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
133139
<SpecificVersion>False</SpecificVersion>
@@ -157,8 +163,10 @@
157163
<SpecificVersion>False</SpecificVersion>
158164
<HintPath>..\..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
159165
</Reference>
160-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
161-
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
166+
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
167+
<SpecificVersion>False</SpecificVersion>
168+
<HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
169+
<Private>True</Private>
162170
</Reference>
163171
<Reference Include="System" />
164172
<Reference Include="System.Core" />
@@ -211,6 +219,7 @@
211219
<DependentUpon>Resources.resx</DependentUpon>
212220
</Compile>
213221
<Compile Include="ScenarioTests\ReadScaleCrudTests.cs" />
222+
<Compile Include="ScenarioTests\DataSyncTests.cs" />
214223
<Compile Include="ScenarioTests\RecommendedActionTests.cs" />
215224
<Compile Include="ScenarioTests\DatabaseBackupStretchTests.cs" />
216225
<Compile Include="ScenarioTests\DatabaseCrudStretchTests.cs" />
@@ -220,12 +229,16 @@
220229
<Compile Include="ScenarioTests\DatabaseReplicationTests.cs" />
221230
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
222231
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
232+
<None Include="app.config" />
223233
<None Include="ScenarioTests\FailoverGroupTests.ps1">
224234
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
225235
</None>
226236
<None Include="ScenarioTests\ReadScaleCrudTests.ps1">
227237
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
228238
</None>
239+
<None Include="ScenarioTests\DataSyncTests.ps1">
240+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
241+
</None>
229242
<None Include="ScenarioTests\RecommendedActionTests.ps1">
230243
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
231244
</None>
@@ -632,6 +645,60 @@
632645
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests\TestDatabaseDataMaskingTextRuleLifecycle.json">
633646
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
634647
</None>
648+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentCreate.json">
649+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
650+
</None>
651+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentCrud.json">
652+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
653+
</None>
654+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentKeyCreate.json">
655+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
656+
</None>
657+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentLinkedDatabaseList.json">
658+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
659+
</None>
660+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentRemove.json">
661+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
662+
</None>
663+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncAgentsGetAndList.json">
664+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
665+
</None>
666+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupCreate.json">
667+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
668+
</None>
669+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupCrud.json">
670+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
671+
</None>
672+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupsGetAndList.json">
673+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
674+
</None>
675+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupHubSchemaRefreshAndGet.json">
676+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
677+
</None>
678+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupRemove.json">
679+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
680+
</None>
681+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncGroupUpdate.json">
682+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
683+
</None>
684+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberCreate.json">
685+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
686+
</None>
687+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberCrud.json">
688+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
689+
</None>
690+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMembersGetAndList.json">
691+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
692+
</None>
693+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberSchemaRefreshAndGet.json">
694+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
695+
</None>
696+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberRemove.json">
697+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
698+
</None>
699+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataSyncTests\TestSyncMemberUpdate.json">
700+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
701+
</None>
635702
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreate.json">
636703
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
637704
</None>
@@ -843,7 +910,6 @@
843910
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
844911
</None>
845912
</ItemGroup>
846-
<ItemGroup />
847913
<ItemGroup>
848914
<EmbeddedResource Include="Properties\Resources.resx">
849915
<Generator>ResXFileCodeGenerator</Generator>

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

Lines changed: 64 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,55 @@ 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 ($testSuffix)
503+
{
504+
return @{
505+
intervalInSeconds = 300;
506+
conflictResolutionPolicy = "HubWin";
507+
}
508+
}
509+
510+
<#
511+
.SYNOPSIS
512+
Gets the values of the parameters used by the sync member tests
513+
#>
514+
function Get-SqlSyncMemberTestEnvironmentParameters ($testSuffix)
515+
{
516+
return @{
517+
syncDirection = "Bidirectional";
518+
databaseType = "AzureSqlDatabase";
519+
}
459520
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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 TestSyncAgentCrud()
33+
{
34+
RunPowerShellTest("Test-CrudSyncAgent");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestSyncAgentCreate()
40+
{
41+
RunPowerShellTest("Test-CreateSyncAgent");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestSyncAgentsGetAndList()
47+
{
48+
RunPowerShellTest("Test-GetAndListSyncAgents");
49+
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestSyncAgentRemove()
54+
{
55+
RunPowerShellTest("Test-RemoveSyncAgent");
56+
}
57+
58+
[Fact]
59+
[Trait(Category.AcceptanceType, Category.CheckIn)]
60+
public void TestSyncAgentKeyCreate()
61+
{
62+
RunPowerShellTest("Test-CreateSyncAgentKey");
63+
}
64+
65+
[Fact]
66+
[Trait(Category.AcceptanceType, Category.CheckIn)]
67+
public void TestSyncAgentLinkedDatabaseList()
68+
{
69+
RunPowerShellTest("Test-listSyncAgentLinkedDatabase");
70+
}
71+
72+
[Fact]
73+
[Trait(Category.AcceptanceType, Category.CheckIn)]
74+
public void TestSyncGroupCrud()
75+
{
76+
RunPowerShellTest("Test-CrudSyncGroup");
77+
}
78+
79+
[Fact]
80+
[Trait(Category.AcceptanceType, Category.CheckIn)]
81+
public void TestSyncGroupCreate()
82+
{
83+
RunPowerShellTest("Test-CreateSyncGroup");
84+
}
85+
86+
[Fact]
87+
[Trait(Category.AcceptanceType, Category.CheckIn)]
88+
public void TestSyncGroupUpdate()
89+
{
90+
RunPowerShellTest("Test-UpdateSyncGroup");
91+
}
92+
93+
[Fact]
94+
[Trait(Category.AcceptanceType, Category.CheckIn)]
95+
public void TestSyncGroupsGetAndList()
96+
{
97+
RunPowerShellTest("Test-GetAndListSyncGroups");
98+
}
99+
100+
[Fact]
101+
[Trait(Category.AcceptanceType, Category.CheckIn)]
102+
public void TestSyncGroupHubSchemaRefreshAndGet()
103+
{
104+
RunPowerShellTest("Test-RefreshAndGetSyncGroupHubSchema");
105+
}
106+
107+
[Fact]
108+
[Trait(Category.AcceptanceType, Category.CheckIn)]
109+
public void TestSyncGroupTriggerAndCancelSync()
110+
{
111+
RunPowerShellTest("Test-TriggerAndCancelSyncGroupSync");
112+
}
113+
114+
[Fact]
115+
[Trait(Category.AcceptanceType, Category.CheckIn)]
116+
public void TestSyncGroupRemove()
117+
{
118+
RunPowerShellTest("Test-RemoveSyncGroup");
119+
}
120+
121+
[Fact]
122+
[Trait(Category.AcceptanceType, Category.CheckIn)]
123+
public void TestSyncMemberCrud()
124+
{
125+
RunPowerShellTest("Test-CrudSyncMember");
126+
}
127+
128+
[Fact]
129+
[Trait(Category.AcceptanceType, Category.CheckIn)]
130+
public void TestSyncMemberCreate()
131+
{
132+
RunPowerShellTest("Test-CreateSyncMember");
133+
}
134+
135+
[Fact]
136+
[Trait(Category.AcceptanceType, Category.CheckIn)]
137+
public void TestSyncMembersGetAndList()
138+
{
139+
RunPowerShellTest("Test-GetAndListSyncMembers");
140+
}
141+
142+
[Fact]
143+
[Trait(Category.AcceptanceType, Category.CheckIn)]
144+
public void TestSyncMemberUpdate()
145+
{
146+
RunPowerShellTest("Test-UpdateSyncMember");
147+
}
148+
149+
[Fact]
150+
[Trait(Category.AcceptanceType, Category.CheckIn)]
151+
public void TestSyncMemberSchemaRefreshAndGet()
152+
{
153+
RunPowerShellTest("Test-RefreshAndGetSyncMemberSchema");
154+
}
155+
156+
[Fact]
157+
[Trait(Category.AcceptanceType, Category.CheckIn)]
158+
public void TestSyncMemberRemove()
159+
{
160+
RunPowerShellTest("Test-RemoveSyncMember");
161+
}
162+
}
163+
}

0 commit comments

Comments
 (0)