Skip to content

Commit 8239a52

Browse files
committed
Merge pull request #94 from akromm/dev-Sql-Fixes-0.8.14
Dev sql fixes 0.8.14
2 parents d223c84 + 239ffc6 commit 8239a52

File tree

12 files changed

+38812
-5594
lines changed

12 files changed

+38812
-5594
lines changed

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/Resources/MockSessions.xml

Lines changed: 38617 additions & 5483 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/UnitTests/Database/Cmdlet/AzureSqlDatabaseCertAuthTests.cs

Lines changed: 70 additions & 55 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/UnitTests/Database/Cmdlet/AzureSqlDatabaseCopyCertAuthTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public void InitializeTest()
9292
testSession);
9393
}
9494

95-
9695
[TestCleanup]
9796
public void CleanupTest()
9897
{

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/UnitTests/Database/Cmdlet/DatabaseTestHelper.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,22 @@ public static class DatabaseTestHelper
2525
/// The unique GUID for identifying the Shared SLO.
2626
/// </summary>
2727
public static readonly Guid SharedSloGuid = new Guid("910b4fcb-8a29-4c3e-958f-f7ba794388b2");
28-
28+
2929
/// <summary>
3030
/// The unique GUID for identifying the System SLO.
3131
/// </summary>
3232
public static readonly Guid SystemSloGuid = new Guid("26e021db-f1f9-4c98-84c6-92af8ef433d7");
3333

34+
/// <summary>
35+
/// The unique GUID for identifying the System2 SLO.
36+
/// </summary>
37+
public static readonly Guid System2SloGuid = new Guid("620323bf-2879-4807-b30d-c2e6d7b3b3aa");
38+
39+
/// <summary>
40+
/// The unique GUID for identifying the Business SLO.
41+
/// </summary>
42+
public static readonly Guid BusinessSloGuid = new Guid("4518ce8e-6026-4113-b4fd-3b5d777c6881");
43+
3444
/// <summary>
3545
/// The unique GUID for identifying the Basic SLO.
3646
/// </summary>

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/UnitTests/Database/Cmdlet/NewAzureSqlDatabaseTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public static void CreateTestDatabasesWithCertAuth(System.Management.Automation.
346346
@"-ServerName $serverName " +
347347
@"-DatabaseName testdb2 " +
348348
@"-Collation Japanese_CI_AS " +
349-
@"-Edition Web " +
349+
@"-Edition Standard " +
350350
@"-MaxSizeGB 5 " +
351351
@"-Force",
352352
@"$testdb2");
@@ -365,15 +365,15 @@ public static void CreateTestDatabasesWithCertAuth(System.Management.Automation.
365365

366366
Services.Server.Database database = database1.Single().BaseObject as Services.Server.Database;
367367
Assert.IsTrue(database != null, "Expecting a Database object");
368-
DatabaseTestHelper.ValidateDatabaseProperties(database, "testdb1", "Web", 1, 1073741824L, "SQL_Latin1_General_CP1_CI_AS", "Shared", false, DatabaseTestHelper.SharedSloGuid);
368+
DatabaseTestHelper.ValidateDatabaseProperties(database, "testdb1", "Standard", 250, 268435456000L, "SQL_Latin1_General_CP1_CI_AS", "S0", false, DatabaseTestHelper.StandardS0SloGuid);
369369

370370
database = database2.Single().BaseObject as Services.Server.Database;
371371
Assert.IsTrue(database != null, "Expecting a Database object");
372-
DatabaseTestHelper.ValidateDatabaseProperties(database, "testdb2", "Web", 5, 5368709120L, "Japanese_CI_AS", "Shared", false, DatabaseTestHelper.SharedSloGuid);
372+
DatabaseTestHelper.ValidateDatabaseProperties(database, "testdb2", "Standard", 250, 268435456000L, "Japanese_CI_AS", "S0", false, DatabaseTestHelper.StandardS0SloGuid);
373373

374374
database = database3.Single().BaseObject as Services.Server.Database;
375375
Assert.IsTrue(database != null, "Expecting a Database object");
376-
DatabaseTestHelper.ValidateDatabaseProperties(database, "testdb3", "Web", 0, 104857600L, "SQL_Latin1_General_CP1_CI_AS", "Shared", false, DatabaseTestHelper.SharedSloGuid);
376+
DatabaseTestHelper.ValidateDatabaseProperties(database, "testdb3", "Standard", 0, 104857600L, "SQL_Latin1_General_CP1_CI_AS", "S0", false, DatabaseTestHelper.StandardS0SloGuid);
377377
}
378378
}
379379

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/UnitTests/Server/Cmdlet/ServerCmdletTests.cs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,35 @@ namespace Microsoft.WindowsAzure.Commands.SqlDatabase.Test.UnitTests.Server.Cmdl
3333
[TestClass]
3434
public class ServerCmdletTests : TestBase
3535
{
36+
// String ID for server version 2.
37+
public const string ServerVersion2 = "2.0";
38+
39+
// String ID for server version 12.
40+
public const string ServerVersion12 = "12.0";
41+
42+
// The default server version
43+
public const string DefaultServerVersion = ServerVersion12;
44+
3645
[TestCleanup]
3746
public void CleanupTest()
3847
{
3948
// Save the mock session results
4049
MockServerHelper.SaveDefaultSessionCollection();
4150
}
4251

43-
private static void VerifyServer(SqlDatabaseServerContext server, string adminLogin, string location)
52+
/// <summary>
53+
/// Verifys the server object to make sure the fields match what is provided
54+
/// </summary>
55+
/// <param name="server">The server object to validate</param>
56+
/// <param name="adminLogin">The expected administration login</param>
57+
/// <param name="location">The expected server location</param>
58+
/// <param name="version">The expected server verions</param>
59+
/// <param name="state">The expected state of the server</param>
60+
private static void VerifyServer(SqlDatabaseServerContext server, string adminLogin, string location, string version, string state)
4461
{
4562
Assert.AreEqual(adminLogin, server.AdministratorLogin, "Expecting server login to match.");
4663
Assert.AreEqual(location, server.Location, "Expecting matching location.");
4764
Assert.AreEqual(10, server.ServerName.Length, "Expecting a valid server name.");
48-
}
49-
50-
private static void VerifyServer(SqlDatabaseServerContext server, string adminLogin, string location, string version, string state)
51-
{
52-
VerifyServer(server, adminLogin, location);
5365
Assert.AreEqual(version, server.Version, "Server version doesn't match");
5466
Assert.AreEqual(state, server.State, "Server state does not match");
5567
}
@@ -190,14 +202,18 @@ public void AzureSqlDatabaseServerTests()
190202
VerifyServer(
191203
server,
192204
(string)powershell.Runspace.SessionStateProxy.GetVariable("login"),
193-
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"));
205+
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"),
206+
ServerVersion12,
207+
"Ready");
194208

195209
SqlDatabaseServerContext server2 = newServerResult2.Single().BaseObject as SqlDatabaseServerContext;
196210
Assert.IsNotNull(server2, "Expecting a SqlDatabaseServerContext object");
197211
VerifyServer(
198212
server,
199213
(string)powershell.Runspace.SessionStateProxy.GetVariable("login"),
200-
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"));
214+
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"),
215+
ServerVersion12,
216+
"Ready");
201217

202218
// Validate Get-AzureSqlDatabaseServer results
203219
server = getServerResult.Single().BaseObject as SqlDatabaseServerContext;
@@ -206,7 +222,7 @@ public void AzureSqlDatabaseServerTests()
206222
server,
207223
(string)powershell.Runspace.SessionStateProxy.GetVariable("login"),
208224
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"),
209-
"2.0",
225+
ServerVersion12,
210226
"Ready");
211227

