Skip to content

Commit d1fd2f6

Browse files
committed
Merge pull request Azure#146 from jamestao/build
Add test for Get-Metric on a ElasticPool
2 parents c74ac51 + 69fd150 commit d1fd2f6

File tree

8 files changed

+239
-4
lines changed

8 files changed

+239
-4
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@
319319
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolGet.json">
320320
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
321321
</None>
322+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolMetricGet.json">
323+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
324+
</None>
322325
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolRemove.json">
323326
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
324327
</None>

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ElasticPoolCrudTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public void TestElasticPoolGet()
4141
RunPowerShellTest("Test-GetElasticPool");
4242
}
4343

44+
[Fact]
45+
[Trait(Category.Sql, Category.CheckIn)]
46+
public void TestElasticPoolMetricGet()
47+
{
48+
RunPowerShellTest("Test-GetElasticPoolMetric");
49+
}
50+
4451
[Fact]
4552
[Trait(Category.Sql, Category.CheckIn)]
4653
public void TestElasticPoolRemove()

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,31 @@ function Test-GetElasticPool
151151
}
152152
}
153153

154+
<#
155+
.SYNOPSIS
156+
Tests getting an elastic pool metric
157+
#>
158+
function Test-GetElasticPoolMetric
159+
{
160+
# This test requires that an elastic pool has been created and has metrics ready
161+
# To prevent requiring putting something like a Sleep(10 minutes) in the code
162+
# this test requires the server/elastic pool be pre-created with metrics data available.
163+
164+
# Setup and retrieve the existing pool
165+
$rgName = "test-group"
166+
$serverName = "groupserver1"
167+
$elasticPoolName = "testpool2"
168+
169+
$ep1 = Get-AzureSqlElasticPool -ServerName $serverName -ResourceGroupName $rgName `
170+
-ElasticPoolName $elasticPoolName
171+
Assert-NotNull $ep1
172+
173+
# Get pool metrics with all values
174+
$metrics = $ep1 | Get-Metrics -TimeGrain "0:5:0" -StartTime "2015-04-22T16:00:00Z" -EndTime "2015-04-22T17:00:00Z"
175+
Assert-NotNull $metrics
176+
Assert-True { $metrics.Count -gt 0 }
177+
}
178+
154179

155180
<#
156181
.SYNOPSIS

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests/TestElasticPoolMetricGet.json

Lines changed: 188 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql/Common/AzureSqlCmdletBase.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,17 @@ public override void ExecuteCmdlet()
9696

9797
if(responseModel != null)
9898
{
99-
if (WriteResult()) this.WriteObject(responseModel);
99+
if (WriteResult())
100+
{
101+
this.WriteObject(responseModel, true);
102+
}
100103
}
101104
else
102105
{
103-
if (WriteResult()) this.WriteObject(updatedModel);
106+
if (WriteResult())
107+
{
108+
this.WriteObject(updatedModel);
109+
}
104110
}
105111
}
106112
}

src/ResourceManager/Sql/Commands.Sql/Elastic Pools/Model/AzureSqlElasticPoolModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ namespace Microsoft.Azure.Commands.Sql.ElasticPool.Model
2323
/// </summary>
2424
public class AzureSqlElasticPoolModel
2525
{
26+
/// <summary>
27+
/// Gets or sets the resource id for this resource
28+
/// </summary>
29+
public string ResourceId { get; set; }
30+
2631
/// <summary>
2732
/// Gets or sets the name of the resource group
2833
/// </summary>

src/ResourceManager/Sql/Commands.Sql/Elastic Pools/Services/AzureSqlElasticPoolAdapter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private AzureSqlElasticPoolModel CreateElasticPoolModelFromResponse(string resou
268268
{
269269
AzureSqlElasticPoolModel model = new AzureSqlElasticPoolModel();
270270

271+
model.ResourceId = pool.Id;
271272
model.ResourceGroupName = resourceGroup;
272273
model.ServerName = serverName;
273274
model.ElasticPoolName = pool.Name;

src/ResourceManager/Sql/Commands.Sql/Elastic Pools/Services/AzureSqlElasticPoolCommunicator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public class AzureSqlElasticPoolCommunicator
3333
/// The Sql client to be used by this end points communicator
3434
/// </summary>
3535
private static SqlManagementClient SqlClient { get; set; }
36-
36+
3737
/// <summary>
3838
/// Gets or set the Azure subscription
3939
/// </summary>
40-
private static AzureSubscription Subscription {get ; set; }
40+
private static AzureSubscription Subscription { get; set; }
4141

4242
/// <summary>
4343
/// Gets or sets the Azure profile

0 commit comments

Comments
 (0)