You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2014/03/05 19:20:28 UTC
svn commit: r1574600 - in
/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase:
client/TestRestoreSnapshotFromClient.java snapshot/SnapshotTestingUtils.java
Author: larsh
Date: Wed Mar 5 18:20:28 2014
New Revision: 1574600
URL: http://svn.apache.org/r1574600
Log:
HBASE-10594 Speed up TestRestoreSnapshotFromClient.
Modified:
hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java
Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java?rev=1574600&r1=1574599&r2=1574600&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java (original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java Wed Mar 5 18:20:28 2014
@@ -124,13 +124,6 @@ public class TestRestoreSnapshotFromClie
admin.enableTable(tableName);
SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, FAMILY);
snapshot1Rows = TEST_UTIL.countRows(table);
- admin.disableTable(tableName);
-
- // take a snapshot of the updated table
- admin.snapshot(snapshotName1, tableName);
-
- // re-enable table
- admin.enableTable(tableName);
table.close();
}
@@ -144,9 +137,9 @@ public class TestRestoreSnapshotFromClie
@Test
public void testRestoreSnapshot() throws IOException {
SnapshotTestingUtils.verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
-
- // Restore from snapshot-0
admin.disableTable(tableName);
+ admin.snapshot(snapshotName1, tableName);
+ // Restore from snapshot-0
admin.restoreSnapshot(snapshotName0);
admin.enableTable(tableName);
SnapshotTestingUtils.verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java?rev=1574600&r1=1574599&r2=1574600&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java (original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java Wed Mar 5 18:20:28 2014
@@ -73,6 +73,7 @@ import com.google.protobuf.ServiceExcept
public class SnapshotTestingUtils {
private static final Log LOG = LogFactory.getLog(SnapshotTestingUtils.class);
+ private static byte[] KEYS = Bytes.toBytes("0123456789");
/**
* Assert that we don't have any snapshots lists
@@ -434,14 +435,13 @@ public class SnapshotTestingUtils {
HColumnDescriptor hcd = new HColumnDescriptor(family);
htd.addFamily(hcd);
}
- byte[][] splitKeys = new byte[14][];
- byte[] hex = Bytes.toBytes("123456789abcde");
+ byte[][] splitKeys = new byte[KEYS.length-2][];
for (int i = 0; i < splitKeys.length; ++i) {
- splitKeys[i] = new byte[] { hex[i] };
+ splitKeys[i] = new byte[] { KEYS[i+1] };
}
util.getHBaseAdmin().createTable(htd, splitKeys);
waitForTableToBeOnline(util, tableName);
- assertEquals(15, util.getHBaseAdmin().getTableRegions(tableName).size());
+ assertEquals(KEYS.length-1, util.getHBaseAdmin().getTableRegions(tableName).size());
}
public static void loadData(final HBaseTestingUtility util, final TableName tableName, int rows,
@@ -454,8 +454,8 @@ public class SnapshotTestingUtils {
table.setAutoFlush(false, true);
// Ensure one row per region
- assertTrue(rows >= 16);
- for (byte k0: Bytes.toBytes("0123456789abcdef")) {
+ assertTrue(rows >= KEYS.length);
+ for (byte k0: KEYS) {
byte[] k = new byte[] { k0 };
byte[] value = Bytes.add(Bytes.toBytes(System.currentTimeMillis()), k);
byte[] key = Bytes.add(k, Bytes.toBytes(MD5Hash.getMD5AsHex(value)));