212228
server = setServerResult.Single().BaseObject as SqlDatabaseServerContext;
@@ -215,7 +231,7 @@ public void AzureSqlDatabaseServerTests()
215231
server,
216232
(string)powershell.Runspace.SessionStateProxy.GetVariable("login"),
217233
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"),
218-
"2.0",
234+
ServerVersion12,
219235
"Ready");
220236

221237
server2 = setServerResult2.Single().BaseObject as SqlDatabaseServerContext;
@@ -224,7 +240,7 @@ public void AzureSqlDatabaseServerTests()
224240
server2,
225241
(string)powershell.Runspace.SessionStateProxy.GetVariable("login"),
226242
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"),
227-
"2.0",
243+
ServerVersion12,
228244
"Ready");
229245

230246
// Validate Remove-AzureSqlDatabaseServer results
@@ -319,7 +335,9 @@ public void AzureSqlDatabaseServerV2Tests()
319335
VerifyServer(
320336
server,
321337
(string)powershell.Runspace.SessionStateProxy.GetVariable("login"),
322-
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"));
338+
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"),
339+
ServerVersion2,
340+
"Ready");
323341

324342

325343
// Validate Get-AzureSqlDatabaseServer results
@@ -329,8 +347,8 @@ public void AzureSqlDatabaseServerV2Tests()
329347
server,
330348
(string)powershell.Runspace.SessionStateProxy.GetVariable("login"),
331349
(string)powershell.Runspace.SessionStateProxy.GetVariable("location"),
332-
"2.0",
333-
null);
350+
ServerVersion2,
351+
"Ready");
334352

