Permalink
Browse files

This change fixes test failures in both local machine and in the lab

because of the switch to VS2015. Switching to VS2015 changed the testing
database engine from SQL Express to LocalDb. Since VS2015 installs LocalDb,
this is a change that make sense to keep.

For local tests, some client tests were failing due to a failure to
clean up local database entries in LocalDB. The change to artdbclean.js
uses SQL Native Client for LocalDB to fix a connection issue, allowing the
script to properly clean up after the tests.

For lab tests, the machine configuration is a bit different and LocalDb is not
available; therefore, use SQL Express when building the lab. Since the current
VS2015 symbol was only used for test DB selection, I renamed the symbol to
reflect its usage.

- [   ] Test cases added
- [ x ] Build and test with one-click build and test script passed
  • Loading branch information...
robward-ms authored and AlanWong-MS committed Apr 12, 2017
1 parent fafac04 commit 170827a01f9141649a848aefb13531163dedd65e
@@ -20,7 +20,7 @@
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Build.props))\Build.props" />
<PropertyGroup>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' ">$(DefineConstants);VS2015</DefineConstants>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' and '$(BuildingInLab)' != 'true'">$(DefineConstants);USELOCALDB</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -96,7 +96,7 @@ internal static string ConnectionString
private static string GetConnectionString()
{
var connStr = ConfigurationManager.ConnectionStrings["AstoriaDefaultServiceDBEntities"].ConnectionString;
#if VS2015
#if USELOCALDB
connStr = connStr.Replace(@".\SQLExpress", @"(LocalDB)\MSSQLLocalDB");
#endif
return connStr;
@@ -23,7 +23,7 @@
</PropertyGroup>
<Import Project="..\Build.props" />
<PropertyGroup>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' ">$(DefineConstants);VS2015</DefineConstants>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' and '$(BuildingInLab)' != 'true'">$(DefineConstants);USELOCALDB</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="CustomMarshalers" />
@@ -139,7 +139,7 @@ public string Machine
break;
case "Local":
#if !VS2015
#if !USELOCALDB
if (ServiceUtil.IsLocalSqlServerExpressRunning)
#endif
{
@@ -26,7 +26,7 @@ public static string DefaultDataSource
[DebuggerStepThrough]
get
{
#if VS2015
#if USELOCALDB
return @"(LocalDB)\MSSQLLocalDB";
#else
return @".\SQLEXPRESS";
@@ -19,7 +19,7 @@
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Build.props))\Build.props" />
<PropertyGroup>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' ">$(DefineConstants);VS2015</DefineConstants>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' and '$(BuildingInLab)' != 'true'">$(DefineConstants);USELOCALDB</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -18,7 +18,7 @@ namespace AstoriaUnitTests.EFFK
public static class PopulateData
{
#if VS2015
#if USELOCALDB
private static string ConnectionString = @"server=(LocalDB)\MSSQLLocalDB;integrated security=true;";
#else
private static string ConnectionString = @"server=.\sqlexpress;integrated security=true;";
@@ -16,7 +16,7 @@
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Build.props))\Build.props" />
<PropertyGroup>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' ">$(DefineConstants);VS2015</DefineConstants>
<DefineConstants Condition=" '$(VisualStudioVersion)' == '14.0' and '$(BuildingInLab)' != 'true'">$(DefineConstants);USELOCALDB</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
@@ -26,7 +26,7 @@ public static string DefaultDataSource
[DebuggerStepThrough]
get
{
#if VS2015
#if USELOCALDB
return @"(LocalDB)\MSSQLLocalDB";
#else
return @".\SQLEXPRESS";
@@ -17,9 +17,9 @@ function OpenResultSet(connection, queryText)
// Opens an ADO SQL Server driver connection to the specified.
function OpenSqlServerConnection(serverName, initialCatalog, useTrustedConnection,
username, password)
username, password, provider)
{
var connectionString = "Provider='sqloledb';Data Source=" + serverName + ";";
var connectionString = "Provider='" + provider + "';Data Source=" + serverName + ";";
if (initialCatalog != null && initialCatalog != "")
{
connectionString += "Initial Catalog='" + initialCatalog + "';";
@@ -38,12 +38,12 @@ function OpenSqlServerConnection(serverName, initialCatalog, useTrustedConnectio
return result;
}
function DropDatabasesForServer(serverName, path)
function DropDatabasesForServer(serverName, path, provider)
{
var connection;
try
{
connection = OpenSqlServerConnection(serverName, null, true, null, null);
connection = OpenSqlServerConnection(serverName, null, true, null, null, provider);
} catch (e) {
//WScript.Echo("Continuing after failing to connect to server '" + serverName + "' with error: " + e.message);
return;
@@ -85,9 +85,17 @@ if (enlistmentRoot == null || enlistmentRoot == "")
WScript.Quit(1);
}
var serverNames = ["(local)", ".\\SQLEXPRESS", "(localdb)\\MSSQLLocalDB"];
for (var i in serverNames) {
DropDatabasesForServer(serverNames[i], enlistmentRoot);
var oledbServerNames = ["(local)", ".\\SQLEXPRESS"];
for (var i in oledbServerNames)
{
DropDatabasesForServer(oledbServerNames[i], enlistmentRoot, "sqloledb");
}
var sqlncliServerNames = ["(localdb)\\MSSQLLocalDB"];
for (var i in sqlncliServerNames)
{
// Use Sql native client for localDB.
DropDatabasesForServer(sqlncliServerNames[i], enlistmentRoot, "sqlncli11");
}
WScript.Quit(0);

0 comments on commit 170827a

Please sign in to comment.