You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by mp...@apache.org on 2018/07/03 02:59:25 UTC

[2/4] kudu git commit: java: Expose test name in BaseKuduTest

java: Expose test name in BaseKuduTest

Expose the currently-running test method name in BaseKuduTest, since
that seems to be the least-worst way to do it in JUnit 4.

We also use the method name for the default test table name in
TestKuduClient and other tests that included the test name in table
names.

Change-Id: I63049288e1ab6b32fe629a5c009f2d7d523fd5c0
Reviewed-on: http://gerrit.cloudera.org:8080/10808
Tested-by: Kudu Jenkins
Reviewed-by: Grant Henke <gr...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/8155d8c4
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/8155d8c4
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/8155d8c4

Branch: refs/heads/master
Commit: 8155d8c4102d1c36465ab83e680bd1314f80be1f
Parents: 90bc812
Author: Mike Percy <mp...@apache.org>
Authored: Fri Jun 22 20:17:24 2018 -0700
Committer: Mike Percy <mp...@apache.org>
Committed: Tue Jul 3 02:57:48 2018 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/client/BaseKuduTest.java    | 22 ++++++
 .../org/apache/kudu/client/TestKuduClient.java  |  4 +-
 .../org/apache/kudu/client/TestKuduSession.java | 57 ++++++--------
 .../org/apache/kudu/client/TestKuduTable.java   | 79 +++++++++-----------
 4 files changed, 83 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/8155d8c4/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
