@@ -55,6 +55,12 @@ internal class TestHeartbeats : IntegrationFixture
55
55
[ Category ( "Focus" ) ]
56
56
public void TestThatHeartbeatWriterUsesConfigurableInterval ( )
57
57
{
58
+ if ( ! LongRunningTestsEnabled ( ) )
59
+ {
60
+ Console . WriteLine ( "RABBITMQ_LONG_RUNNING_TESTS is not set, skipping test" ) ;
61
+ return ;
62
+ }
63
+
58
64
var cf = new ConnectionFactory ( )
59
65
{
60
66
RequestedHeartbeat = heartbeatTimeout ,
@@ -75,7 +81,7 @@ public void TestThatHeartbeatWriterUsesConfigurableInterval()
75
81
}
76
82
}
77
83
} ;
78
- Thread . Sleep ( heartbeatTimeout * 10 * 1000 ) ;
84
+ SleepFor ( 30 ) ;
79
85
80
86
Assert . IsFalse ( wasShutdown , "shutdown event should not have been fired" ) ;
81
87
Assert . IsTrue ( conn . IsOpen , "connection should be open" ) ;
@@ -87,6 +93,13 @@ public void TestThatHeartbeatWriterUsesConfigurableInterval()
87
93
[ Category ( "Focus" ) ]
88
94
public void TestHundredsOfConnectionsWithRandomHeartbeatInterval ( )
89
95
{
96
+ if ( ! LongRunningTestsEnabled ( ) )
97
+ {
98
+ Console . WriteLine ( "RABBITMQ_LONG_RUNNING_TESTS is not set, skipping test" ) ;
99
+ return ;
100
+ }
101
+
102
+
90
103
var rnd = new Random ( ) ;
91
104
List < IConnection > xs = new List < IConnection > ( ) ;
92
105
for ( var i = 0 ; i < 200 ; i ++ )
@@ -104,7 +117,7 @@ public void TestHundredsOfConnectionsWithRandomHeartbeatInterval()
104
117
} ;
105
118
}
106
119
107
- Thread . Sleep ( 20 * 1000 ) ;
120
+ SleepFor ( 60 ) ;
108
121
109
122
foreach ( var x in xs )
110
123
{
@@ -123,5 +136,21 @@ private void CheckInitiator(ShutdownEventArgs evt)
123
136
Assert . Fail ( s ) ;
124
137
}
125
138
}
139
+
140
+ private bool LongRunningTestsEnabled ( )
141
+ {
142
+ var s = Environment . GetEnvironmentVariable ( "RABBITMQ_LONG_RUNNING_TESTS" ) ;
143
+ if ( s == null || s . Equals ( "" ) )
144
+ {
145
+ return false ;
146
+ }
147
+ return true ;
148
+ }
149
+
150
+ private void SleepFor ( int t )
151
+ {
152
+ Console . WriteLine ( "Testing heartbeats, sleeping for {0} seconds" , t ) ;
153
+ Thread . Sleep ( t * 1000 ) ;
154
+ }
126
155
}
127
156
}
0 commit comments