Skip to content

Commit 60e3928

Browse files
committed
Wait longer when IsRunningInCI
1 parent 1ec090f commit 60e3928

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

projects/Test/Common/IntegrationFixture.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace Test
4444
{
4545
public class IntegrationFixture : IDisposable
4646
{
47+
private static bool s_isRunningInCI = false;
4748
private static int _connectionIdx = 0;
4849

4950
protected readonly RabbitMQCtl _rabbitMQCtl;
@@ -67,9 +68,10 @@ public class IntegrationFixture : IDisposable
6768
static IntegrationFixture()
6869
{
6970
S_Random = new Random();
71+
InitIsRunningInCI();
7072

7173
int threadCount;
72-
if (IsRunningInCI())
74+
if (s_isRunningInCI)
7375
{
7476
threadCount = _processorCount * 16;
7577
WaitSpan = TimeSpan.FromSeconds(45);
@@ -136,6 +138,11 @@ protected virtual void TearDown()
136138
{
137139
}
138140

141+
protected bool IsRunningInCI
142+
{
143+
get { return s_isRunningInCI; }
144+
}
145+
139146
internal AutorecoveringConnection CreateAutorecoveringConnection(IList<string> hostnames)
140147
{
141148
return CreateAutorecoveringConnection(RecoveryInterval, hostnames);
@@ -285,31 +292,32 @@ protected void HandleChannelShutdown(IChannel ch, ShutdownEventArgs args, Action
285292
}
286293
}
287294

288-
private static int GetConnectionIdx()
289-
{
290-
return Interlocked.Increment(ref _connectionIdx);
291-
}
292-
293-
private static bool IsRunningInCI()
295+
private static void InitIsRunningInCI()
294296
{
295-
bool ci = false;
296-
297+
bool ci;
297298
if (bool.TryParse(Environment.GetEnvironmentVariable("CI"), out ci))
298299
{
299300
if (ci == true)
300301
{
301-
return ci;
302+
s_isRunningInCI = true;
302303
}
303304
}
304305
else if (bool.TryParse(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"), out ci))
305306
{
306307
if (ci == true)
307308
{
308-
return ci;
309+
s_isRunningInCI = true;
309310
}
310311
}
312+
else
313+
{
314+
s_isRunningInCI = false;
315+
}
316+
}
311317

312-
return ci;
318+
private static int GetConnectionIdx()
319+
{
320+
return Interlocked.Increment(ref _connectionIdx);
313321
}
314322

315323
protected static string GetUniqueString(ushort length)

projects/Test/Integration/TestConsumerOperationDispatch.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class TestConsumerOperationDispatch : IntegrationFixture
4646
// number of messages to be published
4747
private const int N = 100;
4848

49-
private static readonly CountdownEvent counter = new CountdownEvent(Y);
49+
private static readonly CountdownEvent s_counter = new CountdownEvent(Y);
5050

5151
private const string _x = "dotnet.tests.consumer-operation-dispatch.fanout";
5252
private readonly List<IChannel> _channels = new List<IChannel>();
@@ -68,7 +68,7 @@ protected override void TearDown()
6868
}
6969
}
7070

71-
counter.Reset();
71+
s_counter.Reset();
7272
}
7373

7474
private class CollectingConsumer : DefaultBasicConsumer
@@ -92,7 +92,7 @@ public override void HandleBasicDeliver(string consumerTag,
9292

9393
if (deliveryTag == N)
9494
{
95-
counter.Signal();
95+
s_counter.Signal();
9696
}
9797

9898
Channel.BasicAck(deliveryTag: deliveryTag, multiple: false);
@@ -121,7 +121,14 @@ public void TestDeliveryOrderingWithSingleChannel()
121121
_channel.BasicPublish(_x, "", _encoding.GetBytes("msg"));
122122
}
123123

124-
counter.Wait(TimeSpan.FromMinutes(2));
124+
if (IsRunningInCI)
125+
{
126+
s_counter.Wait(TimeSpan.FromMinutes(5));
127+
}
128+
else
129+
{
130+
s_counter.Wait(TimeSpan.FromMinutes(2));
131+
}
125132

126133
foreach (CollectingConsumer cons in _consumers)
127134
{

0 commit comments

Comments
 (0)