1
1
using System ;
2
2
using System . Globalization ;
3
3
using System . Net ;
4
- using System . Threading ;
5
4
using System . Threading . Tasks ;
6
5
using Test ;
7
6
using Toxiproxy . Net ;
@@ -11,12 +10,10 @@ namespace Integration
11
10
{
12
11
public class ToxiproxyManager : IAsyncDisposable
13
12
{
13
+ public const ushort ProxyPort = 55672 ;
14
14
private const string ProxyNamePrefix = "rmq" ;
15
- private const ushort ProxyPortStart = 55669 ;
16
- private static int s_proxyPort = ProxyPortStart ;
17
15
18
16
private readonly string _testDisplayName ;
19
- private readonly int _proxyPort ;
20
17
private readonly Connection _proxyConnection ;
21
18
private readonly Client _proxyClient ;
22
19
private readonly Proxy _proxy ;
@@ -32,8 +29,6 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
32
29
33
30
_testDisplayName = testDisplayName ;
34
31
35
- _proxyPort = Interlocked . Increment ( ref s_proxyPort ) ;
36
-
37
32
/*
38
33
* Note:
39
34
* Do NOT set resetAllToxicsAndProxiesOnClose to true, because it will
@@ -46,13 +41,13 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
46
41
_proxy = new Proxy
47
42
{
48
43
Enabled = true ,
49
- Listen = $ "{ IPAddress . Loopback } :{ _proxyPort } ",
44
+ Listen = $ "{ IPAddress . Loopback } :{ ProxyPort } ",
50
45
Upstream = $ "{ IPAddress . Loopback } :5672",
51
46
} ;
52
47
53
48
if ( isRunningInCI )
54
49
{
55
- _proxy . Listen = $ "0.0.0.0:{ _proxyPort } ";
50
+ _proxy . Listen = $ "0.0.0.0:{ ProxyPort } ";
56
51
57
52
// GitHub Actions
58
53
if ( false == isWindows )
@@ -66,11 +61,14 @@ public ToxiproxyManager(string testDisplayName, bool isRunningInCI, bool isWindo
66
61
}
67
62
}
68
63
69
- public int ProxyPort => _proxyPort ;
70
-
71
64
public async Task InitializeAsync ( )
72
65
{
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 } ";
74
72
_proxy . Name = proxyName ;
75
73
76
74
ushort retryCount = 5 ;
0 commit comments