Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.ResourceManager.Models;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
Expand Down
2 changes: 1 addition & 1 deletion src/SDKs/SqlManagement/Sql.Tests/BlobAuditingTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Azure.Test.HttpRecorder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System.Collections.Generic;
Expand Down
9 changes: 5 additions & 4 deletions src/SDKs/SqlManagement/Sql.Tests/DatabaseCrudScenarioTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System;
Expand Down Expand Up @@ -298,13 +298,14 @@ public void TestDatabaseTransparentDataEncryptionConfiguration()
Assert.NotNull(db1);

// Get TDE config
// Recently changed to be enabled by default
var config = sqlClient.Databases.GetTransparentDataEncryptionConfiguration(resourceGroup.Name, server.Name, dbName);
Assert.Equal(TransparentDataEncryptionStatus.Disabled, config.Status);
Assert.Equal(TransparentDataEncryptionStatus.Enabled, config.Status);

// Update TDE config
config.Status = TransparentDataEncryptionStatus.Enabled;
config.Status = TransparentDataEncryptionStatus.Disabled;
config = sqlClient.Databases.CreateOrUpdateTransparentDataEncryptionConfiguration(resourceGroup.Name, server.Name, dbName, config);
Assert.Equal(TransparentDataEncryptionStatus.Enabled, config.Status);
Assert.Equal(TransparentDataEncryptionStatus.Disabled, config.Status);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.ResourceManager.Models;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System;
Expand All @@ -23,8 +23,8 @@ public void TestCrudFailoverGroup()
{
// Create primary and partner servers
//
Server sourceServer = SqlManagementTestUtilities.CreateServer(sqlClient, resourceGroup, testPrefix, SqlManagementTestUtilities.DefaultStagePrimaryLocation);
Server targetServer = SqlManagementTestUtilities.CreateServer(sqlClient, resourceGroup, testPrefix, SqlManagementTestUtilities.DefaultStageSecondaryLocation);
Server sourceServer = SqlManagementTestUtilities.CreateServer(sqlClient, resourceGroup, testPrefix, SqlManagementTestUtilities.DefaultLocation);
Server targetServer = SqlManagementTestUtilities.CreateServer(sqlClient, resourceGroup, testPrefix, SqlManagementTestUtilities.DefaultSecondaryLocation);

// Create a failover group
//
Expand Down Expand Up @@ -93,6 +93,8 @@ public void TestCrudFailoverGroup()
Assert.Equal(1, failoverGroupsOnSecondary.Count());

var primaryDatabase = sqlClient.Databases.Get(resourceGroup.Name, sourceServer.Name, databaseName);

// Potential race condition here. If this request fails with 404, put a breakpoint on the previous line, wait a beat, then continue.
var secondaryDatabase = sqlClient.Databases.Get(resourceGroup.Name, targetServer.Name, databaseName);
Assert.NotNull(primaryDatabase.FailoverGroupId);
Assert.NotNull(secondaryDatabase.FailoverGroupId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Azure.Test.HttpRecorder;
Expand Down
38 changes: 38 additions & 0 deletions src/SDKs/SqlManagement/Sql.Tests/OperationsScenarioTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System.Collections.Generic;
using System.Net;
using Xunit;

namespace Sql.Tests
{
public class OperationsScenarioTests
{
[Fact]
public void TestListOperations()
{
string suiteName = this.GetType().FullName;
using (MockContext context = MockContext.Start(suiteName, "TestListOperations"))
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };
var resourceClient = SqlManagementTestUtilities.GetResourceManagementClient(context, handler);
var sqlClient = SqlManagementTestUtilities.GetSqlManagementClient(context, handler);

OperationListResult result = sqlClient.Operations.List();

foreach(Operation operation in result.Value)
{
Assert.NotNull(operation.Display);
Assert.NotNull(operation.Display.Provider);
Assert.NotNull(operation.Display.Resource);
Assert.NotNull(operation.Display.Operation);
}
}
}
}
}
26 changes: 12 additions & 14 deletions src/SDKs/SqlManagement/Sql.Tests/ServerCrudScenarioTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.ResourceManager.Models;
using Microsoft.Azure.Management.Sql;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System;
Expand Down Expand Up @@ -33,36 +33,34 @@ public void TestCreateUpdateGetDropServer()
};

