You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2015/06/04 20:53:03 UTC
[22/43] accumulo git commit: ACCUMULO-3871 move ITs into distro jar,
stop building test jar
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/main/resources/conf/monitor_logger.xml
----------------------------------------------------------------------
diff --git a/test/src/main/resources/conf/monitor_logger.xml b/test/src/main/resources/conf/monitor_logger.xml
new file mode 100644
index 0000000..91a7671
--- /dev/null
+++ b/test/src/main/resources/conf/monitor_logger.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Write out everything at the DEBUG level to the debug log -->
+ <appender name="A2" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${org.apache.accumulo.core.dir.log}/${org.apache.accumulo.core.application}_${org.apache.accumulo.core.ip.localhost.hostname}.debug.log"/>
+ <param name="MaxFileSize" value="100MB"/>
+ <param name="MaxBackupIndex" value="10"/>
+ <param name="Threshold" value="DEBUG"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ISO8601} [%-8c{2}] %-5p: %X{application} %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- Write out INFO and higher to the regular log -->
+ <appender name="A3" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${org.apache.accumulo.core.dir.log}/${org.apache.accumulo.core.application}_${org.apache.accumulo.core.ip.localhost.hostname}.log"/>
+ <param name="MaxFileSize" value="100MB"/>
+ <param name="MaxBackupIndex" value="10"/>
+ <param name="Threshold" value="INFO"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ISO8601} [%-8c{2}] %-5p: %X{application} %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- Keep the last few log messages for display to the user -->
+ <appender name="GUI" class="org.apache.accumulo.server.monitor.LogService">
+ <param name="keep" value="40"/>
+ <param name="Threshold" value="WARN"/>
+ </appender>
+
+ <!-- Log accumulo messages to debug, normal and GUI -->
+ <logger name="org.apache.accumulo" additivity="false">
+ <level value="DEBUG"/>
+ <appender-ref ref="A2" />
+ <appender-ref ref="A3" />
+ <appender-ref ref="GUI" />
+ </logger>
+
+ <!-- Log non-accumulo messages to debug, normal logs. -->
+ <root>
+ <level value="INFO"/>
+ <appender-ref ref="A2" />
+ <appender-ref ref="A3" />
+ </root>
+
+</log4j:configuration>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/test/src/main/resources/log4j.properties b/test/src/main/resources/log4j.properties
new file mode 100644
index 0000000..26ea762
--- /dev/null
+++ b/test/src/main/resources/log4j.properties
@@ -0,0 +1,55 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=DEBUG, CA
+log4j.appender.CA=org.apache.log4j.ConsoleAppender
+log4j.appender.CA.layout=org.apache.log4j.PatternLayout
+log4j.appender.CA.layout.ConversionPattern=%d{ISO8601} [%c{2}] %-5p: %m%n
+
+log4j.logger.org.apache.accumulo.core=DEBUG
+log4j.logger.org.apache.accumulo.core.client.impl.MasterClient=INFO
+log4j.logger.org.apache.accumulo.core.client.impl.ServerClient=ERROR
+log4j.logger.org.apache.accumulo.core.util.shell.Shell.audit=OFF
+log4j.logger.org.apache.accumulo.core.util.shell.Shell=FATAL
+log4j.logger.org.apache.commons.vfs2.impl.DefaultFileSystemManager=WARN
+log4j.logger.org.apache.hadoop.io.compress.CodecPool=WARN
+log4j.logger.org.apache.hadoop.mapred=ERROR
+log4j.logger.org.apache.hadoop.tools.DistCp=WARN
+log4j.logger.org.apache.hadoop.util.NativeCodeLoader=ERROR
+log4j.logger.org.apache.hadoop.util.ProcessTree=WARN
+log4j.logger.org.apache.zookeeper.ClientCnxn=FATAL
+log4j.logger.org.apache.zookeeper.ClientCnxnSocketNIO=INFO
+log4j.logger.org.apache.zookeeper.ZooKeeper=WARN
+log4j.logger.org.apache.accumulo.core.file.rfile.bcfile=INFO
+log4j.logger.org.apache.accumulo.server.util.ReplicationTableUtil=TRACE
+log4j.logger.org.apache.accumulo.core.client.impl.ThriftScanner=INFO
+log4j.logger.org.apache.accumulo.fate.zookeeper.DistributedReadWriteLock=WARN
+log4j.logger.org.mortbay.log=WARN
+log4j.logger.org.apache.hadoop=WARN
+log4j.logger.org.apache.jasper=INFO
+log4j.logger.org.apache.hadoop.hdfs.server.namenode.FSNamesystem.audit=WARN
+log4j.logger.org.apache.hadoop.hdfs.server.datanode.DataNode.clienttrace=WARN
+log4j.logger.BlockStateChange=WARN
+log4j.logger.org.apache.accumulo.core.client.impl.TabletServerBatchReaderIterator=INFO
+log4j.logger.org.apache.hadoop.security=DEBUG
+log4j.logger.org.apache.hadoop.minikdc=DEBUG
+log4j.logger.org.apache.directory=INFO
+log4j.logger.org.apache.directory.api.ldap=WARN
+# This is really spammy at debug
+log4j.logger.org.apache.thrift.transport.TSaslTransport=INFO
+# From apache-ds/minikdc
+log4j.logger.org.apache.mina=INFO
+log4j.logger.org.apache.accumulo.server.thrift.UGIAssumingProcessor=TRACE
+log4j.logger.org.apache.hadoop.security.UserGroupInformation=INFO
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/main/resources/randomwalk/Basic.xml
----------------------------------------------------------------------
diff --git a/test/src/main/resources/randomwalk/Basic.xml b/test/src/main/resources/randomwalk/Basic.xml
new file mode 100644
index 0000000..2dead02
--- /dev/null
+++ b/test/src/main/resources/randomwalk/Basic.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<module>
+
+<package prefix="test" value="org.apache.accumulo.test.randomwalk.unit"/>
+
+<init id="test.CreateTable"/>
+
+<node id="test.CreateTable">
+ <edge id="unit/Simple.xml" weight="1"/>
+</node>
+
+<node id="unit/Simple.xml">
+ <edge id="unit/Simple.xml" weight="3"/>
+ <edge id="test.DeleteTable" weight="1"/>
+</node>
+
+<node id="test.DeleteTable">
+ <edge id="END" weight="1"/>
+</node>
+
+</module>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/main/resources/randomwalk/Simple.xml
----------------------------------------------------------------------
diff --git a/test/src/main/resources/randomwalk/Simple.xml b/test/src/main/resources/randomwalk/Simple.xml
new file mode 100644
index 0000000..cad940e
--- /dev/null
+++ b/test/src/main/resources/randomwalk/Simple.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<module>
+
+<package prefix="test" value="org.apache.accumulo.test.randomwalk.unit"/>
+
+<init id="dummy.all"/>
+
+<node id="dummy.all">
+ <edge id="test.Ingest" weight="1"/>
+ <edge id="test.Verify" weight="1"/>
+ <edge id="test.Scan" weight="1"/>
+ <edge id="END" weight="1"/>
+</node>
+
+<node id="test.Ingest">
+ <edge id="dummy.all" weight="1"/>
+</node>
+
+<node id="test.Verify">
+ <edge id="dummy.all" weight="1"/>
+</node>
+
+<node id="test.Scan">
+ <edge id="dummy.all" weight="1"/>
+</node>
+
+</module>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/main/resources/unit/Basic.xml
----------------------------------------------------------------------
diff --git a/test/src/main/resources/unit/Basic.xml b/test/src/main/resources/unit/Basic.xml
new file mode 100644
index 0000000..2dead02
--- /dev/null
+++ b/test/src/main/resources/unit/Basic.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<module>
+
+<package prefix="test" value="org.apache.accumulo.test.randomwalk.unit"/>
+
+<init id="test.CreateTable"/>
+
+<node id="test.CreateTable">
+ <edge id="unit/Simple.xml" weight="1"/>
+</node>
+
+<node id="unit/Simple.xml">
+ <edge id="unit/Simple.xml" weight="3"/>
+ <edge id="test.DeleteTable" weight="1"/>
+</node>
+
+<node id="test.DeleteTable">
+ <edge id="END" weight="1"/>
+</node>
+
+</module>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/main/resources/unit/Simple.xml
----------------------------------------------------------------------
diff --git a/test/src/main/resources/unit/Simple.xml b/test/src/main/resources/unit/Simple.xml
new file mode 100644
index 0000000..cad940e
--- /dev/null
+++ b/test/src/main/resources/unit/Simple.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<module>
+
+<package prefix="test" value="org.apache.accumulo.test.randomwalk.unit"/>
+
+<init id="dummy.all"/>
+
+<node id="dummy.all">
+ <edge id="test.Ingest" weight="1"/>
+ <edge id="test.Verify" weight="1"/>
+ <edge id="test.Scan" weight="1"/>
+ <edge id="END" weight="1"/>
+</node>
+
+<node id="test.Ingest">
+ <edge id="dummy.all" weight="1"/>
+</node>
+
+<node id="test.Verify">
+ <edge id="dummy.all" weight="1"/>
+</node>
+
+<node id="test.Scan">
+ <edge id="dummy.all" weight="1"/>
+</node>
+
+</module>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterHarness.java b/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
deleted file mode 100644
index 30058db..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import org.apache.accumulo.cluster.AccumuloCluster;
-import org.apache.accumulo.cluster.ClusterControl;
-import org.apache.accumulo.cluster.ClusterUser;
-import org.apache.accumulo.cluster.ClusterUsers;
-import org.apache.accumulo.cluster.standalone.StandaloneAccumuloCluster;
-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.admin.SecurityOperations;
-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.KerberosToken;
-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.conf.AccumuloClusterConfiguration;
-import org.apache.accumulo.harness.conf.AccumuloClusterPropertyConfiguration;
-import org.apache.accumulo.harness.conf.AccumuloMiniClusterConfiguration;
-import org.apache.accumulo.harness.conf.StandaloneAccumuloClusterConfiguration;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * General Integration-Test base class that provides access to an Accumulo instance for testing. This instance could be MAC or a standalone instance.
- */
-public abstract class AccumuloClusterHarness extends AccumuloITBase implements MiniClusterConfigurationCallback, ClusterUsers {
- private static final Logger log = LoggerFactory.getLogger(AccumuloClusterHarness.class);
- private static final String TRUE = Boolean.toString(true);
-
- public static enum ClusterType {
- MINI, STANDALONE;
-
- public boolean isDynamic() {
- return this == MINI;
- }
- }
-
- private static boolean initialized = false;
-
- protected static AccumuloCluster cluster;
- protected static ClusterType type;
- protected static AccumuloClusterPropertyConfiguration clusterConf;
- protected static TestingKdc krb;
-
- @BeforeClass
- public static void setUp() throws Exception {
- clusterConf = AccumuloClusterPropertyConfiguration.get();
- type = clusterConf.getClusterType();
-
- if (ClusterType.MINI == type && TRUE.equals(System.getProperty(MiniClusterHarness.USE_KERBEROS_FOR_IT_OPTION))) {
- krb = new TestingKdc();
- krb.start();
- log.info("MiniKdc started");
- }
-
- initialized = true;
- }
-
- @AfterClass
- public static void tearDownKdc() throws Exception {
- if (null != krb) {
- krb.stop();
- }
- }
-
- /**
- * The {@link TestingKdc} used for this {@link AccumuloCluster}. Might be null.
- */
- public static TestingKdc getKdc() {
- return krb;
- }
-
- @Before
- public void setupCluster() throws Exception {
- // Before we try to instantiate the cluster, check to see if the test even wants to run against this type of cluster
- Assume.assumeTrue(canRunTest(type));
-
- switch (type) {
- case MINI:
- MiniClusterHarness miniClusterHarness = new MiniClusterHarness();
- // Intrinsically performs the callback to let tests alter MiniAccumuloConfig and core-site.xml
- MiniAccumuloClusterImpl impl = miniClusterHarness.create(this, getAdminToken(), krb);
- cluster = impl;
- // MAC makes a ClientConf for us, just set it
- ((AccumuloMiniClusterConfiguration) clusterConf).setClientConf(impl.getClientConfig());
- // Login as the "root" user
- if (null != krb) {
- ClusterUser rootUser = krb.getRootUser();
- // Log in the 'client' user
- UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());
- }
- break;
- case STANDALONE:
- StandaloneAccumuloClusterConfiguration conf = (StandaloneAccumuloClusterConfiguration) clusterConf;
- ClientConfiguration clientConf = conf.getClientConf();
- StandaloneAccumuloCluster standaloneCluster = new StandaloneAccumuloCluster(conf.getInstance(), clientConf, conf.getTmpDirectory(), conf.getUsers(),
- conf.getAccumuloServerUser());
- // If these are provided in the configuration, pass them into the cluster
- standaloneCluster.setAccumuloHome(conf.getAccumuloHome());
- standaloneCluster.setClientAccumuloConfDir(conf.getClientAccumuloConfDir());
- standaloneCluster.setServerAccumuloConfDir(conf.getServerAccumuloConfDir());
- standaloneCluster.setHadoopConfDir(conf.getHadoopConfDir());
-
- // For SASL, we need to get the Hadoop configuration files as well otherwise UGI will log in as SIMPLE instead of KERBEROS
- Configuration hadoopConfiguration = standaloneCluster.getHadoopConfiguration();
- if (clientConf.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false)) {
- UserGroupInformation.setConfiguration(hadoopConfiguration);
- // Login as the admin user to start the tests
- UserGroupInformation.loginUserFromKeytab(conf.getAdminPrincipal(), conf.getAdminKeytab().getAbsolutePath());
- }
-
- // Set the implementation
- cluster = standaloneCluster;
- break;
- default:
- throw new RuntimeException("Unhandled type");
- }
-
- if (type.isDynamic()) {
- cluster.start();
- } else {
- log.info("Removing tables which appear to be from a previous test run");
- cleanupTables();
- log.info("Removing users which appear to be from a previous test run");
- cleanupUsers();
- }
-
- switch (type) {
- case MINI:
- if (null != krb) {
- final String traceTable = Property.TRACE_TABLE.getDefaultValue();
- final ClusterUser systemUser = krb.getAccumuloServerUser(), rootUser = krb.getRootUser();
-
- // Login as the trace user
- UserGroupInformation.loginUserFromKeytab(systemUser.getPrincipal(), systemUser.getKeytab().getAbsolutePath());
-
- // Open a connector as the system user (ensures the user will exist for us to assign permissions to)
- Connector conn = cluster.getConnector(systemUser.getPrincipal(), new KerberosToken(systemUser.getPrincipal(), systemUser.getKeytab(), true));
-
- // Then, log back in as the "root" user and do the grant
- UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());
- conn = getConnector();
-
- // Create the trace table
- conn.tableOperations().create(traceTable);
-
- // Trace user (which is the same kerberos principal as the system user, but using a normal KerberosToken) needs
- // to have the ability to read, write and alter the trace table
- conn.securityOperations().grantTablePermission(systemUser.getPrincipal(), traceTable, TablePermission.READ);
- conn.securityOperations().grantTablePermission(systemUser.getPrincipal(), traceTable, TablePermission.WRITE);
- conn.securityOperations().grantTablePermission(systemUser.getPrincipal(), traceTable, TablePermission.ALTER_TABLE);
- }
- break;
- default:
- // do nothing
- }
- }
-
- public void cleanupTables() throws Exception {
- final String tablePrefix = this.getClass().getSimpleName() + "_";
- final TableOperations tops = getConnector().tableOperations();
- for (String table : tops.list()) {
- if (table.startsWith(tablePrefix)) {
- log.debug("Removing table {}", table);
- tops.delete(table);
- }
- }
- }
-
- public void cleanupUsers() throws Exception {
- final String userPrefix = this.getClass().getSimpleName();
- final SecurityOperations secOps = getConnector().securityOperations();
- for (String user : secOps.listLocalUsers()) {
- if (user.startsWith(userPrefix)) {
- log.info("Dropping local user {}", user);
- secOps.dropLocalUser(user);
- }
- }
- }
-
- @After
- public void teardownCluster() throws Exception {
- if (null != cluster) {
- if (type.isDynamic()) {
- cluster.stop();
- } else {
- log.info("Removing tables which appear to be from the current test");
- cleanupTables();
- log.info("Removing users which appear to be from the current test");
- cleanupUsers();
- }
- }
- }
-
- public static AccumuloCluster getCluster() {
- Preconditions.checkState(initialized);
- return cluster;
- }
-
- public static ClusterControl getClusterControl() {
- Preconditions.checkState(initialized);
- return cluster.getClusterControl();
- }
-
- public static ClusterType getClusterType() {
- Preconditions.checkState(initialized);
- return type;
- }
-
- public static String getAdminPrincipal() {
- Preconditions.checkState(initialized);
- return clusterConf.getAdminPrincipal();
- }
-
- public static AuthenticationToken getAdminToken() {
- Preconditions.checkState(initialized);
- return clusterConf.getAdminToken();
- }
-
- @Override
- public ClusterUser getAdminUser() {
- switch (type) {
- case MINI:
- if (null == krb) {
- PasswordToken passwordToken = (PasswordToken) getAdminToken();
- return new ClusterUser(getAdminPrincipal(), new String(passwordToken.getPassword(), UTF_8));
- }
- return krb.getRootUser();
- case STANDALONE:
- return new ClusterUser(getAdminPrincipal(), ((StandaloneAccumuloClusterConfiguration) clusterConf).getAdminKeytab());
- default:
- throw new RuntimeException("Unknown cluster type");
- }
- }
-
- @Override
- public ClusterUser getUser(int offset) {
- switch (type) {
- case MINI:
- if (null != krb) {
- // Defer to the TestingKdc when kerberos is on so we can get the keytab instead of a password
- return krb.getClientPrincipal(offset);
- } else {
- // Come up with a mostly unique name
- String principal = getClass().getSimpleName() + "_" + testName.getMethodName() + "_" + offset;
- // Username and password are the same
- return new ClusterUser(principal, principal);
- }
- case STANDALONE:
- return ((StandaloneAccumuloCluster) cluster).getUser(offset);
- default:
- throw new RuntimeException("Unknown cluster type");
- }
- }
-
- public static FileSystem getFileSystem() throws IOException {
- Preconditions.checkState(initialized);
- return cluster.getFileSystem();
- }
-
- public static AccumuloClusterConfiguration getClusterConfiguration() {
- Preconditions.checkState(initialized);
- return clusterConf;
- }
-
- public Connector getConnector() {
- try {
- String princ = getAdminPrincipal();
- AuthenticationToken token = getAdminToken();
- log.debug("Creating connector as {} with {}", princ, token);
- return cluster.getConnector(princ, token);
- } catch (Exception e) {
- log.error("Could not connect to Accumulo", e);
- fail("Could not connect to Accumulo: " + e.getMessage());
-
- throw new RuntimeException("Could not connect to Accumulo", e);
- }
- }
-
- // TODO Really don't want this here. Will ultimately need to abstract configuration method away from MAConfig
- // and change over to something more generic
- @Override
- public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {}
-
- /**
- * A test may not be capable of running against a given AccumuloCluster. Implementations can override this method to advertise that they cannot (or perhaps do
- * not) want to run the test.
- */
- public boolean canRunTest(ClusterType type) {
- return true;
- }
-
- /**
- * Tries to give a reasonable directory which can be used to create temporary files for the test. Makes a basic attempt to create the directory if it does not
- * already exist.
- *
- * @return A directory which can be expected to exist on the Cluster's FileSystem
- */
- public Path getUsableDir() throws IllegalArgumentException, IOException {
- return cluster.getTemporaryPath();
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/AccumuloITBase.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/AccumuloITBase.java b/test/src/test/java/org/apache/accumulo/harness/AccumuloITBase.java
deleted file mode 100644
index 8e2f6e0..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/AccumuloITBase.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.junit.rules.Timeout;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Methods, setup and/or infrastructure which are common to any Accumulo integration test.
- */
-public class AccumuloITBase {
- private static final Logger log = LoggerFactory.getLogger(AccumuloITBase.class);
-
- @Rule
- public TestName testName = new TestName();
-
- public String[] getUniqueNames(int num) {
- String[] names = new String[num];
- for (int i = 0; i < num; i++)
- names[i] = this.getClass().getSimpleName() + "_" + testName.getMethodName() + i;
- return names;
- }
-
- /**
- * Determines an appropriate directory name for holding generated ssl files for a test. The directory returned will have the same name as the provided
- * directory, but with the suffix "-ssl" appended. This new directory is not created here, but is expected to be created as needed.
- *
- * @param baseDir
- * the original directory, which the new directory will be created next to; it should exist
- * @return the new directory (is not created)
- */
- public static File getSslDir(File baseDir) {
- assertTrue(baseDir.exists() && baseDir.isDirectory());
- return new File(baseDir.getParentFile(), baseDir.getName() + "-ssl");
- }
-
- public static File createTestDir(String name) {
- File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests");
- assertTrue(baseDir.mkdirs() || baseDir.isDirectory());
- if (name == null)
- return baseDir;
- File testDir = new File(baseDir, name);
- FileUtils.deleteQuietly(testDir);
- assertTrue(testDir.mkdir());
- return testDir;
- }
-
- /**
- * If a given IT test has a method that takes longer than a class-set default timeout, declare it failed.
- *
- * Note that this provides a upper bound on test times, even in the presence of Test annotations with a timeout. That is, the Test annotatation can make the
- * timing tighter but will not be able to allow a timeout that takes longer.
- *
- * Defaults to no timeout and can be changed via two mechanisms
- *
- * 1) A given IT class can override the defaultTimeoutSeconds method if test methods in that class should have a timeout. 2) The system property
- * "timeout.factor" is used as a multiplier for the class provided default
- *
- * Note that if either of these values is '0' tests will run with no timeout. The default class level timeout is set to 0.
- *
- */
- @Rule
- public Timeout testsShouldTimeout() {
- int waitLonger = 0;
- try {
- String timeoutString = System.getProperty("timeout.factor");
- if (timeoutString != null && !timeoutString.isEmpty()) {
- waitLonger = Integer.parseInt(timeoutString);
- }
- } catch (NumberFormatException exception) {
- log.warn("Could not parse timeout.factor, defaulting to no timeout.");
- }
- return new Timeout(waitLonger * defaultTimeoutSeconds() * 1000);
- }
-
- /**
- * time to wait per-method before declaring a timeout, in seconds.
- */
- protected int defaultTimeoutSeconds() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/MiniClusterConfigurationCallback.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/MiniClusterConfigurationCallback.java b/test/src/test/java/org/apache/accumulo/harness/MiniClusterConfigurationCallback.java
deleted file mode 100644
index 5fa6eb5..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/MiniClusterConfigurationCallback.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness;
-
-import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
-import org.apache.hadoop.conf.Configuration;
-
-/**
- * Callback interface to inject configuration into the MiniAccumuloCluster or Hadoop core-site.xml file used by the MiniAccumuloCluster
- */
-public interface MiniClusterConfigurationCallback {
-
- public static class NoCallback implements MiniClusterConfigurationCallback {
-
- private NoCallback() {}
-
- @Override
- public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration coreSite) {
- return;
- }
- }
-
- public static final MiniClusterConfigurationCallback NO_CALLBACK = new NoCallback();
-
- void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration coreSite);
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java b/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java
deleted file mode 100644
index d923593..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.accumulo.cluster.ClusterUser;
-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.MiniAccumuloClusterImpl;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
-import org.apache.accumulo.server.security.handler.KerberosAuthenticator;
-import org.apache.accumulo.server.security.handler.KerberosAuthorizor;
-import org.apache.accumulo.server.security.handler.KerberosPermissionHandler;
-import org.apache.accumulo.test.functional.NativeMapIT;
-import org.apache.accumulo.test.util.CertUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-
-/**
- * Harness that sets up a MiniAccumuloCluster in a manner expected for Accumulo integration tests.
- */
-public class MiniClusterHarness {
- private static final Logger log = LoggerFactory.getLogger(MiniClusterHarness.class);
-
- private static final AtomicLong COUNTER = new AtomicLong(0);
-
- public static final String USE_SSL_FOR_IT_OPTION = "org.apache.accumulo.test.functional.useSslForIT",
- USE_CRED_PROVIDER_FOR_IT_OPTION = "org.apache.accumulo.test.functional.useCredProviderForIT",
- USE_KERBEROS_FOR_IT_OPTION = "org.apache.accumulo.test.functional.useKrbForIT", TRUE = Boolean.toString(true);
-
- // TODO These are defined in MiniKdc >= 2.6.0. Can be removed when minimum Hadoop dependency is increased to that.
- public static final String JAVA_SECURITY_KRB5_CONF = "java.security.krb5.conf", SUN_SECURITY_KRB5_DEBUG = "sun.security.krb5.debug";
-
- /**
- * Create a MiniAccumuloCluster using the given Token as the credentials for the root user.
- */
- public MiniAccumuloClusterImpl create(AuthenticationToken token) throws Exception {
- return create(MiniClusterHarness.class.getName(), Long.toString(COUNTER.incrementAndGet()), token);
- }
-
- public MiniAccumuloClusterImpl create(AuthenticationToken token, TestingKdc kdc) throws Exception {
- return create(MiniClusterHarness.class.getName(), Long.toString(COUNTER.incrementAndGet()), token, kdc);
- }
-
- public MiniAccumuloClusterImpl create(AccumuloITBase testBase, AuthenticationToken token) throws Exception {
- return create(testBase.getClass().getName(), testBase.testName.getMethodName(), token);
- }
-
- public MiniAccumuloClusterImpl create(AccumuloITBase testBase, AuthenticationToken token, TestingKdc kdc) throws Exception {
- return create(testBase, token, kdc, MiniClusterConfigurationCallback.NO_CALLBACK);
- }
-
- public MiniAccumuloClusterImpl create(AccumuloITBase testBase, AuthenticationToken token, TestingKdc kdc, MiniClusterConfigurationCallback configCallback)
- throws Exception {
- return create(testBase.getClass().getName(), testBase.testName.getMethodName(), token, configCallback, kdc);
- }
-
- public MiniAccumuloClusterImpl create(AccumuloClusterHarness testBase, AuthenticationToken token, TestingKdc kdc) throws Exception {
- return create(testBase.getClass().getName(), testBase.testName.getMethodName(), token, testBase, kdc);
- }
-
- public MiniAccumuloClusterImpl create(AccumuloClusterHarness testBase, AuthenticationToken token, MiniClusterConfigurationCallback callback) throws Exception {
- return create(testBase.getClass().getName(), testBase.testName.getMethodName(), token, callback);
- }
-
- public MiniAccumuloClusterImpl create(String testClassName, String testMethodName, AuthenticationToken token) throws Exception {
- return create(testClassName, testMethodName, token, MiniClusterConfigurationCallback.NO_CALLBACK);
- }
-
- public MiniAccumuloClusterImpl create(String testClassName, String testMethodName, AuthenticationToken token, TestingKdc kdc) throws Exception {
- return create(testClassName, testMethodName, token, MiniClusterConfigurationCallback.NO_CALLBACK, kdc);
- }
-
- public MiniAccumuloClusterImpl create(String testClassName, String testMethodName, AuthenticationToken token, MiniClusterConfigurationCallback configCallback)
- throws Exception {
- return create(testClassName, testMethodName, token, configCallback, null);
- }
-
- public MiniAccumuloClusterImpl create(String testClassName, String testMethodName, AuthenticationToken token,
- MiniClusterConfigurationCallback configCallback, TestingKdc kdc) throws Exception {
- Preconditions.checkNotNull(token);
- Preconditions.checkArgument(token instanceof PasswordToken || token instanceof KerberosToken, "A PasswordToken or KerberosToken is required");
-
- String rootPasswd;
- if (token instanceof PasswordToken) {
- rootPasswd = new String(((PasswordToken) token).getPassword(), Charsets.UTF_8);
- } else {
- rootPasswd = UUID.randomUUID().toString();
- }
-
- File baseDir = AccumuloClusterHarness.createTestDir(testClassName + "_" + testMethodName);
- MiniAccumuloConfigImpl cfg = new MiniAccumuloConfigImpl(baseDir, rootPasswd);
-
- // Enable native maps by default
- cfg.setNativeLibPaths(NativeMapIT.nativeMapLocation().getAbsolutePath());
- cfg.setProperty(Property.TSERV_NATIVEMAP_ENABLED, Boolean.TRUE.toString());
-
- Configuration coreSite = new Configuration(false);
-
- // Setup SSL and credential providers if the properties request such
- configureForEnvironment(cfg, getClass(), AccumuloClusterHarness.getSslDir(baseDir), coreSite, kdc);
-
- // Invoke the callback for tests to configure MAC before it starts
- configCallback.configureMiniCluster(cfg, coreSite);
-
- MiniAccumuloClusterImpl miniCluster = new MiniAccumuloClusterImpl(cfg);
-
- // Write out any configuration items to a file so HDFS will pick them up automatically (from the classpath)
- if (coreSite.size() > 0) {
- File csFile = new File(miniCluster.getConfig().getConfDir(), "core-site.xml");
- if (csFile.exists())
- throw new RuntimeException(csFile + " already exist");
-
- OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(miniCluster.getConfig().getConfDir(), "core-site.xml")));
- coreSite.writeXml(out);
- out.close();
- }
-
- return miniCluster;
- }
-
- protected void configureForEnvironment(MiniAccumuloConfigImpl cfg, Class<?> testClass, File folder, Configuration coreSite, TestingKdc kdc) {
- if (TRUE.equals(System.getProperty(USE_SSL_FOR_IT_OPTION))) {
- configureForSsl(cfg, folder);
- }
- if (TRUE.equals(System.getProperty(USE_CRED_PROVIDER_FOR_IT_OPTION))) {
- cfg.setUseCredentialProvider(true);
- }
-
- if (TRUE.equals(System.getProperty(USE_KERBEROS_FOR_IT_OPTION))) {
- if (TRUE.equals(System.getProperty(USE_SSL_FOR_IT_OPTION))) {
- throw new RuntimeException("Cannot use both SSL and Kerberos");
- }
-
- try {
- configureForKerberos(cfg, folder, coreSite, kdc);
- } catch (Exception e) {
- throw new RuntimeException("Failed to initialize KDC", e);
- }
- }
- }
-
- protected void configureForSsl(MiniAccumuloConfigImpl cfg, File folder) {
- Map<String,String> siteConfig = cfg.getSiteConfig();
- if (TRUE.equals(siteConfig.get(Property.INSTANCE_RPC_SSL_ENABLED.getKey()))) {
- // already enabled; don't mess with it
- return;
- }
-
- File sslDir = new File(folder, "ssl");
- assertTrue(sslDir.mkdirs() || sslDir.isDirectory());
- File rootKeystoreFile = new File(sslDir, "root-" + cfg.getInstanceName() + ".jks");
- File localKeystoreFile = new File(sslDir, "local-" + cfg.getInstanceName() + ".jks");
- File publicTruststoreFile = new File(sslDir, "public-" + cfg.getInstanceName() + ".jks");
- final String rootKeystorePassword = "root_keystore_password", truststorePassword = "truststore_password";
- try {
- new CertUtils(Property.RPC_SSL_KEYSTORE_TYPE.getDefaultValue(), "o=Apache Accumulo,cn=MiniAccumuloCluster", "RSA", 2048, "sha1WithRSAEncryption")
- .createAll(rootKeystoreFile, localKeystoreFile, publicTruststoreFile, cfg.getInstanceName(), rootKeystorePassword, cfg.getRootPassword(),
- truststorePassword);
- } catch (Exception e) {
- throw new RuntimeException("error creating MAC keystore", e);
- }
-
- siteConfig.put(Property.INSTANCE_RPC_SSL_ENABLED.getKey(), "true");
- siteConfig.put(Property.RPC_SSL_KEYSTORE_PATH.getKey(), localKeystoreFile.getAbsolutePath());
- siteConfig.put(Property.RPC_SSL_KEYSTORE_PASSWORD.getKey(), cfg.getRootPassword());
- siteConfig.put(Property.RPC_SSL_TRUSTSTORE_PATH.getKey(), publicTruststoreFile.getAbsolutePath());
- siteConfig.put(Property.RPC_SSL_TRUSTSTORE_PASSWORD.getKey(), truststorePassword);
- cfg.setSiteConfig(siteConfig);
- }
-
- protected void configureForKerberos(MiniAccumuloConfigImpl cfg, File folder, Configuration coreSite, TestingKdc kdc) throws Exception {
- Map<String,String> siteConfig = cfg.getSiteConfig();
- if (TRUE.equals(siteConfig.get(Property.INSTANCE_RPC_SSL_ENABLED.getKey()))) {
- throw new RuntimeException("Cannot use both SSL and SASL/Kerberos");
- }
-
- if (TRUE.equals(siteConfig.get(Property.INSTANCE_RPC_SASL_ENABLED.getKey()))) {
- // already enabled
- return;
- }
-
- if (null == kdc) {
- throw new IllegalStateException("MiniClusterKdc was null");
- }
-
- log.info("Enabling Kerberos/SASL for minicluster");
-
- // Turn on SASL and set the keytab/principal information
- cfg.setProperty(Property.INSTANCE_RPC_SASL_ENABLED, "true");
- ClusterUser serverUser = kdc.getAccumuloServerUser();
- cfg.setProperty(Property.GENERAL_KERBEROS_KEYTAB, serverUser.getKeytab().getAbsolutePath());
- cfg.setProperty(Property.GENERAL_KERBEROS_PRINCIPAL, serverUser.getPrincipal());
- cfg.setProperty(Property.INSTANCE_SECURITY_AUTHENTICATOR, KerberosAuthenticator.class.getName());
- cfg.setProperty(Property.INSTANCE_SECURITY_AUTHORIZOR, KerberosAuthorizor.class.getName());
- cfg.setProperty(Property.INSTANCE_SECURITY_PERMISSION_HANDLER, KerberosPermissionHandler.class.getName());
- // Piggy-back on the "system user" credential, but use it as a normal KerberosToken, not the SystemToken.
- cfg.setProperty(Property.TRACE_USER, serverUser.getPrincipal());
- cfg.setProperty(Property.TRACE_TOKEN_TYPE, KerberosToken.CLASS_NAME);
-
- // Pass down some KRB5 debug properties
- Map<String,String> systemProperties = cfg.getSystemProperties();
- systemProperties.put(JAVA_SECURITY_KRB5_CONF, System.getProperty(JAVA_SECURITY_KRB5_CONF, ""));
- systemProperties.put(SUN_SECURITY_KRB5_DEBUG, System.getProperty(SUN_SECURITY_KRB5_DEBUG, "false"));
- cfg.setSystemProperties(systemProperties);
-
- // Make sure UserGroupInformation will do the correct login
- coreSite.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
-
- cfg.setRootUserName(kdc.getRootUser().getPrincipal());
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/SharedMiniClusterBase.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/SharedMiniClusterBase.java b/test/src/test/java/org/apache/accumulo/harness/SharedMiniClusterBase.java
deleted file mode 100644
index 433e035..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/SharedMiniClusterBase.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Random;
-
-import org.apache.accumulo.cluster.ClusterUser;
-import org.apache.accumulo.cluster.ClusterUsers;
-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.security.TablePermission;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Convenience class which starts a single MAC instance for a test to leverage.
- *
- * There isn't a good way to build this off of the {@link AccumuloClusterHarness} (as would be the logical place) because we need to start the MiniAccumuloCluster in
- * a static BeforeClass-annotated method. Because it is static and invoked before any other BeforeClass methods in the implementation, the actual test classes
- * can't expose any information to tell the base class that it is to perform the one-MAC-per-class semantics.
- */
-public abstract class SharedMiniClusterBase extends AccumuloITBase implements ClusterUsers {
- private static final Logger log = LoggerFactory.getLogger(SharedMiniClusterBase.class);
- public static final String TRUE = Boolean.toString(true);
-
- private static String principal = "root";
- private static String rootPassword;
- private static AuthenticationToken token;
- private static MiniAccumuloClusterImpl cluster;
- private static TestingKdc krb;
-
- @BeforeClass
- public static void startMiniCluster() throws Exception {
- File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests");
- assertTrue(baseDir.mkdirs() || baseDir.isDirectory());
-
- // Make a shared MAC instance instead of spinning up one per test method
- MiniClusterHarness harness = new MiniClusterHarness();
-
- if (TRUE.equals(System.getProperty(MiniClusterHarness.USE_KERBEROS_FOR_IT_OPTION))) {
- krb = new TestingKdc();
- krb.start();
- // Enabled krb auth
- Configuration conf = new Configuration(false);
- conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
- UserGroupInformation.setConfiguration(conf);
- // Login as the client
- ClusterUser rootUser = krb.getRootUser();
- // Get the krb token
- principal = rootUser.getPrincipal();
- token = new KerberosToken(principal, rootUser.getKeytab(), true);
- } else {
- rootPassword = "rootPasswordShared1";
- token = new PasswordToken(rootPassword);
- }
-
- cluster = harness.create(SharedMiniClusterBase.class.getName(), System.currentTimeMillis() + "_" + new Random().nextInt(Short.MAX_VALUE), token, krb);
- cluster.start();
-
- if (null != krb) {
- final String traceTable = Property.TRACE_TABLE.getDefaultValue();
- final ClusterUser systemUser = krb.getAccumuloServerUser(), rootUser = krb.getRootUser();
- // Login as the trace user
- // Open a connector as the system user (ensures the user will exist for us to assign permissions to)
- Connector conn = cluster.getConnector(systemUser.getPrincipal(), new KerberosToken(systemUser.getPrincipal(), systemUser.getKeytab(), true));
-
- // Then, log back in as the "root" user and do the grant
- UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());
- conn = cluster.getConnector(principal, token);
-
- // Create the trace table
- conn.tableOperations().create(traceTable);
-
- // Trace user (which is the same kerberos principal as the system user, but using a normal KerberosToken) needs
- // to have the ability to read, write and alter the trace table
- conn.securityOperations().grantTablePermission(systemUser.getPrincipal(), traceTable, TablePermission.READ);
- conn.securityOperations().grantTablePermission(systemUser.getPrincipal(), traceTable, TablePermission.WRITE);
- conn.securityOperations().grantTablePermission(systemUser.getPrincipal(), traceTable, TablePermission.ALTER_TABLE);
- }
- }
-
- @AfterClass
- public static void stopMiniCluster() throws Exception {
- if (null != cluster) {
- try {
- cluster.stop();
- } catch (Exception e) {
- log.error("Failed to stop minicluster", e);
- }
- }
- if (null != krb) {
- try {
- krb.stop();
- } catch (Exception e) {
- log.error("Failed to stop KDC", e);
- }
- }
- }
-
- public static String getRootPassword() {
- return rootPassword;
- }
-
- public static AuthenticationToken getToken() {
- if (token instanceof KerberosToken) {
- try {
- UserGroupInformation.loginUserFromKeytab(getPrincipal(), krb.getRootUser().getKeytab().getAbsolutePath());
- } catch (IOException e) {
- throw new RuntimeException("Failed to login", e);
- }
- }
- return token;
- }
-
- public static String getPrincipal() {
- return principal;
- }
-
- public static MiniAccumuloClusterImpl getCluster() {
- return cluster;
- }
-
- public static File getMiniClusterDir() {
- return cluster.getConfig().getDir();
- }
-
- public static Connector getConnector() {
- try {
- return getCluster().getConnector(principal, getToken());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static TestingKdc getKdc() {
- return krb;
- }
-
- @Override
- public ClusterUser getAdminUser() {
- if (null == krb) {
- return new ClusterUser(getPrincipal(), getRootPassword());
- } else {
- return krb.getRootUser();
- }
- }
-
- @Override
- public ClusterUser getUser(int offset) {
- if (null == krb) {
- String user = SharedMiniClusterBase.class.getName() + "_" + testName.getMethodName() + "_" + offset;
- // Password is the username
- return new ClusterUser(user, user);
- } else {
- return krb.getClientPrincipal(offset);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/TestingKdc.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/TestingKdc.java b/test/src/test/java/org/apache/accumulo/harness/TestingKdc.java
deleted file mode 100644
index 9471274..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/TestingKdc.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.accumulo.cluster.ClusterUser;
-import org.apache.hadoop.minikdc.MiniKdc;
-import org.junit.Assert;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Creates a {@link MiniKdc} for tests to use to exercise secure Accumulo
- */
-public class TestingKdc {
- private static final Logger log = LoggerFactory.getLogger(TestingKdc.class);
-
- public static final int NUM_USERS = 10;
-
- protected MiniKdc kdc = null;
- protected ClusterUser accumuloServerUser = null, accumuloAdmin = null;
- protected List<ClusterUser> clientPrincipals = null;
-
- public final String ORG_NAME = "EXAMPLE", ORG_DOMAIN = "COM";
-
- private String hostname;
- private File keytabDir;
- private boolean started = false;
-
- public TestingKdc() throws Exception {
- this(computeKdcDir(), computeKeytabDir());
- }
-
- private static File computeKdcDir() {
- File targetDir = new File(System.getProperty("user.dir"), "target");
- Assert.assertTrue("Could not find Maven target directory: " + targetDir, targetDir.exists() && targetDir.isDirectory());
-
- // Create the directories: target/kerberos/minikdc
- File kdcDir = new File(new File(targetDir, "kerberos"), "minikdc");
-
- assertTrue(kdcDir.mkdirs() || kdcDir.isDirectory());
-
- return kdcDir;
- }
-
- private static File computeKeytabDir() {
- File targetDir = new File(System.getProperty("user.dir"), "target");
- Assert.assertTrue("Could not find Maven target directory: " + targetDir, targetDir.exists() && targetDir.isDirectory());
-
- // Create the directories: target/kerberos/keytabs
- File keytabDir = new File(new File(targetDir, "kerberos"), "keytabs");
-
- assertTrue(keytabDir.mkdirs() || keytabDir.isDirectory());
-
- return keytabDir;
- }
-
- public TestingKdc(File kdcDir, File keytabDir) throws Exception {
- checkNotNull(kdcDir, "KDC directory was null");
- checkNotNull(keytabDir, "Keytab directory was null");
-
- this.keytabDir = keytabDir;
- this.hostname = InetAddress.getLocalHost().getCanonicalHostName();
-
- log.debug("Starting MiniKdc in {} with keytabs in {}", kdcDir, keytabDir);
-
- Properties kdcConf = MiniKdc.createConf();
- kdcConf.setProperty(MiniKdc.ORG_NAME, ORG_NAME);
- kdcConf.setProperty(MiniKdc.ORG_DOMAIN, ORG_DOMAIN);
- // kdcConf.setProperty(MiniKdc.DEBUG, "true");
- kdc = new MiniKdc(kdcConf, kdcDir);
- }
-
- /**
- * Starts the KDC and creates the principals and their keytabs
- */
- public synchronized void start() throws Exception {
- checkArgument(!started, "KDC was already started");
- kdc.start();
- Thread.sleep(1000);
-
- // Create the identity for accumulo servers
- File accumuloKeytab = new File(keytabDir, "accumulo.keytab");
- String accumuloPrincipal = String.format("accumulo/%s", hostname);
-
- log.info("Creating Kerberos principal {} with keytab {}", accumuloPrincipal, accumuloKeytab);
- kdc.createPrincipal(accumuloKeytab, accumuloPrincipal);
-
- accumuloServerUser = new ClusterUser(qualifyUser(accumuloPrincipal), accumuloKeytab);
-
- // Create the identity for the "root" user
- String rootPrincipal = "root";
- File rootKeytab = new File(keytabDir, rootPrincipal + ".keytab");
-
- log.info("Creating Kerberos principal {} with keytab {}", rootPrincipal, rootKeytab);
- kdc.createPrincipal(rootKeytab, rootPrincipal);
-
- accumuloAdmin = new ClusterUser(qualifyUser(rootPrincipal), rootKeytab);
-
- clientPrincipals = new ArrayList<>(NUM_USERS);
- // Create a number of unprivileged users for tests to use
- for (int i = 1; i <= NUM_USERS; i++) {
- String clientPrincipal = "client" + i;
- File clientKeytab = new File(keytabDir, clientPrincipal + ".keytab");
-
- log.info("Creating Kerberos principal {} with keytab {}", clientPrincipal, clientKeytab);
- kdc.createPrincipal(clientKeytab, clientPrincipal);
-
- clientPrincipals.add(new ClusterUser(qualifyUser(clientPrincipal), clientKeytab));
- }
-
- started = true;
- }
-
- public synchronized void stop() throws Exception {
- checkArgument(started, "KDC is not started");
- kdc.stop();
- started = false;
- }
-
- /**
- * A directory where the automatically-created keytab files are written
- */
- public File getKeytabDir() {
- return keytabDir;
- }
-
- /**
- * A {@link ClusterUser} for Accumulo server processes to use
- */
- public ClusterUser getAccumuloServerUser() {
- checkArgument(started, "The KDC is not started");
- return accumuloServerUser;
- }
-
- /**
- * A {@link ClusterUser} which is the Accumulo "root" user
- */
- public ClusterUser getRootUser() {
- checkArgument(started, "The KDC is not started");
- return accumuloAdmin;
- }
-
- /**
- * The {@link ClusterUser} corresponding to the given offset. Represents an unprivileged user.
- *
- * @param offset
- * The offset to fetch credentials for, valid through {@link #NUM_USERS}
- */
- public ClusterUser getClientPrincipal(int offset) {
- checkArgument(started, "Client principal is not initialized, is the KDC started?");
- checkArgument(offset >= 0 && offset < NUM_USERS, "Offset is invalid, must be non-negative and less than " + NUM_USERS);
- return clientPrincipals.get(offset);
- }
-
- /**
- * @see MiniKdc#createPrincipal(File, String...)
- */
- public void createPrincipal(File keytabFile, String... principals) throws Exception {
- checkArgument(started, "KDC is not started");
- kdc.createPrincipal(keytabFile, principals);
- }
-
- /**
- * @return the name for the realm
- */
- public String getOrgName() {
- return ORG_NAME;
- }
-
- /**
- * @return the domain for the realm
- */
- public String getOrgDomain() {
- return ORG_DOMAIN;
- }
-
- /**
- * Qualify a username (only the primary from the kerberos principal) with the proper realm
- *
- * @param primary
- * The primary or primary and instance
- */
- public String qualifyUser(String primary) {
- return String.format("%s@%s.%s", primary, getOrgName(), getOrgDomain());
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterConfiguration.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterConfiguration.java b/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterConfiguration.java
deleted file mode 100644
index 31ed94a..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterConfiguration.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness.conf;
-
-import org.apache.accumulo.core.client.ClientConfiguration;
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import org.apache.accumulo.harness.AccumuloClusterHarness.ClusterType;
-
-/**
- * Base functionality that must be provided as configuration to the test
- */
-public interface AccumuloClusterConfiguration {
-
- ClusterType getClusterType();
-
- String getAdminPrincipal();
-
- AuthenticationToken getAdminToken();
-
- ClientConfiguration getClientConf();
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterPropertyConfiguration.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterPropertyConfiguration.java b/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterPropertyConfiguration.java
deleted file mode 100644
index 2300da3..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloClusterPropertyConfiguration.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness.conf;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-import org.apache.accumulo.harness.AccumuloClusterHarness.ClusterType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Base class for extracting configuration values from Java Properties
- */
-public abstract class AccumuloClusterPropertyConfiguration implements AccumuloClusterConfiguration {
- private static final Logger log = LoggerFactory.getLogger(AccumuloClusterPropertyConfiguration.class);
-
- public static final String ACCUMULO_IT_PROPERTIES_FILE = "accumulo.it.properties";
-
- public static final String ACCUMULO_CLUSTER_TYPE_KEY = "accumulo.it.cluster.type";
-
- public static final String ACCUMULO_MINI_PREFIX = "accumulo.it.cluster.mini.";
- public static final String ACCUMULO_STANDALONE_PREFIX = "accumulo.it.cluster.standalone.";
-
- public static final String ACCUMULO_CLUSTER_CLIENT_CONF_KEY = "accumulo.it.cluster.clientconf";
-
- protected ClusterType clusterType;
-
- public static AccumuloClusterPropertyConfiguration get() {
- Properties systemProperties = System.getProperties();
-
- String clusterTypeValue = null, clientConf = null;
- String propertyFile = systemProperties.getProperty(ACCUMULO_IT_PROPERTIES_FILE);
-
- if (null != propertyFile) {
- // Check for properties provided in a file
- File f = new File(propertyFile);
- if (f.exists() && f.isFile() && f.canRead()) {
- Properties fileProperties = new Properties();
- FileReader reader = null;
- try {
- reader = new FileReader(f);
- } catch (FileNotFoundException e) {
- log.warn("Could not read properties from specified file: {}", propertyFile, e);
- }
-
- if (null != reader) {
- try {
- fileProperties.load(reader);
- } catch (IOException e) {
- log.warn("Could not load properties from specified file: {}", propertyFile, e);
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- log.warn("Could not close reader", e);
- }
- }
-
- clusterTypeValue = fileProperties.getProperty(ACCUMULO_CLUSTER_TYPE_KEY);
- clientConf = fileProperties.getProperty(ACCUMULO_CLUSTER_CLIENT_CONF_KEY);
- }
- } else {
- log.debug("Property file ({}) is not a readable file", propertyFile);
- }
- } else {
- log.debug("No properties file found in {}", ACCUMULO_IT_PROPERTIES_FILE);
- }
-
- if (null == clusterTypeValue) {
- clusterTypeValue = systemProperties.getProperty(ACCUMULO_CLUSTER_TYPE_KEY);
- }
-
- if (null == clientConf) {
- clientConf = systemProperties.getProperty(ACCUMULO_CLUSTER_CLIENT_CONF_KEY);
- }
-
- ClusterType type;
- if (null == clusterTypeValue) {
- type = ClusterType.MINI;
- } else {
- type = ClusterType.valueOf(clusterTypeValue);
- }
-
- log.info("Using {} cluster type from system properties", type);
-
- switch (type) {
- case MINI:
- // we'll let no client conf pass through and expect that the caller will set it after MAC is started
- return new AccumuloMiniClusterConfiguration();
- case STANDALONE:
- if (null == clientConf) {
- throw new RuntimeException("Expected client configuration to be provided: " + ACCUMULO_CLUSTER_CLIENT_CONF_KEY);
- }
- File clientConfFile = new File(clientConf);
- if (!clientConfFile.exists() || !clientConfFile.isFile()) {
- throw new RuntimeException("Client configuration should be a normal file: " + clientConfFile);
- }
- return new StandaloneAccumuloClusterConfiguration(clientConfFile);
- default:
- throw new RuntimeException("Clusters other than MiniAccumuloCluster are not yet implemented");
- }
- }
-
- public Map<String,String> getConfiguration(ClusterType type) {
- Preconditions.checkNotNull(type);
-
- String prefix;
- switch (type) {
- case MINI:
- prefix = ACCUMULO_MINI_PREFIX;
- break;
- case STANDALONE:
- prefix = ACCUMULO_STANDALONE_PREFIX;
- break;
- default:
- throw new IllegalArgumentException("Unknown ClusterType: " + type);
- }
-
- Map<String,String> configuration = new HashMap<String,String>();
-
- Properties systemProperties = System.getProperties();
-
- String propertyFile = systemProperties.getProperty(ACCUMULO_IT_PROPERTIES_FILE);
-
- // Check for properties provided in a file
- if (null != propertyFile) {
- File f = new File(propertyFile);
- if (f.exists() && f.isFile() && f.canRead()) {
- Properties fileProperties = new Properties();
- FileReader reader = null;
- try {
- reader = new FileReader(f);
- } catch (FileNotFoundException e) {
- log.warn("Could not read properties from specified file: {}", propertyFile, e);
- }
-
- if (null != reader) {
- try {
- fileProperties.load(reader);
- loadFromProperties(prefix, fileProperties, configuration);
- } catch (IOException e) {
- log.warn("Could not load properties from specified file: {}", propertyFile, e);
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- log.warn("Could not close reader", e);
- }
- }
- }
- }
- }
-
- // Load any properties specified directly in the system properties
- loadFromProperties(prefix, systemProperties, configuration);
-
- return configuration;
- }
-
- protected void loadFromProperties(String desiredPrefix, Properties properties, Map<String,String> configuration) {
- for (Entry<Object,Object> entry : properties.entrySet()) {
- if (!(entry.getKey() instanceof String)) {
- continue;
- }
-
- String key = (String) entry.getKey();
- if (key.startsWith(desiredPrefix)) {
- configuration.put(key, (String) entry.getValue());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java b/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
deleted file mode 100644
index 4d233a5..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness.conf;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.accumulo.cluster.ClusterUser;
-import org.apache.accumulo.core.client.ClientConfiguration;
-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.harness.AccumuloClusterHarness;
-import org.apache.accumulo.harness.AccumuloClusterHarness.ClusterType;
-import org.apache.accumulo.harness.MiniClusterHarness;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Extract configuration properties for a MiniAccumuloCluster from Java properties
- */
-public class AccumuloMiniClusterConfiguration extends AccumuloClusterPropertyConfiguration {
- private static final Logger log = LoggerFactory.getLogger(AccumuloMiniClusterConfiguration.class);
- private static final String TRUE = Boolean.toString(true);
-
- public static final String ACCUMULO_MINI_PRINCIPAL_KEY = ACCUMULO_MINI_PREFIX + "principal";
- public static final String ACCUMULO_MINI_PRINCIPAL_DEFAULT = "root";
- public static final String ACCUMULO_MINI_PASSWORD_KEY = ACCUMULO_MINI_PREFIX + "password";
- public static final String ACCUMULO_MINI_PASSWORD_DEFAULT = "rootPassword1";
-
- private final Map<String,String> conf;
- private final boolean saslEnabled;
- private ClientConfiguration clientConf;
-
- public AccumuloMiniClusterConfiguration() {
- ClusterType type = getClusterType();
- if (ClusterType.MINI != type) {
- throw new IllegalStateException("Expected only to see mini cluster state");
- }
-
- this.conf = getConfiguration(type);
- this.saslEnabled = TRUE.equals(System.getProperty(MiniClusterHarness.USE_KERBEROS_FOR_IT_OPTION));
- log.debug("SASL is {}enabled", (saslEnabled ? "" : "not "));
- }
-
- @Override
- public String getAdminPrincipal() {
- if (saslEnabled) {
- return AccumuloClusterHarness.getKdc().getRootUser().getPrincipal();
- } else {
- String principal = conf.get(ACCUMULO_MINI_PRINCIPAL_KEY);
- if (null == principal) {
- principal = ACCUMULO_MINI_PRINCIPAL_DEFAULT;
- }
-
- return principal;
- }
- }
-
- @Override
- public AuthenticationToken getAdminToken() {
- if (saslEnabled) {
- // Turn on Kerberos authentication so UGI acts properly
- final Configuration conf = new Configuration(false);
- conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
- UserGroupInformation.setConfiguration(conf);
-
- ClusterUser rootUser = AccumuloClusterHarness.getKdc().getRootUser();
- try {
- return new KerberosToken(rootUser.getPrincipal(), rootUser.getKeytab(), true);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- } else {
- String password = conf.get(ACCUMULO_MINI_PASSWORD_KEY);
- if (null == password) {
- password = ACCUMULO_MINI_PASSWORD_DEFAULT;
- }
-
- return new PasswordToken(password);
- }
- }
-
- @Override
- public ClusterType getClusterType() {
- return ClusterType.MINI;
- }
-
- @Override
- public ClientConfiguration getClientConf() {
- return clientConf;
- }
-
- public void setClientConf(ClientConfiguration conf) {
- Preconditions.checkNotNull(conf, "Client configuration was null");
- this.clientConf = conf;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/01ae5b85/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java b/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
deleted file mode 100644
index ba9dcef..0000000
--- a/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.harness.conf;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.cluster.ClusterUser;
-import org.apache.accumulo.core.client.ClientConfiguration;
-import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.ZooKeeperInstance;
-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.harness.AccumuloClusterHarness.ClusterType;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.hadoop.fs.Path;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Extract connection information to a standalone Accumulo instance from Java properties
- */
-public class StandaloneAccumuloClusterConfiguration extends AccumuloClusterPropertyConfiguration {
- private static final Logger log = LoggerFactory.getLogger(StandaloneAccumuloClusterConfiguration.class);
-
- public static final String ACCUMULO_STANDALONE_ADMIN_PRINCIPAL_KEY = ACCUMULO_STANDALONE_PREFIX + "admin.principal";
- public static final String ACCUMULO_STANDALONE_ADMIN_PRINCIPAL_DEFAULT = "root";
- public static final String ACCUMULO_STANDALONE_PASSWORD_KEY = ACCUMULO_STANDALONE_PREFIX + "admin.password";
- public static final String ACCUMULO_STANDALONE_PASSWORD_DEFAULT = "rootPassword1";
- public static final String ACCUMULO_STANDALONE_ADMIN_KEYTAB_KEY = ACCUMULO_STANDALONE_PREFIX + "admin.keytab";
- public static final String ACCUMULO_STANDALONE_ZOOKEEPERS_KEY = ACCUMULO_STANDALONE_PREFIX + "zookeepers";
- public static final String ACCUMULO_STANDALONE_ZOOKEEPERS_DEFAULT = "localhost";
- public static final String ACCUMULO_STANDALONE_INSTANCE_NAME_KEY = ACCUMULO_STANDALONE_PREFIX + "instance.name";
- public static final String ACCUMULO_STANDALONE_INSTANCE_NAME_DEFAULT = "accumulo";
- public static final String ACCUMULO_STANDALONE_TMP_DIR_KEY = ACCUMULO_STANDALONE_PREFIX + "tmpdir";
- public static final String ACCUMULO_STANDALONE_TMP_DIR_DEFAULT = "/tmp";
- public static final String ACCUMULO_STANDALONE_SERVER_USER = ACCUMULO_STANDALONE_PREFIX + "server.user";
- public static final String ACCUMULO_STANDALONE_SERVER_USER_DEFAULT = "accumulo";
-
- // A set of users we can use to connect to this instances
- public static final String ACCUMULO_STANDALONE_USER_KEY = ACCUMULO_STANDALONE_PREFIX + "users.";
- // Keytabs for the users
- public static final String ACCUMULO_STANDALONE_USER_KEYTABS_KEY = ACCUMULO_STANDALONE_PREFIX + "keytabs.";
- // Passwords for the users
- public static final String ACCUMULO_STANDALONE_USER_PASSWORDS_KEY = ACCUMULO_STANDALONE_PREFIX + "passwords.";
-
- public static final String ACCUMULO_STANDALONE_HOME = ACCUMULO_STANDALONE_PREFIX + "home";
- public static final String ACCUMULO_STANDALONE_CLIENT_CONF = ACCUMULO_STANDALONE_PREFIX + "client.conf";
- public static final String ACCUMULO_STANDALONE_SERVER_CONF = ACCUMULO_STANDALONE_PREFIX + "server.conf";
- public static final String ACCUMULO_STANDALONE_HADOOP_CONF = ACCUMULO_STANDALONE_PREFIX + "hadoop.conf";
-
- private Map<String,String> conf;
- private String serverUser;
- private File clientConfFile;
- private ClientConfiguration clientConf;
- private List<ClusterUser> clusterUsers;
-
- public StandaloneAccumuloClusterConfiguration(File clientConfFile) {
- ClusterType type = getClusterType();
- if (ClusterType.STANDALONE != type) {
- throw new IllegalStateException("Expected only to see standalone cluster state");
- }
-
- this.conf = getConfiguration(type);
- this.clientConfFile = clientConfFile;
- try {
- this.clientConf = new ClientConfiguration(clientConfFile);
- } catch (ConfigurationException e) {
- throw new RuntimeException("Failed to load client configuration from " + clientConfFile);
- }
- // Update instance name if not already set
- if (!clientConf.containsKey(ClientProperty.INSTANCE_NAME.getKey())) {
- clientConf.withInstance(getInstanceName());
- }
- // Update zookeeper hosts if not already set
- if (!clientConf.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) {
- clientConf.withZkHosts(getZooKeepers());
- }
-
- // The user Accumulo is running as
- serverUser = conf.get(ACCUMULO_STANDALONE_SERVER_USER);
- if (null == serverUser) {
- serverUser = ACCUMULO_STANDALONE_SERVER_USER_DEFAULT;
- }
-
- clusterUsers = new ArrayList<>();
- for (Entry<String,String> entry : conf.entrySet()) {
- String key = entry.getKey();
- if (key.startsWith(ACCUMULO_STANDALONE_USER_KEY)) {
- String suffix = key.substring(ACCUMULO_STANDALONE_USER_KEY.length());
- String keytab = conf.get(ACCUMULO_STANDALONE_USER_KEYTABS_KEY + suffix);
- if (null != keytab) {
- File keytabFile = new File(keytab);
- assertTrue("Keytab doesn't exist: " + keytabFile, keytabFile.exists() && keytabFile.isFile());
- clusterUsers.add(new ClusterUser(entry.getValue(), keytabFile));
- } else {
- String password = conf.get(ACCUMULO_STANDALONE_USER_PASSWORDS_KEY + suffix);
- if (null == password) {
- throw new IllegalArgumentException("Missing password or keytab configuration for user with offset " + suffix);
- }
- clusterUsers.add(new ClusterUser(entry.getValue(), password));
- }
- }
- }
- log.info("Initialized Accumulo users with Kerberos keytabs: {}", clusterUsers);
- }
-
- @Override
- public String getAdminPrincipal() {
- String principal = conf.get(ACCUMULO_STANDALONE_ADMIN_PRINCIPAL_KEY);
- if (null == principal) {
- principal = ACCUMULO_STANDALONE_ADMIN_PRINCIPAL_DEFAULT;
- }
- return principal;
- }
-
- public String getPassword() {
- String password = conf.get(ACCUMULO_STANDALONE_PASSWORD_KEY);
- if (null == password) {
- password = ACCUMULO_STANDALONE_PASSWORD_DEFAULT;
- }
- return password;
- }
-
- public File getAdminKeytab() {
- String keytabPath = conf.get(ACCUMULO_STANDALONE_ADMIN_KEYTAB_KEY);
- if (null == keytabPath) {
- throw new RuntimeException("SASL is enabled, but " + ACCUMULO_STANDALONE_ADMIN_KEYTAB_KEY + " was not provided");
- }
- File keytab = new File(keytabPath);
- if (!keytab.exists() || !keytab.isFile()) {
- throw new RuntimeException(keytabPath + " should be a regular file");
- }
- return keytab;
- }
-
- @Override
- public AuthenticationToken getAdminToken() {
- if (clientConf.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false)) {
- File keytab = getAdminKeytab();
- try {
- return new KerberosToken(getAdminPrincipal(), keytab, true);
- } catch (IOException e) {
- // The user isn't logged in
- throw new RuntimeException("Failed to create KerberosToken", e);
- }
- } else {
- return new PasswordToken(getPassword());
- }
- }
-
- public String getZooKeepers() {
- if (clientConf.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) {
- return clientConf.get(ClientProperty.INSTANCE_ZK_HOST);
- }
-
- String zookeepers = conf.get(ACCUMULO_STANDALONE_ZOOKEEPERS_KEY);
- if (null == zookeepers) {
- zookeepers = ACCUMULO_STANDALONE_ZOOKEEPERS_DEFAULT;
- }
- return zookeepers;
- }
-
- public String getInstanceName() {
- if (clientConf.containsKey(ClientProperty.INSTANCE_NAME.getKey())) {
- return clientConf.get(ClientProperty.INSTANCE_NAME);
- }
-
- String instanceName = conf.get(ACCUMULO_STANDALONE_INSTANCE_NAME_KEY);
- if (null == instanceName) {
- instanceName = ACCUMULO_STANDALONE_INSTANCE_NAME_DEFAULT;
- }
- return instanceName;
- }
-
- public Instance getInstance() {
- // Make sure the ZKI is created with the ClientConf so it gets things like SASL passed through to the connector
- return new ZooKeeperInstance(clientConf);
- }
-
- @Override
- public ClusterType getClusterType() {
- return ClusterType.STANDALONE;
- }
-
- public String getHadoopConfDir() {
- return conf.get(ACCUMULO_STANDALONE_HADOOP_CONF);
- }
-
- public String getAccumuloHome() {
- return conf.get(ACCUMULO_STANDALONE_HOME);
- }
-
- public String getClientAccumuloConfDir() {
- return conf.get(ACCUMULO_STANDALONE_CLIENT_CONF);
- }
-
- public String getServerAccumuloConfDir() {
- return conf.get(ACCUMULO_STANDALONE_SERVER_CONF);
- }
-
- @Override
- public ClientConfiguration getClientConf() {
- return clientConf;
- }
-
- public File getClientConfFile() {
- return clientConfFile;
- }
-
- public Path getTmpDirectory() {
- String tmpDir = conf.get(ACCUMULO_STANDALONE_TMP_DIR_KEY);
- if (null == tmpDir) {
- tmpDir = ACCUMULO_STANDALONE_TMP_DIR_DEFAULT;
- }
- return new Path(tmpDir);
- }
-
- public List<ClusterUser> getUsers() {
- return Collections.unmodifiableList(clusterUsers);
- }
-
- /**
- * @return The user Accumulo is running as
- */
- public String getAccumuloServerUser() {
- return serverUser;
- }
-}