36
36
import org .apache .hadoop .hbase .util .Bytes ;
37
37
import org .apache .hadoop .hbase .util .CommonFSUtils ;
38
38
import org .junit .After ;
39
- import org .junit .AfterClass ;
40
39
import org .junit .Assert ;
41
- import org .junit .BeforeClass ;
40
+ import org .junit .Before ;
42
41
import org .junit .ClassRule ;
43
42
import org .junit .Test ;
44
43
import org .junit .experimental .categories .Category ;
@@ -64,8 +63,8 @@ public class TestCompactSplitThread {
64
63
/**
65
64
* Setup the config for the cluster
66
65
*/
67
- @ BeforeClass
68
- public static void setupCluster () throws Exception {
66
+ @ Before
67
+ public void setupCluster () throws Exception {
69
68
setupConf (TEST_UTIL .getConfiguration ());
70
69
TEST_UTIL .startMiniCluster (NUM_RS );
71
70
fs = TEST_UTIL .getDFSCluster ().getFileSystem ();
@@ -92,12 +91,7 @@ private static void setupConf(Configuration conf) {
92
91
}
93
92
94
93
@ After
95
- public void tearDown () throws Exception {
96
- TEST_UTIL .deleteTable (tableName );
97
- }
98
-
99
- @ AfterClass
100
- public static void cleanupTest () throws Exception {
94
+ public void cleanupTest () throws Exception {
101
95
try {
102
96
TEST_UTIL .shutdownMiniCluster ();
103
97
} catch (Exception e ) {
@@ -173,4 +167,22 @@ public void testFlushWithTableCompactionDisabled() throws Exception {
173
167
Collection <String > hfiles = SnapshotTestingUtils .listHFileNames (fs , tableDir );
174
168
assert (hfiles .size () > blockingStoreFiles + 1 );
175
169
}
170
+
171
+ @ Test
172
+ public void testFlushWithRegionReplicas () throws Exception {
173
+ TableDescriptor htd =
174
+ TableDescriptorBuilder .newBuilder (tableName ).setRegionReplication (2 ).build ();
175
+ TEST_UTIL .createTable (htd , new byte [][] { family }, null );
176
+
177
+ // load the table
178
+ for (int i = 0 ; i < blockingStoreFiles + 1 ; i ++) {
179
+ TEST_UTIL .loadTable (TEST_UTIL .getConnection ().getTable (tableName ), family );
180
+ TEST_UTIL .flush (tableName );
181
+ }
182
+
183
+ // One region split should have taken place, because the primary replica gets split, and not the
184
+ // secondary replica.
185
+ assertEquals (1 , TEST_UTIL .getRSForFirstRegionInTable (tableName ).getCompactSplitThread ()
186
+ .getSubmittedSplitsCount ());
187
+ }
176
188
}
0 commit comments