Skip to content

Commit 2d74335

Browse files
author
Matthew Sackman
committed
Merging bug 22862 onto default
2 parents afff448 + 7637048 commit 2d74335

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

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

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@
3535
import java.util.HashMap;
3636

3737
import com.rabbitmq.client.Channel;
38+
import com.rabbitmq.client.Connection;
39+
import com.rabbitmq.client.ConnectionFactory;
40+
import com.rabbitmq.client.test.BrokerTestCase;
41+
import com.rabbitmq.tools.Host;
3842

3943
/**
4044
* This tests whether exclusive, durable queues are deleted when appropriate
4145
* (following the scenarios given in bug 20578).
4246
*/
43-
public class ExclusiveQueueDurability extends RestartBase {
47+
public class ExclusiveQueueDurability extends BrokerTestCase {
48+
private Channel secondaryChannel;
49+
private Connection secondaryConnection;
4450

4551
HashMap<String, Object> noArgs = new HashMap<String, Object>();
4652

@@ -54,12 +60,47 @@ void verifyQueueMissing(Channel channel, String queueName)
5460
}
5561
}
5662

63+
@Override
64+
protected void createResources() throws IOException {
65+
super.createResources();
66+
openChannel();
67+
68+
}
69+
70+
// TODO extract some commonality between this and DurableBindingLifecycle
71+
public void openChannel()
72+
throws IOException
73+
{
74+
ConnectionFactory cf2 = connectionFactory.clone();
75+
cf2.setHost("localhost");
76+
cf2.setPort(5673);
77+
secondaryConnection = cf2.newConnection();
78+
secondaryChannel = secondaryConnection.createChannel();
79+
}
80+
81+
@Override
82+
protected void releaseResources() throws IOException {
83+
secondaryChannel.abort();
84+
secondaryChannel = null;
85+
secondaryConnection.abort();
86+
secondaryConnection = null;
87+
super.releaseResources();
88+
}
89+
5790
// 1) connection and queue are on same node, node restarts -> queue
5891
// should no longer exist
5992
public void testConnectionQueueSameNode() throws Exception {
60-
channel.queueDeclare("scenario1", true, true, false, noArgs);
93+
secondaryChannel.queueDeclare("scenario1", true, true, false, noArgs);
6194
restartAbruptly();
62-
verifyQueueMissing(channel, "scenario1");
95+
verifyQueueMissing(secondaryChannel, "scenario1");
96+
}
97+
98+
protected void restartAbruptly() throws IOException {
99+
secondaryConnection.abort();
100+
secondaryConnection = null;
101+
secondaryChannel = null;
102+
Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node");
103+
openChannel();
63104
}
64105

65106
/*

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,10 @@
3535

3636
import java.io.IOException;
3737

38-
import com.rabbitmq.client.GetResponse;
39-
import com.rabbitmq.client.MessageProperties;
4038
import com.rabbitmq.tools.Host;
4139

4240
public class RestartBase extends BrokerTestCase
4341
{
44-
45-
// The time in ms the RabbitMQ persister waits before flushing the
46-
// persister log
47-
//
48-
// This matches the value of LOG_BUNDLE_DELAY in
49-
// rabbit_persister.erl
50-
protected static final int PERSISTER_DELAY = 5;
51-
52-
// The number of entries that the RabbitMQ persister needs to
53-
// write before it takes a snapshot.
54-
//
55-
// This matches the value of MAX_WRAP_ENTRIES in
56-
// rabbit_persister.erl
57-
protected final int PERSISTER_SNAPSHOT_THRESHOLD = 500;
58-
5942
protected void restart()
6043
throws IOException
6144
{
@@ -64,19 +47,9 @@ protected void restart()
6447
setUp();
6548
}
6649

67-
protected void restartAbruptly()
68-
throws IOException
69-
{
70-
Host.executeCommand("cd ../rabbitmq-test; make restart-node");
71-
// we do this so that setUp will reconnect
72-
connection = null;
73-
setUp();
74-
}
75-
7650
protected void forceSnapshot()
7751
throws IOException, InterruptedException
7852
{
7953
Host.executeCommand("cd ../rabbitmq-test; make force-snapshot");
8054
}
81-
8255
}

0 commit comments

Comments
 (0)