mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Update memory settings and implement ServerPrototype (#2126)
This commit is contained in:
@@ -9,11 +9,13 @@ using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.ObjectManagement;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
|
||||
using NUnit.Framework;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
|
||||
using Server = Microsoft.SqlServer.Management.Smo.Server;
|
||||
using Microsoft.SqlTools.ServiceLayer.ServerConfigurations;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectManagement
|
||||
{
|
||||
/// <summary>
|
||||
@@ -47,5 +49,59 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectManagement
|
||||
Assert.That(((ServerInfo)result.ViewInfo.ObjectInfo).IsPolyBaseInstalled, Is.Not.Null, $"Server isPolyBaseInstalled property should not be null");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test SetMemoryProperties for Sql Server
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task SetMemoryProperties()
|
||||
{
|
||||
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", serverType: TestServerType.OnPrem);
|
||||
using (SqlConnection sqlConn = ConnectionService.OpenSqlConnection(connectionResult.ConnectionInfo))
|
||||
{
|
||||
var server = new Server(new ServerConnection(sqlConn));
|
||||
var serverHandler = new ServerHandler(ConnectionService.Instance);
|
||||
var serverConfig = new ServerConfigService();
|
||||
|
||||
var requestParams = ObjectManagementTestUtils.GetInitializeViewRequestParams(connectionResult.ConnectionInfo.OwnerUri, "master", true, SqlObjectType.Server, "", "");
|
||||
var result = (ServerInfo)(await serverHandler.InitializeObjectView(requestParams)).ViewInfo.ObjectInfo;
|
||||
ServerInfo serverInfo = new ServerInfo()
|
||||
{
|
||||
Name = result.Name,
|
||||
HardwareGeneration = result.HardwareGeneration,
|
||||
Language = result.Language,
|
||||
MemoryInMB = result.MemoryInMB,
|
||||
OperatingSystem = result.OperatingSystem,
|
||||
Platform = result.Platform,
|
||||
Processors = result.Processors,
|
||||
IsClustered = result.IsClustered,
|
||||
IsHadrEnabled = result.IsHadrEnabled,
|
||||
IsPolyBaseInstalled = result.IsPolyBaseInstalled,
|
||||
IsXTPSupported = result.IsXTPSupported,
|
||||
Product = result.Product,
|
||||
ReservedStorageSizeMB = result.ReservedStorageSizeMB,
|
||||
RootDirectory = result.RootDirectory,
|
||||
ServerCollation = result.ServerCollation,
|
||||
ServiceTier = result.ServiceTier,
|
||||
StorageSpaceUsageInMB = result.StorageSpaceUsageInMB,
|
||||
Version = result.Version,
|
||||
MinServerMemory = result.MinServerMemory,
|
||||
MaxServerMemory = result.MaxServerMemory
|
||||
};
|
||||
|
||||
// Change memory settings
|
||||
serverInfo.MinServerMemory = 10;
|
||||
serverInfo.MaxServerMemory = 500;
|
||||
|
||||
Assert.AreNotEqual(result.MinServerMemory, serverInfo.MinServerMemory, "Server property should not be equal after update");
|
||||
Assert.AreNotEqual(result.MaxServerMemory, serverInfo.MaxServerMemory, "Server property should not be equal after update");
|
||||
|
||||
await ObjectManagementTestUtils.SaveObject(requestParams, serverInfo);
|
||||
result = (ServerInfo)(await serverHandler.InitializeObjectView(requestParams)).ViewInfo.ObjectInfo;
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(result.MinServerMemory, serverInfo.MinServerMemory, "Server property should not be different after update");
|
||||
Assert.AreEqual(result.MaxServerMemory, serverInfo.MaxServerMemory, "Server property should not be different after update");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user