Skip to content

Commit 53d5fea

Browse files
committed
Use rabbitmqctl to manipulate alarms in tests
Avoid using make and depending on the umbrella. (cherry picked from commit 9dc2a6a)
1 parent 846500b commit 53d5fea

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,17 @@ protected void deleteQueues(String [] queues) throws IOException {
320320
}
321321
}
322322

323-
protected void clearAllResourceAlarms() throws IOException, InterruptedException {
323+
protected void clearAllResourceAlarms() throws IOException {
324324
clearResourceAlarm("memory");
325325
clearResourceAlarm("disk");
326326
}
327327

328-
protected void setResourceAlarm(String source) throws IOException, InterruptedException {
329-
Host.invokeMakeTarget("set-resource-alarm SOURCE=" + source);
328+
protected void setResourceAlarm(String source) throws IOException {
329+
Host.setResourceAlarm(source);
330330
}
331331

332-
protected void clearResourceAlarm(String source) throws IOException, InterruptedException {
333-
Host.invokeMakeTarget("clear-resource-alarm SOURCE=" + source);
332+
protected void clearResourceAlarm(String source) throws IOException {
333+
Host.clearResourceAlarm(source);
334334
}
335335

336336
protected void block() throws IOException, InterruptedException {

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void setUp() throws IOException, TimeoutException {
4747

4848
@Override
4949
public void tearDown() throws IOException, TimeoutException {
50+
clearAllResourceAlarms();
5051
if (channel2 != null) {
5152
channel2.abort();
5253
channel2 = null;
@@ -66,13 +67,7 @@ protected void createResources() throws IOException {
6667

6768
@Override
6869
protected void releaseResources() throws IOException {
69-
try {
70-
clearAllResourceAlarms();
71-
} catch (InterruptedException e) {
72-
e.printStackTrace();
73-
} finally {
74-
channel.queueDelete(Q);
75-
}
70+
channel.queueDelete(Q);
7671
}
7772

7873
@Test public void flowControl() throws IOException, InterruptedException {

src/test/java/com/rabbitmq/tools/Host.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ public static Process rabbitmqctlIgnoreErrors(String command) throws IOException
109109
" " + command);
110110
}
111111

112+
public static void setResourceAlarm(String source) throws IOException {
113+
rabbitmqctl("eval 'rabbit_alarm:set_alarm({{resource_limit, " + source + ", node()}, []}).'");
114+
}
115+
116+
public static void clearResourceAlarm(String source) throws IOException {
117+
rabbitmqctl("eval 'rabbit_alarm:clear_alarm({resource_limit, " + source + ", node()}).'");
118+
}
119+
112120
public static Process invokeMakeTarget(String command) throws IOException {
113121
File rabbitmqctl = new File(rabbitmqctlCommand());
114122
return executeCommand(makeCommand() +

0 commit comments

Comments
 (0)