diff --git a/config/assembler.yml b/config/assembler.yml index 75f1aad3a..e7649a87c 100644 --- a/config/assembler.yml +++ b/config/assembler.yml @@ -30,6 +30,8 @@ environments: uri: http://localhost:4000 content_source: current path_prefix: docs + feature_flags: + SEARCH_OR_ASK_AI: true shared_configuration: stack: &stack diff --git a/src/tooling/docs-builder/Http/DocumentationWebHost.cs b/src/tooling/docs-builder/Http/DocumentationWebHost.cs index 3f8c5494f..cac4e260c 100644 --- a/src/tooling/docs-builder/Http/DocumentationWebHost.cs +++ b/src/tooling/docs-builder/Http/DocumentationWebHost.cs @@ -144,7 +144,6 @@ private void SetUpRoutes() _ = _webApplication.MapGet("/api/{**slug}", (string slug, ReloadableGeneratorState holder, Cancel ctx) => ServeApiFile(holder, slug, ctx)); - var apiV1 = _webApplication.MapGroup("/docs/_api/v1"); apiV1.MapElasticDocsApiEndpoints(); diff --git a/src/tooling/docs-builder/Http/StaticWebHost.cs b/src/tooling/docs-builder/Http/StaticWebHost.cs index dd63cb5df..e235bded2 100644 --- a/src/tooling/docs-builder/Http/StaticWebHost.cs +++ b/src/tooling/docs-builder/Http/StaticWebHost.cs @@ -2,9 +2,9 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using Elastic.Documentation.Api.Infrastructure; using Elastic.Documentation.Configuration; using Elastic.Documentation.ServiceDefaults; -using Elastic.Documentation.Tooling; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -28,6 +28,8 @@ public StaticWebHost(int port) _ = builder.AddDocumentationServiceDefaults(); + builder.Services.AddElasticDocsApiUsecases("dev"); + _ = builder.Logging .AddFilter("Microsoft.AspNetCore.Hosting.Diagnostics", LogLevel.Error) .AddFilter("Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware", LogLevel.Error) @@ -51,6 +53,10 @@ private void SetUpRoutes() _ = WebApplication.MapGet("/", (Cancel _) => Results.Redirect("docs")); _ = WebApplication.MapGet("{**slug}", ServeDocumentationFile); + + var apiV1 = WebApplication.MapGroup("/docs/_api/v1"); + apiV1.MapElasticDocsApiEndpoints(); + } private async Task ServeDocumentationFile(string slug, Cancel _) diff --git a/tests-integration/Elastic.Assembler.IntegrationTests/AssembleFixture.cs b/tests-integration/Elastic.Assembler.IntegrationTests/AssembleFixture.cs index 8577ba5e7..a900b1975 100644 --- a/tests-integration/Elastic.Assembler.IntegrationTests/AssembleFixture.cs +++ b/tests-integration/Elastic.Assembler.IntegrationTests/AssembleFixture.cs @@ -34,6 +34,9 @@ public async ValueTask InitializeAsync() _ = builder.Services.AddElasticDocumentationLogging(LogLevel.Information); _ = builder.Services.AddLogging(c => c.AddXUnit()); _ = builder.Services.AddLogging(c => c.AddInMemory()); + // TODO expose this as secrets for now not needed integration tests + _ = builder.AddParameter("LlmGatewayUrl", ""); + _ = builder.AddParameter("LlmGatewayServiceAccountPath", ""); DistributedApplication = await builder.BuildAsync(); InMemoryLogger = DistributedApplication.Services.GetService()!; await DistributedApplication.StartAsync(); diff --git a/tests-integration/Elastic.Documentation.Aspire/AppHost.cs b/tests-integration/Elastic.Documentation.Aspire/AppHost.cs index 4e2d2e260..a8e4e4d8f 100644 --- a/tests-integration/Elastic.Documentation.Aspire/AppHost.cs +++ b/tests-integration/Elastic.Documentation.Aspire/AppHost.cs @@ -19,19 +19,39 @@ var builder = DistributedApplication.CreateBuilder(args); +// Add a secret parameter named "secret" +var llmUrl = builder.AddParameter("LlmGatewayUrl", secret: true); +var llmServiceAccountPath = builder.AddParameter("LlmGatewayServiceAccountPath", secret: true); + var cloneAll = builder.AddProject("DocsAssemblerCloneAll").WithArgs(["repo", "clone-all", .. globalArguments]); var buildAll = builder.AddProject("DocsAssemblerBuildAll").WithArgs(["repo", "build-all", .. globalArguments]) .WaitForCompletion(cloneAll); -var elasticsearch = builder.AddElasticsearch("elasticsearch"); +var elasticsearch = builder.AddElasticsearch("elasticsearch") + .WithEnvironment("LICENSE", "trial"); var api = builder.AddProject("ApiLambda").WithArgs(globalArguments) + .WithEnvironment("ENVIRONMENT", "dev") + .WithEnvironment("LLM_GATEWAY_FUNCTION_URL", llmUrl) + .WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath) .WaitFor(elasticsearch) .WithReference(elasticsearch); var indexElasticsearch = builder.AddProject("DocsAssemblerElasticsearch") - .WithArgs(["repo", "build-all", "--exporters", "html,elasticsearch", .. globalArguments]) + .WithArgs(["repo", "build-all", "--exporters", "elasticsearch", .. globalArguments]) + .WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http")) + .WithEnvironment(context => + { + context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearch.Resource.PasswordParameter; + }) + .WithReference(elasticsearch) + .WithExplicitStart() + .WaitFor(elasticsearch) + .WaitForCompletion(cloneAll); + +var indexElasticsearchSemantic = builder.AddProject("DocsAssemblerElasticsearchSemantic") + .WithArgs(["repo", "build-all", "--exporters", "semantic", .. globalArguments]) .WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http")) .WithEnvironment(context => { @@ -44,11 +64,17 @@ var serveStatic = builder.AddProject("DocsBuilderServeStatic") .WithReference(elasticsearch) + .WithEnvironment("LLM_GATEWAY_FUNCTION_URL", llmUrl) + .WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath) + .WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http")) + .WithEnvironment(context => + { + context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearch.Resource.PasswordParameter; + }) .WithHttpEndpoint(port: 4000, isProxied: false) .WithArgs(["serve-static", .. globalArguments]) .WithHttpHealthCheck("/", 200) + .WaitFor(elasticsearch) .WaitForCompletion(buildAll); - - builder.Build().Run();