Skip to content

Commit 354d4bd

Browse files
authored
Merge pull request #1745 from rabbitmq/lukebakken/toxiproxy-aha
Set TestTfmsInParallel to false for Integration tests
2 parents 5b33811 + b5d6459 commit 354d4bd

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

projects/Test/Integration/Integration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<SignAssembly>true</SignAssembly>
1818
<IsTestProject>true</IsTestProject>
1919
<LangVersion>12.0</LangVersion>
20+
<TestTfmsInParallel>false</TestTfmsInParallel>
2021
</PropertyGroup>
2122

2223
<ItemGroup>

projects/Test/Integration/TestToxiproxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public override Task InitializeAsync()
6262
Assert.Null(_channel);
6363

6464
_toxiproxyManager = new ToxiproxyManager(_testDisplayName, IsRunningInCI, IsWindows);
65-
_proxyPort = _toxiproxyManager.ProxyPort;
65+
_proxyPort = ToxiproxyManager.ProxyPort;
6666
return _toxiproxyManager.InitializeAsync();
6767
}
6868

projects/Test/Integration/ToxiproxyManager.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Globalization;
33
using System.Net;
4-
using System.Threading;
54
using System.Threading.Tasks;
65
using Test;
76
using Toxiproxy.Net;
@@ -11,12 +10,10 @@ namespace Integration
1110
{
1211
public class ToxiproxyManager : IAsyncDisposable
1312
{
13+
public const ushort ProxyPort = 55672;
1414
private const string ProxyNamePrefix = "rmq";
15-
private const ushort ProxyPortStart = 55669;
16-
private static int s_proxyPort = ProxyPortStart;
1715

1816
private readonly string _testDisplayName;
19-
private readonly int _proxyPort;
2017
private readonly Connection _proxyConnection;
2118
private readonly Client _proxyClient;
2219
private readonly Proxy _proxy;
@@ -32,8 +29,6 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
3229

3330
_testDisplayName = testDisplayName;
3431

35-
_proxyPort = Interlocked.Increment(ref s_proxyPort);
36-
3732
/*
3833
* Note:
3934
* Do NOT set resetAllToxicsAndProxiesOnClose to true, because it will
@@ -46,13 +41,13 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
4641
_proxy = new Proxy
4742
{
4843
Enabled = true,
49-
Listen = $"{IPAddress.Loopback}:{_proxyPort}",
44+
Listen = $"{IPAddress.Loopback}:{ProxyPort}",
5045
Upstream = $"{IPAddress.Loopback}:5672",
5146
};
5247

5348
if (isRunningInCI)
5449
{
55-
_proxy.Listen = $"0.0.0.0:{_proxyPort}";
50+
_proxy.Listen = $"0.0.0.0:{ProxyPort}";
5651

5752
// GitHub Actions
5853
if (false == isWindows)
@@ -66,11 +61,14 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
6661
}
6762
}
6863

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

7674
ushort retryCount = 5;

0 commit comments

Comments
 (0)