Skip to content

Commit 53f328c

Browse files
Merge pull request #23 from Azure/dev
PR from parent
2 parents b05f2c3 + b8923d5 commit 53f328c

File tree

59 files changed

+1871
-728
lines changed

Some content is hidden

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

59 files changed

+1871
-728
lines changed

src/Common/Commands.Common/Commands.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
</ItemGroup>
144144
<ItemGroup>
145145
<Compile Include="AzurePowerShell.cs" />
146+
<Compile Include="ComputeCloudException.cs" />
146147
<Compile Include="Constants.cs" />
147148
<Compile Include="SecureStringExtensions.cs" />
148149
<Compile Include="ConversionUtilities.cs" />
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 Hyak.Common;
16+
using System;
17+
using System.Linq;
18+
using System.Text;
19+
20+
namespace Microsoft.WindowsAzure.Commands.Common
21+
{
22+
public class ComputeCloudException : CloudException
23+
{
24+
protected const string RequestIdHeaderInResponse = "x-ms-request-id";
25+
26+
public ComputeCloudException(CloudException ex)
27+
: base(GetErrorMessageWithRequestIdInfo(ex), ex)
28+
{
29+
}
30+
31+
protected static string GetErrorMessageWithRequestIdInfo(CloudException cloudException)
32+
{
33+
if (cloudException == null)
34+
{
35+
throw new ArgumentNullException("cloudException");
36+
}
37+
38+
var sb = new StringBuilder();
39+
40+
if (!string.IsNullOrEmpty(cloudException.Message))
41+
{
42+
sb.Append(cloudException.Message);
43+
}
44+
45+
if (cloudException.Response != null &&
46+
cloudException.Response.Headers != null)
47+
{
48+
var headers = cloudException.Response.Headers;
49+
if (headers.ContainsKey(RequestIdHeaderInResponse))
50+
{
51+
sb.AppendLine().AppendFormat(
52+
Properties.Resources.ComputeCloudExceptionOperationIdMessage,
53+
headers[RequestIdHeaderInResponse].FirstOrDefault());
54+
}
55+
}
56+
57+
return sb.ToString();
58+
}
59+
}
60+
}

src/Common/Commands.Common/Properties/Resources.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Common/Commands.Common/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,4 +1361,7 @@ use and privacy statement at &lt;url&gt; and (c) agree to sharing my contact inf
13611361
<data name="SwitchAzureModeDeprecated" xml:space="preserve">
13621362
<value>The Switch-AzureMode cmdlet is deprecated and will be removed in a future release.</value>
13631363
</data>
1364+
<data name="ComputeCloudExceptionOperationIdMessage" xml:space="preserve">
1365+
<value>OperationID : '{0}'</value>
1366+
</data>
13641367
</root>

src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,13 @@
202202
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.AutomationTests\TestAutomationSuspendAndResumeJob.json">
203203
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
204204
</None>
205-
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.AzureVMTests\TestGetAzureLocation.json">
205+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunServiceManagementCloudExceptionTests.json">
206206
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
207207
</None>
208-
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.AzureVMTests\TestGetAzureVM.json">
208+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\TestGetAzureLocation.json">
209+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
210+
</None>
211+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\TestGetAzureVM.json">
209212
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
210213
</None>
211214
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.SchedulerTests\TestSchedulerEndToEnd.json">
@@ -289,8 +292,8 @@
289292
<Compile Include="Resources\ResourceLocator.cs" />
290293
<Compile Include="Scheduler\SchedulerTests.cs" />
291294
<Compile Include="ServiceBusTests\ServiceBusAuthorizationRuleTests.cs" />
292-
<Compile Include="ServiceManagement\GetLocationTests.cs" />
293-
<Compile Include="ServiceManagement\GetVMTests.cs" />
295+
<Compile Include="ServiceManagement\ScenarioTests.cs" />
296+
<Compile Include="ServiceManagement\ServiceManagementTests.cs" />
294297
<Compile Include="StorageTests\StorageContainerTest.cs" />
295298
<Compile Include="StorageTests\StorageContextTest.cs" />
296299
<Compile Include="StoreTests\StoreTests.cs" />
@@ -414,7 +417,7 @@
414417
<None Include="Resources\CloudService\Cache\mc.tgz">
415418
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
416419
</None>
417-
<None Include="Resources\ServiceManagement\AzureVMTests.ps1">
420+
<None Include="Resources\ServiceManagement\ServiceManagementTests.ps1">
418421
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
419422
</None>
420423
<None Include="Resources\ServiceManagement\Common.ps1">