// Create server
var v12Server = sqlClient.Servers.CreateOrUpdate(resourceGroup.Name, serverNameV12, new Microsoft.Azure.Management.Sql.Models.Server()
var server1 = sqlClient.Servers.CreateOrUpdate(resourceGroup.Name, serverNameV12, new Microsoft.Azure.Management.Sql.Models.Server()
{
AdministratorLogin = login,
AdministratorLoginPassword = password,
Version = version12,
Tags = tags,
Location = SqlManagementTestUtilities.DefaultLocation,
});
SqlManagementTestUtilities.ValidateServer(v12Server, serverNameV12, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);
SqlManagementTestUtilities.ValidateServer(server1, serverNameV12, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);

// We ignore the request for v2.0 and create v12.0 anyway unless subscription is whitelisted.
string serverNameV2 = SqlManagementTestUtilities.GenerateName(testPrefix);
string version2 = "2.0";
var v2Server = sqlClient.Servers.CreateOrUpdate(resourceGroup.Name, serverNameV2, new Microsoft.Azure.Management.Sql.Models.Server()
// Create second server
string server2 = SqlManagementTestUtilities.GenerateName(testPrefix);
var v2Server = sqlClient.Servers.CreateOrUpdate(resourceGroup.Name, server2, new Microsoft.Azure.Management.Sql.Models.Server()
{
AdministratorLogin = login,
AdministratorLoginPassword = password,
Version = version2,
Tags = tags,
Location = SqlManagementTestUtilities.DefaultLocation,
});
SqlManagementTestUtilities.ValidateServer(v2Server, serverNameV2, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);
SqlManagementTestUtilities.ValidateServer(v2Server, server2, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);

// Get first server
var getV12Server = sqlClient.Servers.Get(resourceGroup.Name, serverNameV12);
SqlManagementTestUtilities.ValidateServer(getV12Server, serverNameV12, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);
var getServer1 = sqlClient.Servers.Get(resourceGroup.Name, serverNameV12);
SqlManagementTestUtilities.ValidateServer(getServer1, serverNameV12, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);

// Get second server
var getV2Server = sqlClient.Servers.Get(resourceGroup.Name, serverNameV2);
SqlManagementTestUtilities.ValidateServer(getV2Server, serverNameV2, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);
var getServer2 = sqlClient.Servers.Get(resourceGroup.Name, server2);
SqlManagementTestUtilities.ValidateServer(getServer2, server2, login, version12, tags, SqlManagementTestUtilities.DefaultLocation);

var listServers = sqlClient.Servers.ListByResourceGroup(resourceGroup.Name);
Assert.Equal(2, listServers.Count());
Expand Down
35 changes: 35 additions & 0 deletions src/SDKs/SqlManagement/Sql.Tests/ServiceObjectiveScenarioTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Azure.Management.Sql;
using Xunit;

namespace Sql.Tests
{
public class ServiceObjectiveScenarioTests
{
[Fact]
public void TestGetListServiceObjectives()
{
string testPrefix = "sqlcrudtest-";
string suiteName = this.GetType().FullName;

SqlManagementTestUtilities.RunTestInNewV12Server(suiteName, "TestGetListServiceObjectives", testPrefix, (resClient, sqlClient, resourceGroup, server) =>
{
var serviceObjectives = sqlClient.Servers.ListServiceObjectives(resourceGroup.Name, server.Name);

foreach(ServiceObjective objective in serviceObjectives)
{
Assert.NotNull(objective.ServiceObjectiveName);
Assert.NotNull(objective.IsDefault);
Assert.NotNull(objective.IsSystem);
Assert.NotNull(objective.Enabled);

// Assert Get finds the service objective from List
Assert.NotNull(sqlClient.Servers.GetServiceObjective(resourceGroup.Name, server.Name, objective.Name));
}
});
}
}
}
Loading