Skip to content

Commit 9af8bf8

Browse files
committed
Shorten test durations
1 parent 0e501a5 commit 9af8bf8

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

projects/Unit/TestFloodPublishing.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@
4949
namespace RabbitMQ.Client.Unit
5050
{
5151
[TestFixture]
52-
public class TestFloodPublishing : IntegrationFixture
52+
public class TestFloodPublishing
5353
{
54-
[Test, Category("LongRunning")]
54+
private readonly byte[] _body = new byte[2048];
55+
private readonly TimeSpan _tenSeconds = TimeSpan.FromSeconds(10);
56+
57+
[Test]
5558
public void TestUnthrottledFloodPublishing()
5659
{
5760
var connFactory = new ConnectionFactory()
@@ -60,9 +63,9 @@ public void TestUnthrottledFloodPublishing()
6063
AutomaticRecoveryEnabled = false
6164
};
6265

63-
using(var conn = connFactory.CreateConnection())
66+
using (var conn = connFactory.CreateConnection())
6467
{
65-
using(var model = conn.CreateModel())
68+
using (var model = conn.CreateModel())
6669
{
6770
conn.ConnectionShutdown += (_, args) =>
6871
{
@@ -73,20 +76,19 @@ public void TestUnthrottledFloodPublishing()
7376
};
7477

7578
bool elapsed = false;
76-
using (Timer t = new Timer((_obj) => { elapsed = true; }, null, 1000 * 185, -1))
79+
using (Timer t = new Timer((_obj) => { elapsed = true; }, null, (int)_tenSeconds.TotalMilliseconds, -1))
7780
{
7881
while (!elapsed)
7982
{
80-
model.BasicPublish("", "", null, new byte[2048]);
83+
model.BasicPublish("", "", null, _body);
8184
}
8285
Assert.IsTrue(conn.IsOpen);
8386
}
8487
}
8588
}
8689
}
8790

88-
// rabbitmq/rabbitmq-dotnet-client#802 FIX THIS TODO
89-
[Test, Category("LongRunning")]
91+
[Test]
9092
public async Task TestMultithreadFloodPublishing()
9193
{
9294
string message = "test message";
@@ -95,7 +97,12 @@ public async Task TestMultithreadFloodPublishing()
9597
int receivedCount = 0;
9698
byte[] sendBody = Encoding.UTF8.GetBytes(message);
9799

98-
var cf = new ConnectionFactory();
100+
var cf = new ConnectionFactory()
101+
{
102+
RequestedHeartbeat = TimeSpan.FromSeconds(60),
103+
AutomaticRecoveryEnabled = false
104+
};
105+
99106
using (IConnection c = cf.CreateConnection())
100107
{
101108
using (IModel m = c.CreateModel())
@@ -118,7 +125,7 @@ public async Task TestMultithreadFloodPublishing()
118125
};
119126

120127
string tag = m.BasicConsume(q.QueueName, true, consumer);
121-
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
128+
var cts = new CancellationTokenSource(_tenSeconds);
122129

123130
using (var timeoutRegistration = cts.Token.Register(() => tcs.SetCanceled()))
124131
{

0 commit comments

Comments
 (0)