src/Common/Commands.ScenarioTest/Resources/ServiceManagement/Common.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ function Cleanup-Storage
8888
Write-Warning "Cannot Remove the Storage Account"
8989
}
9090
}
91+

src/Common/Commands.ScenarioTest/Resources/ServiceManagement/AzureVMTests.ps1 renamed to src/Common/Commands.ScenarioTest/Resources/ServiceManagement/ServiceManagementTests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ function Test-GetAzureLocation
6161
Cleanup-CloudService $svcName
6262
}
6363
}
64+
65+
# Test Service Management Cloud Exception
66+
function Run-ServiceManagementCloudExceptionTests
67+
{
68+
$compare = "*OperationID : `'*`'";
69+
Assert-ThrowsLike { $st = Get-AzureService -ServiceName '*' } $compare;
70+
Assert-ThrowsLike { $st = Get-AzureVM -ServiceName '*' } $compare;
71+
Assert-ThrowsLike { $st = Get-AzureAffinityGroup -Name '*' } $compare;
72+
}

src/Common/Commands.ScenarioTest/ServiceManagement/GetLocationTests.cs renamed to src/Common/Commands.ScenarioTest/ServiceManagement/ScenarioTests.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.WindowsAzure.Commands.ScenarioTest.Common;
15+
using Microsoft.Azure.Common.Authentication;
16+
using Microsoft.Azure.Test;
17+
using System.Collections.Generic;
18+
using System.IO;
19+
using System.Linq;
1620
using Xunit;
1721

1822
namespace Microsoft.WindowsAzure.Commands.ScenarioTest
1923
{
20-
public partial class AzureVMTests
24+
public partial class ServiceManagementTests
2125
{
2226
[Fact]
2327
[Trait(Category.Service, Category.ServiceManagement)]
@@ -27,5 +31,14 @@ public void TestGetAzureLocation()
2731
{
2832
this.RunPowerShellTest("Test-GetAzureLocation");
2933
}
34+
35+
[Fact]
36+
[Trait(Category.Service, Category.ServiceManagement)]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
[Trait(Category.AcceptanceType, Category.BVT)]
39+
public void RunServiceManagementCloudExceptionTests()
40+
{
41+
this.RunPowerShellTest("Run-ServiceManagementCloudExceptionTests");
42+
}
3043
}
3144
}

src/Common/Commands.ScenarioTest/ServiceManagement/GetVMTests.cs renamed to src/Common/Commands.ScenarioTest/ServiceManagement/ServiceManagementTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@
2121

