Skip to content

Commit 09d03be

Browse files
committed
Disable global QoS tests for RabbitMQ 4.3 and more
Global QoS denied in RabbitMQ 4.3. References rabbitmq/rabbitmq-server#15460
1 parent 1071c9b commit 09d03be

2 files changed

Lines changed: 49 additions & 16 deletions

File tree

src/test/java/com/rabbitmq/client/test/TestUtils.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.concurrent.CountDownLatch;
3939
import java.util.concurrent.TimeUnit;
4040
import java.util.concurrent.TimeoutException;
41+
import java.util.function.BiFunction;
4142
import java.util.function.Function;
4243
import java.util.function.Supplier;
4344
import org.assertj.core.api.Assertions;
@@ -490,13 +491,17 @@ public static void safeDelete(Connection connection, String queue) {
490491
}
491492
}
492493

493-
private static class BaseBrokerVersionAtLeastCondition
494+
private static class BaseBrokerVersionCondition
494495
implements org.junit.jupiter.api.extension.ExecutionCondition {
495496

496497
private final Function<ExtensionContext, String> versionProvider;
498+
private final BiFunction<String, String, Boolean> versionEvaluator;
497499

498-
private BaseBrokerVersionAtLeastCondition(Function<ExtensionContext, String> versionProvider) {
500+
private BaseBrokerVersionCondition(
501+
Function<ExtensionContext, String> versionProvider,
502+
BiFunction<String, String, Boolean> versionEvaluator) {
499503
this.versionProvider = versionProvider;
504+
this.versionEvaluator = versionEvaluator;
500505
}
501506

502507
@Override
@@ -523,7 +528,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
523528
},
524529
String.class);
525530

526-
if (atLeastVersion(expectedVersion, brokerVersion)) {
531+
if (versionEvaluator.apply(expectedVersion, brokerVersion)) {
527532
return ConditionEvaluationResult.enabled(
528533
"Broker version requirement met, expected "
529534
+ expectedVersion
@@ -540,23 +545,29 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
540545
}
541546
}
542547

543-
private static class AnnotationBrokerVersionAtLeastCondition
544-
extends BaseBrokerVersionAtLeastCondition {
548+
private static class AnnotationBrokerVersionAtLeastCondition extends BaseBrokerVersionCondition {
545549

546550
private AnnotationBrokerVersionAtLeastCondition() {
547551
super(
548552
context -> {
549553
BrokerVersionAtLeast annotation =
550554
context.getElement().get().getAnnotation(BrokerVersionAtLeast.class);
551555
return annotation == null ? null : annotation.value().toString();
552-
});
556+
},
557+
TestUtils::atLeastVersion);
553558
}
554559
}
555560

