A programming framework for agentic AI
adds integration test for the InMemoryRuntime (#4659)
Ryan Sweet7d01bc61368d
diff --git a/dotnet/AutoGen.sln b/dotnet/AutoGen.slnindex 21c1a62a3..b01a59f71 100644--- a/dotnet/AutoGen.sln+++ b/dotnet/AutoGen.sln@@ -134,6 +134,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Agents.TeEndProjectProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AutoGen.Integration.Tests", "test\Microsoft.AutoGen.Integration.Tests\Microsoft.AutoGen.Integration.Tests.csproj", "{D04C6153-8EAF-4E54-9852-52CEC1BE8D31}"EndProject+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloAgent.AppHost", "test\Microsoft.AutoGen.Integration.Tests.AppHosts\HelloAgent.AppHost\HelloAgent.AppHost.csproj", "{99D7766B-076F-4E6F-A8D2-3DF1DAFA2599}"+EndProjectGlobalGlobalSection(SolutionConfigurationPlatforms) = preSolutionDebug|Any CPU = Debug|Any CPU@@ -348,6 +350,10 @@ Global{D04C6153-8EAF-4E54-9852-52CEC1BE8D31}.Debug|Any CPU.Build.0 = Debug|Any CPU{D04C6153-8EAF-4E54-9852-52CEC1BE8D31}.Release|Any CPU.ActiveCfg = Release|Any CPU{D04C6153-8EAF-4E54-9852-52CEC1BE8D31}.Release|Any CPU.Build.0 = Release|Any CPU+ {99D7766B-076F-4E6F-A8D2-3DF1DAFA2599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU+ {99D7766B-076F-4E6F-A8D2-3DF1DAFA2599}.Debug|Any CPU.Build.0 = Debug|Any CPU+ {99D7766B-076F-4E6F-A8D2-3DF1DAFA2599}.Release|Any CPU.ActiveCfg = Release|Any CPU+ {99D7766B-076F-4E6F-A8D2-3DF1DAFA2599}.Release|Any CPU.Build.0 = Release|Any CPUEndGlobalSectionGlobalSection(SolutionProperties) = preSolutionHideSolutionNode = FALSE@@ -409,6 +415,7 @@ Global{65059914-5527-4A00-9308-9FAF23D5E85A} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}{394FDAF8-74F9-4977-94A5-3371737EB774} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}{D04C6153-8EAF-4E54-9852-52CEC1BE8D31} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}+ {99D7766B-076F-4E6F-A8D2-3DF1DAFA2599} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}EndGlobalSectionGlobalSection(ExtensibilityGlobals) = postSolutionSolutionGuid = {93384647-528D-46C8-922C-8DB36A382F0B}diff --git a/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/HelloAgent.AppHost.csproj b/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/HelloAgent.AppHost.csprojnew file mode 100644index 000000000..441d48d18--- /dev/null+++ b/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/HelloAgent.AppHost.csproj@@ -0,0 +1,21 @@+<Project Sdk="Microsoft.NET.Sdk">++ <Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />++ <PropertyGroup>+ <OutputType>Exe</OutputType>+ <TargetFramework>net8.0</TargetFramework>+ <ImplicitUsings>enable</ImplicitUsings>+ <Nullable>enable</Nullable>+ <IsAspireHost>true</IsAspireHost>+ </PropertyGroup>++ <ItemGroup>+ <PackageReference Include="Aspire.Hosting.AppHost" />+ <PackageReference Include="Aspire.Hosting" />+ </ItemGroup>++ <ItemGroup>+ <ProjectReference Include="..\..\..\samples\Hello\HelloAgent\HelloAgent.csproj" />+ </ItemGroup>+</Project>diff --git a/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/Program.cs b/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/Program.csnew file mode 100644index 000000000..3234a7aba--- /dev/null+++ b/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/Program.cs@@ -0,0 +1,10 @@+// Copyright (c) Microsoft Corporation. All rights reserved.+// Program.cs++using Microsoft.Extensions.Hosting;++var appHost = DistributedApplication.CreateBuilder();+appHost.AddProject<Projects.HelloAgent>("HelloAgentsDotNetInMemoryRuntime");+var app = appHost.Build();+await app.StartAsync();+await app.WaitForShutdownAsync();diff --git a/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/Properties/launchSettings.json b/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/Properties/launchSettings.jsonnew file mode 100644index 000000000..ea78f2933--- /dev/null+++ b/dotnet/test/Microsoft.AutoGen.Integration.Tests.AppHosts/HelloAgent.AppHost/Properties/launchSettings.json@@ -0,0 +1,43 @@+{+ "profiles": {+ "https": {+ "commandName": "Project",+ "launchBrowser": true,+ "dotnetRunMessages": true,+ "applicationUrl": "https://localhost:15887;http://localhost:15888",+ "environmentVariables": {+ "ASPNETCORE_ENVIRONMENT": "Development",+ "DOTNET_ENVIRONMENT": "Development",+ //"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16037",+ "DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL": "https://localhost:16038",+ "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037",+ "DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"+ }+ },+ "http": {+ "commandName": "Project",+ "launchBrowser": true,+ "dotnetRunMessages": true,+ "applicationUrl": "http://localhost:15888",+ "environmentVariables": {+ "ASPNETCORE_ENVIRONMENT": "Development",+ "DOTNET_ENVIRONMENT": "Development",+ //"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16031",+ "DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL": "http://localhost:16032",+ "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17031",+ "DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true",+ "ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"+ }+ },+ "generate-manifest": {+ "commandName": "Project",+ "dotnetRunMessages": true,+ "commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",+ "environmentVariables": {+ "ASPNETCORE_ENVIRONMENT": "Development",+ "DOTNET_ENVIRONMENT": "Development"+ }+ }+ },+ "$schema": "https://json.schemastore.org/launchsettings.json"+}diff --git a/dotnet/test/Microsoft.AutoGen.Integration.Tests/InMemoryRuntimeIntegrationTests.cs b/dotnet/test/Microsoft.AutoGen.Integration.Tests/InMemoryRuntimeIntegrationTests.csnew file mode 100644index 000000000..0795cf8be--- /dev/null+++ b/dotnet/test/Microsoft.AutoGen.Integration.Tests/InMemoryRuntimeIntegrationTests.cs@@ -0,0 +1,43 @@+// Copyright (c) Microsoft Corporation. All rights reserved.+// InMemoryRuntimeIntegrationTests.cs+using Xunit.Abstractions;++namespace Microsoft.AutoGen.Integration.Tests;++public class InMemoryRuntimeIntegrationTests(ITestOutputHelper testOutput)+{++ [Theory, Trait("type", "integration")]+ [MemberData(nameof(AppHostAssemblies))]+ public async Task HelloAgentsE2EInMemory(string appHostAssemblyPath)+ {+ var appHost = await DistributedApplicationTestFactory.CreateAsync(appHostAssemblyPath, testOutput);+ await using var app = await appHost.BuildAsync().WaitAsync(TimeSpan.FromSeconds(15));++ await app.StartAsync().WaitAsync(TimeSpan.FromSeconds(120));+ await app.WaitForResourcesAsync().WaitAsync(TimeSpan.FromSeconds(120));++ await app.StartAsync().WaitAsync(TimeSpan.FromSeconds(120));+ await app.WaitForResourcesAsync().WaitAsync(TimeSpan.FromSeconds(120));++ //sleep 5 seconds to make sure the app is running+ await Task.Delay(15000);+ app.EnsureNoErrorsLogged();+ app.EnsureLogContains("Hello World");+ app.EnsureLogContains("HelloAgents said Goodbye");++ await app.StopAsync().WaitAsync(TimeSpan.FromSeconds(15));+ }+ public static TheoryData<string> AppHostAssemblies()+ {+ var appHostAssemblies = GetSamplesAppHostAssemblyPaths();+ var theoryData = new TheoryData<string, bool>();+ return new(appHostAssemblies.Select(p => Path.GetRelativePath(AppContext.BaseDirectory, p)));+ }+ private static IEnumerable<string> GetSamplesAppHostAssemblyPaths()+ {+ // All the AppHost projects are referenced by this project so we can find them by looking for all their assemblies in the base directory+ return Directory.GetFiles(AppContext.BaseDirectory, "HelloAgent.AppHost.dll")+ .Where(fileName => !fileName.EndsWith("Aspire.Hosting.AppHost.dll", StringComparison.OrdinalIgnoreCase));+ }+}diff --git a/dotnet/test/Microsoft.AutoGen.Integration.Tests/Microsoft.AutoGen.Integration.Tests.csproj b/dotnet/test/Microsoft.AutoGen.Integration.Tests/Microsoft.AutoGen.Integration.Tests.csprojindex 0f3adc1c3..2ef1763c3 100644--- a/dotnet/test/Microsoft.AutoGen.Integration.Tests/Microsoft.AutoGen.Integration.Tests.csproj+++ b/dotnet/test/Microsoft.AutoGen.Integration.Tests/Microsoft.AutoGen.Integration.Tests.csproj@@ -29,6 +29,8 @@<ItemGroup><ProjectReference Include="..\..\samples\Hello\Hello.AppHost\Hello.AppHost.csproj" />+ <ProjectReference Include="..\..\samples\Hello\HelloAgent\HelloAgent.csproj" />+ <ProjectReference Include="..\Microsoft.AutoGen.Integration.Tests.AppHosts\HelloAgent.AppHost\HelloAgent.AppHost.csproj" /></ItemGroup><!-- Properties, Items, and targets to ensure Python apps are initialized -->