Skip to content

Commit dffb2da

Browse files
committed
Implement async for simple AMQP methods
Related to: * #1345 * #1308 * #970 * #843 Separate out Unit, Integration and Parallel Integration tests * Creates dedicated test projects for parallel test execution (AsyncIntegration / 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. * Shorten up test names used for connection client provided names * Ensure all async tests are in the AsyncIntegration project. * Convert MassPublish to async/await with multiple publishing connections. * Add MaxParallelThreads in a csproj comment in case we want to try that out * Wait longer when IsRunningInCI * Introduce the RentedMemory struct to encapsulate a rented byte array and its associated ReadOnlyMemory. * Add CreateChannelAsync and modify AsyncIntegration tests to use it. * Add CreateConnectionAsync * Use CreateConnectionAsync in AsyncIntegration * Change the test suite fixes to use ManualResetEventSlim instead of Monitor * Misc refactor to newer language features * SocketFrameHandler CloseAsync * Only increase ThreadPool count for Integration tests * There is no need to expose ClientMemory / RentedMemory * Replace IList with IEnumerable in the API.
1 parent 31d12d3 commit dffb2da

File tree

189 files changed

+11114
-5874
lines changed

Some content is hidden

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

189 files changed

+11114
-5874
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

+163-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,99 @@ 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/AsyncIntegration/bin
42+
projects/Test/Integration/bin
43+
projects/Test/SequentialIntegration/bin
44+
projects/RabbitMQ.*/bin
45+
integration-win32:
46+
name: integration test on windows-latest
47+
needs: build-win32
48+
runs-on: windows-latest
49+
# https://github.com/NuGet/Home/issues/11548
50+
env:
51+
NUGET_CERT_REVOCATION_MODE: offline
52+
steps:
53+
- name: Clone repository
54+
uses: actions/checkout@v4
55+
with:
56+
submodules: true
57+
- name: Cache installers
58+
uses: actions/cache@v3
59+
with:
60+
# Note: the cache path is relative to the workspace directory
61+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
62+
path: ~/installers
63+
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
64+
- name: Download Build (Debug)
65+
uses: actions/download-artifact@v3
66+
with:
67+
name: rabbitmq-dotnet-client-build-win32
68+
path: projects
69+
- name: Install and Start RabbitMQ
70+
id: install-start-rabbitmq
71+
run: .\.ci\windows\gha-setup.ps1
72+
- name: Async Integration Tests
73+
run: dotnet test --environment "RABBITMQ_RABBITMQCTL_PATH=${{ steps.install-start-rabbitmq.outputs.path }}" --environment 'RABBITMQ_LONG_RUNNING_TESTS=false' "${{ github.workspace }}\projects\Test\AsyncIntegration\AsyncIntegration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
74+
- name: Integration Tests
75+
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'
4476
- name: Maybe upload RabbitMQ logs
4577
if: failure()
4678
uses: actions/upload-artifact@v3
4779
with:
48-
name: rabbitmq-logs
80+
name: rabbitmq-logs-integration-win32
4981
path: ~/AppData/Roaming/RabbitMQ/log/
50-
build:
51-
name: build/test on ubuntu-latest
82+
sequential-integration-win32:
83+
name: sequential integration test on windows-latest
84+
needs: build-win32
85+
runs-on: windows-latest
86+
# https://github.com/NuGet/Home/issues/11548
87+
env:
88+
NUGET_CERT_REVOCATION_MODE: offline
89+
steps:
90+
- name: Clone repository
91+
uses: actions/checkout@v4
92+
with:
93+
submodules: true
94+
- name: Cache installers
95+
uses: actions/cache@v3
96+
with:
97+
# Note: the cache path is relative to the workspace directory
98+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
99+
path: ~/installers
100+
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
101+
- name: Download Build (Debug)
102+
uses: actions/download-artifact@v3
103+
with:
104+
name: rabbitmq-dotnet-client-build-win32
105+
path: projects
106+
- name: Install and Start RabbitMQ
107+
id: install-start-rabbitmq
108+
run: .\.ci\windows\gha-setup.ps1
109+
- name: Sequential Integration Tests
110+
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'
111+
- name: Maybe upload RabbitMQ logs
112+
if: failure()
113+
uses: actions/upload-artifact@v3
114+
with:
115+
name: rabbitmq-logs-sequential-integration-win32
116+
path: ~/AppData/Roaming/RabbitMQ/log/
117+
118+
build-ubuntu:
119+
name: build, unit test on ubuntu-latest
52120
runs-on: ubuntu-latest
53121
steps:
54122
- name: Clone repository
@@ -68,26 +136,93 @@ jobs:
68136
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
69137
restore-keys: |
70138
${{ 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
76139
- name: Build (Debug)
77140
run: dotnet build ${{ github.workspace }}/Build.csproj
78141
- name: Verify
79-
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
80-
- name: Test
142+
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --no-restore --verify-no-changes --verbosity=diagnostic
143+
- name: APIApproval Test
144+
run: dotnet test "${{ github.workspace }}/projects/Test/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --filter='FullyQualifiedName=Test.Unit.APIApproval.Approve'
145+
- name: Unit Tests
146+
run: dotnet test "${{ github.workspace }}/projects/Test/Unit/Unit.csproj" --no-restore --no-build --verbosity=diagnostic --logger 'console;verbosity=detailed'
147+
- name: Upload Build (Debug)
148+
uses: actions/upload-artifact@v3
149+
with:
150+
name: rabbitmq-dotnet-client-build-ubuntu
151+
path: |
152+
projects/Test/Unit/bin
153+
projects/Test/AsyncIntegration/bin
154+
projects/Test/Integration/bin
155+
projects/Test/SequentialIntegration/bin
156+
projects/RabbitMQ.*/bin
157+
integration-ubuntu:
158+
name: integration test on ubuntu-latest
159+
needs: build-ubuntu
160+
runs-on: ubuntu-latest
161+
steps:
162+
- name: Clone repository
163+
uses: actions/checkout@v4
164+
with:
165+
submodules: true
166+
- name: Setup .NET
167+
uses: actions/setup-dotnet@v3
168+
with:
169+
dotnet-version: 6.x
170+
- name: Download Build (Debug)
171+
uses: actions/download-artifact@v3
172+
with:
173+
name: rabbitmq-dotnet-client-build-ubuntu
174+
path: projects
175+
- name: Start RabbitMQ
176+
id: start-rabbitmq
177+
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
178+
- name: Async Integration Tests
81179
run: |
82180
dotnet test \
83181
--environment "RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }}" \
84-
--environment 'RABBITMQ_LONG_RUNNING_TESTS=true' \
182+
"${{ github.workspace }}/projects/Test/AsyncIntegration/AsyncIntegration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
183+
- name: Integration Tests
184+
run: |
185+
dotnet test \
186+
--environment "RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }}" \
187+
--environment 'RABBITMQ_LONG_RUNNING_TESTS=false' \
85188
--environment 'PASSWORD=grapefruit' \
86189
--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'
190+
"${{ github.workspace }}/projects/Test/Integration/Integration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
191+
- name: Maybe upload RabbitMQ logs
192+
if: failure()
193+
uses: actions/upload-artifact@v3
194+
with:
195+
name: rabbitmq-logs-integration-ubuntu
196+
path: ${{ github.workspace }}/.ci/ubuntu/log/
197+
sequential-integration-ubuntu:
198+
name: sequential integration test on ubuntu-latest
199+
needs: build-ubuntu
200+
runs-on: ubuntu-latest
201+
steps:
202+
- name: Clone repository
203+
uses: actions/checkout@v4
204+
with:
205+
submodules: true
206+
- name: Setup .NET
207+
uses: actions/setup-dotnet@v3
208+
with:
209+
dotnet-version: 6.x
210+
- name: Download Build (Debug)
211+
uses: actions/download-artifact@v3
212+
with:
213+
name: rabbitmq-dotnet-client-build-ubuntu
214+
path: projects
215+
- name: Start RabbitMQ
216+
id: start-rabbitmq
217+
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
218+
- name: Sequential Integration Tests
219+
run: |
220+
dotnet test \
221+
--environment "RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }}" \
222+
"${{ github.workspace }}/projects/Test/SequentialIntegration/SequentialIntegration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
88223
- name: Maybe upload RabbitMQ logs
89224
if: failure()
90225
uses: actions/upload-artifact@v3
91226
with:
92-
name: rabbitmq-logs
227+
name: rabbitmq-logs-sequential-integration-ubuntu
93228
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

0 commit comments

Comments
 (0)