Profiling tool for running test scripts. (#3243)
* Profiling tool for running test scripts. * Merge with master and fix bug in ask.
This commit is contained in:
Родитель
6e4e3b77c6
Коммит
7265bc4e7e
|
@ -166,6 +166,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.Adapt
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.TestProtocol", "tests\Microsoft.Bot.Builder.TestProtocol\Microsoft.Bot.Builder.TestProtocol.csproj", "{24CCB459-B4F6-484F-8BA4-946A4AB816FA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling", "tests\Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling\Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling.csproj", "{D9242899-AB3F-46BB-BAB4-386CB8EC535C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -670,6 +672,14 @@ Global
|
|||
{24CCB459-B4F6-484F-8BA4-946A4AB816FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{24CCB459-B4F6-484F-8BA4-946A4AB816FA}.Release-Windows|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24CCB459-B4F6-484F-8BA4-946A4AB816FA}.Release-Windows|Any CPU.Build.0 = Release|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug-Windows|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug-Windows|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release-Windows|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release-Windows|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -743,6 +753,7 @@ Global
|
|||
{C8E31CD2-89D4-4659-9557-43EC9C99D984} = {6230B915-B238-4E57-AAC4-06B4498F540F}
|
||||
{1D05EFE4-7F25-4D5A-BCEE-1109B9EF25A8} = {E8CD434A-306F-41D9-B67D-BFFF3287354D}
|
||||
{24CCB459-B4F6-484F-8BA4-946A4AB816FA} = {AD743B78-D61F-4FBF-B620-FA83CE599A50}
|
||||
{D9242899-AB3F-46BB-BAB4-386CB8EC535C} = {AD743B78-D61F-4FBF-B620-FA83CE599A50}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7173C9F3-A7F9-496E-9078-9156E35D6E16}
|
||||
|
|
|
@ -57,8 +57,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
|
||||
dc.GetState().TryGetValue(TurnPath.DIALOGEVENT, out DialogEvent trigger);
|
||||
|
||||
var expected = ExpectedProperties.GetValue(dc.GetState());
|
||||
if (ExpectedProperties != null
|
||||
var expected = ExpectedProperties?.GetValue(dc.GetState());
|
||||
if (expected != null
|
||||
&& dc.GetState().TryGetValue(DialogPath.ExpectedProperties, out List<string> lastExpectedProperties)
|
||||
&& !expected.Any(prop => !lastExpectedProperties.Contains(prop))
|
||||
&& !lastExpectedProperties.Any(prop => !expected.Contains(prop))
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>portable</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\libraries\Microsoft.Bot.Builder.Dialogs.Adaptive\Microsoft.Bot.Builder.Dialogs.Adaptive.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,97 @@
|
|||
// Licensed under the MIT License.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder.AI.QnA;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Testing;
|
||||
using Microsoft.Bot.Builder.Dialogs.Declarative;
|
||||
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
|
||||
using Microsoft.Bot.Builder.Dialogs.Declarative.Types;
|
||||
using Microsoft.Bot.Builder.MockLuis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Help()
|
||||
{
|
||||
Console.Error.WriteLine("[-secret <id=profile>] [-luis <luisDir>] testscripts...");
|
||||
Console.Error.WriteLine("-secret This is your secret id for luis keys.");
|
||||
Console.Error.WriteLine("-luis This is the directory where luis settings arg.");
|
||||
System.Environment.Exit(-1);
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var secret = "profile";
|
||||
string luis = null;
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Help();
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.Length; ++i)
|
||||
{
|
||||
var arg = args[i];
|
||||
if (arg.StartsWith("-"))
|
||||
{
|
||||
if (arg == "-secret")
|
||||
{
|
||||
if (++i < args.Length)
|
||||
{
|
||||
secret = args[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.ArgumentException("Missing --secret value");
|
||||
}
|
||||
}
|
||||
else if (arg == "-luis")
|
||||
{
|
||||
if (++i < args.Length)
|
||||
{
|
||||
luis = args[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.ArgumentException("Missing --luis value");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine($"Unknown arg {arg}");
|
||||
Help();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var cd = Directory.GetCurrentDirectory();
|
||||
var dir = Path.GetDirectoryName(arg);
|
||||
var name = Path.GetFileName(arg);
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection()
|
||||
.UseLuisSettings(luis ?? dir, secret)
|
||||
.Build();
|
||||
var explorer = new ResourceExplorer().AddFolder(dir);
|
||||
DeclarativeTypeLoader.Reset();
|
||||
TypeFactory.Configuration = config;
|
||||
DeclarativeTypeLoader.AddComponent(new DialogComponentRegistration());
|
||||
DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration());
|
||||
DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration());
|
||||
DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration());
|
||||
DeclarativeTypeLoader.AddComponent(new MockLuisComponentRegistration());
|
||||
var script = explorer.LoadType<TestScript>(name);
|
||||
var timer = new System.Diagnostics.Stopwatch();
|
||||
Console.Write($"Executing {arg}");
|
||||
timer.Start();
|
||||
script.ExecuteAsync(testName: name, configuration: config, resourceExplorer: explorer).Wait();
|
||||
timer.Stop();
|
||||
Console.WriteLine($" took {timer.ElapsedMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче