-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into otel-integration-package
- Loading branch information
Showing
15 changed files
with
431 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
[CmdletBinding(PositionalBinding=$false)] | ||
param( | ||
[switch]$RunTests | ||
[switch]$RunTests, | ||
[switch]$RunTestsUntilFailure | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
Set-StrictMode -Version Latest | ||
$PSNativeCommandUseErrorActionPreference = $true | ||
|
||
Write-Host "Run Parameters:" -ForegroundColor Cyan | ||
Write-Host "`tPSScriptRoot: $PSScriptRoot" | ||
Write-Host "`tRunTests: $RunTests" | ||
Write-Host "`tRunTestsUntilFailure: $RunTestsUntilFailure" | ||
Write-Host "`tdotnet --version: $(dotnet --version)" | ||
|
||
Write-Host "[INFO] building all projects (Build.csproj traversal)..." -ForegroundColor "Magenta" | ||
dotnet build "$PSScriptRoot\Build.csproj" | ||
Write-Host "[INFO] done building." -ForegroundColor "Green" | ||
|
||
if ($RunTests) | ||
if ($RunTests -or $RunTestsUntilFailure) | ||
{ | ||
$tests_dir = Join-Path -Path $PSScriptRoot -ChildPath 'projects' | Join-Path -ChildPath 'Test' | ||
$unit_csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $tests_dir -ChildPath 'Unit' | Join-Path -ChildPath 'Unit.csproj') | ||
$integration_csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $tests_dir -ChildPath 'Integration' | Join-Path -ChildPath 'Integration.csproj') | ||
$sequential_integration_csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $tests_dir -ChildPath 'SequentialIntegration' | Join-Path -ChildPath 'SequentialIntegration.csproj') | ||
|
||
foreach ($csproj_file in $unit_csproj_file, $integration_csproj_file, $sequential_integration_csproj_file) | ||
Do | ||
{ | ||
Write-Host "[INFO] running Unit / Integration tests from '$csproj_file' (all frameworks)" -ForegroundColor "Magenta" | ||
dotnet test $csproj_file --environment 'RABBITMQ_LONG_RUNNING_TESTS=true' --no-restore --no-build --logger "console;verbosity=detailed" | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Host "[ERROR] tests errored, exiting" -Foreground "Red" | ||
Exit 1 | ||
} | ||
else | ||
foreach ($csproj_file in $unit_csproj_file, $integration_csproj_file, $sequential_integration_csproj_file) | ||
{ | ||
Write-Host "[INFO] tests passed" -ForegroundColor "Green" | ||
Write-Host "[INFO] running Unit / Integration tests from '$csproj_file' (all frameworks)" -ForegroundColor "Magenta" | ||
& dotnet test $csproj_file --environment 'RABBITMQ_LONG_RUNNING_TESTS=true' --no-restore --no-build --logger "console;verbosity=detailed" | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Host "[ERROR] tests errored, exiting" -Foreground "Red" | ||
Exit 1 | ||
} | ||
else | ||
{ | ||
Write-Host "[INFO] tests passed" -ForegroundColor "Green" | ||
} | ||
} | ||
} | ||
} While ($RunTestsUntilFailure) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.../Integration/ConnectionRecovery/EventHandlerRecovery/Channel/TestRecoveryEventHandlers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// This source code is dual-licensed under the Apache License, version | ||
// 2.0, and the Mozilla Public License, version 2.0. | ||
// | ||
// The APL v2.0: | ||
// | ||
//--------------------------------------------------------------------------- | ||
// Copyright (c) 2007-2020 VMware, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
//--------------------------------------------------------------------------- | ||
// | ||
// The MPL v2.0: | ||
// | ||
//--------------------------------------------------------------------------- | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved. | ||
//--------------------------------------------------------------------------- | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using RabbitMQ.Client.Impl; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Test.Integration.ConnectionRecovery.EventHandlerRecovery.Channel | ||
{ | ||
public class TestRecoveryEventHandlers : TestConnectionRecoveryBase | ||
{ | ||
public TestRecoveryEventHandlers(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task TestRecoveryEventHandlers_Called() | ||
{ | ||
int counter = 0; | ||
((AutorecoveringChannel)_channel).Recovery += (source, ea) => Interlocked.Increment(ref counter); | ||
|
||
await CloseAndWaitForRecoveryAsync(); | ||
await CloseAndWaitForRecoveryAsync(); | ||
await CloseAndWaitForRecoveryAsync(); | ||
await CloseAndWaitForRecoveryAsync(); | ||
Assert.True(_channel.IsOpen); | ||
Assert.True(counter >= 3); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
.../Integration/ConnectionRecovery/EventHandlerRecovery/Channel/TestShutdownEventHandlers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// This source code is dual-licensed under the Apache License, version | ||
// 2.0, and the Mozilla Public License, version 2.0. | ||
// | ||
// The APL v2.0: | ||
// | ||
//--------------------------------------------------------------------------- | ||
// Copyright (c) 2007-2020 VMware, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
//--------------------------------------------------------------------------- | ||
// | ||
// The MPL v2.0: | ||
// | ||
//--------------------------------------------------------------------------- | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved. | ||
//--------------------------------------------------------------------------- | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Test.Integration.ConnectionRecovery.EventHandlerRecovery.Channel | ||
{ | ||
public class TestShutdownEventHandlers : TestConnectionRecoveryBase | ||
{ | ||
public TestShutdownEventHandlers(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task TestShutdownEventHandlersOnChannel_Called() | ||
{ | ||
int counter = 0; | ||
_channel.ChannelShutdown += (c, args) => Interlocked.Increment(ref counter); | ||
|
||
Assert.True(_channel.IsOpen); | ||
await CloseAndWaitForRecoveryAsync(); | ||
await CloseAndWaitForRecoveryAsync(); | ||
await CloseAndWaitForRecoveryAsync(); | ||
await CloseAndWaitForRecoveryAsync(); | ||
Assert.True(_channel.IsOpen); | ||
|
||
Assert.True(counter >= 3); | ||
} | ||
} | ||
} |
Oops, something went wrong.