mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 17:23:48 -05:00
fixed perf tests and added more scenarios (#683)
* fixed perf tests and added more scenarios
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Utility
|
||||
{
|
||||
public class Constants
|
||||
{
|
||||
public const string NumberOfRunsEnvironmentVariable = "NumberOfRuns";
|
||||
public const string ExecutableFileEnvironmentVariable = "SQLTOOLSSERVICE_EXE";
|
||||
public const string ResultFolderEnvironmentVariable = "ResultFolder";
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
@@ -15,9 +16,86 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Utility
|
||||
{
|
||||
public class TestRunner
|
||||
{
|
||||
public static async Task<int> RunTests(string[] tests, string testNamespace)
|
||||
private int numberOfRuns = 20;
|
||||
protected int DefaultNumberOfRuns = 2;
|
||||
|
||||
public static TestRunner Instance { get; } = new TestRunner();
|
||||
public string[] Tests { get; set; }
|
||||
public int NumberOfRuns { get; set; }
|
||||
public string ExecutableFilePath { get; set; }
|
||||
|
||||
private TestRunner()
|
||||
{
|
||||
foreach (var test in tests)
|
||||
InitParameters();
|
||||
}
|
||||
|
||||
private void ParseArguments(string[] args)
|
||||
{
|
||||
int index = 0;
|
||||
while (index < args.Length - 1)
|
||||
{
|
||||
string arg = args[index++];
|
||||
string argValue = args[index++];
|
||||
switch (arg)
|
||||
{
|
||||
case "/t":
|
||||
case "/T":
|
||||
case "/tests":
|
||||
Tests = argValue.Split(" ");
|
||||
break;
|
||||
case "/n":
|
||||
case "/N":
|
||||
case "/numberOfRuns":
|
||||
int value;
|
||||
if (Int32.TryParse(argValue, out value))
|
||||
{
|
||||
NumberOfRuns = value;
|
||||
}
|
||||
break;
|
||||
case "/r":
|
||||
case "/R":
|
||||
case "/Result":
|
||||
ResultFolder = argValue;
|
||||
break;
|
||||
case "/s":
|
||||
case "/S":
|
||||
case "/Service":
|
||||
ExecutableFilePath = argValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Tests == null || Tests.Length == 0) && args.Length >= 1)
|
||||
{
|
||||
Tests = args;
|
||||
}
|
||||
}
|
||||
|
||||
public string ResultFolder = InitResultFolder();
|
||||
|
||||
private static string InitResultFolder()
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("ResultFolder");
|
||||
}
|
||||
|
||||
private void InitParameters()
|
||||
{
|
||||
string numberOfRunsEnv = Environment.GetEnvironmentVariable(Constants.NumberOfRunsEnvironmentVariable);
|
||||
|
||||
if (!Int32.TryParse(numberOfRunsEnv, out numberOfRuns))
|
||||
{
|
||||
numberOfRuns = DefaultNumberOfRuns;
|
||||
}
|
||||
|
||||
NumberOfRuns = numberOfRuns;
|
||||
|
||||
ExecutableFilePath = Environment.GetEnvironmentVariable(Constants.ExecutableFileEnvironmentVariable);
|
||||
}
|
||||
|
||||
public async Task<int> RunTests(string[] args, string testNamespace)
|
||||
{
|
||||
ParseArguments(args);
|
||||
foreach (var test in Tests)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user