Skip to content

Commit dfe8ede

Browse files
committed
Use rabbitmqctl to command secondary node
Not make. (cherry picked from commit 41635af)
1 parent 87a9fea commit dfe8ede

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.InputStream;
2323
import java.io.InputStreamReader;
2424
import java.util.ArrayList;
25-
import java.util.Arrays;
2625
import java.util.List;
2726

2827
import com.rabbitmq.client.Connection;
@@ -142,6 +141,10 @@ public static void stopRabbitOnNode() throws IOException {
142141
}
143142

144143
public static void tryConnectFor(int timeoutInMs) throws IOException {
144+
tryConnectFor(timeoutInMs, node_portA() == null ? 5672 : Integer.valueOf(node_portA()));
145+
}
146+
147+
public static void tryConnectFor(int timeoutInMs, int port) throws IOException {
145148
int waitTime = 100;
146149
int totalWaitTime = 0;
147150
while (totalWaitTime <= timeoutInMs) {
@@ -152,6 +155,7 @@ public static void tryConnectFor(int timeoutInMs) throws IOException {
152155
}
153156
totalWaitTime += waitTime;
154157
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
158+
connectionFactory.setPort(port);
155159
try (Connection ignored = connectionFactory.newConnection()) {
156160
return;
157161

0 commit comments

Comments
 (0)