Skip to content

Commit 8aaf151

Browse files
authored
Use Aspire as distributed service orchestrator, start on integration tests (#1664)
* Initial infra work for assembler integration tests * Move to Aspire * Move integration tests over to aspire * Touchup logging * ensure we log startup in case of failed tests * LlmGatwewayAskAiGateway needs to be registered as scoped since it depends on scoped options * Ensure we set default branch on CI to main To limit noise from clone-all * Support building only public repositories * update test names * format * ensure we only mutate navigation if --skip-private-repositories is actually specified * formatting * comment * Separate integration tests * update free disk pace * keep dotnet * Disable integration tests temporarily
1 parent 141b3a8 commit 8aaf151

File tree

48 files changed

+876
-261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+876
-261
lines changed

.github/actions/bootstrap/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ runs:
1818
run: |
1919
git fetch --prune --unshallow --tags
2020
git tag --list
21+
22+
- name: Git config
23+
shell: bash
24+
run: |
25+
git config --global init.defaultBranch main
26+
2127
- uses: actions/setup-dotnet@v4
2228
with:
2329
global-json-file: global.json
@@ -37,4 +43,3 @@ runs:
3743
cache: npm
3844
cache-dependency-path: src/Elastic.Documentation.Site/package-lock.json
3945
node-version-file: .nvmrc
40-

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,36 @@ jobs:
8484
id: bootstrap
8585
uses: ./.github/actions/bootstrap
8686

87+
- name: Install Aspire workload
88+
run: dotnet workload install aspire
89+
8790
- name: Build
8891
run: dotnet run --project build -c release
8992

9093
- name: Test
91-
run: dotnet run --project build -c release -- test
94+
run: dotnet run --project build -c release -- unit-test
9295

9396
- name: Publish AOT
9497
run: dotnet run --project build -c release -- publishbinaries
98+
99+
integration:
100+
if: false
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- name: Free Disk Space
106+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
107+
with:
108+
tool-cache: false
109+
dotnet: true
110+
111+
- name: Bootstrap Action Workspace
112+
id: bootstrap
113+
uses: ./.github/actions/bootstrap
114+
115+
- name: Install Aspire workload
116+
run: dotnet workload install aspire
117+
118+
- name: Integration Tests
119+
run: dotnet run --project build -c release -- integrate

Directory.Packages.props

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<!-- Enable central package management, https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management -->
44
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
55
<MinVerSkip Condition="'$(Configuration)' == 'Debug'">true</MinVerSkip>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
68
</PropertyGroup>
79
<ItemGroup>
810
<GlobalPackageReference Include="MinVer" Version="6.0.0" PrivateAssets="All" />
@@ -15,14 +17,21 @@
1517
<PackageVersion Include="Amazon.Lambda.S3Events" Version="3.1.0" />
1618
<PackageVersion Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" />
1719
<PackageVersion Include="Amazon.Lambda.SQSEvents" Version="2.2.0" />
20+
<PackageVersion Include="Aspire.Hosting" Version="9.4.0" />
21+
<PackageVersion Include="Aspire.Hosting.Testing" Version="9.4.0" />
1822
<PackageVersion Include="AWSSDK.Core" Version="4.0.0.2" />
1923
<PackageVersion Include="AWSSDK.SQS" Version="4.0.0.1" />
2024
<PackageVersion Include="AWSSDK.S3" Version="4.0.0.1" />
25+
<PackageVersion Include="Elastic.Aspire.Hosting.Elasticsearch" Version="9.3.0" />
2126
<PackageVersion Include="FakeItEasy" Version="8.3.0" />
2227
<PackageVersion Include="Elastic.Ingest.Elasticsearch" Version="0.11.3" />
28+
<PackageVersion Include="InMemoryLogger" Version="1.0.66" />
29+
<PackageVersion Include="MartinCostello.Logging.XUnit.v3" Version="0.6.0" />
2330
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.4" />
2431
<PackageVersion Include="Microsoft.OpenApi" Version="2.0.0-preview9" />
2532
<PackageVersion Include="System.Text.Json" Version="9.0.5" />
33+
<PackageVersion Include="TUnit" Version="0.25.21" />
34+
<PackageVersion Include="xunit.v3.extensibility.core" Version="2.0.2" />
2635
</ItemGroup>
2736
<!-- Build -->
2837
<ItemGroup>
@@ -40,8 +49,8 @@
4049
<PackageVersion Include="DotNet.Glob" Version="3.1.3" />
4150
<PackageVersion Include="Errata" Version="0.14.0" />
4251
<PackageVersion Include="Github.Actions.Core" Version="9.0.0" />
43-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.4" />
44-
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.4" />
52+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.7" />
53+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.7" />
4554
<PackageVersion Include="Markdig" Version="0.41.1" />
4655
<PackageVersion Include="NetEscapades.EnumGenerators" Version="1.0.0-beta12" PrivateAssets="all" ExcludeAssets="runtime" />
4756
<PackageVersion Include="Proc" Version="0.9.1" />
@@ -58,6 +67,17 @@
5867
</ItemGroup>
5968
<!-- Test packages -->
6069
<ItemGroup>
70+
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.7.0" />
71+
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.4.0" />
72+
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
73+
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
74+
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
75+
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
76+
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
77+
</ItemGroup>
78+
<!-- Test packages -->
79+
<ItemGroup>
80+
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.4.0" />
6181
<PackageVersion Include="AngleSharp.Diffing" Version="1.0.0" />
6282
<PackageVersion Include="DiffPlex" Version="1.7.2" />
6383
<PackageVersion Include="FluentAssertions" Version="7.2.0" />

build/CommandLine.fs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@ open Microsoft.FSharp.Reflection
99
open System
1010
open Bullseye
1111

12+
type TestSuite = All | Unit | Integration
13+
with
14+
member this.SuitName =
15+
match FSharpValue.GetUnionFields(this, typeof<TestSuite>) with
16+
| case, _ -> case.Name.ToLowerInvariant()
17+
1218
type Build =
1319
| [<CliPrefix(CliPrefix.None);SubCommand>] Clean
1420
| [<CliPrefix(CliPrefix.None);SubCommand>] Version
1521
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] Compile
1622
| [<CliPrefix(CliPrefix.None);SubCommand>] Build
23+
1724
| [<CliPrefix(CliPrefix.None);SubCommand>] Test
18-
25+
| [<CliPrefix(CliPrefix.None);SubCommand>] Unit_Test
26+
| [<CliPrefix(CliPrefix.None);SubCommand>] Integrate
27+
1928
| [<CliPrefix(CliPrefix.None);SubCommand>] Format
2029
| [<CliPrefix(CliPrefix.None);SubCommand>] Watch
2130

