Skip to content

Commit

Permalink
Merge pull request #1745 from rabbitmq/lukebakken/toxiproxy-aha
Browse files Browse the repository at this point in the history
Set TestTfmsInParallel to false for Integration tests
  • Loading branch information
lukebakken authored Dec 12, 2024
2 parents 5b33811 + b5d6459 commit 354d4bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions projects/Test/Integration/Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<SignAssembly>true</SignAssembly>
<IsTestProject>true</IsTestProject>
<LangVersion>12.0</LangVersion>
<TestTfmsInParallel>false</TestTfmsInParallel>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion projects/Test/Integration/TestToxiproxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override Task InitializeAsync()
Assert.Null(_channel);

_toxiproxyManager = new ToxiproxyManager(_testDisplayName, IsRunningInCI, IsWindows);
_proxyPort = _toxiproxyManager.ProxyPort;
_proxyPort = ToxiproxyManager.ProxyPort;
return _toxiproxyManager.InitializeAsync();
}

Expand Down
20 changes: 9 additions & 11 deletions projects/Test/Integration/ToxiproxyManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Globalization;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Test;
using Toxiproxy.Net;
Expand All @@ -11,12 +10,10 @@ namespace Integration
{
public class ToxiproxyManager : IAsyncDisposable
{
public const ushort ProxyPort = 55672;
private const string ProxyNamePrefix = "rmq";
private const ushort ProxyPortStart = 55669;
private static int s_proxyPort = ProxyPortStart;

private readonly string _testDisplayName;
private readonly int _proxyPort;
private readonly Connection _proxyConnection;
private readonly Client _proxyClient;
private readonly Proxy _proxy;
Expand All @@ -32,8 +29,6 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo

_testDisplayName = testDisplayName;

_proxyPort = Interlocked.Increment(ref s_proxyPort);

/*
* Note:
* Do NOT set resetAllToxicsAndProxiesOnClose to true, because it will
Expand All @@ -46,13 +41,13 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
_proxy = new Proxy
{
Enabled = true,
Listen = $"{IPAddress.Loopback}:{_proxyPort}",
Listen = $"{IPAddress.Loopback}:{ProxyPort}",
Upstream = $"{IPAddress.Loopback}:5672",
};

if (isRunningInCI)
{
_proxy.Listen = $"0.0.0.0:{_proxyPort}";
_proxy.Listen = $"0.0.0.0:{ProxyPort}";

// GitHub Actions
if (false == isWindows)
Expand All @@ -66,11 +61,14 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
}
}

public int ProxyPort => _proxyPort;

public async Task InitializeAsync()
{
string proxyName = $"{ProxyNamePrefix}-{_testDisplayName}-{Util.Now}-{Guid.NewGuid()}";
/*
* Note: since all Toxiproxy tests are in the same test class, they will run sequentially,
* so we can use 55672 for the listen port. In addition, TestTfmsInParallel is set to false
* so we know only one set of integration tests are running at a time
*/
string proxyName = $"{ProxyNamePrefix}-{_testDisplayName}-{Util.Now}";
_proxy.Name = proxyName;

ushort retryCount = 5;
Expand Down

0 comments on commit 354d4bd

Please sign in to comment.