2222
namespace Microsoft.WindowsAzure.Commands.ScenarioTest
2323
{
24-
public partial class AzureVMTests
24+
public partial class ServiceManagementTests
2525
{
2626
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper();
2727

28-
#region Get-AzureVM Scenario Tests
29-
3028
[Fact]
3129
[Trait(Category.AcceptanceType, Category.CheckIn)]
3230
public void TestGetAzureVM()
3331
{
3432
this.RunPowerShellTest("Test-GetAzureVM");
3533
}
36-
#endregion
3734

3835
protected void SetupManagementClients()
3936
{
@@ -48,7 +45,7 @@ protected void RunPowerShellTest(params string[] scripts)
4845

4946
SetupManagementClients();
5047

51-
List<string> modules = Directory.GetFiles("Resources\\ServiceManagement", "*.ps1").ToList();
48+
List<string> modules = Directory.GetFiles(@"Resources\ServiceManagement", "*.ps1").ToList();
5249
modules.Add("Common.ps1");
5350
modules.Add(@"..\..\..\..\Package\Debug\ServiceManagement\Azure\Azure.psd1");
5451

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/4d368445-cbb1-42a7-97a6-6850ab99f48e/services/hostedservices/*",
5+
"EncodedRequestUri": "LzRkMzY4NDQ1LWNiYjEtNDJhNy05N2E2LTY4NTBhYjk5ZjQ4ZS9zZXJ2aWNlcy9ob3N0ZWRzZXJ2aWNlcy8lMkE=",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-version": [
10+
"2015-04-01"
11+
],
12+
"User-Agent": [
13+
"Microsoft.WindowsAzure.Management.Compute.ComputeManagementClient/12.0.0.0"
14+
]
15+
},
16+
"ResponseBody": "<Error xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Code>BadRequest</Code>\r\n <Message>The hosted service name is invalid.</Message>\r\n</Error>",
17+
"ResponseHeaders": {
18+
"Content-Length": [
19+
"194"
20+
],
21+
"Content-Type": [
22+
"application/xml; charset=utf-8"
23+
],
24+
"x-ms-servedbyregion": [
25+
"ussouth3"
26+
],
27+
"Strict-Transport-Security": [
28+
"max-age=31536000; includeSubDomains"
29+
],
30+
"x-ms-request-id": [
31+
"8fbc1c1bfd26be549be7ac6edfe8fd67"
32+
],
33+
"Cache-Control": [
34+
"no-cache"
35+
],
36+
"Date": [
37+
"Wed, 24 Jun 2015 21:52:37 GMT"
38+
],
39+
"Server": [
40+
"1.0.6198.243",
41+
"(rd_rdfe_stable.150618-1025)",
42+
"Microsoft-HTTPAPI/2.0"
43+
]
44+
},
45+
"StatusCode": 400
46+
},
47+
{
48+
"RequestUri": "/4d368445-cbb1-42a7-97a6-6850ab99f48e/services/hostedservices/*/deploymentslots/Production",
49+
"EncodedRequestUri": "LzRkMzY4NDQ1LWNiYjEtNDJhNy05N2E2LTY4NTBhYjk5ZjQ4ZS9zZXJ2aWNlcy9ob3N0ZWRzZXJ2aWNlcy8lMkEvZGVwbG95bWVudHNsb3RzL1Byb2R1Y3Rpb24=",
50+
"RequestMethod": "GET",
51+
"RequestBody": "",
52+
"RequestHeaders": {
53+
"x-ms-version": [
54+
"2015-04-01"
55+
],
56+
"User-Agent": [
57+
"Microsoft.WindowsAzure.Management.Compute.ComputeManagementClient/12.0.0.0"
58+
]
59+
},
60+
"ResponseBody": "<Error xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Code>BadRequest</Code>\r\n <Message>The hosted service name is invalid.</Message>\r\n</Error>",
61+
"ResponseHeaders": {
62+
"Content-Length": [
63+
"194"
64+
],
65+
"Content-Type": [
66+
"application/xml; charset=utf-8"
67+
],
68+
"x-ms-servedbyregion": [
69+
"ussouth3"
70+
],
71+
"Strict-Transport-Security": [
72+
"max-age=31536000; includeSubDomains"
73+
],
74+
"x-ms-request-id": [
75+
"235043d87cdfbdbea385a799a177dbeb"
76+
],
77+
"Cache-Control": [
78+
"no-cache"
79+
],
80+
"Date": [
81+
"Wed, 24 Jun 2015 21:52:37 GMT"
82+
],
83+
"Server": [
84+
"1.0.6198.243",
85+
"(rd_rdfe_stable.150618-1025)",
86+
"Microsoft-HTTPAPI/2.0"
87+
]
88+
},
89+
"StatusCode": 400
90+
},
91+
{
92+
"RequestUri": "/4d368445-cbb1-42a7-97a6-6850ab99f48e/affinitygroups/*",
93+
"EncodedRequestUri": "LzRkMzY4NDQ1LWNiYjEtNDJhNy05N2E2LTY4NTBhYjk5ZjQ4ZS9hZmZpbml0eWdyb3Vwcy8lMkE=",
94+
"RequestMethod": "GET",
95+
"RequestBody": "",
96+
"RequestHeaders": {
97+
"x-ms-version": [
98+
"2014-10-01"
99+
],
100+
"User-Agent": [
101+
"Microsoft.WindowsAzure.Management.ManagementClient/4.0.0.0"
102+
]
103+
},
104+
"ResponseBody": "<Error xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Code>ResourceNotFound</Code>\r\n <Message>The affinity group does not exist.</Message>\r\n</Error>",
105+
"ResponseHeaders": {
106+
"Content-Length": [
107+
"199"
108+
],
109+
"Content-Type": [
110+
"application/xml; charset=utf-8"
111+
],
112+
"x-ms-servedbyregion": [
113+
"ussouth3"
114+
],
115+
"x-ms-request-id": [
116+
"e7eb6116c17abe61b27520096b982601"
117+
],
118+
"Cache-Control": [
119+
"no-cache"
120+
],
121+
"Date": [
122+
"Wed, 24 Jun 2015 21:52:38 GMT"
123+
],
124+
"Server": [
125+
"1.0.6198.243",
126+
"(rd_rdfe_stable.150618-1025)",
127+
"Microsoft-HTTPAPI/2.0"
128+
]
129+
},
130+
"StatusCode": 404
131+
}
132+
],
133+
"Names": {},
134+
"Variables": {
135+
"SubscriptionId": "4d368445-cbb1-42a7-97a6-6850ab99f48e"
136+
}
137+
}

0 commit comments

Comments
 (0)