Skip to content

Commit 6c8d953

Browse files
committed
Separate out Unit, Integration and Parallel Integration tests
* Creates dedicated test projects for parallel test execution (Integration.csproj) and sequential (SequentialIntegration.csproj). * Ensures that the ThreadPool is set with enough threads. * Ensures that all test connections have their client provided name set.
1 parent 3414b32 commit 6c8d953

File tree

109 files changed

+2752
-2228
lines changed

Some content is hidden

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

109 files changed

+2752
-2228
lines changed

.ci/ubuntu/rabbitmq.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
log.console = false
2+
log.exchange = false
23
log.file = /var/log/rabbitmq/rabbitmq.log
3-
log.file.level = debug
4+
log.file.level = info
5+
log.connection.level = warning
6+
log.channel.level = warning
47
listeners.tcp.default = 5672
58
listeners.ssl.default = 5671
69
reverse_dns_lookups = false

.ci/windows/gha-run-tests.ps1

Lines changed: 0 additions & 39 deletions
This file was deleted.

.ci/windows/gha-setup.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ $erlang_home = (Get-ItemProperty -LiteralPath $erlang_reg_path\$erlang_erts_vers
6565
Write-Host "[INFO] Setting ERLANG_HOME to '$erlang_home'..."
6666
$env:ERLANG_HOME = $erlang_home
6767
[Environment]::SetEnvironmentVariable('ERLANG_HOME', $erlang_home, 'Machine')
68+
Add-Content -Verbose -LiteralPath $env:GITHUB_ENV -Value "ERLANG_HOME=$erlang_home"
6869

6970
Write-Host "[INFO] Setting RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS..."
7071
$env:RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS = '-rabbitmq_stream advertised_host localhost'
@@ -189,6 +190,17 @@ Write-Host '[INFO] Enabling plugins...'
189190
& $rabbitmq_plugins_path enable rabbitmq_management rabbitmq_stream rabbitmq_stream_management rabbitmq_amqp1_0
190191

191192
echo Q | openssl s_client -connect localhost:5671 -CAfile "$certs_dir/ca_certificate.pem" -cert "$certs_dir/client_localhost_certificate.pem" -key "$certs_dir/client_localhost_key.pem" -pass pass:grapefruit
192-
if ($LASTEXITCODE -ne 0) {
193+
if ($LASTEXITCODE -ne 0)
194+
{
193195
throw "[ERROR] 'openssl s_client' returned error: $LASTEXITCODE"
194196
}
197+
198+
199+
$rabbitmqctl_path = Resolve-Path -LiteralPath `
200+
(Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version" | Join-Path -ChildPath 'sbin' | Join-Path -ChildPath 'rabbitmqctl.bat')
201+
202+
Write-Host "[INFO] Setting RABBITMQ_RABBITMQCTL_PATH to '$rabbitmqctl_path'..."
203+
$env:RABBITMQ_RABBITMQCTL_PATH = $rabbitmqctl_path
204+
[Environment]::SetEnvironmentVariable('RABBITMQ_RABBITMQCTL_PATH', $rabbitmqctl_path, 'Machine')
205+
Add-Content -Verbose -LiteralPath $env:GITHUB_OUTPUT -Value "path=$rabbitmqctl_path"
206+
Add-Content -Verbose -LiteralPath $env:GITHUB_ENV -Value "RABBITMQ_RABBITMQCTL_PATH=$rabbitmqctl_path"

.ci/windows/rabbitmq.conf.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
log.console = false
2-
log.file.level = debug
2+
log.exchange = false
3+
log.file.level = info
4+
log.connection.level = warning
5+
log.channel.level = warning
36
listeners.tcp.default = 5672
47
listeners.ssl.default = 5671
58
reverse_dns_lookups = false

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://github.com/rabbitmq/rabbitmq-dotnet-client/commit/1713f50eb2dc52a97184f3857f70841dd55b5bef
2+
1713f50eb2dc52a97184f3857f70841dd55b5bef
3+
67c02d79d3ae48fea7de93c758dce91a51d14988
4+
# Revert the above
5+
6b1a06bd429f395891a3230cad92e674dcbbb0d2

.github/workflows/build-test.yaml

Lines changed: 154 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
build-win32:
8-
name: build/test on windows-latest
8+
name: build, unit test on windows-latest
99
runs-on: windows-latest
1010
# https://github.com/NuGet/Home/issues/11548
1111
env:
@@ -15,13 +15,6 @@ jobs:
1515
uses: actions/checkout@v4
1616
with:
1717
submodules: true
18-
- name: Cache installers
19-
uses: actions/cache@v3
20-
with:
21-
# Note: the cache path is relative to the workspace directory
22-
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
23-
path: ~/installers
24-
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
2518
- name: Cache NuGet packages
2619
uses: actions/cache@v3
2720
with:
@@ -31,24 +24,96 @@ jobs:
3124
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
3225
restore-keys: |
3326
${{ runner.os }}-v1-nuget-
34-
- name: Install and Start RabbitMQ
35-
run: .\.ci\windows\gha-setup.ps1
36-
- name: List NuGet sources
37-
run: dotnet nuget locals all --list
3827
- name: Build (Debug)
3928
run: dotnet build ${{ github.workspace }}\Build.csproj
4029
- name: Verify
41-
run: dotnet format ${{ github.workspace }}\RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
42-
- name: Test
43-
run: .\.ci\windows\gha-run-tests.ps1
30+
run: dotnet format ${{ github.workspace }}\RabbitMQDotNetClient.sln --no-restore --verify-no-changes --verbosity=diagnostic
31+
- name: APIApproval Test
32+
run: dotnet test "${{ github.workspace }}\projects\Test\Unit\Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --filter='FullyQualifiedName=Test.Unit.APIApproval.Approve'
33+
- name: Unit Tests
34+
run: dotnet test "${{ github.workspace }}\projects\Test\Unit\Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
35+
- name: Upload Build (Debug)
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: rabbitmq-dotnet-client-build-win32
39+
path: |
40+
projects/Test/Unit/bin
41+
projects/Test/Integration/bin
42+
projects/Test/SequentialIntegration/bin
43+
projects/RabbitMQ.*/bin
44+
integration-win32:
45+
name: integration test on windows-latest
46+
needs: build-win32
47+
runs-on: windows-latest
48+
# https://github.com/NuGet/Home/issues/11548
49+
env:
50+
NUGET_CERT_REVOCATION_MODE: offline
51+
steps:
52+
- name: Clone repository
53+
uses: actions/checkout@v4
54+
with:
55+
submodules: true
56+
- name: Cache installers
57+
uses: actions/cache@v3
58+
with:
59+
# Note: the cache path is relative to the workspace directory
60+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
61+
path: ~/installers
62+
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
63+
- name: Download Build (Debug)
64+
uses: actions/download-artifact@v3
65+
with:
66+
name: rabbitmq-dotnet-client-build-win32
67+
path: projects
68+
- name: Install and Start RabbitMQ
69+
id: install-start-rabbitmq
70+
run: .\.ci\windows\gha-setup.ps1
71+
- name: Integration Tests
72+
run: dotnet test --environment "RABBITMQ_RABBITMQCTL_PATH=${{ steps.install-start-rabbitmq.outputs.path }}" --environment 'RABBITMQ_LONG_RUNNING_TESTS=false' --environment 'PASSWORD=grapefruit' --environment SSL_CERTS_DIR="${{ github.workspace }}\.ci\certs" "${{ github.workspace }}\projects\Test\Integration\Integration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
73+
- name: Maybe upload RabbitMQ logs
74+
if: failure()
75+
uses: actions/upload-artifact@v3
76+
with:
77+
name: rabbitmq-logs-integration-win32
78+
path: ~/AppData/Roaming/RabbitMQ/log/
79+
sequential-integration-win32:
80+
name: sequential integration test on windows-latest
81+
needs: build-win32
82+
runs-on: windows-latest
83+
# https://github.com/NuGet/Home/issues/11548
84+
env:
85+
NUGET_CERT_REVOCATION_MODE: offline
86+
steps:
87+
- name: Clone repository
88+
uses: actions/checkout@v4
89+
with:
90+
submodules: true
91+
- name: Cache installers
92+
uses: actions/cache@v3
93+
with:
94+
# Note: the cache path is relative to the workspace directory
95+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
96+
path: ~/installers
97+
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
98+
- name: Download Build (Debug)
99+
uses: actions/download-artifact@v3
100+
with:
101+
name: rabbitmq-dotnet-client-build-win32
102+
path: projects
103+
- name: Install and Start RabbitMQ
104+
id: install-start-rabbitmq
105+
run: .\.ci\windows\gha-setup.ps1
106+
- name: Sequential Integration Tests
107+
run: dotnet test --environment "RABBITMQ_RABBITMQCTL_PATH=${{ steps.install-start-rabbitmq.outputs.path }}" "${{ github.workspace }}\projects\Test\SequentialIntegration\SequentialIntegration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
44108
- name: Maybe upload RabbitMQ logs
45109
if: failure()
46110
uses: actions/upload-artifact@v3
47111
with:
48-
name: rabbitmq-logs
112+
name: rabbitmq-logs-sequential-integration-win32
49113
path: ~/AppData/Roaming/RabbitMQ/log/
50-
build:
51-
name: build/test on ubuntu-latest
114+
115+
build-ubuntu:
116+
name: build, unit test on ubuntu-latest
52117
runs-on: ubuntu-latest
53118
steps:
54119
- name: Clone repository
@@ -68,26 +133,87 @@ jobs:
68133
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
69134
restore-keys: |
70135
${{ runner.os }}-v1-nuget-
71-
- name: Start RabbitMQ
72-
id: start-rabbitmq
73-
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
74-
- name: List NuGet sources
75-
run: dotnet nuget locals all --list
76136
- name: Build (Debug)
77137
run: dotnet build ${{ github.workspace }}/Build.csproj
78138
- name: Verify
79-
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
80-
- name: Test
139+
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --no-restore --verify-no-changes --verbosity=diagnostic
140+
- name: APIApproval Test
141+
run: dotnet test "${{ github.workspace }}/projects/Test/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --filter='FullyQualifiedName=Test.Unit.APIApproval.Approve'
142+
- name: Unit Tests
143+
run: dotnet test "${{ github.workspace }}/projects/Test/Unit/Unit.csproj" --no-restore --no-build --verbosity=diagnostic --logger 'console;verbosity=detailed'
144+
- name: Upload Build (Debug)
145+
uses: actions/upload-artifact@v3
146+
with:
147+
name: rabbitmq-dotnet-client-build-ubuntu
148+
path: |
149+
projects/Test/Unit/bin
150+
projects/Test/Integration/bin
151+
projects/Test/SequentialIntegration/bin
152+
projects/RabbitMQ.*/bin
153+
integration-ubuntu:
154+
name: integration test on ubuntu-latest
155+
needs: build-ubuntu
156+
runs-on: ubuntu-latest
157+
steps:
158+
- name: Clone repository
159+
uses: actions/checkout@v4
160+
with:
161+
submodules: true
162+
- name: Setup .NET
163+
uses: actions/setup-dotnet@v3
164+
with:
165+
dotnet-version: 6.x
166+
- name: Download Build (Debug)
167+
uses: actions/download-artifact@v3
168+
with:
169+
name: rabbitmq-dotnet-client-build-ubuntu
170+
path: projects
171+
- name: Start RabbitMQ
172+
id: start-rabbitmq
173+
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
174+
- name: Integration Tests
81175
run: |
82176
dotnet test \
83177
--environment "RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }}" \
84-
--environment 'RABBITMQ_LONG_RUNNING_TESTS=true' \
178+
--environment 'RABBITMQ_LONG_RUNNING_TESTS=false' \
85179
--environment 'PASSWORD=grapefruit' \
86180
--environment SSL_CERTS_DIR="${{ github.workspace }}/.ci/certs" \
87-
"${{ github.workspace }}/projects/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --framework 'net6.0'
181+
"${{ github.workspace }}/projects/Test/Integration/Integration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
182+
- name: Maybe upload RabbitMQ logs
183+
if: failure()
184+
uses: actions/upload-artifact@v3
185+
with:
186+
name: rabbitmq-logs-integration-ubuntu
187+
path: ${{ github.workspace }}/.ci/ubuntu/log/
188+
sequential-integration-ubuntu:
189+
name: sequential integration test on ubuntu-latest
190+
needs: build-ubuntu
191+
runs-on: ubuntu-latest
192+
steps:
193+
- name: Clone repository
194+
uses: actions/checkout@v4
195+
with:
196+
submodules: true
197+
- name: Setup .NET
198+
uses: actions/setup-dotnet@v3
199+
with:
200+
dotnet-version: 6.x
201+
- name: Download Build (Debug)
202+
uses: actions/download-artifact@v3
203+
with:
204+
name: rabbitmq-dotnet-client-build-ubuntu
205+
path: projects
206+
- name: Start RabbitMQ
207+
id: start-rabbitmq
208+
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
209+
- name: Sequential Integration Tests
210+
run: |
211+
dotnet test \
212+
--environment "RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }}" \
213+
"${{ github.workspace }}/projects/Test/SequentialIntegration/SequentialIntegration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
88214
- name: Maybe upload RabbitMQ logs
89215
if: failure()
90216
uses: actions/upload-artifact@v3
91217
with:
92-
name: rabbitmq-logs
218+
name: rabbitmq-logs-sequential-integration-ubuntu
93219
path: ${{ github.workspace }}/.ci/ubuntu/log/

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [ main ]
66
pull_request:
7-
branches: [ main ]
7+
branches: [ main, lukebakken/async-operations ]
88

99
jobs:
1010
call-build-test:

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ build/
5252

5353
BenchmarkDotNet.Artifacts/*
5454

55-
projects/Unit/APIApproval.Approve.received.txt
56-
projects/Unit/APIApproval.Approve.*.received.txt
55+
projects/Test/Unit/APIApproval.Approve.received.txt
56+
projects/Test/Unit/APIApproval.Approve.*.received.txt
5757

5858
# Visual Studio 2015 cache/options directory
5959
.vs/
@@ -115,7 +115,7 @@ UpgradeLog*.htm
115115

116116
# Unit tests
117117

118-
projects/Unit*/TestResult.xml
118+
projects/Test/Unit*/TestResult.xml
119119

120120
# Development scripts
121121

Build.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
<ProjectReference Include="projects/Benchmarks/Benchmarks.csproj" />
1010
<ProjectReference Include="projects/RabbitMQ.Client/RabbitMQ.Client.csproj" />
1111
<ProjectReference Include="projects/RabbitMQ.Client.OAuth2/RabbitMQ.Client.OAuth2.csproj" />
12-
<ProjectReference Include="projects/TestApplications/CreateChannel/CreateChannel.csproj" />
13-
<ProjectReference Include="projects/TestApplications/MassPublish/MassPublish.csproj" />
14-
<ProjectReference Include="projects/Unit/Unit.csproj" />
15-
<ProjectReference Include="projects/OAuth2Test/OAuth2Test.csproj" />
12+
<ProjectReference Include="projects/Test/Common/Common.csproj" />
13+
<ProjectReference Include="projects/Test/Applications/CreateChannel/CreateChannel.csproj" />
14+
<ProjectReference Include="projects/Test/Applications/MassPublish/MassPublish.csproj" />
15+
<ProjectReference Include="projects/Test/Integration/Integration.csproj" />
16+
<ProjectReference Include="projects/Test/SequentialIntegration/SequentialIntegration.csproj" />
17+
<ProjectReference Include="projects/Test/Unit/Unit.csproj" />
18+
<ProjectReference Include="projects/Test/OAuth2/OAuth2.csproj" />
1619
</ItemGroup>
1720

1821
</Project>

RUNNING_TESTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ in this example, it should be `./rabbitmq-server/deps/rabbit/sbin/rabbitmqctl`.
7171
It is possible to override the location using `RABBITMQ_RABBITMQCTL_PATH`:
7272

7373
```
74-
RABBITMQ_RABBITMQCTL_PATH=/path/to/rabbitmqctl dotnet test projects/Unit
74+
RABBITMQ_RABBITMQCTL_PATH=/path/to/rabbitmqctl dotnet test projects/Test/Unit.csproj
7575
```
7676

7777
### Option Three: Using a Docker Container
@@ -110,9 +110,9 @@ Running individual tests and fixtures on Windows is trivial using the Visual Stu
110110
To run a specific tests fixture on MacOS or Linux, use the NUnit filter expressions to select the tests to be run:
111111

112112
``` shell
113-
dotnet test projects/Unit --filter "Name~TestAmqpUriParseFail"
113+
dotnet test projects/Test/Unit.csproj --filter "Name~TestAmqpUriParseFail"
114114

115-
dotnet test projects/Unit --filter "FullyQualifiedName~RabbitMQ.Client.Unit.TestHeartbeats"
115+
dotnet test projects/Test/Unit.csproj --filter "FullyQualifiedName~RabbitMQ.Client.Unit.TestHeartbeats"
116116
```
117117

118118
## Running Tests for a Specific .NET Target

0 commit comments

Comments
 (0)