HBASE-21311 Split TestRestoreSnapshotFromClient
This commit is contained in:
parent
07e2247d2e
commit
fc7a6a64c2
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RestoreSnapshotFromClientAfterSplittingRegionsTestBase
|
||||
extends RestoreSnapshotFromClientTestBase {
|
||||
|
||||
@Test
|
||||
public void testRestoreSnapshotAfterSplittingRegions() throws IOException, InterruptedException {
|
||||
List<RegionInfo> regionInfos = admin.getRegions(tableName);
|
||||
RegionReplicaUtil.removeNonDefaultRegions(regionInfos);
|
||||
|
||||
// Split the first region
|
||||
splitRegion(regionInfos.get(0));
|
||||
|
||||
// Take a snapshot
|
||||
admin.snapshot(snapshotName1, tableName);
|
||||
|
||||
// Load more data
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
|
||||
// Split the second region
|
||||
splitRegion(regionInfos.get(1));
|
||||
|
||||
// Restore the snapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
admin.enableTable(tableName);
|
||||
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RestoreSnapshotFromClientAfterTruncateTestBase
|
||||
extends RestoreSnapshotFromClientTestBase {
|
||||
|
||||
@Test
|
||||
public void testRestoreSnapshotAfterTruncate() throws Exception {
|
||||
TableName tableName = TableName.valueOf(getValidMethodName());
|
||||
SnapshotTestingUtils.createTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
int numOfRows = 0;
|
||||
|
||||
try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
|
||||
numOfRows = countRows(table);
|
||||
}
|
||||
// take snapshot
|
||||
admin.snapshot("snap", tableName);
|
||||
admin.disableTable(tableName);
|
||||
admin.truncateTable(tableName, false);
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot("snap");
|
||||
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, numOfRows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RestoreSnapshotFromClientCloneTestBase extends RestoreSnapshotFromClientTestBase {
|
||||
|
||||
@Test
|
||||
public void testCloneSnapshotOfCloned() throws IOException, InterruptedException {
|
||||
TableName clonedTableName =
|
||||
TableName.valueOf(getValidMethodName() + "-" + System.currentTimeMillis());
|
||||
admin.cloneSnapshot(snapshotName0, clonedTableName);
|
||||
verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(clonedTableName, admin, getNumReplicas());
|
||||
admin.disableTable(clonedTableName);
|
||||
admin.snapshot(snapshotName2, clonedTableName);
|
||||
TEST_UTIL.deleteTable(clonedTableName);
|
||||
waitCleanerRun();
|
||||
|
||||
admin.cloneSnapshot(snapshotName2, clonedTableName);
|
||||
verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(clonedTableName, admin, getNumReplicas());
|
||||
TEST_UTIL.deleteTable(clonedTableName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloneAndRestoreSnapshot() throws IOException, InterruptedException {
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
waitCleanerRun();
|
||||
|
||||
admin.cloneSnapshot(snapshotName0, tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
waitCleanerRun();
|
||||
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName0);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
}
|
||||
|
||||
private void waitCleanerRun() throws InterruptedException {
|
||||
TEST_UTIL.getMiniHBaseCluster().getMaster().getHFileCleaner().choreForTesting();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RestoreSnapshotFromClientGetCompactionStateTestBase
|
||||
extends RestoreSnapshotFromClientTestBase {
|
||||
|
||||
@Test
|
||||
public void testGetCompactionStateAfterRestoringSnapshot()
|
||||
throws IOException, InterruptedException {
|
||||
// Take a snapshot
|
||||
admin.snapshot(snapshotName1, tableName);
|
||||
|
||||
// Restore the snapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
|
||||
// Get the compaction state of the restored table
|
||||
CompactionState compactionState = admin.getCompactionState(tableName);
|
||||
|
||||
// The compactionState should be NONE because the table is disabled
|
||||
assertEquals(CompactionState.NONE, compactionState);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.master.MasterFileSystem;
|
||||
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RestoreSnapshotFromClientSchemaChangeTestBase
|
||||
extends RestoreSnapshotFromClientTestBase {
|
||||
|
||||
private Set<String> getFamiliesFromFS(final TableName tableName) throws IOException {
|
||||
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
|
||||
Set<String> families = new HashSet<>();
|
||||
Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), tableName);
|
||||
for (Path regionDir : FSUtils.getRegionDirs(mfs.getFileSystem(), tableDir)) {
|
||||
for (Path familyDir : FSUtils.getFamilyDirs(mfs.getFileSystem(), regionDir)) {
|
||||
families.add(familyDir.getName());
|
||||
}
|
||||
}
|
||||
return families;
|
||||
}
|
||||
|
||||
protected ColumnFamilyDescriptor getTestRestoreSchemaChangeHCD() {
|
||||
return ColumnFamilyDescriptorBuilder.of(TEST_FAMILY2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreSchemaChange() throws Exception {
|
||||
Table table = TEST_UTIL.getConnection().getTable(tableName);
|
||||
|
||||
// Add one column family and put some data in it
|
||||
admin.disableTable(tableName);
|
||||
admin.addColumnFamily(tableName, getTestRestoreSchemaChangeHCD());
|
||||
admin.enableTable(tableName);
|
||||
assertEquals(2, table.getDescriptor().getColumnFamilyCount());
|
||||
TableDescriptor htd = admin.getDescriptor(tableName);
|
||||
assertEquals(2, htd.getColumnFamilyCount());
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, TEST_FAMILY2);
|
||||
long snapshot2Rows = snapshot1Rows + 500L;
|
||||
assertEquals(snapshot2Rows, countRows(table));
|
||||
assertEquals(500, countRows(table, TEST_FAMILY2));
|
||||
Set<String> fsFamilies = getFamiliesFromFS(tableName);
|
||||
assertEquals(2, fsFamilies.size());
|
||||
|
||||
// Take a snapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.snapshot(snapshotName2, tableName);
|
||||
|
||||
// Restore the snapshot (without the cf)
|
||||
admin.restoreSnapshot(snapshotName0);
|
||||
admin.enableTable(tableName);
|
||||
assertEquals(1, table.getDescriptor().getColumnFamilyCount());
|
||||
try {
|
||||
countRows(table, TEST_FAMILY2);
|
||||
fail("family '" + Bytes.toString(TEST_FAMILY2) + "' should not exists");
|
||||
} catch (NoSuchColumnFamilyException e) {
|
||||
// expected
|
||||
}
|
||||
assertEquals(snapshot0Rows, countRows(table));
|
||||
htd = admin.getDescriptor(tableName);
|
||||
assertEquals(1, htd.getColumnFamilyCount());
|
||||
fsFamilies = getFamiliesFromFS(tableName);
|
||||
assertEquals(1, fsFamilies.size());
|
||||
|
||||
// Restore back the snapshot (with the cf)
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName2);
|
||||
admin.enableTable(tableName);
|
||||
htd = admin.getDescriptor(tableName);
|
||||
assertEquals(2, htd.getColumnFamilyCount());
|
||||
assertEquals(2, table.getDescriptor().getColumnFamilyCount());
|
||||
assertEquals(500, countRows(table, TEST_FAMILY2));
|
||||
assertEquals(snapshot2Rows, countRows(table));
|
||||
fsFamilies = getFamiliesFromFS(tableName);
|
||||
assertEquals(2, fsFamilies.size());
|
||||
table.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.snapshot.CorruptedSnapshotException;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RestoreSnapshotFromClientSimpleTestBase extends RestoreSnapshotFromClientTestBase {
|
||||
|
||||
@Test
|
||||
public void testRestoreSnapshot() throws IOException {
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
admin.disableTable(tableName);
|
||||
admin.snapshot(snapshotName1, tableName);
|
||||
// Restore from snapshot-0
|
||||
admin.restoreSnapshot(snapshotName0);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
|
||||
// Restore from emptySnapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(emptySnapshot);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, 0);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
|
||||
// Restore from snapshot-1
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
|
||||
// Restore from snapshot-1
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorruptedSnapshot() throws IOException, InterruptedException {
|
||||
SnapshotTestingUtils.corruptSnapshot(TEST_UTIL, Bytes.toString(snapshotName0));
|
||||
TableName cloneName =
|
||||
TableName.valueOf(getValidMethodName() + "-" + System.currentTimeMillis());
|
||||
try {
|
||||
admin.cloneSnapshot(snapshotName0, cloneName);
|
||||
fail("Expected CorruptedSnapshotException, got succeeded cloneSnapshot()");
|
||||
} catch (CorruptedSnapshotException e) {
|
||||
// Got the expected corruption exception.
|
||||
// check for no references of the cloned table.
|
||||
assertFalse(admin.tableExists(cloneName));
|
||||
} catch (Exception e) {
|
||||
fail("Expected CorruptedSnapshotException got: " + e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
/**
|
||||
* Base class for testing restore snapshot
|
||||
*/
|
||||
public class RestoreSnapshotFromClientTestBase {
|
||||
protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
||||
|
||||
protected final byte[] FAMILY = Bytes.toBytes("cf");
|
||||
protected final byte[] TEST_FAMILY2 = Bytes.toBytes("cf2");
|
||||
|
||||
protected TableName tableName;
|
||||
protected byte[] emptySnapshot;
|
||||
protected byte[] snapshotName0;
|
||||
protected byte[] snapshotName1;
|
||||
protected byte[] snapshotName2;
|
||||
protected int snapshot0Rows;
|
||||
protected int snapshot1Rows;
|
||||
protected Admin admin;
|
||||
|
||||
@Rule
|
||||
public TestName name = new TestName();
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
setupConf(TEST_UTIL.getConfiguration());
|
||||
TEST_UTIL.startMiniCluster(3);
|
||||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
|
||||
TEST_UTIL.getConfiguration().setInt("hbase.hstore.compactionThreshold", 10);
|
||||
TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
|
||||
TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
|
||||
TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
|
||||
TEST_UTIL.getConfiguration().setBoolean("hbase.master.enabletable.roundrobin", true);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
TEST_UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the tests with a table filled with some data and two snapshots (snapshotName0,
|
||||
* snapshotName1) of different states. The tableName, snapshotNames and the number of rows in the
|
||||
* snapshot are initialized.
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
this.admin = TEST_UTIL.getAdmin();
|
||||
|
||||
long tid = System.currentTimeMillis();
|
||||
tableName = TableName.valueOf(getValidMethodName() + "-" + tid);
|
||||
emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
|
||||
snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
|
||||
snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
|
||||
snapshotName2 = Bytes.toBytes("snaptb2-" + tid);
|
||||
|
||||
// create Table and disable it
|
||||
createTable();
|
||||
admin.disableTable(tableName);
|
||||
|
||||
// take an empty snapshot
|
||||
admin.snapshot(emptySnapshot, tableName);
|
||||
|
||||
// enable table and insert data
|
||||
admin.enableTable(tableName);
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
|
||||
snapshot0Rows = countRows(table);
|
||||
}
|
||||
admin.disableTable(tableName);
|
||||
|
||||
// take a snapshot
|
||||
admin.snapshot(snapshotName0, tableName);
|
||||
|
||||
// enable table and insert more data
|
||||
admin.enableTable(tableName);
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
|
||||
snapshot1Rows = countRows(table);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createTable() throws Exception {
|
||||
SnapshotTestingUtils.createTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
SnapshotTestingUtils.deleteAllSnapshots(TEST_UTIL.getAdmin());
|
||||
SnapshotTestingUtils.deleteArchiveDirectory(TEST_UTIL);
|
||||
}
|
||||
|
||||
protected int getNumReplicas() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected int countRows(Table table, byte[]... families) throws IOException {
|
||||
return TEST_UTIL.countRows(table, families);
|
||||
}
|
||||
|
||||
protected void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows)
|
||||
throws IOException {
|
||||
SnapshotTestingUtils.verifyRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
protected final void splitRegion(RegionInfo regionInfo) throws IOException {
|
||||
byte[][] splitPoints = Bytes.split(regionInfo.getStartKey(), regionInfo.getEndKey(), 1);
|
||||
admin.split(regionInfo.getTable(), splitPoints[1]);
|
||||
}
|
||||
|
||||
protected final String getValidMethodName() {
|
||||
return name.getMethodName().replaceAll("[^0-9A-Za-z_]", "_");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestMobRestoreSnapshotFromClientAfterSplittingRegions
|
||||
extends RestoreSnapshotFromClientAfterSplittingRegionsTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestMobRestoreSnapshotFromClientAfterSplittingRegions.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
setupConf(TEST_UTIL.getConfiguration());
|
||||
TEST_UTIL.startMiniCluster(3);
|
||||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
RestoreSnapshotFromClientTestBase.setupConf(conf);
|
||||
TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createTable() throws Exception {
|
||||
MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows)
|
||||
throws IOException {
|
||||
MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int countRows(Table table, byte[]... families) throws IOException {
|
||||
return MobSnapshotTestingUtils.countMobRows(table, families);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestMobRestoreSnapshotFromClientAfterTruncate
|
||||
extends RestoreSnapshotFromClientAfterTruncateTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestMobRestoreSnapshotFromClientAfterTruncate.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
setupConf(TEST_UTIL.getConfiguration());
|
||||
TEST_UTIL.startMiniCluster(3);
|
||||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
RestoreSnapshotFromClientTestBase.setupConf(conf);
|
||||
TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createTable() throws Exception {
|
||||
MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows)
|
||||
throws IOException {
|
||||
MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int countRows(Table table, byte[]... families) throws IOException {
|
||||
return MobSnapshotTestingUtils.countMobRows(table, families);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestMobRestoreSnapshotFromClientClone extends RestoreSnapshotFromClientCloneTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestMobRestoreSnapshotFromClientClone.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
setupConf(TEST_UTIL.getConfiguration());
|
||||
TEST_UTIL.startMiniCluster(3);
|
||||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
RestoreSnapshotFromClientTestBase.setupConf(conf);
|
||||
TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createTable() throws Exception {
|
||||
MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows)
|
||||
throws IOException {
|
||||
MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int countRows(Table table, byte[]... families) throws IOException {
|
||||
return MobSnapshotTestingUtils.countMobRows(table, families);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestMobRestoreSnapshotFromClientGetCompactionState
|
||||
extends RestoreSnapshotFromClientGetCompactionStateTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestMobRestoreSnapshotFromClientGetCompactionState.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
setupConf(TEST_UTIL.getConfiguration());
|
||||
TEST_UTIL.startMiniCluster(3);
|
||||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
RestoreSnapshotFromClientTestBase.setupConf(conf);
|
||||
TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createTable() throws Exception {
|
||||
MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows)
|
||||
throws IOException {
|
||||
MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int countRows(Table table, byte[]... families) throws IOException {
|
||||
return MobSnapshotTestingUtils.countMobRows(table, families);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
|
||||
|
@ -31,15 +30,13 @@ import org.junit.BeforeClass;
|
|||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
/**
|
||||
* Test restore snapshots from the client
|
||||
*/
|
||||
@Category({ClientTests.class, LargeTests.class})
|
||||
public class TestMobRestoreSnapshotFromClient extends TestRestoreSnapshotFromClient {
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestMobRestoreSnapshotFromClientSchemaChange
|
||||
extends RestoreSnapshotFromClientSchemaChangeTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestMobRestoreSnapshotFromClient.class);
|
||||
HBaseClassTestRule.forClass(TestMobRestoreSnapshotFromClientSchemaChange.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
|
@ -48,7 +45,7 @@ public class TestMobRestoreSnapshotFromClient extends TestRestoreSnapshotFromCli
|
|||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
TestRestoreSnapshotFromClient.setupConf(conf);
|
||||
RestoreSnapshotFromClientTestBase.setupConf(conf);
|
||||
TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
|
||||
}
|
||||
|
||||
|
@ -58,21 +55,19 @@ public class TestMobRestoreSnapshotFromClient extends TestRestoreSnapshotFromCli
|
|||
}
|
||||
|
||||
@Override
|
||||
protected HColumnDescriptor getTestRestoreSchemaChangeHCD() {
|
||||
HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2);
|
||||
hcd.setMobEnabled(true);
|
||||
hcd.setMobThreshold(3L);
|
||||
return hcd;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyRowCount(final HBaseTestingUtility util, final TableName tableName,
|
||||
long expectedRows) throws IOException {
|
||||
protected void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows)
|
||||
throws IOException {
|
||||
MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int countRows(final Table table, final byte[]... families) throws IOException {
|
||||
protected int countRows(Table table, byte[]... families) throws IOException {
|
||||
return MobSnapshotTestingUtils.countMobRows(table, families);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ColumnFamilyDescriptor getTestRestoreSchemaChangeHCD() {
|
||||
return ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY2).setMobEnabled(true)
|
||||
.setMobThreshold(3L).build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestMobRestoreSnapshotFromClientSimple
|
||||
extends RestoreSnapshotFromClientSimpleTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestMobRestoreSnapshotFromClientSimple.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
setupConf(TEST_UTIL.getConfiguration());
|
||||
TEST_UTIL.startMiniCluster(3);
|
||||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
RestoreSnapshotFromClientTestBase.setupConf(conf);
|
||||
TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createTable() throws Exception {
|
||||
MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows)
|
||||
throws IOException {
|
||||
MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int countRows(Table table, byte[]... families) throws IOException {
|
||||
return MobSnapshotTestingUtils.countMobRows(table, families);
|
||||
}
|
||||
}
|
|
@ -1,396 +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.hadoop.hbase.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.master.MasterFileSystem;
|
||||
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
|
||||
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
|
||||
import org.apache.hadoop.hbase.snapshot.CorruptedSnapshotException;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
/**
|
||||
* Test restore snapshots from the client
|
||||
*/
|
||||
@Category({LargeTests.class, ClientTests.class})
|
||||
public class TestRestoreSnapshotFromClient {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClient.class);
|
||||
|
||||
protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
||||
|
||||
protected final byte[] FAMILY = Bytes.toBytes("cf");
|
||||
protected final byte[] TEST_FAMILY2 = Bytes.toBytes("cf2");
|
||||
|
||||
protected TableName tableName;
|
||||
protected byte[] emptySnapshot;
|
||||
protected byte[] snapshotName0;
|
||||
protected byte[] snapshotName1;
|
||||
protected byte[] snapshotName2;
|
||||
protected int snapshot0Rows;
|
||||
protected int snapshot1Rows;
|
||||
protected Admin admin;
|
||||
|
||||
@Rule
|
||||
public TestName name = new TestName();
|
||||
|
||||
@BeforeClass
|
||||
public static void setupCluster() throws Exception {
|
||||
setupConf(TEST_UTIL.getConfiguration());
|
||||
TEST_UTIL.startMiniCluster(3);
|
||||
}
|
||||
|
||||
protected static void setupConf(Configuration conf) {
|
||||
TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
|
||||
TEST_UTIL.getConfiguration().setInt("hbase.hstore.compactionThreshold", 10);
|
||||
TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
|
||||
TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
|
||||
TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
|
||||
TEST_UTIL.getConfiguration().setBoolean(
|
||||
"hbase.master.enabletable.roundrobin", true);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
TEST_UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the tests with a table filled with some data
|
||||
* and two snapshots (snapshotName0, snapshotName1) of different states.
|
||||
* The tableName, snapshotNames and the number of rows in the snapshot are initialized.
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
this.admin = TEST_UTIL.getAdmin();
|
||||
|
||||
long tid = System.currentTimeMillis();
|
||||
tableName = TableName.valueOf(name.getMethodName() + "-" + tid);
|
||||
emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
|
||||
snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
|
||||
snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
|
||||
snapshotName2 = Bytes.toBytes("snaptb2-" + tid);
|
||||
|
||||
// create Table and disable it
|
||||
createTable();
|
||||
admin.disableTable(tableName);
|
||||
|
||||
// take an empty snapshot
|
||||
admin.snapshot(emptySnapshot, tableName);
|
||||
|
||||
// enable table and insert data
|
||||
admin.enableTable(tableName);
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
|
||||
snapshot0Rows = countRows(table);
|
||||
}
|
||||
admin.disableTable(tableName);
|
||||
|
||||
// take a snapshot
|
||||
admin.snapshot(snapshotName0, tableName);
|
||||
|
||||
// enable table and insert more data
|
||||
admin.enableTable(tableName);
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
|
||||
snapshot1Rows = countRows(table);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createTable() throws Exception {
|
||||
SnapshotTestingUtils.createTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
SnapshotTestingUtils.deleteAllSnapshots(TEST_UTIL.getAdmin());
|
||||
SnapshotTestingUtils.deleteArchiveDirectory(TEST_UTIL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreSnapshot() throws IOException {
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
admin.disableTable(tableName);
|
||||
admin.snapshot(snapshotName1, tableName);
|
||||
// Restore from snapshot-0
|
||||
admin.restoreSnapshot(snapshotName0);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
|
||||
// Restore from emptySnapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(emptySnapshot);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, 0);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
|
||||
// Restore from snapshot-1
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
|
||||
// Restore from snapshot-1
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
}
|
||||
|
||||
protected int getNumReplicas() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected HColumnDescriptor getTestRestoreSchemaChangeHCD() {
|
||||
return new HColumnDescriptor(TEST_FAMILY2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreSchemaChange() throws Exception {
|
||||
Table table = TEST_UTIL.getConnection().getTable(tableName);
|
||||
|
||||
// Add one column family and put some data in it
|
||||
admin.disableTable(tableName);
|
||||
admin.addColumnFamily(tableName, getTestRestoreSchemaChangeHCD());
|
||||
admin.enableTable(tableName);
|
||||
assertEquals(2, table.getTableDescriptor().getFamilies().size());
|
||||
HTableDescriptor htd = admin.getTableDescriptor(tableName);
|
||||
assertEquals(2, htd.getFamilies().size());
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, TEST_FAMILY2);
|
||||
long snapshot2Rows = snapshot1Rows + 500L;
|
||||
assertEquals(snapshot2Rows, countRows(table));
|
||||
assertEquals(500, countRows(table, TEST_FAMILY2));
|
||||
Set<String> fsFamilies = getFamiliesFromFS(tableName);
|
||||
assertEquals(2, fsFamilies.size());
|
||||
|
||||
// Take a snapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.snapshot(snapshotName2, tableName);
|
||||
|
||||
// Restore the snapshot (without the cf)
|
||||
admin.restoreSnapshot(snapshotName0);
|
||||
admin.enableTable(tableName);
|
||||
assertEquals(1, table.getTableDescriptor().getFamilies().size());
|
||||
try {
|
||||
countRows(table, TEST_FAMILY2);
|
||||
fail("family '" + Bytes.toString(TEST_FAMILY2) + "' should not exists");
|
||||
} catch (NoSuchColumnFamilyException e) {
|
||||
// expected
|
||||
}
|
||||
assertEquals(snapshot0Rows, countRows(table));
|
||||
htd = admin.getTableDescriptor(tableName);
|
||||
assertEquals(1, htd.getFamilies().size());
|
||||
fsFamilies = getFamiliesFromFS(tableName);
|
||||
assertEquals(1, fsFamilies.size());
|
||||
|
||||
// Restore back the snapshot (with the cf)
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName2);
|
||||
admin.enableTable(tableName);
|
||||
htd = admin.getTableDescriptor(tableName);
|
||||
assertEquals(2, htd.getFamilies().size());
|
||||
assertEquals(2, table.getTableDescriptor().getFamilies().size());
|
||||
assertEquals(500, countRows(table, TEST_FAMILY2));
|
||||
assertEquals(snapshot2Rows, countRows(table));
|
||||
fsFamilies = getFamiliesFromFS(tableName);
|
||||
assertEquals(2, fsFamilies.size());
|
||||
table.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloneSnapshotOfCloned() throws IOException, InterruptedException {
|
||||
TableName clonedTableName = TableName.valueOf(name.getMethodName() + "-" +
|
||||
System.currentTimeMillis());
|
||||
admin.cloneSnapshot(snapshotName0, clonedTableName);
|
||||
verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(clonedTableName, admin, getNumReplicas());
|
||||
admin.disableTable(clonedTableName);
|
||||
admin.snapshot(snapshotName2, clonedTableName);
|
||||
TEST_UTIL.deleteTable(clonedTableName);
|
||||
waitCleanerRun();
|
||||
|
||||
admin.cloneSnapshot(snapshotName2, clonedTableName);
|
||||
verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(clonedTableName, admin, getNumReplicas());
|
||||
TEST_UTIL.deleteTable(clonedTableName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloneAndRestoreSnapshot() throws IOException, InterruptedException {
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
waitCleanerRun();
|
||||
|
||||
admin.cloneSnapshot(snapshotName0, tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
waitCleanerRun();
|
||||
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName0);
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorruptedSnapshot() throws IOException, InterruptedException {
|
||||
SnapshotTestingUtils.corruptSnapshot(TEST_UTIL, Bytes.toString(snapshotName0));
|
||||
TableName cloneName = TableName.valueOf(name.getMethodName() + "-" +
|
||||
System.currentTimeMillis());
|
||||
try {
|
||||
admin.cloneSnapshot(snapshotName0, cloneName);
|
||||
fail("Expected CorruptedSnapshotException, got succeeded cloneSnapshot()");
|
||||
} catch (CorruptedSnapshotException e) {
|
||||
// Got the expected corruption exception.
|
||||
// check for no references of the cloned table.
|
||||
assertFalse(admin.tableExists(cloneName));
|
||||
} catch (Exception e) {
|
||||
fail("Expected CorruptedSnapshotException got: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreSnapshotAfterSplittingRegions() throws IOException, InterruptedException {
|
||||
List<RegionInfo> regionInfos = admin.getRegions(tableName);
|
||||
RegionReplicaUtil.removeNonDefaultRegions(regionInfos);
|
||||
|
||||
// Split the first region
|
||||
splitRegion(regionInfos.get(0));
|
||||
|
||||
// Take a snapshot
|
||||
admin.snapshot(snapshotName1, tableName);
|
||||
|
||||
// Load more data
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
|
||||
// Split the second region
|
||||
splitRegion(regionInfos.get(1));
|
||||
|
||||
// Restore the snapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
admin.enableTable(tableName);
|
||||
|
||||
verifyRowCount(TEST_UTIL, tableName, snapshot1Rows);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreSnapshotAfterTruncate() throws Exception {
|
||||
TableName tableName = TableName.valueOf("testRestoreSnapshotAfterTruncate");
|
||||
SnapshotTestingUtils.createTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
|
||||
SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
|
||||
int numOfRows = 0;
|
||||
|
||||
try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
|
||||
numOfRows = countRows(table);
|
||||
}
|
||||
// take snapshot
|
||||
admin.snapshot("snap", tableName);
|
||||
admin.disableTable(tableName);
|
||||
admin.truncateTable(tableName, false);
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot("snap");
|
||||
|
||||
admin.enableTable(tableName);
|
||||
verifyRowCount(TEST_UTIL, tableName, numOfRows);
|
||||
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
|
||||
}
|
||||
|
||||
@Test(timeout = 30000)
|
||||
public void testGetCompactionStateAfterRestoringSnapshot() throws IOException,
|
||||
InterruptedException {
|
||||
// Take a snapshot
|
||||
admin.snapshot(snapshotName1, tableName);
|
||||
|
||||
// Restore the snapshot
|
||||
admin.disableTable(tableName);
|
||||
admin.restoreSnapshot(snapshotName1);
|
||||
|
||||
// Get the compaction state of the restored table
|
||||
CompactionState compactionState = admin.getCompactionState(tableName);
|
||||
|
||||
// The compactionState should be NONE because the table is disabled
|
||||
assertEquals(CompactionState.NONE, compactionState);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// Helpers
|
||||
// ==========================================================================
|
||||
private void waitCleanerRun() throws InterruptedException {
|
||||
TEST_UTIL.getMiniHBaseCluster().getMaster().getHFileCleaner().choreForTesting();
|
||||
}
|
||||
|
||||
private Set<String> getFamiliesFromFS(final TableName tableName) throws IOException {
|
||||
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
|
||||
Set<String> families = new HashSet<>();
|
||||
Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), tableName);
|
||||
for (Path regionDir: FSUtils.getRegionDirs(mfs.getFileSystem(), tableDir)) {
|
||||
for (Path familyDir: FSUtils.getFamilyDirs(mfs.getFileSystem(), regionDir)) {
|
||||
families.add(familyDir.getName());
|
||||
}
|
||||
}
|
||||
return families;
|
||||
}
|
||||
|
||||
protected void verifyRowCount(final HBaseTestingUtility util, final TableName tableName,
|
||||
long expectedRows) throws IOException {
|
||||
SnapshotTestingUtils.verifyRowCount(util, tableName, expectedRows);
|
||||
}
|
||||
|
||||
protected int countRows(final Table table, final byte[]... families) throws IOException {
|
||||
return TEST_UTIL.countRows(table, families);
|
||||
}
|
||||
|
||||
protected void splitRegion(final RegionInfo regionInfo) throws IOException {
|
||||
byte[][] splitPoints = Bytes.split(regionInfo.getStartKey(), regionInfo.getEndKey(), 1);
|
||||
admin.split(regionInfo.getTable(), splitPoints[1]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestRestoreSnapshotFromClientAfterSplittingRegions
|
||||
extends RestoreSnapshotFromClientAfterSplittingRegionsTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientAfterSplittingRegions.class);
|
||||
|
||||
@Parameter
|
||||
public int numReplicas;
|
||||
|
||||
@Parameters(name = "{index}: regionReplication={0}")
|
||||
public static List<Object[]> params() {
|
||||
return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumReplicas() {
|
||||
return numReplicas;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestRestoreSnapshotFromClientAfterTruncate
|
||||
extends RestoreSnapshotFromClientAfterTruncateTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientAfterTruncate.class);
|
||||
|
||||
@Parameter
|
||||
public int numReplicas;
|
||||
|
||||
@Parameters(name = "{index}: regionReplication={0}")
|
||||
public static List<Object[]> params() {
|
||||
return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumReplicas() {
|
||||
return numReplicas;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestRestoreSnapshotFromClientClone extends RestoreSnapshotFromClientCloneTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientClone.class);
|
||||
|
||||
@Parameter
|
||||
public int numReplicas;
|
||||
|
||||
@Parameters(name = "{index}: regionReplication={0}")
|
||||
public static List<Object[]> params() {
|
||||
return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumReplicas() {
|
||||
return numReplicas;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestRestoreSnapshotFromClientGetCompactionState
|
||||
extends RestoreSnapshotFromClientGetCompactionStateTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientGetCompactionState.class);
|
||||
|
||||
@Parameter
|
||||
public int numReplicas;
|
||||
|
||||
@Parameters(name = "{index}: regionReplication={0}")
|
||||
public static List<Object[]> params() {
|
||||
return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumReplicas() {
|
||||
return numReplicas;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestRestoreSnapshotFromClientSchemaChange
|
||||
extends RestoreSnapshotFromClientSchemaChangeTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientSchemaChange.class);
|
||||
|
||||
@Parameter
|
||||
public int numReplicas;
|
||||
|
||||
@Parameters(name = "{index}: regionReplication={0}")
|
||||
public static List<Object[]> params() {
|
||||
return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumReplicas() {
|
||||
return numReplicas;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* 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.hadoop.hbase.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestRestoreSnapshotFromClientSimple extends RestoreSnapshotFromClientSimpleTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientSimple.class);
|
||||
|
||||
@Parameter
|
||||
public int numReplicas;
|
||||
|
||||
@Parameters(name = "{index}: regionReplication={0}")
|
||||
public static List<Object[]> params() {
|
||||
return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNumReplicas() {
|
||||
return numReplicas;
|
||||
}
|
||||
}
|
|
@ -28,14 +28,13 @@ import org.junit.ClassRule;
|
|||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
|
||||
@Category({LargeTests.class, ClientTests.class})
|
||||
public class TestRestoreSnapshotFromClientWithRegionReplicas extends
|
||||
TestRestoreSnapshotFromClient {
|
||||
@Category({ LargeTests.class, ClientTests.class })
|
||||
public class TestRestoreSnapshotFromClientWithRegionReplicas
|
||||
extends RestoreSnapshotFromClientTestBase {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientWithRegionReplicas.class);
|
||||
HBaseClassTestRule.forClass(TestRestoreSnapshotFromClientWithRegionReplicas.class);
|
||||
|
||||
@Override
|
||||
protected int getNumReplicas() {
|
||||
|
@ -54,8 +53,8 @@ public class TestRestoreSnapshotFromClientWithRegionReplicas extends
|
|||
admin.snapshot(snapshotName1, tableName);
|
||||
|
||||
// Clone the snapshot to another table
|
||||
TableName clonedTableName = TableName.valueOf(name.getMethodName() + "-" +
|
||||
System.currentTimeMillis());
|
||||
TableName clonedTableName =
|
||||
TableName.valueOf(name.getMethodName() + "-" + System.currentTimeMillis());
|
||||
admin.cloneSnapshot(snapshotName1, clonedTableName);
|
||||
|
||||
verifyRowCount(TEST_UTIL, clonedTableName, snapshot1Rows);
|
||||
|
|
Loading…
Reference in New Issue