Skip to content

Commit c04d6b3

Browse files
author
Emile Joubert
committed
Relaxed test timing for slower hardware
1 parent 7ecb0c1 commit c04d6b3

File tree

3 files changed

+140
-134
lines changed

3 files changed

+140
-134
lines changed

projects/client/Unit/src/unit/IntegrationFixture.cs renamed to projects/client/Unit/src/unit/Fixtures.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@ public void Dispose()
6363
Conn.Close();
6464
}
6565
}
66+
67+
public class TimingFixture
68+
{
69+
public static readonly int TimingInterval = 200;
70+
public static readonly int SafetyMargin = 50;
71+
}
6672
}

projects/client/Unit/src/unit/TestBlockingCell.cs

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
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-2011 VMware, 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 VMware, Inc.
38-
// Copyright (c) 2007-2011 VMware, Inc. All rights reserved.
39-
//---------------------------------------------------------------------------
40-
41-
using NUnit.Framework;
42-
43-
using System;
44-
using System.IO;
45-
using System.Collections;
46-
using System.Threading;
47-
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-2011 VMware, 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 VMware, Inc.
38+
// Copyright (c) 2007-2011 VMware, Inc. All rights reserved.
39+
//---------------------------------------------------------------------------
40+
41+
using NUnit.Framework;
42+
43+
using System;
44+
using System.IO;
45+
using System.Collections;
46+
using System.Threading;
47+
4848
using RabbitMQ.Util;
4949

5050
namespace RabbitMQ.Client.Unit
5151
{
5252
[TestFixture]
53-
public class TestBlockingCell
53+
public class TestBlockingCell : TimingFixture
5454
{
5555
public class DelayedSetter
5656
{
@@ -101,8 +101,8 @@ public void TestTimeoutShort()
101101

102102
ResetTimer();
103103
object v;
104-
bool r = k.GetValue(250, out v);
105-
Assert.Greater(50, ElapsedMs());
104+
bool r = k.GetValue(TimingInterval, out v);
105+
Assert.Greater(SafetyMargin, ElapsedMs());
106106
Assert.IsTrue(r);
107107
Assert.AreEqual(123, v);
108108
}
@@ -114,8 +114,8 @@ public void TestTimeoutLong()
114114

115115
ResetTimer();
116116
object v;
117-
bool r = k.GetValue(250, out v);
118-
Assert.Greater(ElapsedMs(), 200);
117+
bool r = k.GetValue(TimingInterval, out v);
118+
Assert.Less(TimingInterval - SafetyMargin, ElapsedMs());
119119
Assert.IsTrue(!r);
120120
Assert.AreEqual(null, v);
121121
}
@@ -128,7 +128,7 @@ public void TestTimeoutNegative()
128128
ResetTimer();
129129
object v;
130130
bool r = k.GetValue(-10000, out v);
131-
Assert.Greater(50, ElapsedMs());
131+
Assert.Greater(SafetyMargin, ElapsedMs());
132132
Assert.IsTrue(!r);
133133
Assert.AreEqual(null, v);
134134
}
@@ -137,12 +137,12 @@ public void TestTimeoutNegative()
137137
public void TestTimeoutInfinite()
138138
{
139139
BlockingCell k = new BlockingCell();
140-
SetAfter(250, k, 123);
140+
SetAfter(TimingInterval, k, 123);
141141

142142
ResetTimer();
143143
object v;
144144
bool r = k.GetValue(Timeout.Infinite, out v);
145-
Assert.Greater(ElapsedMs(), 200);
145+
Assert.Less(TimingInterval - SafetyMargin, ElapsedMs());
146146
Assert.IsTrue(r);
147147
Assert.AreEqual(123, v);
148148
}
@@ -151,12 +151,12 @@ public void TestTimeoutInfinite()
151151
public void TestBgShort()
152152
{
153153
BlockingCell k = new BlockingCell();
154-
SetAfter(50, k, 123);
154+
SetAfter(TimingInterval, k, 123);
155155

156156
ResetTimer();
157157
object v;
158-
bool r = k.GetValue(100, out v);
159-
Assert.Greater(ElapsedMs(), 40);
158+
bool r = k.GetValue(TimingInterval * 2, out v);
159+
Assert.Less( TimingInterval - SafetyMargin, ElapsedMs());
160160
Assert.IsTrue(r);
161161
Assert.AreEqual(123, v);
162162
}
@@ -165,12 +165,12 @@ public void TestBgShort()
165165
public void TestBgLong()
166166
{
167167
BlockingCell k = new BlockingCell();
168-
SetAfter(150, k, 123);
168+
SetAfter(TimingInterval * 2, k, 123);
169169

170170
ResetTimer();
171171
object v;
172-
bool r = k.GetValue(100, out v);
173-
Assert.Greater(110, ElapsedMs());
172+
bool r = k.GetValue(TimingInterval, out v);
173+
Assert.Greater(TimingInterval + SafetyMargin, ElapsedMs());
174174
Assert.IsTrue(!r);
175175
Assert.AreEqual(null, v);
176176
}

0 commit comments

Comments
 (0)