Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test | Adjust tests to read IsAzureSynapse value from database #2367

Merged
merged 6 commits into from Feb 26, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
JRahnama marked this conversation as resolved.
Show resolved Hide resolved
Expand Up @@ -51,7 +51,7 @@ public static class DataTestUtility
public static readonly bool TracingEnabled = false;
public static readonly bool SupportsIntegratedSecurity = false;
public static readonly bool UseManagedSNIOnWindows = false;
public static readonly bool IsAzureSynapse = false;

public static Uri AKVBaseUri = null;
public static readonly string PowerShellPath = null;
public static string FileStreamDirectory = null;
Expand Down Expand Up @@ -95,13 +95,35 @@ public static class DataTestUtility
private static string s_sQLServerVersion = string.Empty;
private static bool s_isTDS8Supported;

//SQL Server EnginEditionId
JRahnama marked this conversation as resolved.
Show resolved Hide resolved
private static string s_sqlServerEndinEditionId;
JRahnama marked this conversation as resolved.
Show resolved Hide resolved

private static string SQLServerEnginEditionId()
JRahnama marked this conversation as resolved.
Show resolved Hide resolved
{

if (!string.IsNullOrEmpty(TCPConnectionString))
{
s_sqlServerEndinEditionId ??= GetSqlServerProperty(TCPConnectionString, "EngineEdition");
}
return s_sqlServerEndinEditionId;
}
// Azure Synapse EnginEditionId == 6
// More could be read at https://learn.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver16#propertyname
public static bool IsAzureSynapse
{
get
{
return string.Equals("6", SQLServerEnginEditionId().Trim());
}
}

public static string SQLServerVersion
{
get
{
if (!string.IsNullOrEmpty(TCPConnectionString))
{
s_sQLServerVersion ??= GetSqlServerVersion(TCPConnectionString);
s_sQLServerVersion ??= GetSqlServerProperty(TCPConnectionString, "ProductMajorVersion");
}
return s_sQLServerVersion;
}
Expand Down Expand Up @@ -143,7 +165,6 @@ static DataTestUtility()
DNSCachingConnString = c.DNSCachingConnString;
DNSCachingServerCR = c.DNSCachingServerCR;
DNSCachingServerTR = c.DNSCachingServerTR;
IsAzureSynapse = c.IsAzureSynapse;
IsDNSCachingSupportedCR = c.IsDNSCachingSupportedCR;
IsDNSCachingSupportedTR = c.IsDNSCachingSupportedTR;
EnclaveAzureDatabaseConnString = c.EnclaveAzureDatabaseConnString;
Expand Down Expand Up @@ -272,19 +293,27 @@ private static string GenerateAccessToken(string authorityURL, string aADAuthUse

public static bool IsKerberosTest => !string.IsNullOrEmpty(KerberosDomainUser) && !string.IsNullOrEmpty(KerberosDomainPassword);

public static string GetSqlServerVersion(string connectionString)
public static string GetSqlServerProperty(string connectionString, string propertyName)
{
string version = string.Empty;
string propertyValue = string.Empty;
using SqlConnection conn = new(connectionString);
conn.Open();
SqlCommand command = conn.CreateCommand();
command.CommandText = "SELECT SERVERProperty('ProductMajorVersion')";
command.CommandText = $"SELECT SERVERProperty('{propertyName}')";
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
version = reader.GetString(0);
switch (propertyName)
{
case "EngineEdition":
propertyValue = reader.GetInt32(0).ToString();
break;
case "ProductMajorVersion":
propertyValue = reader.GetString(0);
break;
}
}
return version;
return propertyValue;
}

public static bool GetSQLServerStatusOnTDS8(string connectionString)
Expand Down