Skip to content

Commit a506f97

Browse files
author
Steve Powell
committed
Restart primary node app instead of secondary node.
1 parent c74168b commit a506f97

File tree

3 files changed

+13
-49
lines changed

3 files changed

+13
-49
lines changed

src/com/rabbitmq/client/impl/ValueWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public final void writeTable(Map<String, Object> table)
107107
out.writeInt(0);
108108
} else {
109109
out.writeInt((int)Frame.tableSize(table));
110-
for(Map.Entry<String,Object> entry: table.entrySet()) {
110+
for(Map.Entry<String,Object> entry: table.entrySet()) {
111111
writeShortstr(entry.getKey());
112112
Object value = entry.getValue();
113113
writeFieldValue(value);

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

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818
package com.rabbitmq.client.test.server;
1919

2020
import java.io.IOException;
21-
import java.util.HashMap;
2221

2322
import com.rabbitmq.client.AMQP;
2423
import com.rabbitmq.client.Channel;
25-
import com.rabbitmq.client.Connection;
26-
import com.rabbitmq.client.ConnectionFactory;
2724
import com.rabbitmq.client.test.BrokerTestCase;
2825
import com.rabbitmq.tools.Host;
2926

@@ -32,63 +29,30 @@
3229
* (following the scenarios given in bug 20578).
3330
*/
3431
public class ExclusiveQueueDurability extends BrokerTestCase {
35-
private Channel secondaryChannel;
36-
private Connection secondaryConnection;
3732

38-
HashMap<String, Object> noArgs = new HashMap<String, Object>();
39-
40-
void verifyQueueMissing(Channel channel, String queueName)
41-
throws IOException {
33+
void verifyQueueMissing(Channel channel, String queueName)
34+
throws IOException {
4235
try {
43-
channel.queueDeclare(queueName, false, false, false, null);
36+
channel.queueDeclare(queueName, true, true, false, null);
4437
} catch (IOException ioe) {
4538
checkShutdownSignal(AMQP.RESOURCE_LOCKED, ioe);
4639
fail("Declaring the queue resulted in a channel exception, probably meaning that it already exists");
4740
}
4841
}
4942

50-
@Override
51-
protected void createResources() throws IOException {
52-
super.createResources();
53-
openChannel();
54-
55-
}
56-
57-
// TODO extract some commonality between this and DurableBindingLifecycle
58-
public void openChannel()
59-
throws IOException
60-
{
61-
Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node");
62-
ConnectionFactory cf2 = connectionFactory.clone();
63-
cf2.setHost("localhost");
64-
cf2.setPort(5673);
65-
secondaryConnection = cf2.newConnection();
66-
secondaryChannel = secondaryConnection.createChannel();
67-
}
68-
69-
@Override
70-
protected void releaseResources() throws IOException {
71-
secondaryChannel.abort();
72-
secondaryChannel = null;
73-
secondaryConnection.abort();
74-
secondaryConnection = null;
75-
super.releaseResources();
76-
}
77-
7843
// 1) connection and queue are on same node, node restarts -> queue
7944
// should no longer exist
8045
public void testConnectionQueueSameNode() throws Exception {
81-
secondaryChannel.queueDeclare("scenario1", true, true, false, noArgs);
82-
restartAbruptly();
83-
verifyQueueMissing(secondaryChannel, "scenario1");
46+
channel.queueDeclare("scenario1", true, true, false, null);
47+
restartPrimaryAbruptly();
48+
verifyQueueMissing(channel, "scenario1");
8449
}
8550

86-
protected void restartAbruptly() throws IOException {
87-
secondaryConnection.abort();
88-
secondaryConnection = null;
89-
secondaryChannel = null;
90-
Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node");
91-
openChannel();
51+
private void restartPrimaryAbruptly() throws IOException {
52+
connection = null;
53+
channel = null;
54+
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
55+
setUp();
9256
}
9357

9458
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class MessageRecovery extends ConfirmBase
2424

2525
private final static String Q = "recovery-test";
2626

27-
public void test() throws IOException, InterruptedException {
27+
public void testMessageRecovery() throws IOException, InterruptedException {
2828
channel.queueDeclare(Q, true, false, false, null);
2929
publish("", Q, true, false, false);
3030
waitAcks();

0 commit comments

Comments
 (0)