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
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion BUILDGUIDE.md
Expand Up @@ -184,7 +184,6 @@ Manual Tests require the below setup to run:
|FileStreamDirectory | (Optional) If File Stream is enabled on SQL Server, pass local directory path to be used for setting up File Stream enabled database. | `D:\\escaped\\absolute\\path\\to\\directory\\` |
|UseManagedSNIOnWindows | (Optional) Enables testing with Managed SNI on Windows| `true` OR `false`|
|DNSCachingConnString | Connection string for a server that supports DNS Caching|
|IsAzureSynpase | (Optional) When set to 'true', test suite runs compatible tests for Azure Synapse/Parallel Data Warehouse. | `true` OR `false`|
|EnclaveAzureDatabaseConnString | (Optional) Connection string for Azure database with enclaves |
|ManagedIdentitySupported | (Optional) When set to `false` **Managed Identity** related tests won't run. The default value is `true`. |
|IsManagedInstance | (Optional) When set to `true` **TVP** related tests will use on non-Azure bs files to compare test results. this is needed when testing against Managed Instances or TVP Tests will fail on Test set 3. The default value is `false`. |
Expand Down
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,31 @@ public static class DataTestUtility
private static string s_sQLServerVersion = string.Empty;
private static bool s_isTDS8Supported;

//SQL Server EngineEdition
private static string s_sqlServerEngineEdition;

// Azure Synapse EngineEditionId == 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
{
if (!string.IsNullOrEmpty(TCPConnectionString))
{
s_sqlServerEngineEdition ??= GetSqlServerProperty(TCPConnectionString, "EngineEdition");
}
_ = int.TryParse(s_sqlServerEngineEdition, out int engineEditon);
return engineEditon == 6;
}
}

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 +161,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 +289,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