49
49
namespace RabbitMQ . Client . Unit
50
50
{
51
51
[ TestFixture ]
52
- public class TestFloodPublishing : IntegrationFixture
52
+ public class TestFloodPublishing
53
53
{
54
- [ Test , Category ( "LongRunning" ) ]
54
+ private readonly byte [ ] _body = new byte [ 2048 ] ;
55
+ private readonly TimeSpan _tenSeconds = TimeSpan . FromSeconds ( 10 ) ;
56
+
57
+ [ Test ]
55
58
public void TestUnthrottledFloodPublishing ( )
56
59
{
57
60
var connFactory = new ConnectionFactory ( )
@@ -60,9 +63,9 @@ public void TestUnthrottledFloodPublishing()
60
63
AutomaticRecoveryEnabled = false
61
64
} ;
62
65
63
- using ( var conn = connFactory . CreateConnection ( ) )
66
+ using ( var conn = connFactory . CreateConnection ( ) )
64
67
{
65
- using ( var model = conn . CreateModel ( ) )
68
+ using ( var model = conn . CreateModel ( ) )
66
69
{
67
70
conn . ConnectionShutdown += ( _ , args ) =>
68
71
{
@@ -73,20 +76,19 @@ public void TestUnthrottledFloodPublishing()
73
76
} ;
74
77
75
78
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 ) )
77
80
{
78
81
while ( ! elapsed )
79
82
{
80
- model . BasicPublish ( "" , "" , null , new byte [ 2048 ] ) ;
83
+ model . BasicPublish ( "" , "" , null , _body ) ;
81
84
}
82
85
Assert . IsTrue ( conn . IsOpen ) ;
83
86
}
84
87
}
85
88
}
86
89
}
87
90
88
- // rabbitmq/rabbitmq-dotnet-client#802 FIX THIS TODO
89
- [ Test , Category ( "LongRunning" ) ]
91
+ [ Test ]
90
92
public async Task TestMultithreadFloodPublishing ( )
91
93
{
92
94
string message = "test message" ;
@@ -95,7 +97,12 @@ public async Task TestMultithreadFloodPublishing()
95
97
int receivedCount = 0 ;
96
98
byte [ ] sendBody = Encoding . UTF8 . GetBytes ( message ) ;
97
99
98
- var cf = new ConnectionFactory ( ) ;
100
+ var cf = new ConnectionFactory ( )
101
+ {
102
+ RequestedHeartbeat = TimeSpan . FromSeconds ( 60 ) ,
103
+ AutomaticRecoveryEnabled = false
104
+ } ;
105
+
99
106
using ( IConnection c = cf . CreateConnection ( ) )
100
107
{
101
108
using ( IModel m = c . CreateModel ( ) )
@@ -118,7 +125,7 @@ public async Task TestMultithreadFloodPublishing()
118
125
} ;
119
126
120
127
string tag = m . BasicConsume ( q . QueueName , true , consumer ) ;
121
- var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 30 ) ) ;
128
+ var cts = new CancellationTokenSource ( _tenSeconds ) ;
122
129
123
130
using ( var timeoutRegistration = cts . Token . Register ( ( ) => tcs . SetCanceled ( ) ) )
124
131
{
0 commit comments