@@ -33,6 +42,7 @@ type Build =
3342
| [<Inherit;AltCommandLine("-s")>] Single_Target
3443
| [<Inherit>] Token of string
3544
| [<Inherit;AltCommandLine("-c")>] Skip_Dirty_Check
45+
| [<Inherit;EqualsAssignment>] Test_Suite of TestSuite
3646
with
3747
interface IArgParserTemplate with
3848
member this.Usage =
@@ -41,8 +51,11 @@ with
4151
| Clean -> "clean known output locations"
4252
| Version -> "print version information"
4353
| Build -> "Run build"
44-
45-
| Test -> "runs a clean build and then runs all the tests "
54+
55+
| Unit_Test -> "alias to providing: test --test-suite=unit"
56+
| Integrate -> "alias to providing: test --test-suite=integration"
57+
| Test -> "runs a clean build and then runs all the tests unless --test-suite is provided"
58+
4659
| Release -> "runs build, tests, and create and validates the packages shy of publishing them"
4760
| Publish -> "Publishes artifacts"
4861
| Format -> "runs dotnet format"
@@ -62,6 +75,7 @@ with
6275
| Single_Target -> "Runs the provided sub command without running their dependencies"
6376
| Token _ -> "Token to be used to authenticate with github"
6477
| Skip_Dirty_Check -> "Skip the clean checkout check that guards the release/publish targets"
78+
| Test_Suite _ -> "Specify the test suite to run, defaults to all"
6579

