Skip to content

Commit 134a1fa

Browse files
committed
Merge pull request Azure#118 from akromm/build-ps-servercrud
Adding SQL cmdlets for //build
2 parents 77c2842 + 398e072 commit 134a1fa

File tree

119 files changed

+25177
-149
lines changed

Some content is hidden

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

119 files changed

+25177
-149
lines changed

src/Common/Commands.ScenarioTests.Common/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class Category
3838

3939
public const string Store = "Store";
4040

41+
public const string Sql = "Sql";
42+
4143
public const string ServiceManagement = "ServiceManagement";
4244

4345
public const string Resources = "Resources";

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

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@
6060
<Reference Include="Microsoft.Azure.Gallery">
6161
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
6262
</Reference>
63-
<Reference Include="Microsoft.Azure.Management.Sql">
64-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.20.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
63+
<Reference Include="Microsoft.Azure.Management.Authorization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<SpecificVersion>False</SpecificVersion>
65+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.0-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
66+
</Reference>
67+
<Reference Include="Microsoft.Azure.Management.Sql, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
68+
<SpecificVersion>False</SpecificVersion>
69+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.21.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
6570
</Reference>
6671
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6772
<SpecificVersion>False</SpecificVersion>
@@ -145,19 +150,27 @@
145150
<DesignTime>True</DesignTime>
146151
<DependentUpon>Resources.resx</DependentUpon>
147152
</Compile>
153+
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
148154
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
155+
<None Include="ScenarioTests\ElasticPoolCrudTests.ps1">
156+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
157+
</None>
158+
<Compile Include="ScenarioTests\ElasticPoolCrudTests.cs" />
149159
<Compile Include="ScenarioTests\SecurityTests.cs" />
160+
<Compile Include="ScenarioTests\ServerCrudTests.cs" />
150161
<Compile Include="ScenarioTests\SqlTestsBase.cs" />
162+
<Compile Include="UnitTests\AzureSqlCmdletBaseAttributeTests.cs" />
163+
<Compile Include="UnitTests\AzureSqlDatabaseAttributeTests.cs" />
164+
<Compile Include="UnitTests\AzureSqlDatabaseServerServiceObjectiveAttributeTests.cs" />
165+
<Compile Include="UnitTests\AzureSqlDatabaseServerFirewallRuleAttributeTests.cs" />
166+
<Compile Include="UnitTests\AzureSqlDatabaseServerAttributeTests.cs" />
167+
<Compile Include="Utilities\UnitTestHelper.cs" />
151168
</ItemGroup>
152169
<ItemGroup>
153170
<ProjectReference Include="..\..\..\Common\Commands.ScenarioTests.Common\Commands.ScenarioTests.Common.csproj">
154171
<Project>{c1bda476-a5cc-4394-914d-48b0ec31a710}</Project>
155172
<Name>Commands.ScenarioTests.Common</Name>
156173
</ProjectReference>
157-
<ProjectReference Include="..\..\..\ServiceManagement\Services\Commands.Test.Utilities\Commands.Test.Utilities.csproj">
158-
<Project>{bc420543-c04e-4bf3-96e1-cd81b823bdd7}</Project>
159-
<Name>Commands.Test.Utilities</Name>
160-
</ProjectReference>
161174
<ProjectReference Include="..\..\Resources\Commands.Resources\Commands.Resources.csproj">
162175
<Project>{e1f5201d-6067-430e-b303-4e367652991b}</Project>
163176
<Name>Commands.Resources</Name>
@@ -187,6 +200,12 @@
187200
<None Include="packages.config">
188201
<SubType>Designer</SubType>
189202
</None>
203+
<None Include="ScenarioTests\DatabaseCrudTests.ps1">
204+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
205+
</None>
206+
<None Include="ScenarioTests\ServerCrudTests.ps1">
207+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208+
</None>
190209
<None Include="ScenarioTests\DataMaskingTests.ps1">
191210
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
192211
</None>
@@ -283,6 +302,34 @@
283302
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.SqlTests.SecurityTests\TestUseServerDefault.json">
284303
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
285304
</None>
305+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreate.json">
306+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
307+
</None>
308+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseGet.json">
309+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
310+
</None>
311+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseRemove.json">
312+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
313+
</None>
314+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdate.json">
315+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
316+
</None>
317+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreate.json" />
318+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolGet.json" />
319+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolRemove.json" />
320+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolUpdate.json" />
321+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerCreate.json">
322+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
323+
</None>
324+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerGet.json">
325+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
326+
</None>
327+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerRemove.json">
328+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
329+
</None>
330+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerUpdate.json">
331+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
332+
</None>
286333
<None Include="Templates\sql-audit-test-env-setup.json">
287334
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
288335
</None>

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

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ function Get-SqlDataMaskingTestEnvironmentParameters ($testSuffix)
3737
}
3838
}
3939

