Skip to content
Merged
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 @@ -159,7 +159,7 @@ void deleteOnHost(final URL url)
lookupCoordinatorManagerConfig.getHostDeleteTimeout()
).get()) {
// 404 is ok here, that means it was already deleted
if (!httpStatusIsSuccess(returnCode.get()) || !httpStatusIsNotFound(returnCode.get())) {
if (!httpStatusIsSuccess(returnCode.get()) && !httpStatusIsNotFound(returnCode.get())) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
StreamUtils.copyAndClose(result, baos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.util.concurrent.SettableFuture;
import com.metamx.common.ISE;
import com.metamx.common.StringUtils;
import com.metamx.emitter.core.Event;
import com.metamx.emitter.core.LoggingEmitter;
import com.metamx.emitter.service.ServiceEmitter;
import com.metamx.http.client.HttpClient;
Expand All @@ -40,13 +41,13 @@
import io.druid.query.lookup.LookupModule;
import io.druid.server.listener.announcer.ListenerDiscoverer;
import io.druid.server.listener.resource.ListenerResource;
import io.druid.server.lookup.cache.LookupCoordinatorManager;
import io.druid.server.lookup.cache.LookupCoordinatorManagerConfig;
import org.easymock.EasyMock;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.joda.time.Duration;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -62,6 +63,7 @@
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;

public class LookupCoordinatorManagerTest
Expand Down Expand Up @@ -89,12 +91,38 @@ public class LookupCoordinatorManagerTest
SINGLE_LOOKUP_MAP
);
private static final Map<String, Map<String, Map<String, Object>>> EMPTY_TIERED_LOOKUP = (Map<String, Map<String, Map<String, Object>>>) ImmutableMap.<String, Map<String, Map<String, Object>>>of();
private static final AtomicLong EVENT_EMITS = new AtomicLong(0L);
private static ServiceEmitter SERVICE_EMITTER;

@BeforeClass
public static void setUpStatic()
{
final LoggingEmitter loggingEmitter = EasyMock.createNiceMock(LoggingEmitter.class);
com.metamx.emitter.EmittingLogger.registerEmitter(new ServiceEmitter("", "", loggingEmitter));
LoggingEmitter loggingEmitter = EasyMock.createNiceMock(LoggingEmitter.class);
EasyMock.replay(loggingEmitter);
SERVICE_EMITTER = new ServiceEmitter("", "", loggingEmitter)
{
@Override
public void emit(Event event)
{
EVENT_EMITS.incrementAndGet();
super.emit(event);
}
};
com.metamx.emitter.EmittingLogger.registerEmitter(SERVICE_EMITTER);
}

@Before
public void setUp() throws IOException
{
SERVICE_EMITTER.flush();
EVENT_EMITS.set(0L);
}

@After
public void tearDown() throws IOException
{
SERVICE_EMITTER.flush();
Assert.assertEquals(0, EVENT_EMITS.get());
}

@Test
Expand Down Expand Up @@ -431,6 +459,9 @@ void updateAllOnHost(final URL url, Map<String, Map<String, Object>> updatedLook
};
// Should log and pass io exception
manager.updateAllOnTier(LOOKUP_TIER, SINGLE_LOOKUP_MAP);
SERVICE_EMITTER.flush();
Assert.assertEquals(1, EVENT_EMITS.get());
EVENT_EMITS.set(0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this happens in setUp so should not be necessary here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for tearDown when it checks that there are 0 events.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok

}

@Test
Expand Down