Perf Test fixing bugs and Update command (#155)

* Fixed some bugs caused by rafactoring

* Verifying a test db is created before running the tests
This commit is contained in:
Leila Lali
2016-11-30 12:56:48 -08:00
committed by GitHub
parent d1b791805a
commit 453ff9de15
19 changed files with 708 additions and 804 deletions

View File

@@ -11,27 +11,55 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts
{
public class Scripts
{
public const string SimpleQuery = "SELECT * FROM sys.all_columns";
public const string MasterBasicQuery = "SELECT * FROM sys.all_columns"; //basic queries should return at least 10000 rows
public const string DelayQuery = "WAITFOR DELAY '00:01:00'";
private static readonly Lazy<string> ComplexQueryInstance = new Lazy<string>(() =>
public const string TestDbSimpleSelectQuery = "SELECT * FROM [Person].[Address]";
public const string SelectQuery = "SELECT * FROM ";
public static string CreateDatabaseObjectsQuery { get { return CreateDatabaseObjectsQueryInstance.Value; } }
public static string CreateDatabaseQuery { get { return CreateDatabaseQueryInstance.Value; } }
public static string TestDbComplexSelectQueries { get { return TestDbSelectQueriesInstance.Value; } }
private static readonly Lazy<string> CreateDatabaseObjectsQueryInstance = new Lazy<string>(() =>
{
return GetScriptFileContent("Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts.CreateTestDatabaseObjects.sql");
});
private static readonly Lazy<string> CreateDatabaseQueryInstance = new Lazy<string>(() =>
{
return GetScriptFileContent("Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts.CreateTestDatabase.sql");
});
private static readonly Lazy<string> TestDbSelectQueriesInstance = new Lazy<string>(() =>
{
return GetScriptFileContent("Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts.TestDbTableQueries.sql");
});
private static string GetScriptFileContent(string fileName)
{
string fileContent = string.Empty;
try
{
string assemblyLocation = typeof(Scripts).GetTypeInfo().Assembly.Location;
string folderName = Path.GetDirectoryName(assemblyLocation);
string filePath = Path.Combine(folderName, "Scripts/AdventureWorks.sql");
return File.ReadAllText(filePath);
using (Stream stream = typeof(Scripts).GetTypeInfo().Assembly.GetManifestResourceStream(fileName))
{
using (StreamReader reader = new StreamReader(stream))
{
fileContent = reader.ReadToEnd();
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Failed to load the sql script. error: {ex.Message}");
return string.Empty;
}
});
return fileContent;
}
public static string ComplexQuery { get { return ComplexQueryInstance.Value; } }
}
}