335353
powershell.Streams.ClearStreams();
336354
}

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/UnitTests/UnitTestHelper.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,13 @@ public static AzureSubscription SetupUnitTestSubscription(System.Management.Auto
290290
{
291291
UnitTestHelper.ImportAzureModule(powershell);
292292

293+
X509Certificate2 certificate = UnitTestHelper.GetUnitTestClientCertificate();
294+
Guid subscriptionId = new Guid(UnitTestSubscriptionId);
295+
293296
// Set the client certificate used in the subscription
294297
powershell.Runspace.SessionStateProxy.SetVariable(
295298
"clientCertificate",
296-
UnitTestHelper.GetUnitTestClientCertificate());
299+
certificate);
297300

298301
ProfileClient client = new ProfileClient();
299302
client.Profile.Environments[UnitTestEnvironmentName] = new AzureEnvironment
@@ -308,13 +311,13 @@ public static AzureSubscription SetupUnitTestSubscription(System.Management.Auto
308311

309312
var account = new AzureAccount
310313
{
311-
Id = UnitTestHelper.GetUnitTestClientCertificate().Thumbprint,
314+
Id = certificate.Thumbprint,
312315
Type = AzureAccount.AccountType.Certificate
313316
};
314317

315318
var subscription = new AzureSubscription
316319
{
317-
Id = new Guid(UnitTestSubscriptionId),
320+
Id = subscriptionId,
318321
Name = UnitTestSubscriptionName,
319322
Environment = UnitTestEnvironmentName,
320323
Account = account.Id
@@ -324,7 +327,7 @@ public static AzureSubscription SetupUnitTestSubscription(System.Management.Auto
324327
client.AddOrSetSubscription(subscription);
325328
client.SetSubscriptionAsCurrent(UnitTestSubscriptionName, account.Id);
326329
client.Profile.Save();
327-
330+
328331
return subscription;
329332
}
330333

src/ServiceManagement/Sql/Commands.SqlDatabase/Microsoft.WindowsAzure.Commands.SqlDatabase.dll-Help.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,7 +2192,7 @@ Business Edition values: 10, 20, 30, 40, 50, 100, or 150</maml:para>
21922192
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
21932193
<maml:name>Version</maml:name>
21942194
<maml:description>
2195-
<maml:para>Specifies the type of SQL Database Server to create. Accepts values 1.0 or 2.0.</maml:para>
2195+
<maml:para>Specifies the type of SQL Database Server to create. Accepts values 2.0 or 12.0.</maml:para>
21962196
</maml:description>
21972197
<command:parameterValue required="true" variableLength="false">Single</command:parameterValue>
21982198
</command:parameter>
@@ -2259,7 +2259,7 @@ Business Edition values: 10, 20, 30, 40, 50, 100, or 150</maml:para>
22592259
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
22602260
<maml:name>Version</maml:name>
22612261
<maml:description>
2262-
<maml:para>Specifies the type of SQL Database Server to create. Accepts values 1.0 or 2.0.</maml:para>
2262+
<maml:para>Specifies the type of SQL Database Server to create. Accepts values 2.0 or 12.0.</maml:para>
22632263
</maml:description>
22642264
<command:parameterValue required="true" variableLength="false">Single</command:parameterValue>
22652265
<dev:type>

src/ServiceManagement/Sql/Commands.SqlDatabase/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/ServiceManagement/Sql/Commands.SqlDatabase/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@
121121
<value>Invalid Parameter combination: Both "DatabaseName" and "DatabaseDeletionDate" need to be specified to get a restorable dropped database.</value>
122122
<comment>Parameter validation</comment>
123123
</data>
124+
<data name="CreateServerServerNotFound" xml:space="preserve">
125+
<value>Unable to retrieve newly created server '{0}'.</value>
126+
</data>
124127
<data name="CredentialNotSpecified" xml:space="preserve">
125128
<value>The Sql Authenticate Credential was not specified.</value>
126129
<comment>Parameter validation</comment>

src/ServiceManagement/Sql/Commands.SqlDatabase/Server/Cmdlet/NewAzureSqlDatabaseServer.cs

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

15+
using Hyak.Common.TransientFaultHandling;
1516
using Microsoft.WindowsAzure.Commands.SqlDatabase.Model;
1617
using Microsoft.WindowsAzure.Commands.SqlDatabase.Properties;
17-
using Microsoft.Azure.Common.Internals;
1818
using Microsoft.WindowsAzure.Management.Sql;
1919
using Microsoft.WindowsAzure.Management.Sql.Models;
20-
using Hyak.Common;
2120
using System;
21+
using System.Collections.Generic;
22+
using System.Globalization;
23+
using System.Linq;
2224
using System.Management.Automation;
23-
using Hyak.Common.TransientFaultHandling;
2425

2526
namespace Microsoft.WindowsAzure.Commands.SqlDatabase.Server.Cmdlet
2627
{
@@ -119,14 +120,26 @@ internal SqlDatabaseServerContext NewAzureSqlDatabaseServerProcess(
119120
Version = version.HasValue ? version.Value.ToString("F1") : null
120121
});
121122

123+
var newServer = sqlManagementClient.Servers.List().Servers.Where(s => s.Name == response.ServerName).FirstOrDefault();
124+
125+
if (newServer == null)
126+
{
127+
throw new ItemNotFoundException(string.Format(
128+
CultureInfo.InvariantCulture,
129+
Resources.CreateServerServerNotFound,
130+
response.ServerName));
131+
}
132+
122133
SqlDatabaseServerContext operationContext = new SqlDatabaseServerContext()
123134
{
124135
OperationStatus = Services.Constants.OperationSuccess,
125136
OperationDescription = CommandRuntime.ToString(),
126137
OperationId = response.RequestId,
127-
ServerName = response.ServerName,
138+
ServerName = newServer.Name,
128139
Location = location,
129140
AdministratorLogin = adminLogin,
141+
State = newServer.State,
142+
Version = newServer.Version
130143
};
131144

132145
return operationContext;

0 commit comments

Comments
 (0)