1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase;
19
20 import com.google.common.collect.Sets;
21 import org.apache.hadoop.conf.Configuration;
22 import org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy;
23 import org.apache.hadoop.hbase.testclassification.IntegrationTests;
24 import org.apache.hadoop.hbase.util.Bytes;
25 import org.apache.hadoop.util.ToolRunner;
26 import org.junit.Test;
27 import org.junit.experimental.categories.Category;
28
29 import java.util.Set;
30
31
32
33
34
35
36
37
38
39
40
41
42
43 @Category(IntegrationTests.class)
44 public class IntegrationTestAcidGuarantees extends IntegrationTestBase {
45 private static final int SERVER_COUNT = 1;
46
47
48 TestAcidGuarantees tag;
49
50 @Override
51 public int runTestFromCommandLine() throws Exception {
52 Configuration c = getConf();
53 int millis = c.getInt("millis", 5000);
54 int numWriters = c.getInt("numWriters", 50);
55 int numGetters = c.getInt("numGetters", 2);
56 int numScanners = c.getInt("numScanners", 2);
57 int numUniqueRows = c.getInt("numUniqueRows", 3);
58 tag.runTestAtomicity(millis, numWriters, numGetters, numScanners, numUniqueRows, true);
59 return 0;
60 }
61
62 @Override
63 public void setUpCluster() throws Exception {
64
65 util = getTestingUtil(getConf());
66 util.initializeCluster(SERVER_COUNT);
67 conf = getConf();
68 conf.set(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, String.valueOf(128*1024));
69
70 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
71 ConstantSizeRegionSplitPolicy.class.getName());
72 this.setConf(util.getConfiguration());
73
74
75
76 tag = new TestAcidGuarantees();
77 tag.setHBaseTestingUtil(util);
78 }
79
80 @Override
81 public TableName getTablename() {
82 return TestAcidGuarantees.TABLE_NAME;
83 }
84
85 @Override
86 protected Set<String> getColumnFamilies() {
87 return Sets.newHashSet(Bytes.toString(TestAcidGuarantees.FAMILY_A),
88 Bytes.toString(TestAcidGuarantees.FAMILY_B),
89 Bytes.toString(TestAcidGuarantees.FAMILY_C));
90 }
91
92
93
94 @Test
95 public void testGetAtomicity() throws Exception {
96 tag.runTestAtomicity(20000, 4, 4, 0, 3);
97 }
98
99 @Test
100 public void testScanAtomicity() throws Exception {
101 tag.runTestAtomicity(20000, 3, 0, 2, 3);
102 }
103
104 @Test
105 public void testMixedAtomicity() throws Exception {
106 tag.runTestAtomicity(20000, 4, 2, 2, 3);
107 }
108
109
110
111
112 public static void main(String[] args) throws Exception {
113 Configuration conf = HBaseConfiguration.create();
114 IntegrationTestingUtility.setUseDistributedCluster(conf);
115 int ret = ToolRunner.run(conf, new IntegrationTestAcidGuarantees(), args);
116 System.exit(ret);
117 }
118 }