Skip to content

Commit 7beb472

Browse files
committed
Add logging to topic permissions test
Test tends to hang on CI. (cherry picked from commit f2e5a24)
1 parent e0c389f commit 7beb472

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,45 @@
2525
import java.io.IOException;
2626
import java.util.concurrent.Callable;
2727
import java.util.concurrent.TimeoutException;
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
2830

2931
import static org.junit.Assert.fail;
3032

3133
public class TopicPermissions extends BrokerTestCase {
3234

35+
private static final Logger LOGGER = LoggerFactory.getLogger(TopicPermissions.class);
36+
3337
String protectedTopic = "protected.topic";
3438
String notProtectedTopic = "not.protected.topic";
3539
String noneTopicExchange = "not.a.topic";
3640

3741
@Override
3842
protected boolean shouldRun() throws IOException {
43+
LOGGER.debug("Checking if test should run");
3944
return Host.isRabbitMqCtlCommandAvailable("set_topic_permissions");
4045
}
4146

4247
@Override
4348
protected void createResources() throws IOException, TimeoutException {
49+
LOGGER.debug("Creating AMQP resources");
4450
channel.exchangeDeclare(protectedTopic, BuiltinExchangeType.TOPIC);
4551
channel.exchangeDeclare(notProtectedTopic, BuiltinExchangeType.TOPIC);
4652
channel.exchangeDeclare(noneTopicExchange, BuiltinExchangeType.DIRECT);
4753

54+
LOGGER.debug("Setting permissions");
4855
Host.rabbitmqctl("set_topic_permissions -p / guest " + protectedTopic + " \"^{username}\" \"^{username}\"");
4956
Host.rabbitmqctl("set_topic_permissions -p / guest " + noneTopicExchange + " \"^{username}\" \"^{username}\"");
5057
}
5158

5259
@Override
5360
protected void releaseResources() throws IOException {
61+
LOGGER.debug("Deleting AMQP resources");
5462
channel.exchangeDelete(protectedTopic);
5563
channel.exchangeDelete(notProtectedTopic);
5664
channel.exchangeDelete(noneTopicExchange);
5765

66+
LOGGER.debug("Clearing permissions");
5867
Host.rabbitmqctl("clear_topic_permissions -p / guest");
5968
}
6069

@@ -107,14 +116,18 @@ public void topicPermissions() throws IOException {
107116
}
108117

109118
void assertAccessOk(String description, Callable<Void> action) {
119+
LOGGER.debug("Running '" + description + "'");
110120
try {
111121
action.call();
112122
} catch(Exception e) {
113123
fail(description + " (" + e.getMessage()+")");
124+
} finally {
125+
LOGGER.debug("'" + description + "' done");
114126
}
115127
}
116128

117129
void assertAccessRefused(String description, Callable<Void> action) throws IOException {
130+
LOGGER.debug("Running '" + description + "'");
118131
try {
119132
action.call();
120133
fail(description);
@@ -126,6 +139,8 @@ void assertAccessRefused(String description, Callable<Void> action) throws IOExc
126139
openChannel();
127140
} catch(Exception e) {
128141
fail("Unexpected exception: " + e.getMessage());
142+
} finally {
143+
LOGGER.debug("'" + description + "' done");
129144
}
130145
}
131146
}

src/test/resources/logback-test.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</appender>
77

88
<logger name="com.rabbitmq.client.test.BrokerTestCase" level="info" />
9+
<logger name="com.rabbitmq.client.test.server.TopicPermissions" level="debug" />
910

1011
<root level="warn">
1112
<appender-ref ref="STDOUT" />

0 commit comments

Comments
 (0)