6680
member this.StepName =
6781
match FSharpValue.GetUnionFields(this, typeof<Build>) with
@@ -87,4 +101,4 @@ with
87101
let dependsOn = if singleTarget then [] else dependsOn
88102

89103
let steps = dependsOn @ composedOf |> List.map _.StepName
90-
Targets.Target(target.StepName, steps, Action(fun _ -> action parsed))
104+
Targets.Target(target.StepName, steps, Action(fun _ -> action parsed))

build/Targets.fs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@ let private publishContainers _ =
107107
createImage "docs-builder"
108108
createImage "docs-assembler"
109109

110-
let private runTests _ =
110+
let private runTests (testSuite: TestSuite) _ =
111+
let testFilter =
112+
match testSuite with
113+
| All -> []
114+
| Unit -> ["--filter"; "FullyQualifiedName~.Tests"]
115+
| Integration -> ["--filter"; "FullyQualifiedName~.IntegrationTests"]
116+
111117
exec {
112118
run "dotnet" (
113119
["test"; "-c"; "release"; "--no-restore"; "--no-build"; "--logger"; "GitHubActions"]
120+
@ testFilter
114121
@ ["--"; "RunConfiguration.CollectSourceInformation=true"]
115122
)
116123
}
@@ -132,8 +139,10 @@ let Setup (parsed:ParseResults<Build>) =
132139
Build.Cmd
133140
[Clean; Lint; Compile] [] build
134141

135-
| Test -> Build.Cmd [Compile] [] runTests
136-
142+
| Test -> Build.Cmd [Compile] [] <| runTests TestSuite.All
143+
| Unit_Test -> Build.Cmd [Compile] [] <| runTests TestSuite.Unit
144+
| Integrate -> Build.Cmd [Compile] [] <| runTests TestSuite.Integration
145+
137146
| Release ->
138147
Build.Cmd
139148
[PristineCheck; Build]
@@ -159,6 +168,7 @@ let Setup (parsed:ParseResults<Build>) =
159168

160169
// flags
161170
| Single_Target
171+
| Test_Suite _
162172
| Token _
163173
| Skip_Dirty_Check -> Build.Ignore
164174

config/assembler.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ references:
9595
elastic-otel-python:
9696
elastic-serverless-forwarder:
9797
integration-docs:
98+
private: true
9899
integrations:
99100
logstash-docs-md:
100101
opentelemetry:
@@ -105,7 +106,12 @@ references:
105106

106107
# @elastic/admin-docs
107108
cloud-on-k8s:
108-
cloud: *master
109+
cloud:
110+
current: master
111+
next: master
112+
edge: master
113+
private: true
114+
109115
curator: *master
110116
ecctl: *master
111117