40+
<#
41+
.SYNOPSIS
42+
Gets the values of the parameters used in the s
43+
#>
44+
function Get-SqlDataMaskingTestEnvironmentParameters ($testSuffix)
45+
{
46+
return @{ rgname = "sql-dm-cmdlet-test-rg" +$testSuffix;
47+
serverName = "sql-dm-cmdlet-server" +$testSuffix;
48+
databaseName = "sql-dm-cmdlet-db" + $testSuffix
49+
}
50+
}
51+
4052
<#
4153
.SYNOPSIS
4254
Creates the test environment needed to perform the Sql auditing tests
@@ -59,6 +71,91 @@ function Create-DataMaskingTestEnvironment ($testSuffix)
5971
return $params
6072
}
6173

74+
<#
75+
.SYNOPSIS
76+
Gets valid resource group name
77+
#>
78+
function Get-ResourceGroupName
79+
{
80+
return getAssetName
81+
}
82+
83+
<#
84+
.SYNOPSIS
85+
Gets valid server name
86+
#>
87+
function Get-ServerName
88+
{
89+
return getAssetName
90+
}
91+
92+
<#
93+
.SYNOPSIS
94+
Gets valid database name
95+
#>
96+
function Get-DatabaseName
97+
{
98+
return getAssetName
99+
}
100+
101+
<#
102+
.SYNOPSIS
103+
Gets valid elastic pool name
104+
#>
105+
function Get-ElasticPoolName
106+
{
107+
return getAssetName
108+
}
109+
110+
<#
111+
.SYNOPSIS
112+
Creates a resource group for tests
113+
#>
114+
function Create-ResourceGroupForTest ()
115+
{
116+
$location = "Japan East"
117+
$rgName = Get-ResourceGroupName
118+
119+
$rg = New-AzureResourceGroup -Name $rgName -Location $location
120+
121+
return $rg
122+
}
123+
124+
125+
<#
126+
.SYNOPSIS
127+
removes a resource group that was used for testing
128+
#>
129+
function Remove-ResourceGroupForTest ($rg)
130+
{
131+
Remove-AzureResourceGroup -Name $rg.ResourceGroupName -Force
132+
}
133+
134+
<#
135+
.SYNOPSIS
136+
Creates the test environment needed to perform the Sql server CRUD tests
137+
#>
138+
function Create-ServerForTest ($resourceGroup, $location = "Japan East")
139+
{
140+
$serverName = Get-ServerName
141+
$version = "12.0"
142+
$serverLogin = "testusername"
143+
$serverPassword = "t357ingP@s5w0rd!"
144+
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
145+
146+
$server = New-AzureSqlServer -ResourceGroupName $resourceGroup.ResourceGroupName -ServerName $serverName -Location $location -ServerVersion $version -SqlAdminCredentials $credentials
147+
return $server
148+
}
149+
150+
<#
151+
.SYNOPSIS
152+
Remove a server that is no longer needed for tests
153+
#>
154+
function Remove-ServerForTest ($server)
155+
{
156+
$server | Remove-AzureSqlServer -Force
157+
}
158+
62159
<#
63160
.SYNOPSIS
64161
Removes the test environment that was needed to perform the Sql auditing tests
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.WindowsAzure.Commands.ScenarioTest;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
20+
{
21+
public class DatabaseCrudTests : SqlTestsBase
22+
{
23+
[Fact]
24+
[Trait(Category.Sql, Category.CheckIn)]
25+
public void TestDatabaseCreate()
26+
{
27+
RunPowerShellTest("Test-CreateDatabase");
28+
}
29+
30+
[Fact]
31+
[Trait(Category.Sql, Category.CheckIn)]
32+
public void TestDatabaseUpdate()
33+
{
34+
RunPowerShellTest("Test-UpdateDatabase");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.Sql, Category.CheckIn)]
39+
public void TestDatabaseGet()
40+
{
41+
RunPowerShellTest("Test-GetDatabase");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.Sql, Category.CheckIn)]
46+
public void TestDatabaseRemove()
47+
{
48+
RunPowerShellTest("Test-RemoveDatabase");
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)