Skip to content

Commit

Permalink
Run core tests on Windows and test run stability (#464)
Browse files Browse the repository at this point in the history
* Run core tests on windows

* wip

* Add Core2 and CoreUnit tests projects

* Build debug on Windows as well

* dotnet format

* Exclude core on Windows

* Fixed build warnings

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Debugging Windows tests

* Improve test's .NET Framework compatibility

* Shared test server

* Server download

* Server download

* Simplify tests

* Enabled all tests

* Script fix

* Update workflows

* dotnet format

* Test fix

* Test fix

* Update protocol tests

* dotnet format

* Tweak workflow

* Integrate NatsServerFixture into ConsumerFetchTest class

* Rename test configs with unique prefixes

* Rename test configs with unique prefixes

* Organize project files and GitHub workflows

Reorganized solution items for better project structure, moving miscellaneous files to a general grouping and creating dedicated sections for GitHub workflows and scripts. This improves clarity and maintainability of the project.

* Add NATS server fixture and test improvements

Introduced a base NATS server fixture for test classes and updated test cases to utilize the fixture. This simplifies server management and ensures consistent URL handling. Also, enhanced tests to use unique prefixes for identifiers to improve reliability.

* Format
  • Loading branch information
mtmk authored Sep 27, 2024
1 parent 442db86 commit 4a30725
Show file tree
Hide file tree
Showing 48 changed files with 1,244 additions and 723 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ jobs:
nats-server -v
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- id: tag
name: Determine tag
Expand Down
116 changes: 91 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- main

jobs:
dotnet:
name: dotnet
linux_test:
name: Linux
strategy:
fail-fast: false
matrix:
Expand All @@ -35,36 +35,77 @@ jobs:
run: nats-server -v

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Build
run: dotnet build -c Debug
run: dotnet build -c Release

- name: Test Core
run: dotnet test -c Debug --no-build --logger:"console;verbosity=normal" tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.Core.Tests
dotnet test -c Release --no-build --logger:"console;verbosity=normal"
- name: Test Core2
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.Core2.Tests
dotnet test -c Release --no-build
- name: Test CoreUnit
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.CoreUnit.Tests
dotnet test -c Release --no-build
- name: Test JetStream
run: dotnet test -c Debug --no-build --logger:"console;verbosity=normal" tests/NATS.Client.JetStream.Tests/NATS.Client.JetStream.Tests.csproj
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.JetStream.Tests
dotnet test -c Release --no-build
- name: Test Key/Value Store
run: dotnet test -c Debug --no-build --logger:"console;verbosity=normal" tests/NATS.Client.KeyValueStore.Tests/NATS.Client.KeyValueStore.Tests.csproj
- name: Test KeyValueStore
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.KeyValueStore.Tests
dotnet test -c Release --no-build
- name: Test Object Store
run: dotnet test -c Debug --no-build --logger:"console;verbosity=normal" tests/NATS.Client.ObjectStore.Tests/NATS.Client.ObjectStore.Tests.csproj
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.ObjectStore.Tests
dotnet test -c Release --no-build
- name: Test Services
run: dotnet test -c Debug --no-build --logger:"console;verbosity=normal" tests/NATS.Client.Services.Tests/NATS.Client.Services.Tests.csproj
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.Services.Tests
dotnet test -c Release --no-build
- name: Test OpenTelemetry
run: dotnet test -c Debug --no-build --logger:"console;verbosity=normal" tests/NATS.Net.OpenTelemetry.Tests/NATS.Net.OpenTelemetry.Tests.csproj
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Net.OpenTelemetry.Tests
dotnet test -c Release --no-build
- name: Check Native AOT
run: |
killall nats-server 2> /dev/null | echo -n
nats-server -v
cd tests/NATS.Client.CheckNativeAot
rm -rf bin obj
dotnet publish -r linux-x64 -c Release -o dist | tee output.txt
Expand All @@ -84,8 +125,8 @@ jobs:
./NATS.Client.CheckNativeAot
memory_test:
name: memory test
windows_test:
name: Windows
strategy:
fail-fast: false
matrix:
Expand All @@ -98,14 +139,15 @@ jobs:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip
MSYS_NO_PATHCONV: 1
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

Expand All @@ -114,11 +156,7 @@ jobs:
run: |
mkdir tools-nats-server && cd tools-nats-server
branch=$(curl https://api.mtmk.dev/gh/v1/releases/tag/nats-io/nats-server/${{ matrix.config.branch }})
for i in 1 2 3
do
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@$branch | PREFIX=. sh && break || sleep 30
done
mv nats-server nats-server.exe
curl -sL -o nats-server.exe "https://binaries.nats.dev/binary/github.com/nats-io/nats-server/v2?os=windows&arch=amd64&version=$branch"
cygpath -w "$(pwd)" | tee -a "$GITHUB_PATH"
- name: Check nats-server
Expand All @@ -133,11 +171,39 @@ jobs:
dotnet tool install --global NUnit.ConsoleRunner.NetCore
- name: Build
run: dotnet build -c Release
run: dotnet build -c Release

- name: Memory Test (net6.0)
run: dotMemoryUnit $env:userprofile\.dotnet\tools\nunit.exe --propagate-exit-code -- .\tests\NATS.Client.Core.MemoryTests\bin\Release\net6.0\NATS.Client.Core.MemoryTests.dll
run: |
tasklist | grep -i nats-server && taskkill -F -IM nats-server.exe
nats-server.exe -v
dotMemoryUnit $env:userprofile\.dotnet\tools\nunit.exe --propagate-exit-code -- .\tests\NATS.Client.Core.MemoryTests\bin\Release\net6.0\NATS.Client.Core.MemoryTests.dll
- name: Platform Test (Windows net481)
run: dotnet test -c Release --no-build --logger:"console;verbosity=normal" -f net481 .\tests\NATS.Client.Platform.Windows.Tests\NATS.Client.Platform.Windows.Tests.csproj
- name: Platform Test
run: |
tasklist | grep -i nats-server && taskkill -F -IM nats-server.exe
nats-server.exe -v
cd tests\NATS.Client.Platform.Windows.Tests
dotnet test -c Release --no-build
# Not working on Windows reliably yet
#- name: Test Core
# run: |
# tasklist | grep -i nats-server && taskkill -F -IM nats-server.exe
# nats-server.exe -v
# cd tests/NATS.Client.Core.Tests
# dotnet test -c Release --no-build

- name: Test Core2
run: |
tasklist | grep -i nats-server && taskkill -F -IM nats-server.exe
nats-server.exe -v
cd tests/NATS.Client.Core2.Tests
dotnet test -c Release --no-build
- name: Test CoreUnit
run: |
tasklist | grep -i nats-server && taskkill -F -IM nats-server.exe
nats-server.exe -v
cd tests/NATS.Client.CoreUnit.Tests
dotnet test -c Release --no-build
42 changes: 39 additions & 3 deletions NATS.Client.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NATS.Client.Core.Tests", "t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicroBenchmark", "sandbox\MicroBenchmark\MicroBenchmark.csproj", "{A10F0D89-13F3-49B3-ACF7-66E45DC95225}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "files", "files", "{899BE3EA-C5CA-4394-9B62-C45CBFF3AF4E}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".", ".", "{899BE3EA-C5CA-4394-9B62-C45CBFF3AF4E}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\build-debug.yml = .github\workflows\build-debug.yml
.github\workflows\build-release.yml = .github\workflows\build-release.yml
Directory.Build.props = Directory.Build.props
README.md = README.md
version.txt = version.txt
.gitattributes = .gitattributes
.gitignore = .gitignore
CODE-OF-CONDUCT.md = CODE-OF-CONDUCT.md
CONTRIBUTING.md = CONTRIBUTING.md
dependencies.md = dependencies.md
global.json = global.json
Icon.png = Icon.png
LICENSE = LICENSE
REPO_RENAME.md = REPO_RENAME.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NATS.Client.Hosting", "src\NATS.Client.Hosting\NATS.Client.Hosting.csproj", "{D3F09B30-1ED5-48C2-81CD-A2AD88E751AC}"
Expand Down Expand Up @@ -115,6 +124,21 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.Simplified.Test
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.Simplified", "src\NATS.Client.Simplified\NATS.Client.Simplified.csproj", "{227C88B1-0510-4010-B142-C44725578FCD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.Core2.Tests", "tests\NATS.Client.Core2.Tests\NATS.Client.Core2.Tests.csproj", "{8A676AAA-FEE3-4C18-870A-66E59AD9069F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.CoreUnit.Tests", "tests\NATS.Client.CoreUnit.Tests\NATS.Client.CoreUnit.Tests.csproj", "{9521D9E0-642A-4C7E-BD10-372DF235CF62}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{B9EF0111-6720-46DF-B11A-8F8C88C3F5C1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{0B7F1286-4426-45DE-82C2-FE7CF13CA0DA}"
ProjectSection(SolutionItems) = preProject
.github\workflows\docs.yml = .github\workflows\docs.yml
.github\workflows\format.yml = .github\workflows\format.yml
.github\workflows\perf.yml = .github\workflows\perf.yml
.github\workflows\release.yml = .github\workflows\release.yml
.github\workflows\test.yml = .github\workflows\test.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -309,6 +333,14 @@ Global
{227C88B1-0510-4010-B142-C44725578FCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{227C88B1-0510-4010-B142-C44725578FCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{227C88B1-0510-4010-B142-C44725578FCD}.Release|Any CPU.Build.0 = Release|Any CPU
{8A676AAA-FEE3-4C18-870A-66E59AD9069F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8A676AAA-FEE3-4C18-870A-66E59AD9069F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A676AAA-FEE3-4C18-870A-66E59AD9069F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A676AAA-FEE3-4C18-870A-66E59AD9069F}.Release|Any CPU.Build.0 = Release|Any CPU
{9521D9E0-642A-4C7E-BD10-372DF235CF62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9521D9E0-642A-4C7E-BD10-372DF235CF62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9521D9E0-642A-4C7E-BD10-372DF235CF62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9521D9E0-642A-4C7E-BD10-372DF235CF62}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -362,6 +394,10 @@ Global
{A15CCDD5-B707-4142-B99A-64F0AB62318A} = {95A69671-16CA-4133-981C-CC381B7AAA30}
{6DAAAA87-8DDF-4E60-81CE-D8900327DE33} = {C526E8AB-739A-48D7-8FC4-048978C9B650}
{227C88B1-0510-4010-B142-C44725578FCD} = {4827B3EC-73D8-436D-AE2A-5E29AC95FD0C}
{8A676AAA-FEE3-4C18-870A-66E59AD9069F} = {C526E8AB-739A-48D7-8FC4-048978C9B650}
{9521D9E0-642A-4C7E-BD10-372DF235CF62} = {C526E8AB-739A-48D7-8FC4-048978C9B650}
{B9EF0111-6720-46DF-B11A-8F8C88C3F5C1} = {899BE3EA-C5CA-4394-9B62-C45CBFF3AF4E}
{0B7F1286-4426-45DE-82C2-FE7CF13CA0DA} = {B9EF0111-6720-46DF-B11A-8F8C88C3F5C1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8CBB7278-D093-448E-B3DE-B5991209A1AA}
Expand Down
4 changes: 2 additions & 2 deletions sandbox/BlazorWasm/Client/BlazorWasm.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.33" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.33" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion sandbox/BlazorWasm/Server/BlazorWasm.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.33" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions sandbox/MicroBenchmark/MicroBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="StackExchange.Redis" Version="2.5.43" />
<PackageReference Include="ZLogger" Version="1.6.1" />
<PackageReference Include="NATS.Client" Version="0.14.5" />
<PackageReference Include="System.Drawing.Common" Version="8.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/NATS.Client.Core/NATS.Client.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<ItemGroup>
<InternalsVisibleTo Include="MicroBenchmark, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db7da1f2f89089327b47d26d69666fad20861f24e9acdb13965fb6c64dfee8da589b495df37a75e934ddbacb0752a42c40f3dbc79614eec9bb2a0b6741f9e2ad2876f95e74d54c23eef0063eb4efb1e7d824ee8a695b647c113c92834f04a3a83fb60f435814ddf5c4e5f66a168139c4c1b1a50a3e60c164d180e265b1f000cd"/>
<InternalsVisibleTo Include="$(AssemblyName).Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db7da1f2f89089327b47d26d69666fad20861f24e9acdb13965fb6c64dfee8da589b495df37a75e934ddbacb0752a42c40f3dbc79614eec9bb2a0b6741f9e2ad2876f95e74d54c23eef0063eb4efb1e7d824ee8a695b647c113c92834f04a3a83fb60f435814ddf5c4e5f66a168139c4c1b1a50a3e60c164d180e265b1f000cd"/>
<InternalsVisibleTo Include="$(AssemblyName)2.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db7da1f2f89089327b47d26d69666fad20861f24e9acdb13965fb6c64dfee8da589b495df37a75e934ddbacb0752a42c40f3dbc79614eec9bb2a0b6741f9e2ad2876f95e74d54c23eef0063eb4efb1e7d824ee8a695b647c113c92834f04a3a83fb60f435814ddf5c4e5f66a168139c4c1b1a50a3e60c164d180e265b1f000cd"/>
<InternalsVisibleTo Include="$(AssemblyName)Unit.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db7da1f2f89089327b47d26d69666fad20861f24e9acdb13965fb6c64dfee8da589b495df37a75e934ddbacb0752a42c40f3dbc79614eec9bb2a0b6741f9e2ad2876f95e74d54c23eef0063eb4efb1e7d824ee8a695b647c113c92834f04a3a83fb60f435814ddf5c4e5f66a168139c4c1b1a50a3e60c164d180e265b1f000cd"/>
<InternalsVisibleTo Include="$(AssemblyName).MemoryTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db7da1f2f89089327b47d26d69666fad20861f24e9acdb13965fb6c64dfee8da589b495df37a75e934ddbacb0752a42c40f3dbc79614eec9bb2a0b6741f9e2ad2876f95e74d54c23eef0063eb4efb1e7d824ee8a695b647c113c92834f04a3a83fb60f435814ddf5c4e5f66a168139c4c1b1a50a3e60c164d180e265b1f000cd"/>
<InternalsVisibleTo Include="NatsBenchmark, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db7da1f2f89089327b47d26d69666fad20861f24e9acdb13965fb6c64dfee8da589b495df37a75e934ddbacb0752a42c40f3dbc79614eec9bb2a0b6741f9e2ad2876f95e74d54c23eef0063eb4efb1e7d824ee8a695b647c113c92834f04a3a83fb60f435814ddf5c4e5f66a168139c4c1b1a50a3e60c164d180e265b1f000cd"/>
<InternalsVisibleTo Include="NATS.Client.JetStream, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db7da1f2f89089327b47d26d69666fad20861f24e9acdb13965fb6c64dfee8da589b495df37a75e934ddbacb0752a42c40f3dbc79614eec9bb2a0b6741f9e2ad2876f95e74d54c23eef0063eb4efb1e7d824ee8a695b647c113c92834f04a3a83fb60f435814ddf5c4e5f66a168139c4c1b1a50a3e60c164d180e265b1f000cd"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<ItemGroup>
<Content Include="resources\**\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

Expand Down
Loading

0 comments on commit 4a30725

Please sign in to comment.