11using System ;
22using System . Globalization ;
33using System . Net ;
4- using System . Threading ;
54using System . Threading . Tasks ;
65using Test ;
76using 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