Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
Python - Merge - Tests / paths-filter (push) Has been cancelled
Python - Merge - Tests / Python Tests - Core (integration, ubuntu-latest, 3.10) (push) Has been cancelled
Python - Merge - Tests / Python Tests - Azure AI (integration, ubuntu-latest, 3.10) (push) Has been cancelled
Python - Merge - Tests / python-integration-tests-check (push) Has been cancelled
Python - Lab Tests / paths-filter (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.10) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.10) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.11) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.12) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.13) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.14) (push) Has been cancelled
Check .md links / markdown-link-check (push) Has been cancelled
91 lines
2.7 KiB
C#
91 lines
2.7 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Threading.Tasks;
|
|
using Azure.Identity;
|
|
using Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents;
|
|
using Microsoft.Agents.AI.Workflows.Declarative.PowerFx;
|
|
using Microsoft.Bot.ObjectModel;
|
|
using Microsoft.Extensions.AI;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Framework;
|
|
|
|
/// <summary>
|
|
/// Base class for workflow tests.
|
|
/// </summary>
|
|
public abstract class IntegrationTest : IDisposable
|
|
{
|
|
protected IConfigurationRoot Configuration => field ??= InitializeConfig();
|
|
|
|
public Uri TestEndpoint { get; }
|
|
|
|
public TestOutputAdapter Output { get; }
|
|
|
|
protected IntegrationTest(ITestOutputHelper output)
|
|
{
|
|
this.Output = new TestOutputAdapter(output);
|
|
this.TestEndpoint =
|
|
new Uri(
|
|
this.Configuration?[AgentProvider.Settings.FoundryEndpoint] ??
|
|
throw new InvalidOperationException($"Undefined configuration setting: {AgentProvider.Settings.FoundryEndpoint}"));
|
|
Console.SetOut(this.Output);
|
|
SetProduct();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(isDisposing: true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
protected virtual void Dispose(bool isDisposing)
|
|
{
|
|
if (isDisposing)
|
|
{
|
|
this.Output.Dispose();
|
|
}
|
|
}
|
|
|
|
protected static void SetProduct()
|
|
{
|
|
if (!ProductContext.IsLocalScopeSupported())
|
|
{
|
|
ProductContext.SetContext(Product.Foundry);
|
|
}
|
|
}
|
|
|
|
internal static string FormatVariablePath(string variableName, string? scope = null) => $"{scope ?? WorkflowFormulaState.DefaultScopeName}.{variableName}";
|
|
|
|
protected async ValueTask<DeclarativeWorkflowOptions> CreateOptionsAsync(bool externalConversation = false, params IEnumerable<AIFunction> functionTools)
|
|
{
|
|
AzureAgentProvider agentProvider =
|
|
new(this.TestEndpoint, new AzureCliCredential())
|
|
{
|
|
Functions = functionTools,
|
|
};
|
|
|
|
string? conversationId = null;
|
|
if (externalConversation)
|
|
{
|
|
conversationId = await agentProvider.CreateConversationAsync().ConfigureAwait(false);
|
|
}
|
|
|
|
return
|
|
new DeclarativeWorkflowOptions(agentProvider)
|
|
{
|
|
ConversationId = conversationId,
|
|
LoggerFactory = this.Output
|
|
};
|
|
}
|
|
|
|
private static IConfigurationRoot InitializeConfig() =>
|
|
new ConfigurationBuilder()
|
|
.AddEnvironmentVariables()
|
|
.AddUserSecrets(Assembly.GetExecutingAssembly())
|
|
.Build();
|
|
}
|