556-
static class BrokerVersionAtLeast310Condition extends BaseBrokerVersionAtLeastCondition {
561+
private static class AnnotationBrokerVersionAtMostCondition extends BaseBrokerVersionCondition {
557562

558-
private BrokerVersionAtLeast310Condition() {
559-
super(context -> "3.10.0");
563+
private AnnotationBrokerVersionAtMostCondition() {
564+
super(
565+
context -> {
566+
BrokerVersionAtMost annotation =
567+
context.getElement().get().getAnnotation(BrokerVersionAtMost.class);
568+
return annotation == null ? null : annotation.value().toString();
569+
},
570+
TestUtils::atMostVersion);
560571
}
561572
}
562573

@@ -569,10 +580,20 @@ private BrokerVersionAtLeast310Condition() {
569580
BrokerVersion value();
570581
}
571582

583+
@Target({ElementType.TYPE, ElementType.METHOD})
584+
@Retention(RetentionPolicy.RUNTIME)
585+
@Documented
586+
@ExtendWith(AnnotationBrokerVersionAtMostCondition.class)
587+
public @interface BrokerVersionAtMost {
588+
589+
BrokerVersion value();
590+
}
591+
572592
public enum BrokerVersion {
573593
RABBITMQ_3_8("3.8.0"),
574594
RABBITMQ_3_10("3.10.0"),
575-
RABBITMQ_4_0("4.0.0");
595+
RABBITMQ_4_0("4.0.0"),
596+
RABBITMQ_4_2("4.2.0");
576597

577598
final String value;
578599

src/test/java/com/rabbitmq/client/test/functional/QosTests.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.rabbitmq.client.test.functional;
1818

19+
import static com.rabbitmq.client.test.TestUtils.BrokerVersion.RABBITMQ_4_2;
1920
import static org.junit.jupiter.api.Assertions.assertNotNull;
2021
import static org.junit.jupiter.api.Assertions.assertNull;
2122
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -31,6 +32,7 @@
3132
import java.util.Map;
3233
import java.util.concurrent.TimeoutException;
3334

35+
import com.rabbitmq.client.test.TestUtils.BrokerVersionAtMost;
3436
import org.junit.jupiter.api.Test;
3537

3638
import com.rabbitmq.client.AMQP;
@@ -70,9 +72,7 @@ public void fill(int n)
7072
* receive n messages - check that we receive no fewer and cannot
7173
* receive more
7274
**/
73-
public static List<Delivery> drain(QueueingConsumer c, int n)
74-
throws IOException
75-
{
75+
public static List<Delivery> drain(QueueingConsumer c, int n) {
7676
List<Delivery> res = new LinkedList<Delivery>();
7777
try {
7878
long start = System.currentTimeMillis();
@@ -90,9 +90,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
9090
return res;
9191
}
9292

93-
@Test public void messageLimitPrefetchSizeFails()
94-
throws IOException
95-
{
93+
@Test public void messageLimitPrefetchSizeFails() {
9694
try {
9795
channel.basicQos(1000, 0, false);
9896
fail("basic.qos{pretfetch_size=NonZero} should not be supported");
@@ -101,6 +99,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
10199
}
102100
}
103101

102+
@BrokerVersionAtMost(RABBITMQ_4_2)
104103
@Test public void messageLimitUnlimited()
105104
throws IOException
106105
{
@@ -109,6 +108,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
109108
drain(c, 2);
110109
}
111110

111+
@BrokerVersionAtMost(RABBITMQ_4_2)
112112
@Test public void noAckNoAlterLimit()
113113
throws IOException
114114
{
@@ -119,6 +119,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
119119
drain(c, 2);
120120
}
121121

122+
@BrokerVersionAtMost(RABBITMQ_4_2)
122123
@Test public void noAckObeysLimit()
123124
throws IOException
124125
{
@@ -142,6 +143,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
142143
drain(c2, 1);
143144
}
144145

146+
@BrokerVersionAtMost(RABBITMQ_4_2)
145147
@Test public void permutations()
146148
throws IOException
147149
{
@@ -159,6 +161,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
159161
}
160162
}
161163

164+
@BrokerVersionAtMost(RABBITMQ_4_2)
162165
@Test public void fairness()
163166
throws IOException
164167
{
@@ -188,6 +191,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
188191

189192
}
190193

194+
@BrokerVersionAtMost(RABBITMQ_4_2)
191195
@Test public void singleChannelAndQueueFairness()
192196
throws IOException
193197
{
@@ -237,6 +241,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
237241
assertTrue(counts.get("c2").intValue() > 0);
238242
}
239243

244+
@BrokerVersionAtMost(RABBITMQ_4_2)
240245
@Test public void consumerLifecycle()
241246
throws IOException
242247
{
@@ -258,6 +263,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
258263
channel.queueDelete(queue);
259264
}
260265

266+
@BrokerVersionAtMost(RABBITMQ_4_2)
261267
@Test public void setLimitAfterConsume()
262268
throws IOException
263269
{
@@ -273,6 +279,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
273279
drain(c, 1);
274280
}
275281

282+
@BrokerVersionAtMost(RABBITMQ_4_2)
276283
@Test public void limitIncrease()
277284
throws IOException
278285
{
@@ -282,6 +289,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
282289
drain(c, 1);
283290
}
284291

292+
@BrokerVersionAtMost(RABBITMQ_4_2)
285293
@Test public void limitDecrease()
286294
throws IOException
287295
{
@@ -293,6 +301,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
293301
drain(c, 1);
294302
}
295303

304+
@BrokerVersionAtMost(RABBITMQ_4_2)
296305
@Test public void limitedToUnlimited()
297306
throws IOException
298307
{
@@ -302,6 +311,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
302311
drain(c, 2);
303312
}
304313

314+
@BrokerVersionAtMost(RABBITMQ_4_2)
305315
@Test public void limitingMultipleChannels()
306316
throws IOException
307317
{
@@ -326,6 +336,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
326336
ch2.abort();
327337
}
328338

339+
@BrokerVersionAtMost(RABBITMQ_4_2)
329340
@Test public void limitInheritsUnackedCount()
330341
throws IOException
331342
{
@@ -338,6 +349,7 @@ public static List<Delivery> drain(QueueingConsumer c, int n)
338349
drain(c, 1);
339350
}
340351

352+
@BrokerVersionAtMost(RABBITMQ_4_2)
341353
@Test public void recoverReducesLimit() throws Exception {
342354
channel.basicQos(2, true);
343355
QueueingConsumer c = new QueueingConsumer(channel);

0 commit comments

Comments
 (0)