Fixes to JDBCExtractionNamespaceTest

This commit is contained in:
Charles Allen 2016-01-04 09:18:35 -08:00
parent 43e7523474
commit 957646be2c
2 changed files with 26 additions and 28 deletions

View File

@ -363,7 +363,7 @@ public abstract class NamespaceExtractionCacheManager
tasksStarted.incrementAndGet(); tasksStarted.incrementAndGet();
final String newVersion = runnable.call(); final String newVersion = runnable.call();
if (preVersion != null && preVersion.equals(newVersion)) { if (preVersion != null && preVersion.equals(newVersion)) {
throw new IllegalStateException("Already exists"); throw new CancellationException(String.format("Version `%s` already exists", preVersion));
} }
if (newVersion != null) { if (newVersion != null) {
lastVersion.put(namespaceName, newVersion); lastVersion.put(namespaceName, newVersion);
@ -379,6 +379,9 @@ public abstract class NamespaceExtractionCacheManager
} else { } else {
log.error(t, "Failed update namespace [%s]", namespace); log.error(t, "Failed update namespace [%s]", namespace);
} }
if(Thread.currentThread().isInterrupted()) {
throw Throwables.propagate(t);
}
} }
} }
}; };

View File

@ -140,33 +140,29 @@ public class JDBCExtractionNamespaceTest
); );
handle.createStatement(String.format("TRUNCATE TABLE %s", tableName)).setQueryTimeout(1).execute(); handle.createStatement(String.format("TRUNCATE TABLE %s", tableName)).setQueryTimeout(1).execute();
handle.commit(); handle.commit();
closer.register( closer.register(new Closeable()
new Closeable() {
{ @Override
@Override public void close() throws IOException
public void close() throws IOException {
{ handle.createStatement("DROP TABLE " + tableName).setQueryTimeout(1).execute();
// Register first so it gets run last and checks for cleanup handle.close();
final NamespaceExtractionCacheManager.NamespaceImplData implData = }
extractionCacheManager.implData.get(namespace); });
if (implData != null && implData.future != null) { closer.register(new Closeable()
implData.future.cancel(true); {
Assert.assertTrue(implData.future.isDone()); @Override
} public void close() throws IOException
} {
// Register first so it gets run last and checks for cleanup
final NamespaceExtractionCacheManager.NamespaceImplData implData = extractionCacheManager.implData.get(
namespace);
if (implData != null && implData.future != null) {
implData.future.cancel(true);
Assert.assertTrue(implData.future.isDone());
} }
); }
closer.register( });
new Closeable()
{
@Override
public void close() throws IOException
{
handle.createStatement("DROP TABLE " + tableName).setQueryTimeout(1).execute();
handle.close();
}
}
);
for (Map.Entry<String, String> entry : renames.entrySet()) { for (Map.Entry<String, String> entry : renames.entrySet()) {
try { try {
insertValues(entry.getKey(), entry.getValue(), "2015-01-01 00:00:00"); insertValues(entry.getKey(), entry.getValue(), "2015-01-01 00:00:00");
@ -427,7 +423,6 @@ public class JDBCExtractionNamespaceTest
assertUpdated(extractionNamespace.getNamespace(), "foo", "bar"); assertUpdated(extractionNamespace.getNamespace(), "foo", "bar");
} }
@Ignore // https://github.com/druid-io/druid/issues/2160
@Test(timeout = 60_000L) @Test(timeout = 60_000L)
public void testFindNew() public void testFindNew()
throws NoSuchFieldException, IllegalAccessException, ExecutionException, InterruptedException throws NoSuchFieldException, IllegalAccessException, ExecutionException, InterruptedException