Skip to content

Commit b7df26b

Browse files
committed
Use rabbitmqctl to command secondary node
Not make. (cherry picked from commit 41635af) Conflicts: src/test/java/com/rabbitmq/tools/Host.java
1 parent c16776b commit b7df26b

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,15 @@ public void closeConnection() throws IOException {
124124
}
125125

126126
protected void stopSecondary() throws IOException {
127-
Host.invokeMakeTarget("stop-rabbit-on-node RABBITMQ_NODENAME=\'" + Host.nodenameB() + "\'");
127+
Host.executeCommand(Host.rabbitmqctlCommand() +
128+
" -n \'" + Host.nodenameB() + "\'" +
129+
" stop_app");
128130
}
129131

130132
protected void startSecondary() throws IOException {
131-
Host.invokeMakeTarget("start-rabbit-on-node RABBITMQ_NODENAME=\'" + Host.nodenameB() + "\'");
133+
Host.executeCommand(Host.rabbitmqctlCommand() +
134+
" -n \'" + Host.nodenameB() + "\'" +
135+
" start_app");
136+
Host.tryConnectFor(10_000, Host.node_portB() == null ? 5673 : Integer.valueOf(Host.node_portB()));
132137
}
133138
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import com.rabbitmq.client.GetResponse;
2828
import com.rabbitmq.client.test.functional.BindingLifecycleBase;
29-
import com.rabbitmq.tools.Host;
3029

3130
/**
3231
* This tests whether bindings are created and nuked properly.
@@ -47,13 +46,8 @@ protected void restart() throws IOException, TimeoutException {
4746
alternateConnection = null;
4847
alternateChannel = null;
4948

50-
Host.invokeMakeTarget(
51-
"stop-node" +
52-
" start-background-broker" +
53-
" RABBITMQ_NODENAME=\'" + Host.nodenameB() + "\'" +
54-
" RABBITMQ_NODE_PORT=" + Host.node_portB() +
55-
" RABBITMQ_CONFIG_FILE=\'" + Host.config_fileB() + "\'"
56-
);
49+
stopSecondary();
50+
startSecondary();
5751
}
5852
restartPrimary();
5953
}

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
package com.rabbitmq.tools;
1818

1919
import java.io.BufferedReader;
20-
import java.io.File;
2120
import java.io.IOException;
2221
import java.io.InputStream;
2322
import java.io.InputStreamReader;
2423
import java.util.ArrayList;
25-
import java.util.Arrays;
2624
import java.util.List;
2725

2826
import com.rabbitmq.client.Connection;
@@ -121,17 +119,6 @@ public static void clearResourceAlarm(String source) throws IOException {
121119
rabbitmqctl("eval 'rabbit_alarm:clear_alarm({resource_limit, " + source + ", node()}).'");
122120
}
123121

124-
public static Process invokeMakeTarget(String command) throws IOException {
125-
File rabbitmqctl = new File(rabbitmqctlCommand());
126-
return executeCommand(makeCommand() +
127-
" -C \'" + rabbitmqDir() + "\'" +
128-
" RABBITMQCTL=\'" + rabbitmqctl.getAbsolutePath() + "\'" +
129-
" RABBITMQ_NODENAME=\'" + nodenameA() + "\'" +
130-
" RABBITMQ_NODE_PORT=" + node_portA() +
131-
" RABBITMQ_CONFIG_FILE=\'" + config_fileA() + "\'" +
132-
" " + command);
133-
}
134-
135122
public static void startRabbitOnNode() throws IOException {
136123
rabbitmqctl("start_app");
137124
tryConnectFor(10 * 1000);
@@ -142,6 +129,10 @@ public static void stopRabbitOnNode() throws IOException {
142129
}
143130

144131
public static void tryConnectFor(int timeoutInMs) throws IOException {
132+
tryConnectFor(timeoutInMs, node_portA() == null ? 5672 : Integer.valueOf(node_portA()));
133+
}
134+
135+
public static void tryConnectFor(int timeoutInMs, int port) throws IOException {
145136
int waitTime = 100;
146137
int totalWaitTime = 0;
147138
while (totalWaitTime <= timeoutInMs) {
@@ -152,6 +143,7 @@ public static void tryConnectFor(int timeoutInMs) throws IOException {
152143
}
153144
totalWaitTime += waitTime;
154145
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
146+
connectionFactory.setPort(port);
155147
Connection c = null;
156148
try {
157149
c = connectionFactory.newConnection();

0 commit comments

Comments
 (0)