Skip to content

Commit 2c5c1e1

Browse files
committed
Fix test by using messagesReceived and messageCount
Add ConfirmSelectAsync Add BasicNackAsync and fix small bug in ConfirmSelectAsync Add TestBasicGetAsync Implement CloseAsync Doc blocks and simplify return thanks to @Tornhoof No need to set an exception when a channel shutdown was explicitly requested Add QueuePurgeAsync Fix sync Channel Close and add test using CloseAsync() Add QueueUnbindAsync Add async Tx methods Remove BasicRecover and BasicRecoverAsync since they are both deprecated. 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. * Fix SequentialTests that require a unique connection name. Fix OAuth2 test runners
1 parent a28441a commit 2c5c1e1

File tree

122 files changed

+4231
-3368
lines changed

Some content is hidden

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

122 files changed

+4231
-3368
lines changed

.ci/oauth2/setup.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ function start_rabbitmq
4646
--network "$docker_network" \
4747
--publish 5672:5672 \
4848
--publish 15672:15672 \
49-
--volume "$GITHUB_WORKSPACE/projects/OAuth2Test/enabled_plugins:/etc/rabbitmq/enabled_plugins" \
50-
--volume "$GITHUB_WORKSPACE/projects/OAuth2Test/$mode/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro" \
51-
--volume "$GITHUB_WORKSPACE/projects/OAuth2Test/$mode/signing-key/signing-key.pem:/etc/rabbitmq/signing-key.pem:ro" \
49+
--volume "$GITHUB_WORKSPACE/projects/Test/OAuth2/enabled_plugins:/etc/rabbitmq/enabled_plugins" \
50+
--volume "$GITHUB_WORKSPACE/projects/Test/OAuth2/$mode/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro" \
51+
--volume "$GITHUB_WORKSPACE/projects/Test/OAuth2/$mode/signing-key/signing-key.pem:/etc/rabbitmq/signing-key.pem:ro" \
5252
rabbitmq:3-management
5353
}
5454

@@ -90,7 +90,7 @@ function start_oauth_service
9090
--publish 8080:8080 \
9191
--env 'UAA_CONFIG_PATH=/uaa' \
9292
--env 'JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom' \
93-
--volume "$GITHUB_WORKSPACE/projects/OAuth2Test/uaa:/uaa" \
93+
--volume "$GITHUB_WORKSPACE/projects/Test/OAuth2/uaa:/uaa" \
9494
"cloudfoundry/uaa:$uaa_image_version"
9595
else
9696
readonly keycloak_docker_name="$docker_name_prefix-keycloak"
@@ -101,7 +101,7 @@ function start_oauth_service
101101
--env 'KEYCLOAK_ADMIN=admin' \
102102
--env 'KEYCLOAK_ADMIN_PASSWORD=admin' \
103103
--env KC_HEALTH_ENABLED=true \
104-
--volume "$GITHUB_WORKSPACE/projects/OAuth2Test/keycloak/import:/opt/keycloak/data/import" \
104+
--volume "$GITHUB_WORKSPACE/projects/Test/OAuth2/keycloak/import:/opt/keycloak/data/import" \
105105
"quay.io/keycloak/keycloak:$keycloak_image_version" start-dev --metrics-enabled=true --import-realm
106106
fi
107107
}

.ci/oauth2/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ source "$script_dir/common.sh"
1212

1313
export OAUTH2_MODE="$mode"
1414

15-
dotnet test --environment OAUTH2_MODE="$mode" "$GITHUB_WORKSPACE/projects/OAuth2Test/OAuth2Test.csproj" --logger "console;verbosity=detailed" --framework "net6.0"
15+
dotnet test --environment OAUTH2_MODE="$mode" "$GITHUB_WORKSPACE/projects/Test/OAuth2/OAuth2.csproj" --logger "console;verbosity=detailed"

.ci/ubuntu/rabbitmq.conf

+4-1
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

-39
This file was deleted.

.ci/windows/gha-setup.ps1

+13-1
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

+4-1
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

+5
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

+154-28
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/

.gitignore

+3-3
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

+7-4
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>

0 commit comments

Comments
 (0)