You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2020/12/21 18:37:40 UTC

[accumulo] branch 2.0.1-rc1 created (now 76247b1)

This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a change to branch 2.0.1-rc1
in repository https://gitbox.apache.org/repos/asf/accumulo.git.


      at 76247b1  [maven-release-plugin] prepare release rel/2.0.1

This branch includes the following new commits:

     new 775b9fc  Update release candidate script (#1724)
     new 6ceb006  Fix a bug in the AccumuloClient builder
     new 024a72e  Fix ClientPropertiesTest for #1839
     new 877ad50  Throw exceptions when permissions checks fail (#1828)
     new 435f184  Add additional permission checks (#1832)
     new 76247b1  [maven-release-plugin] prepare release rel/2.0.1

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[accumulo] 04/06: Throw exceptions when permissions checks fail (#1828)

Posted by ct...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.0.1-rc1
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 877ad502f6857e48342664e4b0ce83db74e4cda4
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Tue Dec 8 14:08:36 2020 -0500

    Throw exceptions when permissions checks fail (#1828)
    
    (cherry-picked for 2.0.1)
    
    Add and throw missing exceptions when permissions checks fail. This
    prevents certain operations that the user does not have privileges to
    perform from succeeding anyway.
---
 .../accumulo/master/MasterClientServiceHandler.java | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
index 49b1303..21ad543 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
@@ -112,7 +112,8 @@ public class MasterClientServiceHandler extends FateServiceHandler
       throws ThriftSecurityException, ThriftTableOperationException {
     TableId tableId = TableId.of(tableIdStr);
     NamespaceId namespaceId = getNamespaceIdFromTableId(TableOperation.FLUSH, tableId);
-    master.security.canFlush(c, tableId, namespaceId);
+    if (!master.security.canFlush(c, tableId, namespaceId))
+      throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
 
     String zTablePath = Constants.ZROOT + "/" + master.getInstanceID() + Constants.ZTABLES + "/"
         + tableId + Constants.ZTABLE_FLUSH_ID;
@@ -145,7 +146,8 @@ public class MasterClientServiceHandler extends FateServiceHandler
       throws ThriftSecurityException, ThriftTableOperationException {
     TableId tableId = TableId.of(tableIdStr);
     NamespaceId namespaceId = getNamespaceIdFromTableId(TableOperation.FLUSH, tableId);
-    master.security.canFlush(c, tableId, namespaceId);
+    if (!master.security.canFlush(c, tableId, namespaceId))
+      throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
 
     Text startRow = ByteBufferUtil.toText(startRowBB);
     Text endRow = ByteBufferUtil.toText(endRowBB);
@@ -247,7 +249,8 @@ public class MasterClientServiceHandler extends FateServiceHandler
   @Override
   public void shutdown(TInfo info, TCredentials c, boolean stopTabletServers)
       throws ThriftSecurityException {
-    master.security.canPerformSystemActions(c);
+    if (!master.security.canPerformSystemActions(c))
+      throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
     if (stopTabletServers) {
       master.setMasterGoalState(MasterGoalState.CLEAN_STOP);
       EventCoordinator.Listener eventListener = master.nextEvent.getListener();
@@ -261,7 +264,8 @@ public class MasterClientServiceHandler extends FateServiceHandler
   @Override
   public void shutdownTabletServer(TInfo info, TCredentials c, String tabletServer, boolean force)
       throws ThriftSecurityException {
-    master.security.canPerformSystemActions(c);
+    if (!master.security.canPerformSystemActions(c))
+      throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
 
     final TServerInstance doomed = master.tserverSet.find(tabletServer);
     if (!force) {
@@ -333,7 +337,8 @@ public class MasterClientServiceHandler extends FateServiceHandler
   @Override
   public void setMasterGoalState(TInfo info, TCredentials c, MasterGoalState state)
       throws ThriftSecurityException {
-    master.security.canPerformSystemActions(c);
+    if (!master.security.canPerformSystemActions(c))
+      throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
 
     master.setMasterGoalState(state);
   }
@@ -341,7 +346,8 @@ public class MasterClientServiceHandler extends FateServiceHandler
   @Override
   public void removeSystemProperty(TInfo info, TCredentials c, String property)
       throws ThriftSecurityException {
-    master.security.canPerformSystemActions(c);
+    if (!master.security.canPerformSystemActions(c))
+      throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
 
     try {
       SystemPropUtil.removeSystemProperty(master.getContext(), property);
@@ -355,7 +361,8 @@ public class MasterClientServiceHandler extends FateServiceHandler
   @Override
   public void setSystemProperty(TInfo info, TCredentials c, String property, String value)
       throws ThriftSecurityException, TException {
-    master.security.canPerformSystemActions(c);
+    if (!master.security.canPerformSystemActions(c))
+      throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
 
     try {
       SystemPropUtil.setSystemProperty(master.getContext(), property, value);


[accumulo] 03/06: Fix ClientPropertiesTest for #1839

Posted by ct...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.0.1-rc1
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 024a72ed8b80c21470ab2eed04787e3216b7b606
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Wed Dec 16 14:36:05 2020 -0500

    Fix ClientPropertiesTest for #1839
    
    (cherry-picked for 2.0.1)
    
    Ensure correct copy behavior when constructing a client from a previous
    client's properties.
---
 .../accumulo/core/client/ClientPropertiesTest.java | 28 ++++++++++++++--------
 pom.xml                                            |  2 +-
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/core/src/test/java/org/apache/accumulo/core/client/ClientPropertiesTest.java b/core/src/test/java/org/apache/accumulo/core/client/ClientPropertiesTest.java
index fcea350..23fa35b 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/ClientPropertiesTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/ClientPropertiesTest.java
@@ -17,7 +17,7 @@
 package org.apache.accumulo.core.client;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
 
 import java.nio.file.Paths;
 import java.util.Properties;
@@ -37,20 +37,28 @@ public class ClientPropertiesTest {
     assertEquals("password", ClientProperty.AUTH_TYPE.getValue(props1));
     assertEquals("pass1", ClientProperty.AUTH_TOKEN.getValue(props1));
 
+    ClientProperty.validate(props1);
+
     Properties props2 =
         Accumulo.newClientProperties().from(props1).as("user2", Paths.get("/path2")).build();
+
+    // verify props1 is unchanged
     assertEquals("inst1", ClientProperty.INSTANCE_NAME.getValue(props1));
     assertEquals("zoo1", ClientProperty.INSTANCE_ZOOKEEPERS.getValue(props1));
-    assertEquals("user2", ClientProperty.AUTH_PRINCIPAL.getValue(props1));
-    assertEquals("kerberos", ClientProperty.AUTH_TYPE.getValue(props1));
-    assertEquals("/path2", ClientProperty.AUTH_TOKEN.getValue(props1));
+    assertEquals("user1", ClientProperty.AUTH_PRINCIPAL.getValue(props1));
+    assertEquals("password", ClientProperty.AUTH_TYPE.getValue(props1));
+    assertEquals("pass1", ClientProperty.AUTH_TOKEN.getValue(props1));
+
+    // verify props2 has new values for overridden fields
+    assertEquals("inst1", ClientProperty.INSTANCE_NAME.getValue(props2));
+    assertEquals("zoo1", ClientProperty.INSTANCE_ZOOKEEPERS.getValue(props2));
+    assertEquals("user2", ClientProperty.AUTH_PRINCIPAL.getValue(props2));
+    assertEquals("kerberos", ClientProperty.AUTH_TYPE.getValue(props2));
+    assertEquals("/path2", ClientProperty.AUTH_TOKEN.getValue(props2));
 
     props2.remove(ClientProperty.AUTH_PRINCIPAL.getKey());
-    try {
-      ClientProperty.validate(props2);
-      fail();
-    } catch (IllegalArgumentException e) {
-      // expected
-    }
+    Exception e =
+        assertThrows(IllegalArgumentException.class, () -> ClientProperty.validate(props2));
+    assertEquals("auth.principal is not set", e.getMessage());
   }
 }
diff --git a/pom.xml b/pom.xml
index ee038cf..a5107ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -301,7 +301,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
-        <version>4.12</version>
+        <version>4.13.1</version>
       </dependency>
       <dependency>
         <groupId>log4j</groupId>


[accumulo] 06/06: [maven-release-plugin] prepare release rel/2.0.1

Posted by ct...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.0.1-rc1
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 76247b1739dd3042cb2d959a7a99f0cf1bcb1324
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Mon Dec 21 13:29:47 2020 -0500

    [maven-release-plugin] prepare release rel/2.0.1
---
 assemble/pom.xml              | 2 +-
 core/pom.xml                  | 2 +-
 hadoop-mapreduce/pom.xml      | 2 +-
 iterator-test-harness/pom.xml | 2 +-
 minicluster/pom.xml           | 2 +-
 pom.xml                       | 4 ++--
 server/base/pom.xml           | 2 +-
 server/gc/pom.xml             | 2 +-
 server/master/pom.xml         | 2 +-
 server/monitor/pom.xml        | 2 +-
 server/native/pom.xml         | 2 +-
 server/tracer/pom.xml         | 2 +-
 server/tserver/pom.xml        | 2 +-
 shell/pom.xml                 | 2 +-
 start/pom.xml                 | 2 +-
 test/pom.xml                  | 2 +-
 16 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/assemble/pom.xml b/assemble/pom.xml
index ddbd95e..73aba90 100644
--- a/assemble/pom.xml
+++ b/assemble/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo</artifactId>
   <packaging>pom</packaging>
diff --git a/core/pom.xml b/core/pom.xml
index 878ef0a..c3ef5c9 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo-core</artifactId>
   <name>Apache Accumulo Core</name>
diff --git a/hadoop-mapreduce/pom.xml b/hadoop-mapreduce/pom.xml
index ac469a9..6a33d6d 100644
--- a/hadoop-mapreduce/pom.xml
+++ b/hadoop-mapreduce/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo-hadoop-mapreduce</artifactId>
   <name>Apache Accumulo Hadoop MapReduce</name>
diff --git a/iterator-test-harness/pom.xml b/iterator-test-harness/pom.xml
index 1009652..591b1dd 100644
--- a/iterator-test-harness/pom.xml
+++ b/iterator-test-harness/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo-iterator-test-harness</artifactId>
   <name>Apache Accumulo Iterator Test Harness</name>
diff --git a/minicluster/pom.xml b/minicluster/pom.xml
index 43b85c4..da46283 100644
--- a/minicluster/pom.xml
+++ b/minicluster/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo-minicluster</artifactId>
   <name>Apache Accumulo MiniCluster</name>
diff --git a/pom.xml b/pom.xml
index a5107ca..3a7d6e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
   </parent>
   <groupId>org.apache.accumulo</groupId>
   <artifactId>accumulo-project</artifactId>
-  <version>2.0.1-SNAPSHOT</version>
+  <version>2.0.1</version>
   <packaging>pom</packaging>
   <name>Apache Accumulo Project</name>
   <description>Apache Accumulo is a sorted, distributed key/value store based
@@ -96,7 +96,7 @@
   <scm>
     <connection>scm:git:https://gitbox.apache.org/repos/asf/accumulo.git</connection>
     <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/accumulo.git</developerConnection>
-    <tag>HEAD</tag>
+    <tag>rel/2.0.1</tag>
     <url>https://gitbox.apache.org/repos/asf?p=accumulo.git</url>
   </scm>
   <issueManagement>
diff --git a/server/base/pom.xml b/server/base/pom.xml
index ded935d..09599f6 100644
--- a/server/base/pom.xml
+++ b/server/base/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <artifactId>accumulo-server-base</artifactId>
diff --git a/server/gc/pom.xml b/server/gc/pom.xml
index 92170aa..c25c1f8 100644
--- a/server/gc/pom.xml
+++ b/server/gc/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <artifactId>accumulo-gc</artifactId>
diff --git a/server/master/pom.xml b/server/master/pom.xml
index e1942c2..7e9618c 100644
--- a/server/master/pom.xml
+++ b/server/master/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <artifactId>accumulo-master</artifactId>
diff --git a/server/monitor/pom.xml b/server/monitor/pom.xml
index 01d44cd..b4bd250 100644
--- a/server/monitor/pom.xml
+++ b/server/monitor/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <artifactId>accumulo-monitor</artifactId>
diff --git a/server/native/pom.xml b/server/native/pom.xml
index 0042387..f676273 100644
--- a/server/native/pom.xml
+++ b/server/native/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <artifactId>accumulo-native</artifactId>
diff --git a/server/tracer/pom.xml b/server/tracer/pom.xml
index c54a4fe..1789b78 100644
--- a/server/tracer/pom.xml
+++ b/server/tracer/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <artifactId>accumulo-tracer</artifactId>
diff --git a/server/tserver/pom.xml b/server/tserver/pom.xml
index 758d487..f230059 100644
--- a/server/tserver/pom.xml
+++ b/server/tserver/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <artifactId>accumulo-tserver</artifactId>
diff --git a/shell/pom.xml b/shell/pom.xml
index cf94610..463482e 100644
--- a/shell/pom.xml
+++ b/shell/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo-shell</artifactId>
   <name>Apache Accumulo Shell</name>
diff --git a/start/pom.xml b/start/pom.xml
index cc574ff..3533fcc 100644
--- a/start/pom.xml
+++ b/start/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo-start</artifactId>
   <name>Apache Accumulo Start</name>
diff --git a/test/pom.xml b/test/pom.xml
index befd5cc..0f7f8dd 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.accumulo</groupId>
     <artifactId>accumulo-project</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.1</version>
   </parent>
   <artifactId>accumulo-test</artifactId>
   <name>Apache Accumulo Testing</name>


[accumulo] 05/06: Add additional permission checks (#1832)

Posted by ct...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.0.1-rc1
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 435f18429a117ea1b7bd0f3cb821d8d6c9674281
Author: Jeffrey Manno <je...@gmail.com>
AuthorDate: Tue Dec 15 22:27:06 2020 -0500

    Add additional permission checks (#1832)
    
    (cherry-picked for 2.0.1)
    
    * Update AuditMessageIT to test auditing of flush commands
    * Add new ManagerApiIT to test permissions checks of
      MasterClientServiceHandler RPC endpoints
    * Fill in missing checks for SYSTEM permissions in PermissionsIT
      (and add flush tests for WRITE and ALTER_TABLE permissions)
    
    Co-authored-by: Dave Marion <dl...@apache.org>
    Co-authored-by: Christopher Tubbs <ct...@apache.org>
---
 .../org/apache/accumulo/test/AuditMessageIT.java   |  36 ++--
 .../accumulo/test/functional/ManagerApiIT.java     | 239 +++++++++++++++++++++
 .../accumulo/test/functional/PermissionsIT.java    | 110 ++++++++--
 3 files changed, 349 insertions(+), 36 deletions(-)

diff --git a/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java b/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
index c2a9b08..2667336 100644
--- a/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.test;
 
@@ -144,7 +146,7 @@ public class AuditMessageIT extends ConfigurableMacBase {
       System.out.println(s);
     }
     System.out.println("End of captured audit messages for step " + stepName);
-    if (result.size() > 0)
+    if (!result.isEmpty())
       lastAuditTimestamp = (result.get(result.size() - 1)).substring(0, 23);
 
     return result;
@@ -455,7 +457,7 @@ public class AuditMessageIT extends ConfigurableMacBase {
       auditAccumuloClient.tableOperations().rename(OLD_TEST_TABLE_NAME, NEW_TEST_TABLE_NAME);
     } catch (AccumuloSecurityException ex) {}
     try {
-      auditAccumuloClient.tableOperations().clone(OLD_TEST_TABLE_NAME, NEW_TEST_TABLE_NAME, true,
+      auditAccumuloClient.tableOperations().clone(OLD_TEST_TABLE_NAME, NEW_TEST_TABLE_NAME, false,
           Collections.emptyMap(), Collections.emptySet());
     } catch (AccumuloSecurityException ex) {}
     try {
@@ -471,6 +473,10 @@ public class AuditMessageIT extends ConfigurableMacBase {
       auditAccumuloClient.tableOperations().deleteRows(OLD_TEST_TABLE_NAME, new Text("myRow"),
           new Text("myRow~"));
     } catch (AccumuloSecurityException ex) {}
+    try {
+      auditAccumuloClient.tableOperations().flush(OLD_TEST_TABLE_NAME, new Text("myRow"),
+          new Text("myRow~"), false);
+    } catch (AccumuloSecurityException ex) {}
 
     // ... that will do for now.
     // End of testing activities
@@ -502,6 +508,8 @@ public class AuditMessageIT extends ConfigurableMacBase {
             "operation: denied;.*"
                 + String.format(AuditedSecurityOperation.CAN_DELETE_RANGE_AUDIT_TEMPLATE,
                     OLD_TEST_TABLE_NAME, "myRow", "myRow~")));
+    assertEquals(1, findAuditMessage(auditMessages, "operation: denied;.*" + String
+        .format(AuditedSecurityOperation.CAN_FLUSH_TABLE_AUDIT_TEMPLATE, "1", "\\+default")));
   }
 
   @Test
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ManagerApiIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ManagerApiIT.java
new file mode 100644
index 0000000..d968584
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ManagerApiIT.java
@@ -0,0 +1,239 @@
+/*
+ * 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.test.functional;
+
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
+
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Function;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.admin.SecurityOperations;
+import org.apache.accumulo.core.client.security.SecurityErrorCode;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.clientImpl.ClientContext;
+import org.apache.accumulo.core.clientImpl.ClientExec;
+import org.apache.accumulo.core.clientImpl.Credentials;
+import org.apache.accumulo.core.clientImpl.MasterClient;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.master.thrift.MasterClientService;
+import org.apache.accumulo.core.master.thrift.MasterGoalState;
+import org.apache.accumulo.core.security.SystemPermission;
+import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.core.securityImpl.thrift.TCredentials;
+import org.apache.accumulo.core.singletons.SingletonManager;
+import org.apache.accumulo.core.singletons.SingletonManager.Mode;
+import org.apache.accumulo.core.util.TextUtil;
+import org.apache.accumulo.harness.SharedMiniClusterBase;
+import org.apache.hadoop.io.Text;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+// the shutdown test should sort last, so other tests don't break
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ManagerApiIT extends SharedMiniClusterBase {
+
+  @Override
+  public int defaultTimeoutSeconds() {
+    return 60;
+  }
+
+  private static Credentials rootUser;
+  private static Credentials regularUser;
+  private static Credentials privilegedUser;
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    // need to pretend to be a server, so we can bypass all of
+    // the singleton resource management in this test
+    SingletonManager.setMode(Mode.SERVER);
+    SharedMiniClusterBase.startMiniCluster();
+    rootUser = new Credentials(getPrincipal(), getToken());
+    regularUser = new Credentials("regularUser", new PasswordToken("regularUser"));
+    privilegedUser = new Credentials("privilegedUser", new PasswordToken("privilegedUser"));
+    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
+      SecurityOperations rootSecOps = client.securityOperations();
+      for (Credentials user : Arrays.asList(regularUser, privilegedUser))
+        rootSecOps.createLocalUser(user.getPrincipal(), (PasswordToken) user.getToken());
+      rootSecOps.grantSystemPermission(privilegedUser.getPrincipal(), SystemPermission.SYSTEM);
+    }
+  }
+
+  @AfterClass
+  public static void teardown() throws Exception {
+    SharedMiniClusterBase.stopMiniCluster();
+  }
+
+  private Function<TCredentials,ClientExec<MasterClientService.Client>> op;
+
+  @Test
+  public void testPermissions_setMasterGoalState() throws Exception {
+    // To setMasterGoalState, user needs SystemPermission.SYSTEM
+    op = user -> client -> client.setMasterGoalState(null, user, MasterGoalState.NORMAL);
+    expectPermissionDenied(op, regularUser);
+    expectPermissionSuccess(op, rootUser);
+    expectPermissionSuccess(op, privilegedUser);
+  }
+
+  @Test
+  public void testPermissions_initiateFlush() throws Exception {
+    // To initiateFlush, user needs TablePermission.WRITE or TablePermission.ALTER_TABLE
+    String[] uniqNames = getUniqueNames(3);
+    String tableName = uniqNames[0];
+    Credentials regUserWithWrite = new Credentials(uniqNames[1], new PasswordToken(uniqNames[1]));
+    Credentials regUserWithAlter = new Credentials(uniqNames[2], new PasswordToken(uniqNames[2]));
+    String tableId;
+    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
+      SecurityOperations rootSecOps = client.securityOperations();
+      rootSecOps.createLocalUser(regUserWithWrite.getPrincipal(),
+          (PasswordToken) regUserWithWrite.getToken());
+      rootSecOps.createLocalUser(regUserWithAlter.getPrincipal(),
+          (PasswordToken) regUserWithAlter.getToken());
+      client.tableOperations().create(tableName);
+      rootSecOps.grantTablePermission(regUserWithWrite.getPrincipal(), tableName,
+          TablePermission.WRITE);
+      rootSecOps.grantTablePermission(regUserWithAlter.getPrincipal(), tableName,
+          TablePermission.ALTER_TABLE);
+      tableId = client.tableOperations().tableIdMap().get(tableName);
+    }
+    op = user -> client -> client.initiateFlush(null, user, tableId);
+    expectPermissionDenied(op, regularUser);
+    // privileged users can grant themselves permission, but it's not default
+    expectPermissionDenied(op, privilegedUser);
+    expectPermissionSuccess(op, regUserWithWrite);
+    expectPermissionSuccess(op, regUserWithAlter);
+    // root user can because they created the table
+    expectPermissionSuccess(op, rootUser);
+  }
+
+  @Test
+  public void testPermissions_waitForFlush() throws Exception {
+    // To waitForFlush, user needs TablePermission.WRITE or TablePermission.ALTER_TABLE
+    String[] uniqNames = getUniqueNames(3);
+    String tableName = uniqNames[0];
+    Credentials regUserWithWrite = new Credentials(uniqNames[1], new PasswordToken(uniqNames[1]));
+    Credentials regUserWithAlter = new Credentials(uniqNames[2], new PasswordToken(uniqNames[2]));
+    String tableId;
+    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
+      SecurityOperations rootSecOps = client.securityOperations();
+      rootSecOps.createLocalUser(regUserWithWrite.getPrincipal(),
+          (PasswordToken) regUserWithWrite.getToken());
+      rootSecOps.createLocalUser(regUserWithAlter.getPrincipal(),
+          (PasswordToken) regUserWithAlter.getToken());
+      client.tableOperations().create(tableName);
+      rootSecOps.grantTablePermission(regUserWithWrite.getPrincipal(), tableName,
+          TablePermission.WRITE);
+      rootSecOps.grantTablePermission(regUserWithAlter.getPrincipal(), tableName,
+          TablePermission.ALTER_TABLE);
+      tableId = client.tableOperations().tableIdMap().get(tableName);
+    }
+    AtomicLong flushId = new AtomicLong();
+    // initiateFlush as the root user to get the flushId, then test waitForFlush with other users
+    op = user -> client -> flushId.set(client.initiateFlush(null, user, tableId));
+    expectPermissionSuccess(op, rootUser);
+    op = user -> client -> client.waitForFlush(null, user, tableId,
+        TextUtil.getByteBuffer(new Text("myrow")), TextUtil.getByteBuffer(new Text("myrow~")),
+        flushId.get(), 1);
+    expectPermissionDenied(op, regularUser);
+    // privileged users can grant themselves permission, but it's not default
+    expectPermissionDenied(op, privilegedUser);
+    expectPermissionSuccess(op, regUserWithWrite);
+    expectPermissionSuccess(op, regUserWithAlter);
+    // root user can because they created the table
+    expectPermissionSuccess(op, rootUser);
+  }
+
+  @Test
+  public void testPermissions_setSystemProperty() throws Exception {
+    // To setSystemProperty, user needs SystemPermission.SYSTEM
+    String propKey = Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey();
+    op = user -> client -> client.setSystemProperty(null, user, propKey, "10000");
+    expectPermissionDenied(op, regularUser);
+    expectPermissionSuccess(op, rootUser);
+    expectPermissionSuccess(op, privilegedUser);
+    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
+      client.instanceOperations().removeProperty(propKey); // clean up property
+    }
+  }
+
+  @Test
+  public void testPermissions_removeSystemProperty() throws Exception {
+    // To removeSystemProperty, user needs SystemPermission.SYSTEM
+    String propKey1 = Property.GC_CYCLE_DELAY.getKey();
+    String propKey2 = Property.GC_CYCLE_START.getKey();
+    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
+      client.instanceOperations().setProperty(propKey1, "10000"); // ensure it exists
+      client.instanceOperations().setProperty(propKey2, "10000"); // ensure it exists
+    }
+    op = user -> client -> client.removeSystemProperty(null, user, propKey1);
+    expectPermissionDenied(op, regularUser);
+    expectPermissionSuccess(op, rootUser);
+    op = user -> client -> client.removeSystemProperty(null, user, propKey2);
+    expectPermissionSuccess(op, privilegedUser);
+  }
+
+  @Test
+  public void testPermissions_shutdownTabletServer() throws Exception {
+    // To shutdownTabletServer, user needs SystemPermission.SYSTEM
+    // this server won't exist, so shutting it down is a NOOP on success
+    String fakeHostAndPort = getUniqueNames(1)[0] + ":0";
+    op = user -> client -> client.shutdownTabletServer(null, user, fakeHostAndPort, false);
+    expectPermissionDenied(op, regularUser);
+    expectPermissionSuccess(op, rootUser);
+    expectPermissionSuccess(op, privilegedUser);
+  }
+
+  // this test should go last, because it shuts things down;
+  // see the junit annotation to control test ordering at the top of this class
+  @Test
+  public void z99_testPermissions_shutdown() throws Exception {
+    // To shutdown, user needs SystemPermission.SYSTEM
+    op = user -> client -> client.shutdown(null, user, false);
+    expectPermissionDenied(op, regularUser);
+    // We should be able to do both of the following RPC calls before it actually shuts down
+    expectPermissionSuccess(op, rootUser);
+    expectPermissionSuccess(op, privilegedUser);
+  }
+
+  private static void expectPermissionSuccess(
+      Function<TCredentials,ClientExec<MasterClientService.Client>> op, Credentials user)
+      throws Exception {
+    try (AccumuloClient client = Accumulo.newClient().from(getClientProps())
+        .as(user.getPrincipal(), user.getToken()).build()) {
+      ClientContext context = (ClientContext) client;
+      MasterClient.executeVoid(context, op.apply(context.rpcCreds()));
+    }
+  }
+
+  private static void expectPermissionDenied(
+      Function<TCredentials,ClientExec<MasterClientService.Client>> op, Credentials user)
+      throws Exception {
+    AccumuloSecurityException e =
+        assertThrows(AccumuloSecurityException.class, () -> expectPermissionSuccess(op, user));
+    assertSame(SecurityErrorCode.PERMISSION_DENIED, e.getSecurityErrorCode());
+  }
+
+}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java b/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
index 5a80f5d..8d9ef80 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
@@ -1,30 +1,32 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.test.functional;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -276,7 +278,35 @@ public class PermissionsIT extends AccumuloClusterHarness {
         }
         break;
       case SYSTEM:
-        // test for system permission would go here
+        try {
+          // Test setProperty
+          loginAs(testUser);
+          test_user_client.instanceOperations()
+              .setProperty(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey(), "10000");
+          throw new IllegalStateException("Should NOT be able to set System Property");
+        } catch (AccumuloSecurityException e) {
+          loginAs(rootUser);
+          if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
+              || root_client.instanceOperations().getSystemConfiguration()
+                  .get(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey()).equals("10000"))
+            throw e;
+        }
+        // Test removal of property
+        loginAs(rootUser);
+        root_client.instanceOperations()
+            .setProperty(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey(), "10000");
+        try {
+          loginAs(testUser);
+          test_user_client.instanceOperations()
+              .removeProperty(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey());
+          throw new IllegalStateException("Should NOT be able to remove Sysem Property");
+        } catch (AccumuloSecurityException e) {
+          loginAs(rootUser);
+          if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
+              || !root_client.instanceOperations().getSystemConfiguration()
+                  .get(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey()).equals("10000"))
+            throw e;
+        }
         break;
       case CREATE_NAMESPACE:
         namespace = "__CREATE_NAMESPACE_WITHOUT_PERM_TEST__";
@@ -462,7 +492,22 @@ public class PermissionsIT extends AccumuloClusterHarness {
           throw new IllegalStateException("Should be able to alter a user");
         break;
       case SYSTEM:
-        // test for system permission would go here
+        // Test setProperty
+        loginAs(testUser);
+        test_user_client.instanceOperations()
+            .setProperty(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey(), "10000");
+        loginAs(rootUser);
+        if (!root_client.instanceOperations().getSystemConfiguration()
+            .get(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey()).equals("10000"))
+          throw new IllegalStateException("Should be able to set system property");
+        // Test removal of property
+        loginAs(testUser);
+        test_user_client.instanceOperations()
+            .removeProperty(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey());
+        loginAs(rootUser);
+        if (root_client.instanceOperations().getSystemConfiguration()
+            .get(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX.getKey()).equals("10000"))
+          throw new IllegalStateException("Should be able remove systemproperty");
         break;
       case CREATE_NAMESPACE:
         namespace = "__CREATE_NAMESPACE_WITH_PERM_TEST__";
@@ -613,7 +658,7 @@ public class PermissionsIT extends AccumuloClusterHarness {
       // put in some initial data
       try (BatchWriter writer = c.createBatchWriter(tableName)) {
         Mutation m = new Mutation(new Text("row"));
-        m.put(new Text("cf"), new Text("cq"), new Value("val".getBytes()));
+        m.put("cf", "cq", "val");
         writer.addMutation(m);
       }
 
@@ -649,10 +694,10 @@ public class PermissionsIT extends AccumuloClusterHarness {
         try {
           try (BatchWriter bw = test_user_client.createBatchWriter(tableName)) {
             m = new Mutation(new Text("row"));
-            m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
+            m.put("a", "b", "c");
             bw.addMutation(m);
           } catch (MutationsRejectedException e1) {
-            if (e1.getSecurityErrorCodes().size() > 0)
+            if (!e1.getSecurityErrorCodes().isEmpty())
               throw new AccumuloSecurityException(test_user_client.whoami(),
                   org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode.PERMISSION_DENIED,
                   e1);
@@ -662,6 +707,15 @@ public class PermissionsIT extends AccumuloClusterHarness {
           if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
             throw e;
         }
+        // Now see if we can flush
+        try {
+          test_user_client.tableOperations().flush(tableName, new Text("myrow"), new Text("myrow~"),
+              false);
+          throw new IllegalStateException("Should NOT be able to flsuh a table");
+        } catch (AccumuloSecurityException e) {
+          if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
+            throw e;
+        }
         break;
       case BULK_IMPORT:
         // test for bulk import permission would go here
@@ -676,6 +730,14 @@ public class PermissionsIT extends AccumuloClusterHarness {
           if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
             throw e;
         }
+        try {
+          test_user_client.tableOperations().flush(tableName, new Text("myrow"), new Text("myrow~"),
+              false);
+          throw new IllegalStateException("Should NOT be able to flsuh a table");
+        } catch (AccumuloSecurityException e) {
+          if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
+            throw e;
+        }
         testArbitraryProperty(test_user_client, tableName, false);
         break;
       case DROP_TABLE:
@@ -720,15 +782,17 @@ public class PermissionsIT extends AccumuloClusterHarness {
     switch (perm) {
       case READ:
         try (Scanner scanner = test_user_client.createScanner(tableName, Authorizations.EMPTY)) {
-          Iterator<Entry<Key,Value>> iter = scanner.iterator();
-          while (iter.hasNext())
-            iter.next();
+          for (Entry<Key,Value> keyValueEntry : scanner) {
+            assertNotNull(keyValueEntry);
+          }
         }
         break;
       case WRITE:
+        test_user_client.tableOperations().flush(tableName, new Text("myrow"), new Text("myrow~"),
+            false);
         try (BatchWriter bw = test_user_client.createBatchWriter(tableName)) {
           Mutation m = new Mutation(new Text("row"));
-          m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
+          m.put("a", "b", "c");
           bw.addMutation(m);
         }
         break;
@@ -736,6 +800,8 @@ public class PermissionsIT extends AccumuloClusterHarness {
         // test for bulk import permission would go here
         break;
       case ALTER_TABLE:
+        test_user_client.tableOperations().flush(tableName, new Text("myrow"), new Text("myrow~"),
+            false);
         testArbitraryProperty(test_user_client, tableName, true);
         break;
       case DROP_TABLE:


[accumulo] 01/06: Update release candidate script (#1724)

Posted by ct...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.0.1-rc1
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 775b9fc38388f006127de90720f0103a93cc08ad
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Wed Oct 7 13:18:21 2020 -0400

    Update release candidate script (#1724)
    
    (cherry-picked for 2.0.1)
    
    Improving generated output:
    * show link to staging repo website
    * show full commits
    * show reminders of which buttons to click on the staging site
    * show reminder to replace `$origin` with actual remote name
    * place `-s` in `git tag` command with the other options
    * update draft release notes link to point to staged site
    
    Optimizing performance:
    * create the `-next` branch and switch to it in one command
    * skip tests during release prep because the release can (and should) be
      tested outside of the actual release candidate creation process and
      this speeds things up significantly
    * change release prep goal to only do `package`, because it's not
      necessary to run `verify` during `release:prepare`; all the QA checks
      done at `verify` can be done before/after release candidate staging
    
    Being more interactive:
    * prompt for gpg key to use
    * prompt for the `remote` to push to (do not assume `origin`)
    
    Removing junk:
    * remove check for `gpg2` (modern Linux uses version 2 for the `gpg` binary)
    * remove unnecessary `--test` option and related `runOrFail` function
    * remove `extraReleaseArguments` to simplify things
---
 assemble/build.sh | 186 ++++++++++++++++++++++++++++++++++++++----------------
 pom.xml           |   6 +-
 2 files changed, 132 insertions(+), 60 deletions(-)

diff --git a/assemble/build.sh b/assemble/build.sh
index 28fa26f..5bbca61 100755
--- a/assemble/build.sh
+++ b/assemble/build.sh
@@ -1,19 +1,22 @@
 #! /usr/bin/env bash
-
-# 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
+# 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.
 #
-# 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.
 
 cd "$(dirname "$0")/.." || exit 1
 scriptname=$(basename "$0")
@@ -25,9 +28,6 @@ export srcQualifier="src"
 export relTestingUrl="https://$tlpName.apache.org/contributor/verifying-release"
 export tagPrefix="rel/"
 
-# check for gpg2
-hash gpg2 2>/dev/null && gpgCommand=gpg2 || gpgCommand=gpg
-
 # check if running in a color terminal
 terminalSupportsColor() {
   local c; c=$(tput colors 2>/dev/null) || c=-1
@@ -43,7 +43,6 @@ yellow() { color 33 "$@"; }
 fail() { echo -e ' ' "$@"; exit 1; }
 runLog() { local o; o=$1 && shift && echo "$(green Running) $(yellow "$@" '>>' "$o")" && echo Running "$@" >> "$o" && eval "$@" >> "$o"; }
 run() { echo "$(green Running) $(yellow "$@")" && eval "$@"; }
-runOrFail() { run "$@" || fail "$(yellow "$@")" "$(red failed)"; }
 
 currentBranch() { local b; b=$(git symbolic-ref -q HEAD) && echo "${b##refs/heads/}"; }
 
@@ -51,9 +50,12 @@ cacheGPG() {
   # make sure gpg agent has key cached
   # first clear cache, to reset timeouts (best attempt)
   { hash gpg-connect-agent && gpg-connect-agent reloadagent /bye; } &>/dev/null
-  # TODO prompt for key instead of using default?
+  # determine fingerprint to use
+  until selectFingerprint; do
+    red 'ERROR - Invalid selection'
+  done
   local TESTFILE; TESTFILE=$(mktemp --tmpdir "${USER}-gpgTestFile-XXXXXXXX.txt")
-  [[ -r $TESTFILE ]] && "$gpgCommand" --sign "${TESTFILE}" && rm -f "${TESTFILE}" "${TESTFILE}.gpg"
+  [[ -r $TESTFILE ]] && gpg --local-user "$SELECTED_FINGERPRINT" --sign "$TESTFILE" && rm -f "$TESTFILE" "$TESTFILE.gpg"
 }
 
 prompter() {
@@ -72,7 +74,42 @@ gitCommits() { pretty %H "$@"; }
 gitCommit()  { gitCommits -n1 "$@"; }
 gitSubject() { pretty %s "$@"; }
 
+selectFingerprint() {
+  local f fingerprints=()
+  if [[ $SELECTED_FINGERPRINT =~ ^[0-9a-fA-F]{40}$ ]]; then
+    # it's already set, don't set it again
+    return 0
+  fi
+  mapfile -t fingerprints < <(gpg --list-secret-keys --with-colons --with-fingerprint 2>/dev/null | awk -F: '$1 == "fpr" {print $10}')
+  fingerprints+=('Other')
+  echo
+  echo "Select the $(green gpg) key to use:"
+  COLUMNS=1
+  select f in "${fingerprints[@]}"; do
+    if [[ -z $f ]]; then
+      return 1
+    elif [[ $f == 'Other' ]]; then
+      SELECTED_FINGERPRINT=$(prompter "$(green gpg) key's $(green fingerprint)" '[0-9a-fA-F]{40}')
+      return 0
+    else
+      SELECTED_FINGERPRINT="$f"
+      return 0
+    fi
+  done
+}
+
 createEmail() {
+  echo
+  yellow  "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!"
+  echo
+  echo    "  Release candidate will be staged at:"
+  echo    "    $(yellow 'https://repository.apache.org/#stagingRepositories')"
+  echo
+  echo    "  $(green 'DO')       click $(green 'Close')   to complete the staging process!"
+  echo    "  $(red 'DO *NOT*') click $(red 'Release') until after the vote has been approved!"
+  echo
+  yellow  "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!"
+  echo
   # $1 version (optional); $2 rc sequence num (optional); $3 staging repo num (optional)
   local ver; [[ -n "$1" ]] && ver=$1 || ver=$(prompter 'version to be released (eg. x.y.z)' '[0-9]+[.][0-9]+[.][0-9]+')
   local rc; [[ -n "$2" ]] && rc=$2 || rc=$(prompter 'release candidate sequence number (eg. 1, 2, etc.)' '[0-9]+')
@@ -86,19 +123,28 @@ createEmail() {
   echo
   yellow  "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!"
   echo
-  echo    "    Don't forget to push a branch named $(green "$branch") with"
-  echo    "    its head at $(green "${commit:0:7}") so others can review using:"
-  echo    "      $(green "git push origin ${commit:0:7}:refs/heads/$branch")"
+  echo    "    Don't forget to make the staged branch available for review by"
+  echo    "    pushing a branch named $(yellow "$branch") with its head at"
+  echo    "      $(yellow "$commit"):"
+  echo
+  echo    "      # replace $(yellow "\$origin") with your upstream remote name "
+  echo    "      $(green "git push") $(yellow "\$origin") $(green "$commit:refs/heads/$branch")"
   echo
   echo    "    Remember, $(red DO NOT PUSH) the $(red "$tag") tag until after the vote"
   echo    "    passes and the tag is re-made with a gpg signature using:"
-  echo    "      $(red "git tag -f -m '$projNameLong $ver' -s $tag ${commit:0:7}")"
+  echo    "      $(red "git tag -f -s -m '$projNameLong $ver' $tag") \\"
+  echo    "      $(red "$commit")"
   echo
   yellow  "IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!! IMPORTANT!!"
   echo
   read -r -s -p 'Press Enter to generate the [VOTE] email...'
   echo 1>&2
 
+  # determine fingerprint to use
+  until selectFingerprint; do
+    red 'ERROR - Invalid selection'
+  done
+
   # compute the date with a buffer of 30 minutes
   local votedate; votedate=$(date -d "+3 days 30 minutes" "+%s")
   # round back to the previous half-hour
@@ -109,9 +155,6 @@ createEmail() {
   export TZ="America/Los_Angeles"
   local pdtvotedate; pdtvotedate=$(date -d"1970-01-01 $halfhour seconds UTC")
 
-  local fingerprint; fingerprint=$("$gpgCommand" --list-secret-keys --with-colons --with-fingerprint 2>/dev/null | awk -F: '$1 == "fpr" {print $10}')
-  [[ -z $fingerprint ]] && fingerprint="UNSPECIFIED"
-
   cat <<EOF
 $(yellow '============================================================')
 Subject: $(green [VOTE] "$projNameLong $branch")
@@ -126,7 +169,7 @@ Branch:
     $(green "$branch")
 
 If this vote passes, a gpg-signed tag will be created using:
-    $(green "git tag -f -m '$projNameLong $ver' -s $tag") \\
+    $(green "git tag -f -s -m '$projNameLong $ver' $tag") \\
     $(green "$commit")
 
 Staging repo: $(green "$stagingRepoPrefix-$stagingrepo")
@@ -138,7 +181,7 @@ Append ".asc" to download the cryptographic signature for a given artifact.
 generated by Maven to verify the integrity of the Nexus repository staging area.)
 
 Signing keys are available at https://www.apache.org/dist/$tlpName/KEYS
-(Expected fingerprint: $(green "$fingerprint"))
+(Expected fingerprint: $(green "$SELECTED_FINGERPRINT"))
 
 In addition to the tarballs and their signatures, the following checksum
 files will be added to the dist/release SVN area after release:
@@ -147,7 +190,7 @@ SHA512 ($(green "$projName-$ver-$srcQualifier.tar.gz")) = $(yellow "$srcSha")
 $(yellow "$projName-$ver-bin.tar.gz.sha512") will contain:
 SHA512 ($(green "$projName-$ver-bin.tar.gz")) = $(yellow "$binSha")
 
-Release notes (in progress) can be found at: $(green "https://$tlpName.apache.org/release/$projName-$ver/")
+Release notes (in progress) can be found at: $(green "https://$tlpName.staged.apache.org/release/$projName-$ver")
 
 Release testing instructions: $relTestingUrl
 
@@ -210,24 +253,51 @@ cleanUpAndFail() {
   exit 1
 }
 
+selectRemote() {
+  local r remotes=()
+  for r in $(git remote); do
+    remotes+=("$r ($(git config "remote.$r.url"))")
+  done
+  remotes+=('Skip')
+  echo "Select a $(green remote) (you will be prompted again before pushing):"
+  COLUMNS=1
+  select r in "${remotes[@]}"; do
+    if [[ -z $r ]]; then
+      return 1
+    elif [[ $r == 'Skip' ]]; then
+      SELECTED_REMOTE=$r
+      return 0
+    else
+      SELECTED_REMOTE="${r%% *}"
+      SELECTED_REMOTE_URL=$(git config "remote.${SELECTED_REMOTE}.url")
+      return 0
+    fi
+  done
+}
+
 createReleaseCandidate() {
+  echo
   yellow  "WARNING!! WARNING!! WARNING!! WARNING!! WARNING!! WARNING!!"
   echo
+  echo    "  Don't forget to $(yellow 'Set up your development environment')!"
+  echo    "  For details, see the section by that name at:"
+  echo    "  $(green 'https://infra.apache.org/publishing-maven-artifacts.html')"
+  echo
   echo    "  This will modify your local git repository by creating"
   echo    "  branches and tags. Afterwards, you may need to perform"
   echo    "  some manual steps to complete the release or to rollback"
   echo    "  in the case of failure."
   echo
+  echo    "  Release candidate will be staged at:"
+  echo    "    $(yellow 'https://repository.apache.org/#stagingRepositories')"
+  echo
   yellow  "WARNING!! WARNING!! WARNING!! WARNING!! WARNING!! WARNING!!"
   echo
 
-  local extraReleaseArgs; extraReleaseArgs=("$@")
-  if [[ ${#extraReleaseArgs[@]} -ne 0 ]]; then
-    red "CAUTION!! Extra release args may create a non-standard release!!"
-    red "You added '${extraReleaseArgs[*]}'"
+  if [[ ${#@} -ne 0 ]]; then
+    red "CAUTION!! Unrecognized arguments!!"
+    fail "You added '$*'"
   fi
-  [[ ${#extraReleaseArgs[@]} -eq 0 ]] && [[ $gpgCommand != 'gpg' ]] && extraReleaseArgs=("-Dgpg.executable=$gpgCommand")
-  local extraReleaseArgsFlat; extraReleaseArgsFlat="-DextraReleaseArguments='${extraReleaseArgs[*]}'"
 
   local ver
   ver=$(xmllint --shell pom.xml <<<'xpath /*[local-name()="project"]/*[local-name()="version"]/text()' | grep content= | cut -f2 -d=)
@@ -246,19 +316,18 @@ createReleaseCandidate() {
   cacheGPG || fail "Unable to cache GPG credentials into gpg-agent"
 
   # create working branch
-  {
-    run git branch "$nBranch" "$cBranch" && run git checkout "$nBranch"
-  } || fail "Unable to create working branch $(red "$nBranch") from $(red "$cBranch")!"
+  run git checkout -b "$nBranch" "$cBranch" || \
+    fail "Unable to create working branch $(red "$nBranch") from $(red "$cBranch")!"
 
   # create a release candidate from a branch
   local oFile; oFile=$(mktemp --tmpdir "$projName-build-$rcBranch-XXXXXXXX.log")
   {
     [[ -w $oFile ]] && runLog "$oFile" mvn clean release:clean
   } || cleanUpAndFail 'mvn clean release:clean' "$oFile" "$cBranch" "$nBranch"
-  runLog "$oFile" mvn -B release:prepare -DdevelopmentVersion="${nextVer}-SNAPSHOT" "${extraReleaseArgsFlat}" || \
-    cleanUpAndFail "mvn -B release:prepare -DdevelopmentVersion=${nextVer}-SNAPSHOT ${extraReleaseArgsFlat}" "$oFile" "$cBranch" "$nBranch"
-  runLog "$oFile" mvn release:perform "${extraReleaseArgsFlat}" || \
-    cleanUpAndFail "mvn release:perform ${extraReleaseArgsFlat}" "$oFile" "$cBranch" "$nBranch"
+  runLog "$oFile" mvn -B release:prepare -DdevelopmentVersion="${nextVer}-SNAPSHOT" "-Dgpg.keyname=$SELECTED_FINGERPRINT" || \
+    cleanUpAndFail "mvn -B release:prepare -DdevelopmentVersion=${nextVer}-SNAPSHOT" "$oFile" "$cBranch" "$nBranch"
+  runLog "$oFile" mvn release:perform "-Dgpg.keyname=$SELECTED_FINGERPRINT" || \
+    cleanUpAndFail "mvn release:perform" "$oFile" "$cBranch" "$nBranch"
 
   # switch back to original branch
   run git checkout "${cBranch}"
@@ -283,16 +352,24 @@ createReleaseCandidate() {
   run git branch "$rcBranch" "${nBranch}~1" || \
     cleanUpAndFail "creating branch $rcBranch"
 
+  # determine remote to use
+  until selectRemote; do
+    red 'ERROR - Invalid selection'
+  done
+
   # push branches (ask first)
-  local origin; origin=$(git remote -v | grep ^origin | grep push | awk '{print $2}')
-  echo "Do you wish to push the following branches to origin ($(green "$origin"))?"
-  echo "  $(yellow "$rcBranch")      (for others to examine for the vote)"
-  echo "  $(yellow "$nBranch") (for merging into $cBranch if vote passes)"
-  local a; a=$(prompter "letter 'y' or 'n'" '[yn]')
-  {
-    [[ $a == 'y' ]] && \
-      run git push -u origin "refs/heads/$nBranch" "refs/heads/$rcBranch"
-  } || red "Did not push branches; you'll need to perform this step manually."
+  if [[ $SELECTED_REMOTE == 'Skip' ]]; then
+    red "Did not push branches; you'll need to perform this step manually."
+  else
+    echo "Do you wish to push the following branches to $SELECTED_REMOTE ($(green "$SELECTED_REMOTE_URL"))?"
+    echo "  $(yellow "$rcBranch")      (for others to examine for the vote)"
+    echo "  $(yellow "$nBranch") (for merging into $cBranch if vote passes)"
+    local a; a=$(prompter "letter 'y' or 'n'" '[yn]')
+    {
+      [[ $a == 'y' ]] && \
+        run git push -u "$SELECTED_REMOTE" "refs/heads/$nBranch" "refs/heads/$rcBranch"
+    } || red "Did not push branches; you'll need to perform this step manually."
+  fi
 
   local numSrc; numSrc=$(find target/checkout/ -type f -name "$projName-$ver-source-release.tar.gz" | wc -l)
   local numBin; numBin=$(find target/checkout/ -type f -name "$projName-$ver-bin.tar.gz" | wc -l)
@@ -307,17 +384,14 @@ createReleaseCandidate() {
   createEmail "$ver" "$rc" "" "$srcSha" "$binSha"
 }
 
+SELECTED_FINGERPRINT=""
 if [[ $1 == '--create-release-candidate' ]]; then
   shift
   createReleaseCandidate "$@"
-elif [[ $1 == '--test' ]]; then
-  cacheGPG
-  # build a tag, but with tests
-  runOrFail mvn clean install -P apache-release,accumulo-release,thrift
 elif [[ $1 == '--create-email' ]]; then
   shift
   createEmail "$@"
 else
-  fail "Missing one of: $(red --create-release-candidate), $(red --test), $(red --create-email)"
+  fail "Missing one of: $(red --create-release-candidate), $(red --create-email)"
 fi
 
diff --git a/pom.xml b/pom.xml
index 3200222..ee038cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,8 +116,6 @@
     <curator.version>2.12.0</curator.version>
     <!-- relative path for Eclipse format; should override in child modules if necessary -->
     <eclipseFormatterStyle>${project.parent.basedir}/contrib/Eclipse-Accumulo-Codestyle.xml</eclipseFormatterStyle>
-    <!-- extra release args for testing -->
-    <extraReleaseArguments />
     <failsafe.excludedGroups />
     <failsafe.groups />
     <!-- surefire/failsafe plugin option -->
@@ -889,10 +887,10 @@
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-release-plugin</artifactId>
           <configuration>
-            <arguments>-P !autoformat,thrift,sunny -Dtimeout.factor=2 ${extraReleaseArguments}</arguments>
+            <arguments>-P !autoformat,thrift -DskipTests</arguments>
             <autoVersionSubmodules>true</autoVersionSubmodules>
             <goals>clean deploy</goals>
-            <preparationGoals>clean verify</preparationGoals>
+            <preparationGoals>clean package</preparationGoals>
             <tagNameFormat>rel/@{project.version}</tagNameFormat>
             <releaseProfiles>apache-release,accumulo-release</releaseProfiles>
             <useReleaseProfile>false</useReleaseProfile>


[accumulo] 02/06: Fix a bug in the AccumuloClient builder

Posted by ct...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.0.1-rc1
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 6ceb00655800dbc5b3d1cf16c1d18570c347a610
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Wed Dec 16 01:12:08 2020 -0500

    Fix a bug in the AccumuloClient builder
    
    (cherry-picked for 2.0.1)
    
    This fixes #1839
    
    Fix a bug in the ClientContext's from(Properties) method, which is used
    to build a new AccumuloClient from an existing set of properties. This
    is often used to initialize a builder, and then to subsequently modify
    the client via the builder to use different credentials, or other
    settings, that were stored in the provided Properties.
    
    This fix modifies the from(Properties) method to make a copy of the
    provided Properties, so that subsequent builder activity does not modify
    the Properties object that the caller provided.
---
 .../main/java/org/apache/accumulo/core/clientImpl/ClientContext.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
index 01474b2..ab7696b 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
@@ -780,7 +780,10 @@ public class ClientContext implements AccumuloClient {
 
     @Override
     public FromOptions<T> from(Properties properties) {
-      this.properties = properties;
+      // make a copy, so that this builder's subsequent methods don't mutate the
+      // properties object provided by the caller
+      this.properties = new Properties();
+      this.properties.putAll(properties);
       return this;
     }