index eed9481..cd28736 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
@@ -29,6 +29,8 @@ import com.google.common.net.HostAndPort;
 import com.stumbleupon.async.Deferred;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,6 +65,9 @@ public class BaseKuduTest {
   protected static final Schema basicSchema = getBasicSchema();
   protected static final Schema allTypesSchema = getSchemaWithAllTypes();
 
+  @Rule
+  public TestName testName = new TestName();
+
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
     LOG.info("Setting up before class...");
@@ -111,6 +116,23 @@ public class BaseKuduTest {
     syncClient = client.syncClient();
   }
 
+  /**
+   * Returns the method name of the currently-running JUnit test.
+   * @return a test method name
+   */
+  protected String getTestMethodName() {
+    return testName.getMethodName();
+  }
+
+  /**
+   * Returns the method name of the currently-running JUnit test with a concatenated millisecond
+   * timestamp. Useful for table names in tests that are automatically retried.
+   * @return a test method name with a millisecond timestamp appended
+   */
+  protected String getTestMethodNameWithTimestamp() {
+    return getTestMethodName() + "-" + System.currentTimeMillis();
+  }
+
   protected static KuduTable createTable(String tableName, Schema schema,
                                          CreateTableOptions builder) throws KuduException {
     LOG.info("Creating table: {}", tableName);

http://git-wip-us.apache.org/repos/asf/kudu/blob/8155d8c4/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
index c35902b..3d84cb1 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
@@ -72,8 +72,8 @@ public class TestKuduClient extends BaseKuduTest {
   private String tableName;
 
   @Before
-  public void setTableName() {
-    tableName = TestKuduClient.class.getName() + "-" + System.currentTimeMillis();
+  public void setUp() {
+    tableName = getTestMethodNameWithTimestamp();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/kudu/blob/8155d8c4/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java
index 74438dc..d1afea7 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java
@@ -31,34 +31,34 @@ import static org.junit.Assert.fail;
 import java.util.List;
 
 import com.google.common.collect.ImmutableList;
-import org.junit.Rule;
+import org.junit.Before;
 import org.junit.Test;
-import org.junit.rules.TestName;
 
 public class TestKuduSession extends BaseKuduTest {
-  @Rule
-  public final TestName name = new TestName();
+  private String tableName;
 
-  private KuduTable table;
+  @Before
+  public void setUp() {
+    tableName = getTestMethodNameWithTimestamp();
+  }
 
   @Test(timeout = 100000)
   public void testBasicOps() throws Exception {
-    String tableName = name.getMethodName();
-    table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
+    KuduTable table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
 
     KuduSession session = syncClient.newSession();
     for (int i = 0; i < 10; i++) {
-      session.apply(createInsert(i));
+      session.apply(createInsert(table, i));
     }
     assertEquals(10, countRowsInScan(client.newScannerBuilder(table).build()));
 
-    OperationResponse resp = session.apply(createInsert(0));
+    OperationResponse resp = session.apply(createInsert(table, 0));
     assertTrue(resp.hasRowError());
 
     session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
 
     for (int i = 10; i < 20; i++) {
-      session.apply(createInsert(i));
+      session.apply(createInsert(table, i));
     }
     session.flush();
     assertEquals(20, countRowsInScan(client.newScannerBuilder(table).build()));
@@ -66,18 +66,17 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testIgnoreAllDuplicateRows() throws Exception {
-    String tableName = name.getMethodName();
-    table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
+    KuduTable table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
 
     KuduSession session = syncClient.newSession();
     session.setIgnoreAllDuplicateRows(true);
     for (int i = 0; i < 10; i++) {
-      session.apply(createInsert(i));
+      session.apply(createInsert(table, i));
     }
     for (SessionConfiguration.FlushMode mode : SessionConfiguration.FlushMode.values()) {
       session.setFlushMode(mode);
       for (int i = 0; i < 10; i++) {
-        OperationResponse resp = session.apply(createInsert(i));
+        OperationResponse resp = session.apply(createInsert(table, i));
         if (mode == SessionConfiguration.FlushMode.AUTO_FLUSH_SYNC) {
           assertFalse(resp.hasRowError());
         }
@@ -98,8 +97,7 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testBatchWithSameRow() throws Exception {
-    String tableName = name.getMethodName();
-    table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
+    KuduTable table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
 
     KuduSession session = syncClient.newSession();
     session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
@@ -108,7 +106,7 @@ public class TestKuduSession extends BaseKuduTest {
     // while also clearing the cache between each batch half the time. The delete is added here
     // so that a misplaced update would fail if it happens later than its delete.
     for (int i = 0; i < 25; i++) {
-      session.apply(createInsert(i));
+      session.apply(createInsert(table, i));
       for (int j = 0; j < 50; j++) {
         Update update = table.newUpdate();
         PartialRow row = update.getRow();
@@ -149,7 +147,6 @@ public class TestKuduSession extends BaseKuduTest {
    */
   @Test(timeout = 10000)
   public void testConcurrentFlushes() throws Exception {
-    String tableName = name.getMethodName();
     CreateTableOptions builder = getBasicCreateTableOptions();
     int numTablets = 4;
     int numRowsPerTablet = 100;
@@ -160,7 +157,7 @@ public class TestKuduSession extends BaseKuduTest {
       split.addInt(0, i * numRowsPerTablet);
       builder.addSplitRow(split);
     }
-    table = createTable(tableName, basicSchema, builder);
+    KuduTable table = createTable(tableName, basicSchema, builder);
 
     // Configure the session to background flush as often as it can (every 1ms).
     KuduSession session = syncClient.newSession();
@@ -171,7 +168,7 @@ public class TestKuduSession extends BaseKuduTest {
     // NPE.
     for (int i = 0; i < numRowsPerTablet; i++) {
       for (int j = 0; j < numTablets; j++) {
-        session.apply(createInsert(i + (numRowsPerTablet * j)));
+        session.apply(createInsert(table, i + (numRowsPerTablet * j)));
       }
       session.flush();
     }
@@ -179,10 +176,9 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 10000)
   public void testOverWritingValues() throws Exception {
-    String tableName = name.getMethodName();
-    table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
+    KuduTable table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
     KuduSession session = syncClient.newSession();
-    Insert insert = createInsert(0);
+    Insert insert = createInsert(table, 0);
     PartialRow row = insert.getRow();
 
     // Overwrite all the normal columns.
@@ -216,12 +212,11 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 10000)
   public void testUpsert() throws Exception {
-    String tableName = name.getMethodName();
-    table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
+    KuduTable table = createTable(tableName, basicSchema, getBasicCreateTableOptions());
     KuduSession session = syncClient.newSession();
 
     // Test an Upsert that acts as an Insert.
-    assertFalse(session.apply(createUpsert(1, 1, false)).hasRowError());
+    assertFalse(session.apply(createUpsert(table, 1, 1, false)).hasRowError());
 
     List<String> rowStrings = scanTableToStrings(table);
     assertEquals(1, rowStrings.size());
@@ -231,7 +226,7 @@ public class TestKuduSession extends BaseKuduTest {
         rowStrings.get(0));
 
     // Test an Upsert that acts as an Update.
-    assertFalse(session.apply(createUpsert(1, 2, false)).hasRowError());
+    assertFalse(session.apply(createUpsert(table, 1, 2, false)).hasRowError());
     rowStrings = scanTableToStrings(table);
     assertEquals(
         "INT32 key=1, INT32 column1_i=2, INT32 column2_i=3, " +
@@ -241,7 +236,6 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 10000)
   public void testInsertManualFlushNonCoveredRange() throws Exception {
-    String tableName = name.getMethodName();
     CreateTableOptions createOptions = getBasicTableOptionsWithNonCoveredRange();
     createOptions.setNumReplicas(1);
     syncClient.createTable(tableName, basicSchema, createOptions);
@@ -281,7 +275,6 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 10000)
   public void testInsertManualFlushResponseOrder() throws Exception {
-    String tableName = name.getMethodName();
     CreateTableOptions createOptions = getBasicTableOptionsWithNonCoveredRange();
     createOptions.setNumReplicas(1);
     syncClient.createTable(tableName, basicSchema, createOptions);
@@ -312,7 +305,6 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 10000)
   public void testInsertAutoFlushSyncNonCoveredRange() throws Exception {
-    String tableName = name.getMethodName();
     CreateTableOptions createOptions = getBasicTableOptionsWithNonCoveredRange();
     createOptions.setNumReplicas(1);
     syncClient.createTable(tableName, basicSchema, createOptions);
@@ -331,7 +323,6 @@ public class TestKuduSession extends BaseKuduTest {
 
   @Test(timeout = 10000)
   public void testInsertAutoFlushBackgrounNonCoveredRange() throws Exception {
-    String tableName = name.getMethodName();
     CreateTableOptions createOptions = getBasicTableOptionsWithNonCoveredRange();
     createOptions.setNumReplicas(1);
     syncClient.createTable(tableName, basicSchema, createOptions);
@@ -366,11 +357,11 @@ public class TestKuduSession extends BaseKuduTest {
     }
   }
 
-  private Insert createInsert(int key) {
+  private Insert createInsert(KuduTable table, int key) {
     return createBasicSchemaInsert(table, key);
   }
 
-  private Upsert createUpsert(int key, int secondVal, boolean hasNull) {
+  private Upsert createUpsert(KuduTable table, int key, int secondVal, boolean hasNull) {
     Upsert upsert = table.newUpsert();
     PartialRow row = upsert.getRow();
     row.addInt(0, key);

http://git-wip-us.apache.org/repos/asf/kudu/blob/8155d8c4/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
index cb3c8fe..7b67b39 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
@@ -33,30 +33,32 @@ import java.util.List;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
+import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestName;
 
 import org.apache.kudu.ColumnSchema;
 import org.apache.kudu.Schema;
 import org.apache.kudu.Type;
 
 public class TestKuduTable extends BaseKuduTest {
-  @Rule
-  public TestName name = new TestName();
-
-  private static Schema schema = getBasicSchema();
+  private static final Schema BASIC_SCHEMA = getBasicSchema();
+  private String tableName;
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
     BaseKuduTest.setUpBeforeClass();
   }
 
+  @Before
+  public void setUp() {
+    tableName = getTestMethodNameWithTimestamp();
+  }
+
   @Test(timeout = 100000)
   public void testAlterColumn() throws Exception {
-    // Used a simplified schema because basicSchema has extra columns that make the asserts verbose.
-    String tableName = name.getMethodName() + System.currentTimeMillis();
+    // Used a simplified schema because BASIC_SCHEMA has extra columns that make the asserts
+    // verbose.
     List<ColumnSchema> columns = ImmutableList.of(
         new ColumnSchema.ColumnSchemaBuilder("key", Type.INT32).key(true).build(),
         new ColumnSchema.ColumnSchemaBuilder("value", Type.STRING)
@@ -145,7 +147,6 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testAlterTable() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
     createTable(tableName, basicSchema, getBasicCreateTableOptions());
     try {
 
@@ -205,24 +206,24 @@ public class TestKuduTable extends BaseKuduTest {
    */
   @Test
   public void testGetLocations() throws Exception {
-    String table1 = name.getMethodName() + System.currentTimeMillis();
-
     int initialTableCount = client.getTablesList().join(DEFAULT_SLEEP).getTablesList().size();
 
+    final String NON_EXISTENT_TABLE = "NON_EXISTENT_TABLE";
+
     // Test a non-existing table
     try {
-      openTable(table1);
+      openTable(NON_EXISTENT_TABLE);
       fail("Should receive an exception since the table doesn't exist");
     } catch (Exception ex) {
       // expected
     }
     // Test with defaults
-    String tableWithDefault = name.getMethodName() + "WithDefault" + System.currentTimeMillis();
+    String tableWithDefault = tableName + "-WithDefault";
     CreateTableOptions builder = getBasicCreateTableOptions();
-    List<ColumnSchema> columns = new ArrayList<ColumnSchema>(schema.getColumnCount());
+    List<ColumnSchema> columns = new ArrayList<ColumnSchema>(BASIC_SCHEMA.getColumnCount());
     int defaultInt = 30;
     String defaultString = "data";
-    for (ColumnSchema columnSchema : schema.getColumns()) {
+    for (ColumnSchema columnSchema : BASIC_SCHEMA.getColumns()) {
 
       Object defaultValue;
 
@@ -253,14 +254,15 @@ public class TestKuduTable extends BaseKuduTest {
     // Test we can open a table that was already created.
     openTable(tableWithDefault);
 
+    String splitTablePrefix = tableName + "-Splits";
     // Test splitting and reading those splits
-    KuduTable kuduTableWithoutDefaults = createTableWithSplitsAndTest(0);
+    KuduTable kuduTableWithoutDefaults = createTableWithSplitsAndTest(splitTablePrefix, 0);
     // finish testing read defaults
     assertNull(kuduTableWithoutDefaults.getSchema().getColumnByIndex(0).getDefaultValue());
-    createTableWithSplitsAndTest(3);
-    createTableWithSplitsAndTest(10);
+    createTableWithSplitsAndTest(splitTablePrefix, 3);
+    createTableWithSplitsAndTest(splitTablePrefix, 10);
 
-    KuduTable table = createTableWithSplitsAndTest(30);
+    KuduTable table = createTableWithSplitsAndTest(splitTablePrefix, 30);
 
     List<LocatedTablet>tablets = table.getTabletsLocations(null, getKeyInBytes(9), DEFAULT_SLEEP);
     assertEquals(9, tablets.size());
@@ -295,7 +297,7 @@ public class TestKuduTable extends BaseKuduTest {
     assertEquals(11, table.asyncGetTabletsLocations(getKeyInBytes(20), getKeyInBytes(10000), DEFAULT_SLEEP).join().size());
 
     // Test listing tables.
-    assertEquals(0, client.getTablesList(table1).join(DEFAULT_SLEEP).getTablesList().size());
+    assertEquals(0, client.getTablesList(NON_EXISTENT_TABLE).join(DEFAULT_SLEEP).getTablesList().size());
     assertEquals(1, client.getTablesList(tableWithDefault)
                           .join(DEFAULT_SLEEP).getTablesList().size());
     assertEquals(initialTableCount + 5,
@@ -303,13 +305,12 @@ public class TestKuduTable extends BaseKuduTest {
     assertFalse(client.getTablesList(tableWithDefault).
         join(DEFAULT_SLEEP).getTablesList().isEmpty());
 
-    assertFalse(client.tableExists(table1).join(DEFAULT_SLEEP));
+    assertFalse(client.tableExists(NON_EXISTENT_TABLE).join(DEFAULT_SLEEP));
     assertTrue(client.tableExists(tableWithDefault).join(DEFAULT_SLEEP));
   }
 
   @Test(timeout = 100000)
   public void testLocateTableNonCoveringRange() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
     syncClient.createTable(tableName, basicSchema, getBasicTableOptionsWithNonCoveredRange());
     KuduTable table = syncClient.openTable(tableName);
 
@@ -349,22 +350,21 @@ public class TestKuduTable extends BaseKuduTest {
   }
 
   public byte[] getKeyInBytes(int i) {
-    PartialRow row = schema.newPartialRow();
+    PartialRow row = BASIC_SCHEMA.newPartialRow();
     row.addInt(0, i);
     return row.encodePrimaryKey();
   }
 
   @Test(timeout = 100000)
   public void testAlterTableNonCoveringRange() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
     syncClient.createTable(tableName, basicSchema, getBasicTableOptionsWithNonCoveredRange());
     KuduTable table = syncClient.openTable(tableName);
     KuduSession session = syncClient.newSession();
 
     AlterTableOptions ato = new AlterTableOptions();
-    PartialRow bLowerBound = schema.newPartialRow();
+    PartialRow bLowerBound = BASIC_SCHEMA.newPartialRow();
     bLowerBound.addInt("key", 300);
-    PartialRow bUpperBound = schema.newPartialRow();
+    PartialRow bUpperBound = BASIC_SCHEMA.newPartialRow();
     bUpperBound.addInt("key", 400);
     ato.addRangePartition(bLowerBound, bUpperBound);
     syncClient.alterTable(tableName, ato);
@@ -384,9 +384,9 @@ public class TestKuduTable extends BaseKuduTest {
     session.apply(insert);
 
     ato = new AlterTableOptions();
-    bLowerBound = schema.newPartialRow();
+    bLowerBound = BASIC_SCHEMA.newPartialRow();
     bLowerBound.addInt("key", 200);
-    bUpperBound = schema.newPartialRow();
+    bUpperBound = BASIC_SCHEMA.newPartialRow();
     bUpperBound.addInt("key", 300);
     ato.dropRangePartition(bLowerBound, bUpperBound);
     syncClient.alterTable(tableName, ato);
@@ -399,7 +399,6 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testFormatRangePartitions() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
     CreateTableOptions builder = getBasicCreateTableOptions();
     List<String> expected = Lists.newArrayList();
 
@@ -452,8 +451,6 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testFormatRangePartitionsCompoundColumns() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
-
     ArrayList<ColumnSchema> columns = new ArrayList<>();
     columns.add(new ColumnSchema.ColumnSchemaBuilder("a", Type.STRING).key(true).build());
     columns.add(new ColumnSchema.ColumnSchemaBuilder("b", Type.INT8).key(true).build());
@@ -503,8 +500,6 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testFormatRangePartitionsStringColumn() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
-
     ArrayList<ColumnSchema> columns = new ArrayList<>();
     columns.add(new ColumnSchema.ColumnSchemaBuilder("a", Type.STRING).key(true).build());
     Schema schema = new Schema(columns);
@@ -550,7 +545,6 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testFormatRangePartitionsUnbounded() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
     CreateTableOptions builder = getBasicCreateTableOptions();
     syncClient.createTable(tableName, basicSchema, builder);
 
@@ -559,18 +553,19 @@ public class TestKuduTable extends BaseKuduTest {
         syncClient.openTable(tableName).getFormattedRangePartitions(10000));
   }
 
-  public KuduTable createTableWithSplitsAndTest(int splitsCount) throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
+  private KuduTable createTableWithSplitsAndTest(String tableNamePrefix, int splitsCount)
+      throws Exception {
+    String newTableName = tableNamePrefix + "-" + splitsCount;
     CreateTableOptions builder = getBasicCreateTableOptions();
 
     if (splitsCount != 0) {
       for (int i = 1; i <= splitsCount; i++) {
-        PartialRow row = schema.newPartialRow();
+        PartialRow row = BASIC_SCHEMA.newPartialRow();
         row.addInt(0, i);
         builder.addSplitRow(row);
       }
     }
-    KuduTable table = createTable(tableName, schema, builder);
+    KuduTable table = createTable(newTableName, BASIC_SCHEMA, builder);
 
     List<LocatedTablet> tablets = table.getTabletsLocations(DEFAULT_SLEEP);
     assertEquals(splitsCount + 1, tablets.size());
@@ -583,8 +578,6 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testGetRangePartitions() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
-
     ArrayList<ColumnSchema> columns = new ArrayList<>();
     columns.add(new ColumnSchema.ColumnSchemaBuilder("a", Type.STRING).key(true).build());
     columns.add(new ColumnSchema.ColumnSchemaBuilder("b", Type.INT8).key(true).build());
@@ -627,9 +620,8 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testGetRangePartitionsUnbounded() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
     CreateTableOptions builder = getBasicCreateTableOptions();
-    KuduTable table = createTable(tableName, schema, builder);
+    KuduTable table = createTable(tableName, BASIC_SCHEMA, builder);
 
     List<Partition> rangePartitions =
         table.getRangePartitions(client.getDefaultOperationTimeoutMs());
@@ -641,7 +633,6 @@ public class TestKuduTable extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testAlterNoWait() throws Exception {
-    String tableName = name.getMethodName() + System.currentTimeMillis();
     createTable(tableName, basicSchema, getBasicCreateTableOptions());
 
     String oldName = "column2_i";
@@ -689,7 +680,7 @@ public class TestKuduTable extends BaseKuduTest {
     for (int i = 1; i <= 3; i++) {
       // Ignore even numbers.
       if (i % 2 != 0) {
-        String tableName = name.getMethodName() + System.currentTimeMillis() + "-" + i;
+        String tableName = getTestMethodNameWithTimestamp() + "-" + i;
         CreateTableOptions options = getBasicCreateTableOptions();
         options.setNumReplicas(i);
         createTable(tableName, basicSchema, options);