Skip to content

Commit f026d13

Browse files
Add a flood publishing test
Investigating odd framing errors reported on the mailing list.
1 parent 1fbf0bb commit f026d13

File tree

2 files changed

+92
-6
lines changed

2 files changed

+92
-6
lines changed

projects/client/Unit/RabbitMQ.Client.Unit.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
<AssemblyName>unit-tests</AssemblyName>
1717
<TargetFrameworkVersion>$(PropTargetFramework)</TargetFrameworkVersion>
1818
<FileAlignment>512</FileAlignment>
19-
<FileUpgradeFlags>
20-
</FileUpgradeFlags>
21-
<UpgradeBackupLocation>
22-
</UpgradeBackupLocation>
23-
<OldToolsVersion>3.5</OldToolsVersion>
2419
</PropertyGroup>
2520
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2621
<DebugSymbols>true</DebugSymbols>
@@ -110,7 +105,8 @@
110105
<Compile Include="src\unit\TestExtensions.cs" />
111106
<Compile Include="src\unit\TestFieldTableFormatting.cs" />
112107
<Compile Include="src\unit\TestFieldTableFormattingGeneric.cs" />
113-
<Compile Include="src\unit\TestHeartbeats.cs" />
108+
<Compile Include="src\unit\TestFloodPublishing.cs" />
109+
<Compile Include="src\unit\TestHeartbeats.cs" />
114110
<Compile Include="src\unit\TestIntAllocator.cs" />
115111
<Compile Include="src\unit\TestInvalidAck.cs" />
116112
<Compile Include="src\unit\TestMainLoop.cs" />
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// This source code is dual-licensed under the Apache License, version
2+
// 2.0, and the Mozilla Public License, version 1.1.
3+
//
4+
// The APL v2.0:
5+
//
6+
//---------------------------------------------------------------------------
7+
// Copyright (C) 2007-2014 GoPivotal, Inc.
8+
//
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// http://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
//---------------------------------------------------------------------------
21+
//
22+
// The MPL v1.1:
23+
//
24+
//---------------------------------------------------------------------------
25+
// The contents of this file are subject to the Mozilla Public License
26+
// Version 1.1 (the "License"); you may not use this file except in
27+
// compliance with the License. You may obtain a copy of the License
28+
// at http://www.mozilla.org/MPL/
29+
//
30+
// Software distributed under the License is distributed on an "AS IS"
31+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
32+
// the License for the specific language governing rights and
33+
// limitations under the License.
34+
//
35+
// The Original Code is RabbitMQ.
36+
//
37+
// The Initial Developer of the Original Code is GoPivotal, Inc.
38+
// Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
39+
//---------------------------------------------------------------------------
40+
41+
using NUnit.Framework;
42+
43+
using System;
44+
using System.Collections.Generic;
45+
using System.Threading;
46+
using System.Timers;
47+
using RabbitMQ.Client.Exceptions;
48+
49+
namespace RabbitMQ.Client.Unit
50+
{
51+
[TestFixture]
52+
public class TestFloodPublishing : IntegrationFixture
53+
{
54+
[SetUp]
55+
public override void Init()
56+
{
57+
var connFactory = new ConnectionFactory()
58+
{
59+
RequestedHeartbeat = 60,
60+
AutomaticRecoveryEnabled = false
61+
};
62+
Conn = connFactory.CreateConnection();
63+
Model = Conn.CreateModel();
64+
}
65+
66+
[Test, Category("LongRunning")]
67+
public void TestUnthrottledFloodPublishing()
68+
{
69+
Conn.ConnectionShutdown += (_, args) =>
70+
{
71+
if (args.Initiator != ShutdownInitiator.Application)
72+
{
73+
Assert.Fail("Unexpected connection shutdown!");
74+
}
75+
};
76+
77+
bool elapsed = false;
78+
var t = new System.Timers.Timer(1000 * 65);
79+
t.Elapsed += (_sender, _args) => { elapsed = true; };
80+
t.AutoReset = false;
81+
t.Start();
82+
83+
while (!elapsed)
84+
{
85+
Model.BasicPublish("", "", null, encoding.GetBytes("msg"));
86+
}
87+
Assert.IsTrue(Conn.IsOpen);
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)