docs-builder.sln

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ EndProject
2525
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = ".github", ".github\.github.csproj", "{1A8659C1-222A-4824-B562-ED8F88658C05}"
2626
EndProject
2727
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{67B576EE-02FA-4F9B-94BC-3630BC09ECE5}"
28+
ProjectSection(SolutionItems) = preProject
29+
tests\Directory.Build.props = tests\Directory.Build.props
30+
EndProjectSection
2831
EndProject
2932
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Markdown.Tests", "tests\Elastic.Markdown.Tests\Elastic.Markdown.Tests.csproj", "{B27C5107-128B-465A-B8F8-8985399E4CFB}"
3033
EndProject
@@ -119,6 +122,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{6FAB56
119122
config\navigation.yml = config\navigation.yml
120123
EndProjectSection
121124
EndProject
125+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests-integration", "tests-integration", "{BCAD38D5-6C83-46E2-8398-4BE463931098}"
126+
ProjectSection(SolutionItems) = preProject
127+
tests-integration\Directory.Build.props = tests-integration\Directory.Build.props
128+
EndProjectSection
129+
EndProject
130+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Assembler.IntegrationTests", "tests-integration\Elastic.Assembler.IntegrationTests\Elastic.Assembler.IntegrationTests.csproj", "{A272D3EC-FAAF-4795-A796-302725382AFF}"
131+
EndProject
132+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Aspire", "tests-integration\Elastic.Documentation.Aspire\Elastic.Documentation.Aspire.csproj", "{4DFECE72-4A1F-4B58-918E-DCD07B585231}"
133+
EndProject
134+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.ServiceDefaults", "src\Elastic.Documentation.ServiceDefaults\Elastic.Documentation.ServiceDefaults.csproj", "{2A83ED35-B631-4F02-8D4C-15611D0DB72C}"
135+
EndProject
122136
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{B042CC78-5060-4091-B95A-79C71BA3908A}"
123137
EndProject
124138
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Api.Core", "src\api\Elastic.Documentation.Api.Core\Elastic.Documentation.Api.Core.csproj", "{F30B90AD-1A01-4A6F-9699-809FA6875B22}"
@@ -212,6 +226,18 @@ Global
212226
{164F55EC-9412-4CD4-81AD-3598B57632A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
213227
{164F55EC-9412-4CD4-81AD-3598B57632A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
214228
{164F55EC-9412-4CD4-81AD-3598B57632A6}.Release|Any CPU.Build.0 = Release|Any CPU
229+
{A272D3EC-FAAF-4795-A796-302725382AFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
230+
{A272D3EC-FAAF-4795-A796-302725382AFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
231+
{A272D3EC-FAAF-4795-A796-302725382AFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
232+
{A272D3EC-FAAF-4795-A796-302725382AFF}.Release|Any CPU.Build.0 = Release|Any CPU
233+
{4DFECE72-4A1F-4B58-918E-DCD07B585231}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
234+
{4DFECE72-4A1F-4B58-918E-DCD07B585231}.Debug|Any CPU.Build.0 = Debug|Any CPU
235+
{4DFECE72-4A1F-4B58-918E-DCD07B585231}.Release|Any CPU.ActiveCfg = Release|Any CPU
236+
{4DFECE72-4A1F-4B58-918E-DCD07B585231}.Release|Any CPU.Build.0 = Release|Any CPU
237+
{2A83ED35-B631-4F02-8D4C-15611D0DB72C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
238+
{2A83ED35-B631-4F02-8D4C-15611D0DB72C}.Debug|Any CPU.Build.0 = Debug|Any CPU
239+
{2A83ED35-B631-4F02-8D4C-15611D0DB72C}.Release|Any CPU.ActiveCfg = Release|Any CPU
240+
{2A83ED35-B631-4F02-8D4C-15611D0DB72C}.Release|Any CPU.Build.0 = Release|Any CPU
215241
{F30B90AD-1A01-4A6F-9699-809FA6875B22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
216242
{F30B90AD-1A01-4A6F-9699-809FA6875B22}.Debug|Any CPU.Build.0 = Debug|Any CPU
217243
{F30B90AD-1A01-4A6F-9699-809FA6875B22}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -254,6 +280,9 @@ Global
254280
{89B83007-71E6-4B57-BA78-2544BFA476DB} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
255281
{111E7029-BB29-4039-9B45-04776798A8DD} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
256282
{164F55EC-9412-4CD4-81AD-3598B57632A6} = {67B576EE-02FA-4F9B-94BC-3630BC09ECE5}
283+
{A272D3EC-FAAF-4795-A796-302725382AFF} = {BCAD38D5-6C83-46E2-8398-4BE463931098}
284+
{4DFECE72-4A1F-4B58-918E-DCD07B585231} = {BCAD38D5-6C83-46E2-8398-4BE463931098}
285+
{2A83ED35-B631-4F02-8D4C-15611D0DB72C} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
257286
{B042CC78-5060-4091-B95A-79C71BA3908A} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
258287
{F30B90AD-1A01-4A6F-9699-809FA6875B22} = {B042CC78-5060-4091-B95A-79C71BA3908A}
259288
{AE3FC78E-167F-4B6E-88EC-84743EB748B7} = {B042CC78-5060-4091-B95A-79C71BA3908A}

src/Elastic.Documentation.Configuration/Assembler/AssemblyConfiguration.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System.Text.RegularExpressions;
66
using Elastic.Documentation.Extensions;
7-
using YamlDotNet.RepresentationModel;
87
using YamlDotNet.Serialization;
98
using YamlStaticContext = Elastic.Documentation.Configuration.Serialization.YamlStaticContext;
109

@@ -13,9 +12,9 @@ namespace Elastic.Documentation.Configuration.Assembler;
1312
public record AssemblyConfiguration
1413
{
1514
public static AssemblyConfiguration Create(ConfigurationFileProvider provider) =>
16-
Deserialize(provider.AssemblerFile.ReadToEnd());
15+
Deserialize(provider.AssemblerFile.ReadToEnd(), skipPrivateRepositories: provider.SkipPrivateRepositories);
1716

18-
public static AssemblyConfiguration Deserialize(string yaml)
17+
public static AssemblyConfiguration Deserialize(string yaml, bool skipPrivateRepositories = false)
1918
{
2019
var input = new StringReader(yaml);
2120

@@ -28,13 +27,28 @@ public static AssemblyConfiguration Deserialize(string yaml)
2827
var config = deserializer.Deserialize<AssemblyConfiguration>(input);
2928
foreach (var (name, r) in config.ReferenceRepositories)
3029
{
30+
if (name == "cloud")
31+
{
32+
}
3133
var repository = RepositoryDefaults(r, name);
3234
config.ReferenceRepositories[name] = repository;
3335
}
36+
var privateRepositories = config.ReferenceRepositories.Where(r => r.Value.Private).ToList();
37+
foreach (var (name, _) in privateRepositories)
38+
{
39+
if (skipPrivateRepositories)
40+
_ = config.ReferenceRepositories.Remove(name);
41+
}
3442

3543
foreach (var (name, env) in config.Environments)
3644
env.Name = name;
3745
config.Narrative = RepositoryDefaults(config.Narrative, NarrativeRepository.RepositoryName);
46+
47+
config.AvailableRepositories = config.ReferenceRepositories.Values
48+
.Where(r => !r.Skip)
49+
.Concat([config.Narrative]).ToDictionary(kvp => kvp.Name, kvp => kvp);
50+
51+
config.PrivateRepositories = privateRepositories.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
3852
return config;
3953
}
4054
catch (Exception e)
@@ -80,6 +94,15 @@ private static TRepository RepositoryDefaults<TRepository>(TRepository r, string
8094
[YamlMember(Alias = "references")]
8195
public Dictionary<string, Repository> ReferenceRepositories { get; set; } = [];
8296

97+
/// All available repositories, combines <see cref="ReferenceRepositories"/> and <see cref="Narrative"/> and will filter private repositories if `skip-private-repositories`
98+
/// is specified
99+
[YamlIgnore]
100+
public IReadOnlyDictionary<string, Repository> AvailableRepositories { get; private set; } = new Dictionary<string, Repository>();
101+
102+
/// Repositories marked as private, these are listed under <see cref="AvailableRepositories"/> if `--skip-private-repositories` is not specified
103+
[YamlIgnore]
104+
public IReadOnlyDictionary<string, Repository> PrivateRepositories { get; private set; } = new Dictionary<string, Repository>();
105+
83106
[YamlMember(Alias = "environments")]
84107
public Dictionary<string, PublishEnvironment> Environments { get; set; } = [];
85108

src/Elastic.Documentation.Configuration/Assembler/Repository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public record Repository
4848
[YamlMember(Alias = "sparse_paths")]
4949
public string[] SparsePaths { get; set; } = ["docs"];
5050

51+
[YamlMember(Alias = "private")]
52+
public bool Private { get; set; }
53+
5154
public string GetBranch(ContentSource contentSource) => contentSource switch
5255
{
5356
ContentSource.Current => GitReferenceCurrent,

0 commit comments

Comments
 (0)