Skip to content

Commit 853d1b0

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 (cherry picked from commit 09d03be)
1 parent 6ea0f21 commit 853d1b0

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;
@@ -501,13 +502,17 @@ public static void safeDelete(Connection connection, String queue) {
501502
}
502503
}
503504

504-
private static class BaseBrokerVersionAtLeastCondition
505+
private static class BaseBrokerVersionCondition
505506
implements org.junit.jupiter.api.extension.ExecutionCondition {
506507

507508
private final Function<ExtensionContext, String> versionProvider;
509+
private final BiFunction<String, String, Boolean> versionEvaluator;
508510

509-
private BaseBrokerVersionAtLeastCondition(Function<ExtensionContext, String> versionProvider) {
511+
private BaseBrokerVersionCondition(
512+
Function<ExtensionContext, String> versionProvider,
513+
BiFunction<String, String, Boolean> versionEvaluator) {
510514
this.versionProvider = versionProvider;
515+
this.versionEvaluator = versionEvaluator;
511516
}
512517

513518
@Override
@@ -534,7 +539,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
534539
},
535540
String.class);
536541

537-
if (atLeastVersion(expectedVersion, brokerVersion)) {
542+
if (versionEvaluator.apply(expectedVersion, brokerVersion)) {
538543
return ConditionEvaluationResult.enabled(
539544
"Broker version requirement met, expected "
540545
+ expectedVersion
@@ -551,23 +556,29 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
551556
}
552557
}
553558

554-
private static class AnnotationBrokerVersionAtLeastCondition
555-
extends BaseBrokerVersionAtLeastCondition {
559+
private static class AnnotationBrokerVersionAtLeastCondition extends BaseBrokerVersionCondition {
556560

557561
private AnnotationBrokerVersionAtLeastCondition() {
558562
super(
559563
context -> {
560564
BrokerVersionAtLeast annotation =
561565
context.getElement().get().getAnnotation(BrokerVersionAtLeast.class);
562566
return annotation == null ? null : annotation.value().toString();
563-
});
567+
},
568+
TestUtils::atLeastVersion);
564569
}
565570
}
566571

567-
static class BrokerVersionAtLeast310Condition extends BaseBrokerVersionAtLeastCondition {
572+
private static class AnnotationBrokerVersionAtMostCondition extends BaseBrokerVersionCondition {
568573

569-
private BrokerVersionAtLeast310Condition() {
570-
super(context -> "3.10.0");
574+
private AnnotationBrokerVersionAtMostCondition() {
575+
super(
576+
context -> {
577+
BrokerVersionAtMost annotation =
578+
context.getElement().get().getAnnotation(BrokerVersionAtMost.class);
579+
return annotation == null ? null : annotation.value().toString();
580+
},
581+
TestUtils::atMostVersion);
571582
}
572583
}
573584

@@ -580,10 +591,20 @@ private BrokerVersionAtLeast310Condition() {
580591
BrokerVersion value();
581592
}
582593

594+
@Target({ElementType.TYPE, ElementType.METHOD})
595+
@Retention(RetentionPolicy.RUNTIME)
596+
@Documented
597+
@ExtendWith(AnnotationBrokerVersionAtMostCondition.class)
598+
public @interface BrokerVersionAtMost {
599+
600+
BrokerVersion value();
601+
}
602+
583603
public enum BrokerVersion {
584604
RABBITMQ_3_8("3.8.0"),
585605
RABBITMQ_3_10("3.10.0"),
586-
RABBITMQ_4_0("4.0.0");
606+
RABBITMQ_4_0("4.0.0"),
607+
RABBITMQ_4_2("4.2.0");
587608

588609
final String value;
589610

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)