Skip to content

Commit 82ae95f

Browse files
author
Simon MacMullen
committed
Merge bug23463
2 parents db71e27 + d288098 commit 82ae95f

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

test/src/com/rabbitmq/client/test/server/MemoryAlarms.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ protected void releaseResources() throws IOException {
6565
channel.queueDelete(Q);
6666
}
6767

68-
protected void setMemoryAlarm() throws IOException, InterruptedException {
69-
Host.executeCommand("cd ../rabbitmq-test; make set-memory-alarm");
68+
protected void setResourceAlarm(String source) throws IOException, InterruptedException {
69+
Host.executeCommand("cd ../rabbitmq-test; make set-resource-alarm SOURCE=" + source);
7070
}
7171

72-
protected void clearMemoryAlarm() throws IOException, InterruptedException {
73-
Host.executeCommand("cd ../rabbitmq-test; make clear-memory-alarm");
72+
protected void clearResourceAlarm(String source) throws IOException, InterruptedException {
73+
Host.executeCommand("cd ../rabbitmq-test; make clear-resource-alarm SOURCE=" + source);
7474
}
7575

7676
public void testFlowControl() throws IOException, InterruptedException {
7777
basicPublishVolatile(Q);
78-
setMemoryAlarm();
78+
setResourceAlarm("memory");
7979
// non-publish actions only after an alarm should be fine
8080
assertNotNull(basicGet(Q));
8181
QueueingConsumer c = new QueueingConsumer(channel);
@@ -86,12 +86,34 @@ public void testFlowControl() throws IOException, InterruptedException {
8686
// by heartbeat (3x heartbeat interval + epsilon)
8787
assertNull(c.nextDelivery(3100));
8888
// once the alarm has cleared the publishes should go through
89-
clearMemoryAlarm();
89+
clearResourceAlarm("memory");
9090
assertNotNull(c.nextDelivery());
9191
// everything should be back to normal
9292
channel.basicCancel(consumerTag);
9393
basicPublishVolatile(Q);
9494
assertNotNull(basicGet(Q));
9595
}
9696

97+
98+
public void testOverlappingAlarmsFlowControl() throws IOException, InterruptedException {
99+
QueueingConsumer c = new QueueingConsumer(channel);
100+
String consumerTag = channel.basicConsume(Q, true, c);
101+
102+
setResourceAlarm("memory");
103+
basicPublishVolatile(Q);
104+
105+
assertNull(c.nextDelivery(100));
106+
setResourceAlarm("disk");
107+
assertNull(c.nextDelivery(100));
108+
clearResourceAlarm("memory");
109+
assertNull(c.nextDelivery(100));
110+
clearResourceAlarm("disk");
111+
assertNotNull(c.nextDelivery());
112+
113+
channel.basicCancel(consumerTag);
114+
basicPublishVolatile(Q);
115+
assertNotNull(basicGet(Q));
116+
}
117+
118+
97119
}

0 commit comments

Comments
 (0)