Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set TestTfmsInParallel fals for Integration tests #1745

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading