Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void checkContainers() throws InterruptedException {
DeleteContainerRequest record = new DeleteContainerRequest(containerPath);
Request request = new Request(null, 0, 0, ZooDefs.OpCode.deleteContainer, RequestRecord.fromRecord(record), null);
try {
LOG.info("Attempting to delete candidate container: {}", containerPath);
LOG.debug("Attempting to delete candidate container: {}", containerPath);
postDeleteRequest(request);
} catch (Exception e) {
LOG.error("Could not delete container: {}", containerPath, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import java.io.IOException;
import java.time.Duration;
import java.util.Arrays;
Expand All @@ -50,6 +54,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.slf4j.LoggerFactory;

public class CreateContainerTest extends ClientBase {

Expand Down Expand Up @@ -147,6 +152,39 @@ public void testSimpleDeletion() throws KeeperException, InterruptedException {
assertNull(zk.exists("/foo", false), "Container should have been deleted");
}

@Test
@Timeout(value = 30)
public void testCandidateContainerDeletionIsLoggedAtDebugLevel() throws Exception {
Logger logger = (Logger) LoggerFactory.getLogger(ContainerManager.class);
Level originalLevel = logger.getLevel();
ListAppender<ILoggingEvent> appender = new ListAppender<>();
appender.start();
logger.addAppender(appender);
logger.setLevel(Level.DEBUG);

try {
zk.create("/foo", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.CONTAINER);
zk.create("/foo/bar", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
zk.delete("/foo/bar", -1);

ContainerManager containerManager = new ContainerManager(
serverFactory.getZooKeeperServer().getZKDatabase(),
serverFactory.getZooKeeperServer().firstProcessor,
1,
100);
containerManager.checkContainers();

assertTrue(completedContainerDeletions.tryAcquire(1, TimeUnit.SECONDS));
assertTrue(appender.list.stream().anyMatch(event ->
event.getLevel() == Level.DEBUG
&& event.getFormattedMessage().equals("Attempting to delete candidate container: /foo")));
} finally {
logger.detachAppender(appender);
logger.setLevel(originalLevel);
appender.stop();
}
}

@Test
@Timeout(value = 30)
public void testMultiWithContainerSimple() throws KeeperException, InterruptedException {
Expand Down