This is an automated email from the ASF dual-hosted git repository. mwalch pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push: new e26532a Fixes several ITs that are broken (#921) e26532a is described below commit e26532a022574551f8c76869e8eb9f878b524a5a Author: Mike Walch <mwa...@apache.org> AuthorDate: Sun Jan 27 09:08:51 2019 -0500 Fixes several ITs that are broken (#921) * Hadoop config cannot be pulled from ServerContext if it has it has been constructed yet * Remove usages of scanner after it has been closed --- .../miniclusterImpl/MiniAccumuloClusterImpl.java | 2 +- .../apache/accumulo/test/ScanFlushWithTimeIT.java | 6 +--- .../accumulo/test/functional/ConcurrencyIT.java | 37 ++++++++++------------ .../org/apache/accumulo/test/functional/SslIT.java | 4 +-- .../test/functional/SslWithClientAuthIT.java | 4 +-- .../test/functional/WriteAheadLogEncryptedIT.java | 2 +- 6 files changed, 21 insertions(+), 34 deletions(-) diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java index db402f2..5037f35 100644 --- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java +++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java @@ -408,7 +408,7 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster { siteConfig.put(Property.INSTANCE_DFS_DIR.getKey(), "/accumulo"); config.setSiteConfig(siteConfig); } else if (config.useExistingInstance()) { - dfsUri = getServerContext().getHadoopConf().get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY); + dfsUri = config.getHadoopConfiguration().get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY); } else { dfsUri = "file:///"; } diff --git a/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java b/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java index deff587..c31246e 100644 --- a/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java +++ b/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java @@ -94,11 +94,7 @@ public class ScanFlushWithTimeIT extends AccumuloClusterHarness { private void testScanner(ScannerBase s, long expected) { long now = System.currentTimeMillis(); - try { - s.iterator().next(); - } finally { - s.close(); - } + s.iterator().next(); long diff = System.currentTimeMillis() - now; log.info("Diff = {}", diff); assertTrue("Scanner taking too long to return intermediate results: " + diff, diff < expected); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java index 20afa56..50613a9 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java @@ -24,14 +24,10 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.client.AccumuloClient; -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.BatchWriterConfig; import org.apache.accumulo.core.client.IteratorSetting; -import org.apache.accumulo.core.client.MutationsRejectedException; import org.apache.accumulo.core.client.Scanner; -import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Mutation; @@ -51,26 +47,27 @@ public class ConcurrencyIT extends AccumuloClusterHarness { static class ScanTask extends Thread { int count = 0; - Scanner scanner = null; + AccumuloClient client; + String tableName; + long time; + + ScanTask(AccumuloClient client, String tableName, long time) { + this.client = client; + this.tableName = tableName; + this.time = time; + } - ScanTask(AccumuloClient client, String tableName, long time) throws Exception { - try { - scanner = client.createScanner(tableName, Authorizations.EMPTY); + @Override + public void run() { + try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) { IteratorSetting slow = new IteratorSetting(30, "slow", SlowIterator.class); SlowIterator.setSleepTime(slow, time); scanner.addScanIterator(slow); - } finally { - if (scanner != null) { - scanner.close(); - } + count = Iterators.size(scanner.iterator()); + } catch (TableNotFoundException e) { + throw new IllegalStateException(e); } } - - @Override - public void run() { - count = Iterators.size(scanner.iterator()); - } - } @Override @@ -103,9 +100,7 @@ public class ConcurrencyIT extends AccumuloClusterHarness { } } - static void runTest(AccumuloClient c, String tableName) - throws AccumuloException, AccumuloSecurityException, TableExistsException, - TableNotFoundException, MutationsRejectedException, Exception, InterruptedException { + static void runTest(AccumuloClient c, String tableName) throws Exception { c.tableOperations().create(tableName); IteratorSetting is = new IteratorSetting(10, SlowIterator.class); SlowIterator.setSleepTime(is, 50); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SslIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SslIT.java index d07265a..aa17e75 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/SslIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/SslIT.java @@ -17,8 +17,6 @@ package org.apache.accumulo.test.functional; import org.apache.accumulo.core.client.AccumuloClient; -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; @@ -43,7 +41,7 @@ public class SslIT extends ConfigurableMacBase { } @Test - public void binary() throws AccumuloException, AccumuloSecurityException, Exception { + public void binary() throws Exception { try (AccumuloClient client = createClient()) { String tableName = getUniqueNames(1)[0]; client.tableOperations().create(tableName); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SslWithClientAuthIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SslWithClientAuthIT.java index 8c893c0..844aded 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/SslWithClientAuthIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/SslWithClientAuthIT.java @@ -18,8 +18,6 @@ package org.apache.accumulo.test.functional; import java.util.Map; -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; import org.apache.hadoop.conf.Configuration; @@ -46,7 +44,7 @@ public class SslWithClientAuthIT extends SslIT { @Override @Test - public void binary() throws AccumuloException, AccumuloSecurityException, Exception { + public void binary() throws Exception { super.binary(); } diff --git a/test/src/main/java/org/apache/accumulo/test/functional/WriteAheadLogEncryptedIT.java b/test/src/main/java/org/apache/accumulo/test/functional/WriteAheadLogEncryptedIT.java index ab6bdaf..19b7121 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/WriteAheadLogEncryptedIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/WriteAheadLogEncryptedIT.java @@ -48,7 +48,7 @@ public class WriteAheadLogEncryptedIT extends AccumuloClusterHarness { // setup key file try { Path keyFile = new Path(keyPath); - FileSystem fs = FileSystem.getLocal(cluster.getServerContext().getHadoopConf()); + FileSystem fs = FileSystem.getLocal(new Configuration()); fs.delete(keyFile, true); if (fs.createNewFile(keyFile)) log.info("Created keyfile at {}", keyPath);