accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] 03/03: ACCUMULO-4732 Consolidate NewTableConfiguration ITs
Date Fri, 22 Dec 2017 05:30:04 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit c389b99d11755659662264731b7ae932c6a6b647
Author: Christopher Tubbs <ctubbsii@apache.org>
AuthorDate: Fri Dec 22 00:24:26 2017 -0500

    ACCUMULO-4732 Consolidate NewTableConfiguration ITs
    
    Consolidate two NewTableConfiguration integration tests into one.
    
    Old:
      CreateTableWithNewTableConfigIT
      NewConfigurationTestIT
    New:
      NewTableConfigurationIT
---
 .../test/CreateTableWithNewTableConfigIT.java      | 205 ---------------------
 ...ionTestIT.java => NewTableConfigurationIT.java} | 162 +++++++++++++++-
 2 files changed, 155 insertions(+), 212 deletions(-)

diff --git a/test/src/main/java/org/apache/accumulo/test/CreateTableWithNewTableConfigIT.java
b/test/src/main/java/org/apache/accumulo/test/CreateTableWithNewTableConfigIT.java
deleted file mode 100644
index 7fd2dd1..0000000
--- a/test/src/main/java/org/apache/accumulo/test/CreateTableWithNewTableConfigIT.java
+++ /dev/null
@@ -1,205 +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.test;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.admin.NewTableConfiguration;
-import org.apache.accumulo.core.client.admin.TimeType;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.harness.SharedMiniClusterBase;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Iterators;
-
-/**
- *
- */
-public class CreateTableWithNewTableConfigIT extends SharedMiniClusterBase {
-  static private final Logger log = LoggerFactory.getLogger(CreateTableWithNewTableConfigIT.class);
-
-  @Override
-  protected int defaultTimeoutSeconds() {
-    return 30;
-  }
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    SharedMiniClusterBase.startMiniCluster();
-  }
-
-  @AfterClass
-  public static void teardown() throws Exception {
-    SharedMiniClusterBase.stopMiniCluster();
-  }
-
-  public int numProperties(Connector connector, String tableName) throws AccumuloException,
TableNotFoundException {
-    return Iterators.size(connector.tableOperations().getProperties(tableName).iterator());
-  }
-
-  public int compareProperties(Connector connector, String tableNameOrig, String tableName,
String changedProp) throws AccumuloException,
-      TableNotFoundException {
-    boolean inNew = false;
-    int countOrig = 0;
-    for (Entry<String,String> orig : connector.tableOperations().getProperties(tableNameOrig))
{
-      countOrig++;
-      for (Entry<String,String> entry : connector.tableOperations().getProperties(tableName))
{
-        if (entry.equals(orig)) {
-          inNew = true;
-          break;
-        } else if (entry.getKey().equals(orig.getKey()) && !entry.getKey().equals(changedProp))
-          Assert.fail("Property " + orig.getKey() + " has different value than deprecated
method");
-      }
-      if (!inNew)
-        Assert.fail("Original property missing after using the new create method");
-    }
-    return countOrig;
-  }
-
-  public boolean checkTimeType(Connector connector, String tableName, TimeType expectedTimeType)
throws TableNotFoundException {
-    final Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    String tableID = connector.tableOperations().tableIdMap().get(tableName) + "<";
-    for (Entry<Key,Value> entry : scanner) {
-      Key k = entry.getKey();
-
-      if (k.getRow().toString().equals(tableID) && k.getColumnQualifier().toString().equals(ServerColumnFamily.TIME_COLUMN.getColumnQualifier().toString()))
{
-        if (expectedTimeType == TimeType.MILLIS && entry.getValue().toString().charAt(0)
== 'M')
-          return true;
-        if (expectedTimeType == TimeType.LOGICAL && entry.getValue().toString().charAt(0)
== 'L')
-          return true;
-      }
-    }
-    return false;
-  }
-
-  @SuppressWarnings("deprecation")
-  @Test
-  public void tableNameOnly() throws Exception {
-    log.info("Starting tableNameOnly");
-
-    // Create a table with the initial properties
-    Connector connector = getConnector();
-    String tableName = getUniqueNames(2)[0];
-    connector.tableOperations().create(tableName, new NewTableConfiguration());
-
-    String tableNameOrig = "original";
-    connector.tableOperations().create(tableNameOrig, true);
-
-    int countNew = numProperties(connector, tableName);
-    int countOrig = compareProperties(connector, tableNameOrig, tableName, null);
-
-    Assert.assertEquals("Extra properties using the new create method", countOrig, countNew);
-    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS));
-  }
-
-  @SuppressWarnings("deprecation")
-  @Test
-  public void tableNameAndLimitVersion() throws Exception {
-    log.info("Starting tableNameAndLimitVersion");
-
-    // Create a table with the initial properties
-    Connector connector = getConnector();
-    String tableName = getUniqueNames(2)[0];
-    boolean limitVersion = false;
-    connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators());
-
-    String tableNameOrig = "originalWithLimitVersion";
-    connector.tableOperations().create(tableNameOrig, limitVersion);
-
-    int countNew = numProperties(connector, tableName);
-    int countOrig = compareProperties(connector, tableNameOrig, tableName, null);
-
-    Assert.assertEquals("Extra properties using the new create method", countOrig, countNew);
-    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS));
-  }
-
-  @SuppressWarnings("deprecation")
-  @Test
-  public void tableNameLimitVersionAndTimeType() throws Exception {
-    log.info("Starting tableNameLimitVersionAndTimeType");
-
-    // Create a table with the initial properties
-    Connector connector = getConnector();
-    String tableName = getUniqueNames(2)[0];
-    boolean limitVersion = false;
-    TimeType tt = TimeType.LOGICAL;
-    connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators().setTimeType(tt));
-
-    String tableNameOrig = "originalWithLimitVersionAndTimeType";
-    connector.tableOperations().create(tableNameOrig, limitVersion, tt);
-
-    int countNew = numProperties(connector, tableName);
-    int countOrig = compareProperties(connector, tableNameOrig, tableName, null);
-
-    Assert.assertEquals("Extra properties using the new create method", countOrig, countNew);
-    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, tt));
-  }
-
-  @SuppressWarnings("deprecation")
-  @Test
-  public void addCustomPropAndChangeExisting() throws Exception {
-    log.info("Starting addCustomPropAndChangeExisting");
-
-    // Create and populate initial properties map for creating table 1
-    Map<String,String> properties = new HashMap<>();
-    String propertyName = Property.TABLE_SPLIT_THRESHOLD.getKey();
-    String volume = "10K";
-    properties.put(propertyName, volume);
-
-    String propertyName2 = "table.custom.testProp";
-    String volume2 = "Test property";
-    properties.put(propertyName2, volume2);
-
-    // Create a table with the initial properties
-    Connector connector = getConnector();
-    String tableName = getUniqueNames(2)[0];
-    connector.tableOperations().create(tableName, new NewTableConfiguration().setProperties(properties));
-
-    String tableNameOrig = "originalWithTableName";
-    connector.tableOperations().create(tableNameOrig, true);
-
-    int countNew = numProperties(connector, tableName);
-    int countOrig = compareProperties(connector, tableNameOrig, tableName, propertyName);
-
-    for (Entry<String,String> entry : connector.tableOperations().getProperties(tableName))
{
-      if (entry.getKey().equals(Property.TABLE_SPLIT_THRESHOLD.getKey()))
-        Assert.assertTrue("TABLE_SPLIT_THRESHOLD has been changed", entry.getValue().equals("10K"));
-      if (entry.getKey().equals("table.custom.testProp"))
-        Assert.assertTrue("table.custom.testProp has been changed", entry.getValue().equals("Test
property"));
-    }
-
-    Assert.assertEquals("Extra properties using the new create method", countOrig + 1, countNew);
-    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS));
-
-  }
-}
diff --git a/test/src/main/java/org/apache/accumulo/test/NewConfigurationTestIT.java b/test/src/main/java/org/apache/accumulo/test/NewTableConfigurationIT.java
similarity index 79%
rename from test/src/main/java/org/apache/accumulo/test/NewConfigurationTestIT.java
rename to test/src/main/java/org/apache/accumulo/test/NewTableConfigurationIT.java
index e7b3e6e..4ec42e3 100644
--- a/test/src/main/java/org/apache/accumulo/test/NewConfigurationTestIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/NewTableConfigurationIT.java
@@ -31,11 +31,18 @@ import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableExistsException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.admin.NewTableConfiguration;
+import org.apache.accumulo.core.client.admin.TimeType;
 import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.metadata.MetadataTable;
