You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2015/03/03 20:15:29 UTC
[3/4] accumulo git commit: ACCUMULO-3599 Refactor tests to run over
MAC using Kerberos
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/ArbitraryTablePropertiesIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ArbitraryTablePropertiesIT.java b/test/src/test/java/org/apache/accumulo/test/ArbitraryTablePropertiesIT.java
index 4481934..4d0260c 100644
--- a/test/src/test/java/org/apache/accumulo/test/ArbitraryTablePropertiesIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ArbitraryTablePropertiesIT.java
@@ -17,19 +17,17 @@
package org.apache.accumulo.test;
import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.accumulo.cluster.ClusterUser;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.security.tokens.KerberosToken;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.harness.SharedMiniClusterIT;
import org.apache.log4j.Logger;
import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
import org.junit.Test;
public class ArbitraryTablePropertiesIT extends SharedMiniClusterIT {
@@ -40,11 +38,6 @@ public class ArbitraryTablePropertiesIT extends SharedMiniClusterIT {
return 30;
};
- @Before
- public void checkNoKerberos() {
- Assume.assumeFalse(getToken() instanceof KerberosToken);
- }
-
// Test set, get, and remove arbitrary table properties on the root account
@Test
public void setGetRemoveTablePropertyRoot() throws Exception {
@@ -102,15 +95,15 @@ public class ArbitraryTablePropertiesIT extends SharedMiniClusterIT {
log.debug("Starting userSetGetRemoveTablePropertyWithPermission test ------------------------");
// Make a test username and password
- String testUser = makeUserName();
- PasswordToken testPasswd = new PasswordToken("test_password");
+ ClusterUser user = getUser(0);
+ String testUser = user.getPrincipal();
+ AuthenticationToken testToken = user.getToken();
// Create a root user and create the table
// Create a test user and grant that user permission to alter the table
final String tableName = getUniqueNames(1)[0];
final Connector c = getConnector();
- c.securityOperations().createLocalUser(testUser, testPasswd);
- Connector conn = c.getInstance().getConnector(testUser, testPasswd);
+ c.securityOperations().createLocalUser(testUser, (testToken instanceof PasswordToken ? (PasswordToken) testToken : null));
c.tableOperations().create(tableName);
c.securityOperations().grantTablePermission(testUser, tableName, TablePermission.ALTER_TABLE);
@@ -120,12 +113,15 @@ public class ArbitraryTablePropertiesIT extends SharedMiniClusterIT {
// Make sure the property name is valid
Assert.assertTrue(Property.isValidPropertyKey(propertyName));
+
+ // Getting a fresh token will ensure we're logged in as this user (if necessary)
+ Connector testConn = c.getInstance().getConnector(testUser, user.getToken());
// Set the property to the desired value
- conn.tableOperations().setProperty(tableName, propertyName, description1);
+ testConn.tableOperations().setProperty(tableName, propertyName, description1);
// Loop through properties to make sure the new property is added to the list
int count = 0;
- for (Entry<String,String> property : conn.tableOperations().getProperties(tableName)) {
+ for (Entry<String,String> property : testConn.tableOperations().getProperties(tableName)) {
if (property.getKey().equals(propertyName) && property.getValue().equals(description1))
count++;
}
@@ -133,22 +129,22 @@ public class ArbitraryTablePropertiesIT extends SharedMiniClusterIT {
// Set the property as something different
String description2 = "set second";
- conn.tableOperations().setProperty(tableName, propertyName, description2);
+ testConn.tableOperations().setProperty(tableName, propertyName, description2);
// / Loop through properties to make sure the new property is added to the list
count = 0;
- for (Entry<String,String> property : conn.tableOperations().getProperties(tableName)) {
+ for (Entry<String,String> property : testConn.tableOperations().getProperties(tableName)) {
if (property.getKey().equals(propertyName) && property.getValue().equals(description2))
count++;
}
Assert.assertEquals(count, 1);
// Remove the property and make sure there is no longer a value associated with it
- conn.tableOperations().removeProperty(tableName, propertyName);
+ testConn.tableOperations().removeProperty(tableName, propertyName);
// / Loop through properties to make sure the new property is added to the list
count = 0;
- for (Entry<String,String> property : conn.tableOperations().getProperties(tableName)) {
+ for (Entry<String,String> property : testConn.tableOperations().getProperties(tableName)) {
if (property.getKey().equals(propertyName))
count++;
}
@@ -162,15 +158,15 @@ public class ArbitraryTablePropertiesIT extends SharedMiniClusterIT {
log.debug("Starting userSetGetTablePropertyWithoutPermission test ------------------------");
// Make a test username and password
- String testUser = makeUserName();
- PasswordToken testPasswd = new PasswordToken("test_password");
+ ClusterUser user = getUser(1);
+ String testUser = user.getPrincipal();
+ AuthenticationToken testToken = user.getToken();
// Create a root user and create the table
// Create a test user and grant that user permission to alter the table
final String tableName = getUniqueNames(1)[0];
final Connector c = getConnector();
- c.securityOperations().createLocalUser(testUser, testPasswd);
- Connector conn = c.getInstance().getConnector(testUser, testPasswd);
+ c.securityOperations().createLocalUser(testUser, (testToken instanceof PasswordToken ? (PasswordToken) testToken : null));
c.tableOperations().create(tableName);
// Set variables for the property name to use and the initial value
@@ -180,26 +176,22 @@ public class ArbitraryTablePropertiesIT extends SharedMiniClusterIT {
// Make sure the property name is valid
Assert.assertTrue(Property.isValidPropertyKey(propertyName));
+ // Getting a fresh token will ensure we're logged in as this user (if necessary)
+ Connector testConn = c.getInstance().getConnector(testUser, user.getToken());
+
// Try to set the property to the desired value.
// If able to set it, the test fails, since permission was never granted
try {
- conn.tableOperations().setProperty(tableName, propertyName, description1);
+ testConn.tableOperations().setProperty(tableName, propertyName, description1);
Assert.fail("Was able to set property without permissions");
} catch (AccumuloSecurityException e) {}
// Loop through properties to make sure the new property is not added to the list
int count = 0;
- for (Entry<String,String> property : conn.tableOperations().getProperties(tableName)) {
+ for (Entry<String,String> property : testConn.tableOperations().getProperties(tableName)) {
if (property.getKey().equals(propertyName))
count++;
}
Assert.assertEquals(count, 0);
}
-
- static AtomicInteger userId = new AtomicInteger(0);
-
- static String makeUserName() {
- return "user_" + userId.getAndIncrement();
- }
-
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java b/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java
index 62031d5..3272262 100644
--- a/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java
@@ -69,7 +69,7 @@ public class BulkImportVolumeIT extends AccumuloClusterIT {
TableOperations to = getConnector().tableOperations();
to.create(tableName);
FileSystem fs = getFileSystem();
- String rootPath = getUsableDir();
+ Path rootPath = new Path(cluster.getTemporaryPath(), getClass().getName());
Path bulk = new Path(rootPath, "bulk");
log.info("bulk: {}", bulk);
if (fs.exists(bulk)) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java b/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
index bdfbd13..2f2cdf5 100644
--- a/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
@@ -39,6 +39,7 @@ import org.apache.accumulo.minicluster.ServerType;
import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
import org.apache.accumulo.test.functional.FunctionalTestUtils;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.RawLocalFileSystem;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
@@ -56,7 +57,8 @@ public class CleanWalIT extends AccumuloClusterIT {
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
cfg.setProperty(Property.INSTANCE_ZK_TIMEOUT, "3s");
cfg.setNumTservers(1);
- cfg.useMiniDFS(true);
+ // use raw local file system so walogs sync and flush will work
+ hadoopCoreSite.set("fs.file.impl", RawLocalFileSystem.class.getName());
}
@Before
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
index b68870d..8b9926c 100644
--- a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
@@ -37,10 +37,13 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.accumulo.cluster.AccumuloCluster;
+import org.apache.accumulo.cluster.ClusterUser;
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.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
import org.apache.accumulo.core.client.ConditionalWriter;
import org.apache.accumulo.core.client.ConditionalWriter.Result;
import org.apache.accumulo.core.client.ConditionalWriter.Status;
@@ -196,14 +199,26 @@ public class ConditionalWriterIT extends AccumuloClusterIT {
Connector conn = getConnector();
String tableName = getUniqueNames(1)[0];
- String user = getClass().getSimpleName() + "_" + testName.getMethodName();
- conn.securityOperations().createLocalUser(user, new PasswordToken("foo"));
+
+ String user= null;
+ ClientConfiguration clientConf = cluster.getClientConfig();
+ final boolean saslEnabled = clientConf.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false);
+
+ ClusterUser user1 = getUser(0);
+ user = user1.getPrincipal();
+ if (saslEnabled) {
+ // The token is pointless for kerberos
+ conn.securityOperations().createLocalUser(user, null);
+ } else {
+ conn.securityOperations().createLocalUser(user, new PasswordToken(user1.getPassword()));
+ }
Authorizations auths = new Authorizations("A", "B");
conn.securityOperations().changeUserAuthorizations(user, auths);
conn.securityOperations().grantSystemPermission(user, SystemPermission.CREATE_TABLE);
- conn = conn.getInstance().getConnector(user, new PasswordToken("foo"));
+
+ conn = conn.getInstance().getConnector(user, user1.getToken());
conn.tableOperations().create(tableName);
@@ -288,7 +303,7 @@ public class ConditionalWriterIT extends AccumuloClusterIT {
Authorizations auths = new Authorizations("A", "B");
- conn.securityOperations().changeUserAuthorizations("root", auths);
+ conn.securityOperations().changeUserAuthorizations(getAdminPrincipal(), auths);
Authorizations filteredAuths = new Authorizations("A");
@@ -514,7 +529,7 @@ public class ConditionalWriterIT extends AccumuloClusterIT {
conn.tableOperations().create(tableName);
- conn.securityOperations().changeUserAuthorizations("root", new Authorizations("A", "B"));
+ conn.securityOperations().changeUserAuthorizations(getAdminPrincipal(), new Authorizations("A", "B"));
ColumnVisibility cvab = new ColumnVisibility("A|B");
@@ -698,7 +713,7 @@ public class ConditionalWriterIT extends AccumuloClusterIT {
conn.tableOperations().addConstraint(tableName, AlphaNumKeyConstraint.class.getName());
conn.tableOperations().clone(tableName, tableName + "_clone", true, new HashMap<String,String>(), new HashSet<String>());
- conn.securityOperations().changeUserAuthorizations("root", new Authorizations("A", "B"));
+ conn.securityOperations().changeUserAuthorizations(getAdminPrincipal(), new Authorizations("A", "B"));
ColumnVisibility cvaob = new ColumnVisibility("A|B");
ColumnVisibility cvaab = new ColumnVisibility("A&B");
@@ -1035,9 +1050,17 @@ public class ConditionalWriterIT extends AccumuloClusterIT {
public void testSecurity() throws Exception {
// test against table user does not have read and/or write permissions for
Connector conn = getConnector();
- String user = getClass().getSimpleName() + "_" + testName.getMethodName();
-
- conn.securityOperations().createLocalUser(user, new PasswordToken("u1p"));
+ String user = null;
+ ClientConfiguration clientConf = cluster.getClientConfig();
+ final boolean saslEnabled = clientConf.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false);
+
+ ClusterUser user1 = getUser(0);
+ user = user1.getPrincipal();
+ if (saslEnabled) {
+ conn.securityOperations().createLocalUser(user, null);
+ } else {
+ conn.securityOperations().createLocalUser(user, new PasswordToken(user1.getPassword()));
+ }
String[] tables = getUniqueNames(3);
String table1 = tables[0], table2 = tables[1], table3 = tables[2];
@@ -1051,7 +1074,7 @@ public class ConditionalWriterIT extends AccumuloClusterIT {
conn.securityOperations().grantTablePermission(user, table3, TablePermission.READ);
conn.securityOperations().grantTablePermission(user, table3, TablePermission.WRITE);
- Connector conn2 = getConnector().getInstance().getConnector(user, new PasswordToken("u1p"));
+ Connector conn2 = conn.getInstance().getConnector(user, user1.getToken());
ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq"));
cm1.put("tx", "seq", "1");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/ImportExportIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ImportExportIT.java b/test/src/test/java/org/apache/accumulo/test/ImportExportIT.java
index 26a1c46..1472d9f 100644
--- a/test/src/test/java/org/apache/accumulo/test/ImportExportIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ImportExportIT.java
@@ -17,8 +17,6 @@
package org.apache.accumulo.test;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Iterator;
@@ -35,15 +33,16 @@ import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema;
import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.harness.SharedMiniClusterIT;
-import org.apache.commons.io.FileUtils;
+import org.apache.accumulo.harness.AccumuloClusterIT;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.Path;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.io.Files;
-
/**
* ImportTable didn't correctly place absolute paths in metadata. This resulted in the imported table only being usable when the actual HDFS directory for
* Accumulo was the same as Property.INSTANCE_DFS_DIR. If any other HDFS directory was used, any interactions with the table would fail because the relative
@@ -52,8 +51,7 @@ import com.google.common.io.Files;
* ACCUMULO-3215
*
*/
-// TODO Can switch to AccumuloClusterIT when FileSystem access from the Cluster is implemented.
-public class ImportExportIT extends SharedMiniClusterIT {
+public class ImportExportIT extends AccumuloClusterIT {
private static final Logger log = LoggerFactory.getLogger(ImportExportIT.class);
@@ -85,45 +83,48 @@ public class ImportExportIT extends SharedMiniClusterIT {
// Make a directory we can use to throw the export and import directories
// Must exist on the filesystem the cluster is running.
- File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests", getClass().getName());
- baseDir.mkdirs();
- File exportDir = new File(baseDir, "export");
- FileUtils.deleteQuietly(exportDir);
- exportDir.mkdir();
- File importDir = new File(baseDir, "import");
- FileUtils.deleteQuietly(importDir);
- importDir.mkdir();
-
- log.info("Exporting table to {}", exportDir.getAbsolutePath());
- log.info("Importing table from {}", importDir.getAbsolutePath());
+ FileSystem fs = cluster.getFileSystem();
+ Path tmp = cluster.getTemporaryPath();
+ Path baseDir = new Path(tmp, getClass().getName());
+ fs.mkdirs(baseDir);
+ Path exportDir = new Path(baseDir, "export");
+ Path importDir = new Path(baseDir, "import");
+ for (Path p : new Path[] {exportDir, importDir}) {
+ fs.delete(p, true);
+ fs.mkdirs(p);
+ }
+
+ log.info("Exporting table to {}", exportDir);
+ log.info("Importing table from {}", importDir);
// Offline the table
conn.tableOperations().offline(srcTable, true);
// Then export it
- conn.tableOperations().exportTable(srcTable, exportDir.getAbsolutePath());
+ conn.tableOperations().exportTable(srcTable, exportDir.toString());
// Make sure the distcp.txt file that exporttable creates is available
- File distcp = new File(exportDir, "distcp.txt");
- Assert.assertTrue("Distcp file doesn't exist", distcp.exists());
- FileInputStream fis = new FileInputStream(distcp);
- BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
+ Path distcp = new Path(exportDir, "distcp.txt");
+ Assert.assertTrue("Distcp file doesn't exist", fs.exists(distcp));
+ FSDataInputStream is = fs.open(distcp);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
// Copy each file that was exported to the import directory
String line;
while (null != (line = reader.readLine())) {
- File f = new File(line.substring(5));
- Assert.assertTrue("File doesn't exist: " + f, f.exists());
- File dest = new File(importDir, f.getName());
- Assert.assertFalse("Did not expect " + dest + " to exist", dest.exists());
- Files.copy(f, dest);
+ Path p = new Path(line.substring(5));
+ Assert.assertTrue("File doesn't exist: " + p, fs.exists(p));
+
+ Path dest = new Path(importDir, p.getName());
+ Assert.assertFalse("Did not expect " + dest + " to exist", fs.exists(dest));
+ FileUtil.copy(fs, p, fs, dest, false, fs.getConf());
}
reader.close();
- log.info("Import dir: {}", Arrays.toString(importDir.list()));
+ log.info("Import dir: {}", Arrays.toString(fs.listStatus(importDir)));
// Import the exported data into a new table
- conn.tableOperations().importTable(destTable, importDir.getAbsolutePath());
+ conn.tableOperations().importTable(destTable, importDir.toString());
// Get the table ID for the table that the importtable command created
final String tableId = conn.tableOperations().tableIdMap().get(destTable);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/InterruptibleScannersIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/InterruptibleScannersIT.java b/test/src/test/java/org/apache/accumulo/test/InterruptibleScannersIT.java
index 5f9b97a..d06b271 100644
--- a/test/src/test/java/org/apache/accumulo/test/InterruptibleScannersIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/InterruptibleScannersIT.java
@@ -73,7 +73,7 @@ public class InterruptibleScannersIT extends AccumuloClusterIT {
while (iter.hasNext()) {
ActiveScan scan = iter.next();
// Remove scans not against our table and not owned by us
- if (!"root".equals(scan.getUser()) || !tableName.equals(scan.getTable())) {
+ if (!getAdminPrincipal().equals(scan.getUser()) || !tableName.equals(scan.getTable())) {
iter.remove();
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java b/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java
index c5fd08f..ab7e125 100644
--- a/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java
@@ -41,9 +41,9 @@ public class MetaConstraintRetryIT extends AccumuloClusterIT {
@Test(expected = ConstraintViolationException.class)
public void test() throws Exception {
- getConnector().securityOperations().grantTablePermission("root", MetadataTable.NAME, TablePermission.WRITE);
+ getConnector().securityOperations().grantTablePermission(getAdminPrincipal(), MetadataTable.NAME, TablePermission.WRITE);
- Credentials credentials = new Credentials(getPrincipal(), getToken());
+ Credentials credentials = new Credentials(getAdminPrincipal(), getAdminToken());
ClientContext context = new ClientContext(getConnector().getInstance(), credentials, cluster.getClientConfig());
Writer w = new Writer(context, MetadataTable.ID);
KeyExtent extent = new KeyExtent(new Text("5"), null, null);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/MetaSplitIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/MetaSplitIT.java b/test/src/test/java/org/apache/accumulo/test/MetaSplitIT.java
index 754e580..82fbd01 100644
--- a/test/src/test/java/org/apache/accumulo/test/MetaSplitIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/MetaSplitIT.java
@@ -23,57 +23,21 @@ import java.util.TreeSet;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.admin.TableOperations;
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.harness.AccumuloIT;
-import org.apache.accumulo.harness.MiniClusterHarness;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.accumulo.harness.AccumuloClusterIT;
import org.apache.hadoop.io.Text;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
-public class MetaSplitIT extends AccumuloIT {
-
- private MiniAccumuloClusterImpl cluster;
+public class MetaSplitIT extends AccumuloClusterIT {
@Override
public int defaultTimeoutSeconds() {
return 3 * 60;
}
- @Before
- public void startMiniCluster() throws Exception {
- MiniClusterHarness harness = new MiniClusterHarness();
- cluster = harness.create(getToken());
- cluster.getConfig().setNumTservers(1);
- cluster.start();
- }
-
- @After
- public void stopMiniCluster() throws Exception {
- if (null != cluster) {
- cluster.stop();
- }
- }
-
- private Connector getConnector() {
- try {
- return cluster.getConnector("root", getToken());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private AuthenticationToken getToken() {
- return new PasswordToken("rootPassword1");
- }
-
@Test(expected = AccumuloException.class)
public void testRootTableSplit() throws Exception {
TableOperations opts = getConnector().tableOperations();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java b/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java
index e30ef98..d4d0f8a 100644
--- a/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java
@@ -65,7 +65,7 @@ public class MultiTableBatchWriterIT extends AccumuloClusterIT {
}
public MultiTableBatchWriter getMultiTableBatchWriter(long cacheTimeoutInSeconds) {
- ClientContext context = new ClientContext(connector.getInstance(), new Credentials(getPrincipal(), getToken()), getCluster().getClientConfig());
+ ClientContext context = new ClientContext(connector.getInstance(), new Credentials(getAdminPrincipal(), getAdminToken()), getCluster().getClientConfig());
return new MultiTableBatchWriterImpl(context, new BatchWriterConfig(), cacheTimeoutInSeconds, TimeUnit.SECONDS);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java b/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
index ab9eb0f..3fc3b39 100644
--- a/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
@@ -34,6 +35,7 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import org.apache.accumulo.cluster.ClusterUser;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
@@ -56,7 +58,6 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
import org.apache.accumulo.core.client.security.SecurityErrorCode;
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -75,20 +76,17 @@ import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.examples.simple.constraints.NumericValueConstraint;
-import org.apache.accumulo.harness.AccumuloIT;
-import org.apache.accumulo.harness.MiniClusterHarness;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.accumulo.harness.AccumuloClusterIT;
import org.apache.hadoop.io.Text;
import org.junit.After;
+import org.junit.Assume;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
// Testing default namespace configuration with inheritance requires altering the system state and restoring it back to normal
// Punt on this for now and just let it use a minicluster.
-public class NamespacesIT extends AccumuloIT {
+public class NamespacesIT extends AccumuloClusterIT {
- private static MiniAccumuloClusterImpl cluster;
private Connector c;
private String namespace;
@@ -97,28 +95,10 @@ public class NamespacesIT extends AccumuloIT {
return 60;
}
- private static AuthenticationToken getToken() {
- return new PasswordToken("rootPassword1");
- }
-
- private Connector getConnector() {
- try {
- return cluster.getConnector("root", getToken());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @BeforeClass
- public static void setupMiniCluster() throws Exception {
- MiniClusterHarness harness = new MiniClusterHarness();
- cluster = harness.create(getToken());
- cluster.getConfig().setNumTservers(1);
- cluster.start();
- }
-
@Before
public void setupConnectorAndNamespace() throws Exception {
+ Assume.assumeTrue(ClusterType.MINI == getClusterType());
+
// prepare a unique namespace and get a new root connector for each test
c = getConnector();
namespace = "ns_" + getUniqueNames(1)[0];
@@ -136,7 +116,7 @@ public class NamespacesIT extends AccumuloIT {
c.namespaceOperations().delete(n);
assertEquals(2, c.namespaceOperations().list().size());
for (String u : c.securityOperations().listLocalUsers())
- if (!"root".equals(u))
+ if (!getAdminPrincipal().equals(u))
c.securityOperations().dropLocalUser(u);
assertEquals(1, c.securityOperations().listLocalUsers().size());
}
@@ -587,15 +567,20 @@ public class NamespacesIT extends AccumuloIT {
assertFalse(c.tableOperations().exists(t5));
}
+ private void loginAs(ClusterUser user) throws IOException {
+ user.getToken();
+ }
+
/**
* Tests new Namespace permissions as well as modifications to Table permissions because of namespaces. Checks each permission to first make sure the user
* doesn't have permission to perform the action, then root grants them the permission and we check to make sure they could perform the action.
*/
@Test
public void testPermissions() throws Exception {
- String u1 = "u1";
- String u2 = "u2";
- PasswordToken pass = new PasswordToken("pass");
+ ClusterUser user1 = getUser(0), user2 = getUser(1), root = getAdminUser();
+ String u1 = user1.getPrincipal();
+ String u2 = user2.getPrincipal();
+ PasswordToken pass = (null != user1.getPassword() ? new PasswordToken(user1.getPassword()) : null);
String n1 = namespace;
String t1 = n1 + ".1";
@@ -604,12 +589,14 @@ public class NamespacesIT extends AccumuloIT {
String n2 = namespace + "_2";
+ loginAs(root);
c.namespaceOperations().create(n1);
c.tableOperations().create(t1);
c.securityOperations().createLocalUser(u1, pass);
- Connector user1Con = c.getInstance().getConnector(u1, pass);
+ loginAs(user1);
+ Connector user1Con = c.getInstance().getConnector(u1, user1.getToken());
try {
user1Con.tableOperations().create(t2);
@@ -618,11 +605,15 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.CREATE_TABLE);
+ loginAs(user1);
user1Con.tableOperations().create(t2);
+ loginAs(root);
assertTrue(c.tableOperations().list().contains(t2));
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.CREATE_TABLE);
+ loginAs(user1);
try {
user1Con.tableOperations().delete(t1);
fail();
@@ -630,8 +621,11 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.DROP_TABLE);
+ loginAs(user1);
user1Con.tableOperations().delete(t1);
+ loginAs(root);
assertTrue(!c.tableOperations().list().contains(t1));
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.DROP_TABLE);
@@ -642,6 +636,7 @@ public class NamespacesIT extends AccumuloIT {
bw.addMutation(m);
bw.close();
+ loginAs(user1);
Iterator<Entry<Key,Value>> i = user1Con.createScanner(t3, new Authorizations()).iterator();
try {
i.next();
@@ -651,6 +646,7 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied((AccumuloSecurityException) e.getCause());
}
+ loginAs(user1);
m = new Mutation(u1);
m.put("cf", "cq", "turtles");
bw = user1Con.createBatchWriter(t3, null);
@@ -669,19 +665,25 @@ public class NamespacesIT extends AccumuloIT {
}
}
+ loginAs(root);
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.READ);
+ loginAs(user1);
i = user1Con.createScanner(t3, new Authorizations()).iterator();
assertTrue(i.hasNext());
+ loginAs(root);
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.READ);
-
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.WRITE);
+
+ loginAs(user1);
m = new Mutation(u1);
m.put("cf", "cq", "turtles");
bw = user1Con.createBatchWriter(t3, null);
bw.addMutation(m);
bw.close();
+ loginAs(root);
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.WRITE);
+ loginAs(user1);
try {
user1Con.tableOperations().setProperty(t3, Property.TABLE_FILE_MAX.getKey(), "42");
fail();
@@ -689,11 +691,15 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.ALTER_TABLE);
+ loginAs(user1);
user1Con.tableOperations().setProperty(t3, Property.TABLE_FILE_MAX.getKey(), "42");
user1Con.tableOperations().removeProperty(t3, Property.TABLE_FILE_MAX.getKey());
+ loginAs(root);
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.ALTER_TABLE);
+ loginAs(user1);
try {
user1Con.namespaceOperations().setProperty(n1, Property.TABLE_FILE_MAX.getKey(), "55");
fail();
@@ -701,12 +707,17 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.ALTER_NAMESPACE);
+ loginAs(user1);
user1Con.namespaceOperations().setProperty(n1, Property.TABLE_FILE_MAX.getKey(), "42");
user1Con.namespaceOperations().removeProperty(n1, Property.TABLE_FILE_MAX.getKey());
+ loginAs(root);
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.ALTER_NAMESPACE);
- c.securityOperations().createLocalUser(u2, pass);
+ loginAs(root);
+ c.securityOperations().createLocalUser(u2, (root.getPassword() == null ? null : new PasswordToken(user2.getPassword())));
+ loginAs(user1);
try {
user1Con.securityOperations().grantNamespacePermission(u2, n1, NamespacePermission.ALTER_NAMESPACE);
fail();
@@ -714,11 +725,15 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.GRANT);
+ loginAs(user1);
user1Con.securityOperations().grantNamespacePermission(u2, n1, NamespacePermission.ALTER_NAMESPACE);
user1Con.securityOperations().revokeNamespacePermission(u2, n1, NamespacePermission.ALTER_NAMESPACE);
+ loginAs(root);
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.GRANT);
+ loginAs(user1);
try {
user1Con.namespaceOperations().create(n2);
fail();
@@ -726,11 +741,15 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantSystemPermission(u1, SystemPermission.CREATE_NAMESPACE);
+ loginAs(user1);
user1Con.namespaceOperations().create(n2);
+ loginAs(root);
c.securityOperations().revokeSystemPermission(u1, SystemPermission.CREATE_NAMESPACE);
c.securityOperations().revokeNamespacePermission(u1, n2, NamespacePermission.DROP_NAMESPACE);
+ loginAs(user1);
try {
user1Con.namespaceOperations().delete(n2);
fail();
@@ -738,10 +757,14 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantSystemPermission(u1, SystemPermission.DROP_NAMESPACE);
+ loginAs(user1);
user1Con.namespaceOperations().delete(n2);
+ loginAs(root);
c.securityOperations().revokeSystemPermission(u1, SystemPermission.DROP_NAMESPACE);
+ loginAs(user1);
try {
user1Con.namespaceOperations().setProperty(n1, Property.TABLE_FILE_MAX.getKey(), "33");
fail();
@@ -749,9 +772,12 @@ public class NamespacesIT extends AccumuloIT {
expectPermissionDenied(e);
}
+ loginAs(root);
c.securityOperations().grantSystemPermission(u1, SystemPermission.ALTER_NAMESPACE);
+ loginAs(user1);
user1Con.namespaceOperations().setProperty(n1, Property.TABLE_FILE_MAX.getKey(), "33");
user1Con.namespaceOperations().removeProperty(n1, Property.TABLE_FILE_MAX.getKey());
+ loginAs(root);
c.securityOperations().revokeSystemPermission(u1, SystemPermission.ALTER_NAMESPACE);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java b/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java
index 10b8810..b74793a 100644
--- a/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java
@@ -42,6 +42,7 @@ import org.apache.accumulo.minicluster.ServerType;
import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
import org.apache.accumulo.test.functional.FunctionalTestUtils;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.RawLocalFileSystem;
import org.apache.hadoop.io.Text;
import org.junit.Test;
@@ -55,8 +56,8 @@ public class NoMutationRecoveryIT extends AccumuloClusterIT {
@Override
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
- cfg.useMiniDFS(true);
cfg.setNumTservers(1);
+ hadoopCoreSite.set("fs.file.impl", RawLocalFileSystem.class.getName());
}
public boolean equals(Entry<Key,Value> a, Entry<Key,Value> b) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/ScanIteratorIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ScanIteratorIT.java b/test/src/test/java/org/apache/accumulo/test/ScanIteratorIT.java
index 7f22ca9..4a791c0 100644
--- a/test/src/test/java/org/apache/accumulo/test/ScanIteratorIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ScanIteratorIT.java
@@ -17,20 +17,23 @@
package org.apache.accumulo.test;
import static org.junit.Assert.assertEquals;
+
import java.util.Collections;
import java.util.Map;
+import org.apache.accumulo.cluster.ClusterUser;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchScanner;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
import org.apache.accumulo.core.client.Connector;
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.ScannerBase;
-import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.data.Key;
@@ -44,14 +47,13 @@ import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
import org.apache.accumulo.test.functional.AuthsIterator;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
+import org.apache.hadoop.security.UserGroupInformation;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class ScanIteratorIT extends AccumuloClusterIT {
- private static final String USER = "authsItrUser";
-
@Override
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
cfg.setNumTservers(1);
@@ -64,6 +66,8 @@ public class ScanIteratorIT extends AccumuloClusterIT {
private Connector connector;
private String tableName;
+ private String user;
+ private boolean saslEnabled;
@Before
public void setup() throws Exception {
@@ -71,40 +75,51 @@ public class ScanIteratorIT extends AccumuloClusterIT {
tableName = getUniqueNames(1)[0];
connector.tableOperations().create(tableName);
- connector.securityOperations().createLocalUser(USER, new PasswordToken(""));
- connector.securityOperations().grantTablePermission(USER, tableName, TablePermission.READ);
- connector.securityOperations().grantTablePermission(USER, tableName, TablePermission.WRITE);
- connector.securityOperations().changeUserAuthorizations(USER, AuthsIterator.AUTHS);
+ ClientConfiguration clientConfig = cluster.getClientConfig();
+ ClusterUser clusterUser = getUser(0);
+ user = clusterUser.getPrincipal();
+ PasswordToken userToken;
+ if (clientConfig.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false)) {
+ userToken = null;
+ saslEnabled = true;
+ } else {
+ userToken = new PasswordToken(clusterUser.getPassword());
+ saslEnabled = false;
+ }
+ connector.securityOperations().createLocalUser(user, userToken);
+ connector.securityOperations().grantTablePermission(user, tableName, TablePermission.READ);
+ connector.securityOperations().grantTablePermission(user, tableName, TablePermission.WRITE);
+ connector.securityOperations().changeUserAuthorizations(user, AuthsIterator.AUTHS);
}
@After
public void tearDown() throws Exception {
- connector.securityOperations().dropLocalUser(USER);
+ if (null != user) {
+ if (saslEnabled) {
+ ClusterUser rootUser = getAdminUser();
+ UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());
+ }
+ connector.securityOperations().dropLocalUser(user);
+ }
}
@Test
- public void testAuthsPresentInIteratorEnvironment()
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException, TableExistsException, InterruptedException {
-
+ public void testAuthsPresentInIteratorEnvironment() throws Exception {
runTest(AuthsIterator.AUTHS, false);
}
@Test
- public void testAuthsNotPresentInIteratorEnvironment()
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException, TableExistsException, InterruptedException {
-
+ public void testAuthsNotPresentInIteratorEnvironment() throws Exception {
runTest(new Authorizations("B"), true);
}
@Test
- public void testEmptyAuthsInIteratorEnvironment()
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException, TableExistsException, InterruptedException {
-
+ public void testEmptyAuthsInIteratorEnvironment() throws Exception {
runTest(Authorizations.EMPTY, true);
}
- private void runTest(ScannerBase scanner, Authorizations auths, boolean shouldFail)
- throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
+ private void runTest(ScannerBase scanner, Authorizations auths, boolean shouldFail) throws AccumuloSecurityException, AccumuloException,
+ TableNotFoundException {
int count = 0;
for (Map.Entry<Key,Value> entry : scanner) {
assertEquals(shouldFail ? AuthsIterator.FAIL : AuthsIterator.SUCCESS, entry.getKey().getRow().toString());
@@ -114,8 +129,9 @@ public class ScanIteratorIT extends AccumuloClusterIT {
assertEquals(1, count);
}
- private void runTest(Authorizations auths, boolean shouldFail) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
- Connector userC = getCluster().getConnector(USER, new PasswordToken(("")));
+ private void runTest(Authorizations auths, boolean shouldFail) throws Exception {
+ ClusterUser clusterUser = getUser(0);
+ Connector userC = getCluster().getConnector(clusterUser.getPrincipal(), clusterUser.getToken());
writeTestMutation(userC);
IteratorSetting setting = new IteratorSetting(10, AuthsIterator.class);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/ShellConfigIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ShellConfigIT.java b/test/src/test/java/org/apache/accumulo/test/ShellConfigIT.java
index bcfa45c..3903e3e 100644
--- a/test/src/test/java/org/apache/accumulo/test/ShellConfigIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ShellConfigIT.java
@@ -19,37 +19,85 @@ package org.apache.accumulo.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.client.security.tokens.KerberosToken;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.harness.AccumuloClusterIT;
+import org.apache.accumulo.harness.conf.StandaloneAccumuloClusterConfiguration;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
import org.apache.accumulo.test.ShellServerIT.TestShell;
-import org.apache.accumulo.test.functional.ConfigurableMacIT;
-import org.apache.hadoop.conf.Configuration;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-public class ShellConfigIT extends ConfigurableMacIT {
+public class ShellConfigIT extends AccumuloClusterIT {
@Override
public int defaultTimeoutSeconds() {
return 30;
}
- @Override
- public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
- cfg.setProperty(Property.CRYPTO_BLOCK_STREAM_SIZE, "7K");
+ private String origPropValue;
+
+ @Before
+ public void checkProperty() throws Exception {
+ Connector conn = getConnector();
+ // TABLE_VOLUME_CHOOSER is a valid property that can be updated in ZK, whereas the crypto properties are not.
+ // This lets us run this test more generically rather than forcibly needing to update some property in accumulo-site.xml
+ origPropValue = conn.instanceOperations().getSystemConfiguration().get(Property.TABLE_VOLUME_CHOOSER.getKey());
+ conn.instanceOperations().setProperty(Property.TABLE_VOLUME_CHOOSER.getKey(), FairVolumeChooser.class.getName());
+ }
+
+ @After
+ public void resetProperty() throws Exception {
+ if (null != origPropValue) {
+ Connector conn = getConnector();
+ conn.instanceOperations().setProperty(Property.TABLE_VOLUME_CHOOSER.getKey(), origPropValue);
+ }
}
@Test
public void experimentalPropTest() throws Exception {
// ensure experimental props do not show up in config output unless set
- TestShell ts = new TestShell(ROOT_PASSWORD, getCluster().getInstanceName(), getCluster().getZooKeepers(), getCluster().getConfig().getClientConfFile()
- .getAbsolutePath());
+ AuthenticationToken token = getAdminToken();
+ File clientConfFile = null;
+ switch (getClusterType()) {
+ case MINI:
+ MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster();
+ clientConfFile = mac.getConfig().getClientConfFile();
+ break;
+ case STANDALONE:
+ StandaloneAccumuloClusterConfiguration standaloneConf = (StandaloneAccumuloClusterConfiguration) getClusterConfiguration();
+ clientConfFile = standaloneConf.getClientConfFile();
+ break;
+ default:
+ Assert.fail("Unknown cluster type");
+ }
+
+ Assert.assertNotNull(clientConfFile);
+
+ TestShell ts = null;
+ if (token instanceof PasswordToken) {
+ String passwd = new String(((PasswordToken) token).getPassword(), StandardCharsets.UTF_8);
+ ts = new TestShell(getAdminPrincipal(), passwd, getCluster().getInstanceName(), getCluster().getZooKeepers(), clientConfFile);
+ } else if (token instanceof KerberosToken) {
+ ts = new TestShell(getAdminPrincipal(), null, getCluster().getInstanceName(), getCluster().getZooKeepers(), clientConfFile);
+ } else {
+ Assert.fail("Unknown token type");
+ }
- assertTrue(Property.CRYPTO_BLOCK_STREAM_SIZE.isExperimental());
+ assertTrue(Property.TABLE_VOLUME_CHOOSER.isExperimental());
assertTrue(Property.CRYPTO_CIPHER_ALGORITHM_NAME.isExperimental());
String configOutput = ts.exec("config");
- assertTrue(configOutput.contains(Property.CRYPTO_BLOCK_STREAM_SIZE.getKey()));
+ assertTrue(configOutput.contains(Property.TABLE_VOLUME_CHOOSER.getKey()));
assertFalse(configOutput.contains(Property.CRYPTO_CIPHER_ALGORITHM_NAME.getKey()));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
index 72f098f..61f4219 100644
--- a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
@@ -22,7 +22,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -40,12 +42,17 @@ import java.util.Random;
import jline.console.ConsoleReader;
import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.client.impl.Namespaces;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.client.security.tokens.KerberosToken;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -61,6 +68,8 @@ import org.apache.accumulo.test.UserCompactionStrategyIT.TestCompactionStrategy;
import org.apache.accumulo.test.functional.FunctionalTestUtils;
import org.apache.accumulo.test.functional.SlowIterator;
import org.apache.accumulo.tracer.TraceServer;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
@@ -72,6 +81,7 @@ import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -134,14 +144,25 @@ public class ShellServerIT extends SharedMiniClusterIT {
public StringInputStream input;
public Shell shell;
- TestShell(String rootPass, String instanceName, String zookeepers, String configFile) throws IOException {
+ TestShell(String user, String rootPass, String instanceName, String zookeepers, File configFile) throws IOException {
+ ClientConfiguration clientConf;
+ try {
+ clientConf = new ClientConfiguration(new PropertiesConfiguration(configFile));
+ } catch (ConfigurationException e) {
+ throw new IOException(e);
+ }
// start the shell
output = new TestOutputStream();
input = new StringInputStream();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(output));
shell = new Shell(new ConsoleReader(input, output), pw);
shell.setLogErrorsToConsole();
- shell.config("-u", "root", "-p", rootPass, "-z", instanceName, zookeepers, "--config-file", configFile);
+ if (clientConf.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false)) {
+ // Pull the kerberos principal out when we're using SASL
+ shell.config("-u", user, "-z", instanceName, zookeepers, "--config-file", configFile.getAbsolutePath());
+ } else {
+ shell.config("-u", user, "-p", rootPass, "-z", instanceName, zookeepers, "--config-file", configFile.getAbsolutePath());
+ }
exec("quit", true);
shell.start();
shell.setExit(false);
@@ -235,7 +256,7 @@ public class ShellServerIT extends SharedMiniClusterIT {
traceProcess = getCluster().exec(TraceServer.class);
- Connector conn = getCluster().getConnector("root", getToken());
+ Connector conn = getCluster().getConnector(getPrincipal(), getToken());
TableOperations tops = conn.tableOperations();
// give the tracer some time to start
@@ -246,8 +267,8 @@ public class ShellServerIT extends SharedMiniClusterIT {
@Before
public void setupShell() throws Exception {
- ts = new TestShell(getRootPassword(), getCluster().getConfig().getInstanceName(), getCluster().getConfig().getZooKeepers(), getCluster().getConfig()
- .getClientConfFile().getAbsolutePath());
+ ts = new TestShell(getPrincipal(), getRootPassword(), getCluster().getConfig().getInstanceName(), getCluster().getConfig().getZooKeepers(), getCluster()
+ .getConfig().getClientConfFile());
}
@AfterClass
@@ -290,11 +311,41 @@ public class ShellServerIT extends SharedMiniClusterIT {
ts.exec("addsplits row5", true);
ts.exec("config -t " + table + " -s table.split.threshold=345M", true);
ts.exec("offline " + table, true);
- String export = "file://" + new File(rootPath, "ShellServerIT.export").toString();
- ts.exec("exporttable -t " + table + " " + export, true);
+ File exportDir = new File(rootPath, "ShellServerIT.export");
+ String exportUri = "file://" + exportDir.toString();
+ String localTmp = "file://" + new File(rootPath, "ShellServerIT.tmp").toString();
+ ts.exec("exporttable -t " + table + " " + exportUri, true);
DistCp cp = newDistCp();
String import_ = "file://" + new File(rootPath, "ShellServerIT.import").toString();
- cp.run(new String[] {"-f", export + "/distcp.txt", import_});
+ if (getCluster().getClientConfig().getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false)) {
+ // DistCp bugs out trying to get a fs delegation token to perform the cp. Just copy it ourselves by hand.
+ FileSystem fs = getCluster().getFileSystem();
+ FileSystem localFs = FileSystem.getLocal(new Configuration(false));
+
+ // Path on local fs to cp into
+ Path localTmpPath = new Path(localTmp);
+ localFs.mkdirs(localTmpPath);
+
+ // Path in remote fs to importtable from
+ Path importDir = new Path(import_);
+ fs.mkdirs(importDir);
+
+ // Implement a poor-man's DistCp
+ try (BufferedReader reader = new BufferedReader(new FileReader(new File(exportDir, "distcp.txt")))) {
+ for (String line; (line = reader.readLine()) != null;) {
+ Path exportedFile = new Path(line);
+ // There isn't a cp on FileSystem??
+ log.info("Copying " + line + " to " + localTmpPath);
+ fs.copyToLocalFile(exportedFile, localTmpPath);
+ Path tmpFile = new Path(localTmpPath, exportedFile.getName());
+ log.info("Moving " + tmpFile + " to the import directory " + importDir);
+ fs.moveFromLocalFile(tmpFile, importDir);
+ }
+ }
+ } else {
+ String[] distCpArgs = new String[] {"-f", exportUri + "/distcp.txt", import_};
+ assertEquals("Failed to run distcp: " + Arrays.toString(distCpArgs), 0, cp.run(distCpArgs));
+ }
ts.exec("importtable " + table2 + " " + import_, true);
ts.exec("config -t " + table2 + " -np", true, "345M", true);
ts.exec("getsplits -t " + table2, true, "row5", true);
@@ -403,9 +454,12 @@ public class ShellServerIT extends SharedMiniClusterIT {
@Test
public void user() throws Exception {
final String table = name.getMethodName();
+ final boolean kerberosEnabled = getToken() instanceof KerberosToken;
// createuser, deleteuser, user, users, droptable, grant, revoke
- ts.input.set("secret\nsecret\n");
+ if (!kerberosEnabled) {
+ ts.input.set("secret\nsecret\n");
+ }
ts.exec("createuser xyzzy", true);
ts.exec("users", true, "xyzzy", true);
String perms = ts.exec("userpermissions -u xyzzy", true);
@@ -413,19 +467,21 @@ public class ShellServerIT extends SharedMiniClusterIT {
ts.exec("grant -u xyzzy -s System.CREATE_TABLE", true);
perms = ts.exec("userpermissions -u xyzzy", true);
assertTrue(perms.contains(""));
- ts.exec("grant -u root -t " + MetadataTable.NAME + " Table.WRITE", true);
- ts.exec("grant -u root -t " + MetadataTable.NAME + " Table.GOOFY", false);
- ts.exec("grant -u root -s foo", false);
+ ts.exec("grant -u " + getPrincipal() + " -t " + MetadataTable.NAME + " Table.WRITE", true);
+ ts.exec("grant -u " + getPrincipal() + " -t " + MetadataTable.NAME + " Table.GOOFY", false);
+ ts.exec("grant -u " + getPrincipal() + " -s foo", false);
ts.exec("grant -u xyzzy -t " + MetadataTable.NAME + " foo", false);
- ts.input.set("secret\nsecret\n");
- ts.exec("user xyzzy", true);
- ts.exec("createtable " + table, true, "xyzzy@", true);
- ts.exec("insert row1 cf cq 1", true);
- ts.exec("scan", true, "row1", true);
- ts.exec("droptable -f " + table, true);
- ts.exec("deleteuser xyzzy", false, "delete yourself", true);
- ts.input.set(getRootPassword() + "\n" + getRootPassword() + "\n");
- ts.exec("user root", true);
+ if (!kerberosEnabled) {
+ ts.input.set("secret\nsecret\n");
+ ts.exec("user xyzzy", true);
+ ts.exec("createtable " + table, true, "xyzzy@", true);
+ ts.exec("insert row1 cf cq 1", true);
+ ts.exec("scan", true, "row1", true);
+ ts.exec("droptable -f " + table, true);
+ ts.input.set(getRootPassword() + "\n" + getRootPassword() + "\n");
+ ts.exec("user root", true);
+ }
+ ts.exec("deleteuser " + getPrincipal(), false, "delete yourself", true);
ts.exec("revoke -u xyzzy -s System.CREATE_TABLE", true);
ts.exec("revoke -u xyzzy -s System.GOOFY", false);
ts.exec("revoke -u xyzzy -s foo", false);
@@ -1313,6 +1369,8 @@ public class ShellServerIT extends SharedMiniClusterIT {
@Test
public void badLogin() throws Exception {
+ // Can't run with Kerberos, can't switch identity in shell presently
+ Assume.assumeTrue(getToken() instanceof PasswordToken);
ts.input.set(getRootPassword() + "\n");
String err = ts.exec("user NoSuchUser", false);
assertTrue(err.contains("BAD_CREDENTIALS for user NoSuchUser"));
@@ -1415,17 +1473,24 @@ public class ShellServerIT extends SharedMiniClusterIT {
@Test
public void whoami() throws Exception {
- assertTrue(ts.exec("whoami", true).contains("root"));
- ts.input.set("secret\nsecret\n");
+ AuthenticationToken token = getToken();
+ assertTrue(ts.exec("whoami", true).contains(getPrincipal()));
+ // Unnecessary with Kerberos enabled, won't prompt for a password
+ if (token instanceof PasswordToken) {
+ ts.input.set("secret\nsecret\n");
+ }
ts.exec("createuser test_user");
ts.exec("setauths -u test_user -s 12,3,4");
String auths = ts.exec("getauths -u test_user");
assertTrue(auths.contains("3") && auths.contains("12") && auths.contains("4"));
- ts.input.set("secret\n");
- ts.exec("user test_user", true);
- assertTrue(ts.exec("whoami", true).contains("test_user"));
- ts.input.set(getRootPassword() + "\n");
- ts.exec("user root", true);
+ // No support to switch users within the shell with Kerberos
+ if (token instanceof PasswordToken) {
+ ts.input.set("secret\n");
+ ts.exec("user test_user", true);
+ assertTrue(ts.exec("whoami", true).contains("test_user"));
+ ts.input.set(getRootPassword() + "\n");
+ ts.exec("user root", true);
+ }
}
private void make10() throws IOException {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java b/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java
index 702c246..0f0a7b1 100644
--- a/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java
@@ -83,7 +83,7 @@ public class SplitRecoveryIT extends AccumuloClusterIT {
UtilWaitThread.sleep(200);
// poke a partial split into the metadata table
- connector.securityOperations().grantTablePermission("root", MetadataTable.NAME, TablePermission.WRITE);
+ connector.securityOperations().grantTablePermission(getAdminPrincipal(), MetadataTable.NAME, TablePermission.WRITE);
String tableId = connector.tableOperations().tableIdMap().get(tableName);
KeyExtent extent = new KeyExtent(new Text(tableId), null, new Text("b"));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/TableOperationsIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TableOperationsIT.java b/test/src/test/java/org/apache/accumulo/test/TableOperationsIT.java
index bbd5a79..083a77a 100644
--- a/test/src/test/java/org/apache/accumulo/test/TableOperationsIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/TableOperationsIT.java
@@ -61,8 +61,6 @@ import com.google.common.collect.Sets;
public class TableOperationsIT extends AccumuloClusterIT {
- static final String ROOT = "root";
-
static TabletClientService.Client client;
private Connector connector;
@@ -86,7 +84,7 @@ public class TableOperationsIT extends AccumuloClusterIT {
assertEquals(0, (long) diskUsage.get(0).getUsage());
assertEquals(tableName, diskUsage.get(0).getTables().iterator().next());
- connector.securityOperations().revokeTablePermission(ROOT, tableName, TablePermission.READ);
+ connector.securityOperations().revokeTablePermission(getAdminPrincipal(), tableName, TablePermission.READ);
try {
connector.tableOperations().getDiskUsage(Collections.singleton(tableName));
fail("Should throw securityexception");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/TransportCachingIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TransportCachingIT.java b/test/src/test/java/org/apache/accumulo/test/TransportCachingIT.java
index e760295..fc50843 100644
--- a/test/src/test/java/org/apache/accumulo/test/TransportCachingIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/TransportCachingIT.java
@@ -57,7 +57,7 @@ public class TransportCachingIT extends AccumuloClusterIT {
Instance instance = conn.getInstance();
ClientConfiguration clientConf = ClientConfiguration.loadDefault();
clientConf.withInstance(instance.getInstanceName()).withZkHosts(instance.getZooKeepers());
- ClientContext context = new ClientContext(instance, new Credentials(getPrincipal(), getToken()), clientConf);
+ ClientContext context = new ClientContext(instance, new Credentials(getAdminPrincipal(), getAdminToken()), clientConf);
long rpcTimeout = DefaultConfiguration.getTimeInMillis(Property.GENERAL_RPC_TIMEOUT.getDefaultValue());
// create list of servers
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java b/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
index b48bebb..02a00f8 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
@@ -44,6 +44,8 @@ import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.harness.AccumuloClusterIT;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.Job;
@@ -59,6 +61,11 @@ public class AccumuloInputFormatIT extends AccumuloClusterIT {
return 4 * 60;
}
+ @Override
+ public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
+ cfg.setNumTservers(1);
+ }
+
@Before
public void before() {
inputFormat = new AccumuloInputFormat();
@@ -74,8 +81,7 @@ public class AccumuloInputFormatIT extends AccumuloClusterIT {
conn.tableOperations().create(table);
insertData(table, currentTimeMillis());
- ClientConfiguration clientConf = new ClientConfiguration().withInstance(conn.getInstance().getInstanceName()).withZkHosts(
- conn.getInstance().getZooKeepers());
+ ClientConfiguration clientConf = cluster.getClientConfig();
AccumuloConfiguration clusterClientConf = new ConfigurationCopy(new DefaultConfiguration());
// Pass SSL and CredentialProvider options into the ClientConfiguration given to AccumuloInputFormat
@@ -95,7 +101,7 @@ public class AccumuloInputFormatIT extends AccumuloClusterIT {
Job job = Job.getInstance();
AccumuloInputFormat.setInputTableName(job, table);
AccumuloInputFormat.setZooKeeperInstance(job, clientConf);
- AccumuloInputFormat.setConnectorInfo(job, getPrincipal(), getToken());
+ AccumuloInputFormat.setConnectorInfo(job, getAdminPrincipal(), getAdminToken());
// split table
TreeSet<Text> splitsToAdd = new TreeSet<Text>();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/BalanceInPresenceOfOfflineTableIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BalanceInPresenceOfOfflineTableIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BalanceInPresenceOfOfflineTableIT.java
index 114d79b..8138ac0 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BalanceInPresenceOfOfflineTableIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BalanceInPresenceOfOfflineTableIT.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.test.functional;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -26,6 +25,8 @@ import org.apache.accumulo.core.cli.BatchWriterOpts;
import org.apache.accumulo.core.cli.ScannerOpts;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.TableExistsException;
@@ -38,10 +39,10 @@ import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.master.thrift.MasterClientService;
import org.apache.accumulo.core.master.thrift.MasterMonitorInfo;
import org.apache.accumulo.core.master.thrift.TableInfo;
+import org.apache.accumulo.core.security.Credentials;
import org.apache.accumulo.core.trace.Tracer;
import org.apache.accumulo.harness.AccumuloClusterIT;
import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
-import org.apache.accumulo.server.security.SystemCredentials;
import org.apache.accumulo.test.TestIngest;
import org.apache.accumulo.test.VerifyIngest;
import org.apache.commons.lang.math.NumberUtils;
@@ -64,7 +65,7 @@ public class BalanceInPresenceOfOfflineTableIT extends AccumuloClusterIT {
@Override
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
- Map<String,String> siteConfig = new HashMap<String,String>();
+ Map<String,String> siteConfig = cfg.getSiteConfig();
siteConfig.put(Property.TSERV_MAXMEM.getKey(), "10K");
siteConfig.put(Property.TSERV_MAJC_DELAY.getKey(), "0");
cfg.setSiteConfig(siteConfig);
@@ -121,6 +122,14 @@ public class BalanceInPresenceOfOfflineTableIT extends AccumuloClusterIT {
TestIngest.Opts opts = new TestIngest.Opts();
VerifyIngest.Opts vopts = new VerifyIngest.Opts();
+ ClientConfiguration conf = cluster.getClientConfig();
+ if (conf.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false)) {
+ opts.updateKerberosCredentials(cluster.getClientConfig());
+ vopts.updateKerberosCredentials(cluster.getClientConfig());
+ } else {
+ opts.setPrincipal("root");
+ vopts.setPrincipal("root");
+ }
vopts.rows = opts.rows = 200000;
opts.setTableName(TEST_TABLE);
TestIngest.ingest(connector, opts, new BatchWriterOpts());
@@ -133,6 +142,7 @@ public class BalanceInPresenceOfOfflineTableIT extends AccumuloClusterIT {
long currentWait = 10 * 1000;
boolean balancingWorked = false;
+ Credentials creds = new Credentials(getAdminPrincipal(), getAdminToken());
while (!balancingWorked && (System.currentTimeMillis() - startTime) < ((5 * 60 + 15) * 1000)) {
Thread.sleep(currentWait);
currentWait *= 2;
@@ -143,8 +153,8 @@ public class BalanceInPresenceOfOfflineTableIT extends AccumuloClusterIT {
MasterMonitorInfo stats = null;
try {
Instance instance = new ZooKeeperInstance(cluster.getClientConfig());
- client = MasterClient.getConnectionWithRetry(new ClientContext(instance, SystemCredentials.get(instance), cluster.getClientConfig()));
- stats = client.getMasterStats(Tracer.traceInfo(), SystemCredentials.get(instance).toThrift(instance));
+ client = MasterClient.getConnectionWithRetry(new ClientContext(instance, creds, cluster.getClientConfig()));
+ stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(instance));
} catch (ThriftSecurityException exception) {
throw new AccumuloSecurityException(exception);
} catch (TException exception) {
@@ -176,7 +186,9 @@ public class BalanceInPresenceOfOfflineTableIT extends AccumuloClusterIT {
log.debug("We should have > 10 tablets. sleeping for " + currentWait + "ms");
continue;
}
- if ((NumberUtils.min(tabletsPerServer) / ((double) NumberUtils.max(tabletsPerServer))) < 0.5) {
+ long min = NumberUtils.min(tabletsPerServer), max = NumberUtils.max(tabletsPerServer);
+ log.debug("Min=" + min + ", Max=" + max);
+ if ((min / ((double) max)) < 0.5) {
log.debug("ratio of min to max tablets per server should be roughly even. sleeping for " + currentWait + "ms");
continue;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java
index 93aac20..3e979d3 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.test.functional;
import static org.junit.Assert.assertTrue;
-import java.util.HashMap;
import java.util.Map;
import org.apache.accumulo.core.client.Connector;
@@ -36,7 +35,7 @@ public class BigRootTabletIT extends AccumuloClusterIT {
@Override
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
- Map<String,String> siteConfig = new HashMap<String,String>();
+ Map<String,String> siteConfig = cfg.getSiteConfig();
siteConfig.put(Property.TABLE_SCAN_MAXMEM.getKey(), "1024");
siteConfig.put(Property.TSERV_MAJC_DELAY.getKey(), "60m");
cfg.setSiteConfig(siteConfig);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/BinaryStressIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BinaryStressIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BinaryStressIT.java
index 5084e45..62d8738 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BinaryStressIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BinaryStressIT.java
@@ -95,7 +95,7 @@ public class BinaryStressIT extends AccumuloClusterIT {
c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K");
BinaryIT.runTest(c, tableName);
String id = c.tableOperations().tableIdMap().get(tableName);
- Set<Text> tablets = new HashSet<Text>();
+ Set<Text> tablets = new HashSet<>();
Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
s.setRange(Range.prefix(id));
for (Entry<Key,Value> entry : s) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/BloomFilterIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BloomFilterIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BloomFilterIT.java
index a4ed85d..64d6827 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BloomFilterIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BloomFilterIT.java
@@ -18,7 +18,6 @@ package org.apache.accumulo.test.functional;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -57,7 +56,7 @@ public class BloomFilterIT extends AccumuloClusterIT {
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
cfg.setDefaultMemory(1, MemoryUnit.GIGABYTE);
cfg.setNumTservers(1);
- Map<String,String> siteConfig = new HashMap<String,String>();
+ Map<String,String> siteConfig = cfg.getSiteConfig();
siteConfig.put(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey(), "10M");
cfg.setSiteConfig(siteConfig);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java
index 7aabdca..6683d73 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java
@@ -68,7 +68,7 @@ public class BulkFileIT extends AccumuloClusterIT {
AccumuloConfiguration aconf = new ServerConfigurationFactory(c.getInstance()).getConfiguration();
FileSystem fs = getCluster().getFileSystem();
- String rootPath = getUsableDir();
+ String rootPath = cluster.getTemporaryPath().toString();
String dir = rootPath + "/bulk_test_diff_files_89723987592_" + getUniqueNames(1)[0];
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/BulkIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BulkIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BulkIT.java
index 39299da..6fae29f 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BulkIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BulkIT.java
@@ -26,15 +26,12 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.util.CachedConfiguration;
-import org.apache.accumulo.harness.AccumuloIT;
-import org.apache.accumulo.harness.MiniClusterHarness;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.accumulo.harness.AccumuloClusterIT;
import org.apache.accumulo.test.TestIngest;
import org.apache.accumulo.test.TestIngest.Opts;
import org.apache.accumulo.test.VerifyIngest;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.After;
@@ -42,42 +39,30 @@ import org.junit.Before;
import org.junit.Test;
// TODO Change test to support bulk ingest on any filesystem, not just the local FS.
-public class BulkIT extends AccumuloIT {
+public class BulkIT extends AccumuloClusterIT {
private static final int N = 100000;
private static final int COUNT = 5;
private static final BatchWriterOpts BWOPTS = new BatchWriterOpts();
private static final ScannerOpts SOPTS = new ScannerOpts();
- private MiniAccumuloClusterImpl cluster;
-
- private AuthenticationToken getToken() {
- return new PasswordToken("rootPassword1");
- }
-
- private Connector getConnector() {
- try {
- return cluster.getConnector("root", getToken());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
@Override
protected int defaultTimeoutSeconds() {
return 4 * 60;
}
+ private Configuration origConf;
+
@Before
- public void startMiniCluster() throws Exception {
- MiniClusterHarness harness = new MiniClusterHarness();
- cluster = harness.create(getToken());
- cluster.start();
+ public void saveConf() {
+ origConf = CachedConfiguration.getInstance();
}
@After
- public void stopMiniCluster() throws Exception {
- cluster.stop();
+ public void restoreConf() {
+ if (null != origConf) {
+ CachedConfiguration.setInstance(origConf);
+ }
}
@Test
@@ -88,11 +73,17 @@ public class BulkIT extends AccumuloIT {
static void runTest(Connector c, String tableName, String filePrefix, String dirSuffix) throws AccumuloException, AccumuloSecurityException,
TableExistsException, IOException, TableNotFoundException, MutationsRejectedException {
c.tableOperations().create(tableName);
- FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
- String base = "target/accumulo-maven-plugin";
- String bulkFailures = base + "/testBulkFail_" + dirSuffix;
- fs.delete(new Path(base + "/testrf"), true);
- fs.mkdirs(new Path(bulkFailures));
+ FileSystem fs = cluster.getFileSystem();
+ CachedConfiguration.setInstance(fs.getConf());
+
+ Path tempPath = cluster.getTemporaryPath();
+ Path base = new Path(tempPath, "testBulkFail_" + dirSuffix);
+ fs.delete(base, true);
+ fs.mkdirs(base);
+ Path bulkFailures = new Path(base, "failures");
+ Path files = new Path(base, "files");
+ fs.mkdirs(bulkFailures);
+ fs.mkdirs(files);
Opts opts = new Opts();
opts.timestamp = 1;
@@ -101,9 +92,11 @@ public class BulkIT extends AccumuloIT {
opts.instance = c.getInstance().getInstanceName();
opts.cols = 1;
opts.setTableName(tableName);
- String fileFormat = "/testrf/" + filePrefix + "rf%02d";
+ opts.conf = CachedConfiguration.getInstance();
+ opts.fs = fs;
+ String fileFormat = filePrefix + "rf%02d";
for (int i = 0; i < COUNT; i++) {
- opts.outputFile = base + String.format(fileFormat, i);
+ opts.outputFile = new Path(files, String.format(fileFormat, i)).toString();
opts.startRow = N * i;
TestIngest.ingest(c, opts, BWOPTS);
}
@@ -112,10 +105,11 @@ public class BulkIT extends AccumuloIT {
opts.rows = 1;
// create an rfile with one entry, there was a bug with this:
TestIngest.ingest(c, opts, BWOPTS);
- c.tableOperations().importDirectory(tableName, base + "/testrf", bulkFailures, false);
+ c.tableOperations().importDirectory(tableName, files.toString(), bulkFailures.toString(), false);
VerifyIngest.Opts vopts = new VerifyIngest.Opts();
vopts.setTableName(tableName);
vopts.random = 56;
+ vopts.setPrincipal(getAdminPrincipal());
for (int i = 0; i < COUNT; i++) {
vopts.startRow = i * N;
vopts.rows = N;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/BulkSplitOptimizationIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BulkSplitOptimizationIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BulkSplitOptimizationIT.java
index e4fdfd8..5beed91 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BulkSplitOptimizationIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BulkSplitOptimizationIT.java
@@ -20,7 +20,10 @@ import static com.google.common.base.Charsets.UTF_8;
import org.apache.accumulo.core.cli.ClientOpts.Password;
import org.apache.accumulo.core.cli.ScannerOpts;
+import org.apache.accumulo.core.client.ClientConfiguration;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.client.security.tokens.KerberosToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.util.UtilWaitThread;
@@ -33,7 +36,7 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.After;
-import org.junit.Assume;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -107,8 +110,6 @@ public class BulkSplitOptimizationIT extends AccumuloClusterIT {
UtilWaitThread.sleep(500);
}
- Assume.assumeTrue(getToken() instanceof PasswordToken);
- PasswordToken token = (PasswordToken) getToken();
FunctionalTestUtils.checkSplits(c, tableName, 50, 100);
VerifyIngest.Opts opts = new VerifyIngest.Opts();
opts.timestamp = 1;
@@ -117,8 +118,20 @@ public class BulkSplitOptimizationIT extends AccumuloClusterIT {
opts.rows = 100000;
opts.startRow = 0;
opts.cols = 1;
- opts.setPassword(new Password(new String(token.getPassword(), UTF_8)));
opts.setTableName(tableName);
+
+ AuthenticationToken adminToken = getAdminToken();
+ if (adminToken instanceof PasswordToken) {
+ PasswordToken token = (PasswordToken) getAdminToken();
+ opts.setPassword(new Password(new String(token.getPassword(), UTF_8)));
+ opts.setPrincipal(getAdminPrincipal());
+ } else if (adminToken instanceof KerberosToken) {
+ ClientConfiguration clientConf = cluster.getClientConfig();
+ opts.updateKerberosCredentials(clientConf);
+ } else {
+ Assert.fail("Unknown token type");
+ }
+
VerifyIngest.verifyIngest(c, opts, new ScannerOpts());
// ensure each tablet does not have all map files, should be ~2.5 files per tablet
http://git-wip-us.apache.org/repos/asf/accumulo/blob/1c5bef32/test/src/test/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java
index e80f823..a2d5971 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/ChaoticBalancerIT.java
@@ -16,13 +16,14 @@
*/
package org.apache.accumulo.test.functional;
-import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.accumulo.core.cli.BatchWriterOpts;
import org.apache.accumulo.core.cli.ScannerOpts;
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.harness.AccumuloClusterIT;
@@ -38,7 +39,7 @@ public class ChaoticBalancerIT extends AccumuloClusterIT {
@Override
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
- Map<String,String> siteConfig = new HashMap<String,String>();
+ Map<String,String> siteConfig = cfg.getSiteConfig();
siteConfig.put(Property.TSERV_MAXMEM.getKey(), "10K");
siteConfig.put(Property.TSERV_MAJC_DELAY.getKey(), "0");
cfg.setSiteConfig(siteConfig);
@@ -68,6 +69,14 @@ public class ChaoticBalancerIT extends AccumuloClusterIT {
vopts.rows = opts.rows = 20000;
opts.setTableName(tableName);
vopts.setTableName(tableName);
+ ClientConfiguration clientConfig = getCluster().getClientConfig();
+ if (clientConfig.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false)) {
+ opts.updateKerberosCredentials(clientConfig);
+ vopts.updateKerberosCredentials(clientConfig);
+ } else {
+ opts.setPrincipal(getAdminPrincipal());
+ vopts.setPrincipal(getAdminPrincipal());
+ }
TestIngest.ingest(c, opts, new BatchWriterOpts());
c.tableOperations().flush(tableName, null, null, true);
VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());