HBASE-26567 Remove IndexType from ChunkCreator (#3947)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / client / CloneSnapshotFromClientCloneLinksAfterDeleteTestBase.java
blob1d7e67c6f285c830f52815b94297a131301ee7f5
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.client;
20 import java.io.IOException;
21 import org.apache.hadoop.hbase.TableName;
22 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
23 import org.junit.Test;
25 public class CloneSnapshotFromClientCloneLinksAfterDeleteTestBase
26 extends CloneSnapshotFromClientTestBase {
28 /**
29 * Verify that tables created from the snapshot are still alive after source table deletion.
31 @Test
32 public void testCloneLinksAfterDelete() throws IOException, InterruptedException {
33 // Clone a table from the first snapshot
34 final TableName clonedTableName =
35 TableName.valueOf(getValidMethodName() + "1-" + EnvironmentEdgeManager.currentTime());
36 admin.cloneSnapshot(snapshotName0, clonedTableName);
37 verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
39 // Take a snapshot of this cloned table.
40 admin.disableTable(clonedTableName);
41 admin.snapshot(snapshotName2, clonedTableName);
43 // Clone the snapshot of the cloned table
44 final TableName clonedTableName2 =
45 TableName.valueOf(getValidMethodName() + "2-" + EnvironmentEdgeManager.currentTime());
46 admin.cloneSnapshot(snapshotName2, clonedTableName2);
47 verifyRowCount(TEST_UTIL, clonedTableName2, snapshot0Rows);
48 admin.disableTable(clonedTableName2);
50 // Remove the original table
51 TEST_UTIL.deleteTable(tableName);
52 waitCleanerRun();
54 // Verify the first cloned table
55 admin.enableTable(clonedTableName);
56 verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
58 // Verify the second cloned table
59 admin.enableTable(clonedTableName2);
60 verifyRowCount(TEST_UTIL, clonedTableName2, snapshot0Rows);
61 admin.disableTable(clonedTableName2);
63 // Delete the first cloned table
64 TEST_UTIL.deleteTable(clonedTableName);
65 waitCleanerRun();
67 // Verify the second cloned table
68 admin.enableTable(clonedTableName2);
69 verifyRowCount(TEST_UTIL, clonedTableName2, snapshot0Rows);
71 // Clone a new table from cloned
72 final TableName clonedTableName3 =
73 TableName.valueOf(getValidMethodName() + "3-" + EnvironmentEdgeManager.currentTime());
74 admin.cloneSnapshot(snapshotName2, clonedTableName3);
75 verifyRowCount(TEST_UTIL, clonedTableName3, snapshot0Rows);
77 // Delete the cloned tables
78 TEST_UTIL.deleteTable(clonedTableName2);
79 TEST_UTIL.deleteTable(clonedTableName3);
80 admin.deleteSnapshot(snapshotName2);
83 private void waitCleanerRun() throws InterruptedException {
84 TEST_UTIL.getMiniHBaseCluster().getMaster().getHFileCleaner().choreForTesting();