+import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily;
+import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.harness.SharedMiniClusterBase;
 import org.apache.hadoop.io.Text;
 import org.junit.AfterClass;
@@ -46,10 +53,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterators;
 
-public class NewConfigurationTestIT extends SharedMiniClusterBase {
-
-  private static final Logger log = LoggerFactory.getLogger(NewConfigurationTestIT.class);
+public class NewTableConfigurationIT extends SharedMiniClusterBase {
+  private static final Logger log = LoggerFactory.getLogger(NewTableConfigurationIT.class);
 
   @Override
   protected int defaultTimeoutSeconds() {
@@ -261,7 +268,8 @@ public class NewConfigurationTestIT extends SharedMiniClusterBase {
    * Test pre-configuring iterator with default iterator. Configure IteratorSetting values
into method call.
    */
   @Test
-  public void testPreconfiguredIteratorWithDefaultIterator2() throws AccumuloException, TableNotFoundException,
AccumuloSecurityException, TableExistsException {
+  public void testPreconfiguredIteratorWithDefaultIterator2()
+      throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException
{
     Connector conn = getConnector();
     String tableName = getUniqueNames(2)[0];
 
@@ -284,7 +292,8 @@ public class NewConfigurationTestIT extends SharedMiniClusterBase {
    * Test pre-configuring iterator with default iterator. Pass in IteratorScope value in
method arguments.
    */
   @Test
-  public void testPreconfiguredIteratorWithDefaultIterator3() throws AccumuloException, TableNotFoundException,
AccumuloSecurityException, TableExistsException {
+  public void testPreconfiguredIteratorWithDefaultIterator3()
+      throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException
{
     Connector conn = getConnector();
     String tableName = getUniqueNames(2)[0];
 
@@ -307,8 +316,8 @@ public class NewConfigurationTestIT extends SharedMiniClusterBase {
    * Test pre-configuring iterator with additional options.
    */
   @Test
-  public void testSettingInitialIteratorWithAdditionalIteratorOptions() throws AccumuloException,
TableNotFoundException, AccumuloSecurityException,
-      TableExistsException {
+  public void testSettingInitialIteratorWithAdditionalIteratorOptions()
+      throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException
{
     Connector conn = getConnector();
     String tableName = getUniqueNames(2)[0];
 
@@ -605,4 +614,143 @@ public class NewConfigurationTestIT extends SharedMiniClusterBase {
     return propertyMap;
   }
 
+  public int numProperties(Connector connector, String tableName) throws AccumuloException,
TableNotFoundException {
+    return Iterators.size(connector.tableOperations().getProperties(tableName).iterator());
+  }
+
+  public int compareProperties(Connector connector, String tableNameOrig, String tableName,
String changedProp)
+      throws AccumuloException, TableNotFoundException {
+    boolean inNew = false;
+    int countOrig = 0;
+    for (Entry<String,String> orig : connector.tableOperations().getProperties(tableNameOrig))
{
+      countOrig++;
+      for (Entry<String,String> entry : connector.tableOperations().getProperties(tableName))
{
+        if (entry.equals(orig)) {
+          inNew = true;
+          break;
+        } else if (entry.getKey().equals(orig.getKey()) && !entry.getKey().equals(changedProp))
+          Assert.fail("Property " + orig.getKey() + " has different value than deprecated
method");
+      }
+      if (!inNew)
+        Assert.fail("Original property missing after using the new create method");
+    }
+    return countOrig;
+  }
+
+  public boolean checkTimeType(Connector connector, String tableName, TimeType expectedTimeType)
throws TableNotFoundException {
+    final Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+    String tableID = connector.tableOperations().tableIdMap().get(tableName) + "<";
+    for (Entry<Key,Value> entry : scanner) {
+      Key k = entry.getKey();
+
+      if (k.getRow().toString().equals(tableID) && k.getColumnQualifier().toString().equals(ServerColumnFamily.TIME_COLUMN.getColumnQualifier().toString()))
{
+        if (expectedTimeType == TimeType.MILLIS && entry.getValue().toString().charAt(0)
== 'M')
+          return true;
+        if (expectedTimeType == TimeType.LOGICAL && entry.getValue().toString().charAt(0)
== 'L')
+          return true;
+      }
+    }
+    return false;
+  }
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void tableNameOnly() throws Exception {
+    log.info("Starting tableNameOnly");
+
+    // Create a table with the initial properties
+    Connector connector = getConnector();
+    String tableName = getUniqueNames(2)[0];
+    connector.tableOperations().create(tableName, new NewTableConfiguration());
+
+    String tableNameOrig = "original";
+    connector.tableOperations().create(tableNameOrig, true);
+
+    int countNew = numProperties(connector, tableName);
+    int countOrig = compareProperties(connector, tableNameOrig, tableName, null);
+
+    Assert.assertEquals("Extra properties using the new create method", countOrig, countNew);
+    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS));
+  }
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void tableNameAndLimitVersion() throws Exception {
+    log.info("Starting tableNameAndLimitVersion");
+
+    // Create a table with the initial properties
+    Connector connector = getConnector();
+    String tableName = getUniqueNames(2)[0];
+    boolean limitVersion = false;
+    connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators());
+
+    String tableNameOrig = "originalWithLimitVersion";
+    connector.tableOperations().create(tableNameOrig, limitVersion);
+
+    int countNew = numProperties(connector, tableName);
+    int countOrig = compareProperties(connector, tableNameOrig, tableName, null);
+
+    Assert.assertEquals("Extra properties using the new create method", countOrig, countNew);
+    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS));
+  }
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void tableNameLimitVersionAndTimeType() throws Exception {
+    log.info("Starting tableNameLimitVersionAndTimeType");
+
+    // Create a table with the initial properties
+    Connector connector = getConnector();
+    String tableName = getUniqueNames(2)[0];
+    boolean limitVersion = false;
+    TimeType tt = TimeType.LOGICAL;
+    connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators().setTimeType(tt));
+
+    String tableNameOrig = "originalWithLimitVersionAndTimeType";
+    connector.tableOperations().create(tableNameOrig, limitVersion, tt);
+
+    int countNew = numProperties(connector, tableName);
+    int countOrig = compareProperties(connector, tableNameOrig, tableName, null);
+
+    Assert.assertEquals("Extra properties using the new create method", countOrig, countNew);
+    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, tt));
+  }
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void addCustomPropAndChangeExisting() throws Exception {
+    log.info("Starting addCustomPropAndChangeExisting");
+
+    // Create and populate initial properties map for creating table 1
+    Map<String,String> properties = new HashMap<>();
+    String propertyName = Property.TABLE_SPLIT_THRESHOLD.getKey();
+    String volume = "10K";
+    properties.put(propertyName, volume);
+
+    String propertyName2 = "table.custom.testProp";
+    String volume2 = "Test property";
+    properties.put(propertyName2, volume2);
+
+    // Create a table with the initial properties
+    Connector connector = getConnector();
+    String tableName = getUniqueNames(2)[0];
+    connector.tableOperations().create(tableName, new NewTableConfiguration().setProperties(properties));
+
+    String tableNameOrig = "originalWithTableName";
+    connector.tableOperations().create(tableNameOrig, true);
+
+    int countNew = numProperties(connector, tableName);
+    int countOrig = compareProperties(connector, tableNameOrig, tableName, propertyName);
+
+    for (Entry<String,String> entry : connector.tableOperations().getProperties(tableName))
{
+      if (entry.getKey().equals(Property.TABLE_SPLIT_THRESHOLD.getKey()))
+        Assert.assertTrue("TABLE_SPLIT_THRESHOLD has been changed", entry.getValue().equals("10K"));
+      if (entry.getKey().equals("table.custom.testProp"))
+        Assert.assertTrue("table.custom.testProp has been changed", entry.getValue().equals("Test
property"));
+    }
+
+    Assert.assertEquals("Extra properties using the new create method", countOrig + 1, countNew);
+    Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS));
+
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@accumulo.apache.org" <commits@accumulo.apache.org>.

Mime
View raw message