Changeset 4108
- Timestamp:
- 2010-06-29 13:08:25 (3 years ago)
- Location:
- projects/lily/trunk
- Files:
-
- 4 edited
-
README.txt (modified) (4 diffs)
-
pom.xml (modified) (1 diff)
-
testfw/src/main/java/org/lilycms/testfw/HBaseProxy.java (modified) (4 diffs)
-
testfw/src/main/java/org/lilycms/testfw/HBaseRunner.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
projects/lily/trunk/README.txt
r4107 r4108 52 52 =============== 53 53 54 Log output of testcases is by default sent to a target/log.txt, errors are however always logged to the 55 console. Debug output to the console of selected log categories can be enabled by running tests as follows: 54 Log output of testcases is by default sent to a target/log.txt, errors 55 are however always logged to the console. Debug output to the console of 56 selected log categories can be enabled by running tests as follows: 56 57 57 58 mvn -Plog test … … 59 60 This is mostly useful when working on individual subprojects/tests. 60 61 61 Running tests faster62 -------------------- 62 Running tests (faster) against an existing HBase 63 ------------------------------------------------ 63 64 64 Test run rather slow because HBase-based tests launch a mini Hadoop/ZooKeeper/HBase-cluster as part of the 65 testcase. While this takes some time in itself, it is especially the creation of tables in HBase which 65 Test run rather slow because HBase-based tests launch a mini 66 Hadoop/ZooKeeper/HBase-cluster as part of the testcase. While this takes 67 some time in itself, it is especially the creation of tables in HBase which 66 68 takes time. 67 69 68 The tests can be sped up by starting an independent cluster and running the tests against that. Instead of 69 dropping and recreating tables between each test, the tables are emptied by deleting all rows from them (thus 70 be very careful against which HBase you run this!). 70 The tests can be sped up by starting an independent cluster and running the 71 tests against that. Instead of dropping and recreating tables between each 72 test, the tables are emptied by deleting all rows from them (thus be very 73 careful against which HBase you run this!). Besides the speed advantages, 74 this is also easier for debugging. 71 75 72 The easy way to do this is: 76 77 === Quick way: dummy HBase === 78 79 80 To easily launch a mini HBase without having to install it, execute: 73 81 74 82 cd testfw … … 76 84 77 85 This prints a line "Minicluster is up" when it is started, though it is 78 quickly followed by more logging so you might not easily notice it.86 quickly followed by more logging. 79 87 80 88 And then run the tests with … … 82 90 mvn -Pconnect test 83 91 84 The first time this will still take more time (though already quite a bit less than before), since the 85 tables still need to be created. Subsequent runs should be way faster. 92 The first time this will still take more time (though already quite a bit 93 less than before), since the tables still need to be created. Subsequent 94 runs should be way faster. 86 95 87 Note that profiles can be combined, for example: 96 Each time this 'mini' HBase is restarted, it looses its state so the first run 97 after restart will again be a bit slower. 98 99 When you run testcases without -Pconnect, and you have a mini HBase launched, 100 it might get confused (because some of the same ports are used), and you 101 might need to restart it. 102 103 104 === Run against existing cluster === 105 106 107 If you want to connect to an HBase you have installed, you need to specify 108 the name(s) and port of Zookeeper: 109 110 mvn -Pconnect -DargLine="-Dlily.test.hbase.zookeeper.quorum=localhost -Dlily.test.hbase.zookeeper.property.clientPort=2181" test 111 112 More in general, any HBase property can be specified by prefixing it with 113 "lily.test." (also when the tests run with an embedded HBase). 114 115 Combining profiles 116 ================== 117 118 Maven profiles can be combined, for example: 88 119 89 120 mvn -Pconnect -Plog test -
projects/lily/trunk/pom.xml
r4107 r4108 315 315 <version>2.5</version> 316 316 <configuration> 317 <argLine>-Xmx256m </argLine>317 <argLine>-Xmx256m ${argLine}</argLine> 318 318 <systemPropertyVariables> 319 319 <lily.test.hbase>${lily.test.hbase}</lily.test.hbase> -
projects/lily/trunk/testfw/src/main/java/org/lilycms/testfw/HBaseProxy.java
r4102 r4108 61 61 System.out.println("HBase usage mode: " + MODE); 62 62 63 CONF = HBaseConfiguration.create(); 64 63 65 switch (MODE) { 64 66 case EMBED: 65 // TODO use optimized hbase config 66 TEST_UTIL = new HBaseTestingUtility(); 67 addHBaseTestProps(CONF); 68 addUserProps(CONF); 69 TEST_UTIL = new HBaseTestingUtility(CONF); 67 70 TEST_UTIL.startMiniCluster(1); 68 71 CONF = TEST_UTIL.getConfiguration(); 69 72 break; 70 73 case CONNECT: 71 CONF = HBaseConfiguration.create();72 74 CONF.set("hbase.zookeeper.quorum", "localhost"); 73 75 CONF.set("hbase.zookeeper.property.clientPort", "21812"); // matches HBaseRunner 76 addUserProps(CONF); 74 77 cleanTables(); 75 78 break; … … 77 80 throw new RuntimeException("Unexpected mode: " + MODE); 78 81 } 82 } 83 84 /** 85 * Adds all system property prefixed with "lily.test.hbase." to the HBase configuration. 86 */ 87 private void addUserProps(Configuration conf) { 88 Properties sysProps = System.getProperties(); 89 for (Map.Entry<Object, Object> entry : sysProps.entrySet()) { 90 String name = entry.getKey().toString(); 91 if (name.startsWith("lily.test.hbase.")) { 92 String hbasePropName = name.substring("lily.test.".length()); 93 conf.set(hbasePropName, entry.getValue().toString()); 94 } 95 } 96 } 97 98 protected static void addHBaseTestProps(Configuration conf) { 99 // The following properties are from HBase's src/test/resources/hbase-site.xml 100 conf.set("hbase.regionserver.msginterval", "1000"); 101 conf.set("hbase.client.pause", "5000"); 102 conf.set("hbase.client.retries.number", "4"); 103 conf.set("hbase.master.meta.thread.rescanfrequency", "10000"); 104 conf.set("hbase.server.thread.wakefrequency", "1000"); 105 conf.set("hbase.regionserver.handler.count", "5"); 106 conf.set("hbase.master.info.port", "-1"); 107 conf.set("hbase.regionserver.info.port", "-1"); 108 conf.set("hbase.regionserver.info.port.auto", "true"); 109 conf.set("hbase.master.lease.thread.wakefrequency", "3000"); 110 conf.set("hbase.regionserver.optionalcacheflushinterval", "1000"); 111 conf.set("hbase.regionserver.safemode", "false"); 79 112 } 80 113 … … 181 214 HTable htable = new HTable(CONF, tableName); 182 215 216 byte[] tmpRowKey = Bytes.toBytes("HBaseProxyDummyRow"); 217 byte[] CF = EXPLOIT_TIMESTAMP_TABLES.get(tableName); 218 byte[] COL = Bytes.toBytes("DummyColumn"); 219 183 220 byte[] value = null; 184 221 while (value == null) { 185 byte[] tmpRowKey = Bytes.toBytes("HBaseProxyDummyRow");186 byte[] CF = EXPLOIT_TIMESTAMP_TABLES.get(tableName);187 byte[] COL = Bytes.toBytes("DummyColumn");188 222 Put put = new Put(tmpRowKey); 189 223 put.add(CF, COL, 1, new byte[] { 0 }); … … 199 233 Thread.sleep(100); 200 234 } 235 236 // Delete our dummy row again 237 htable.delete(new Delete(tmpRowKey)); 201 238 } 202 239 } -
projects/lily/trunk/testfw/src/main/java/org/lilycms/testfw/HBaseRunner.java
r4090 r4108 39 39 conf = HBaseConfiguration.create(); 40 40 41 // The following properties are from HBase's src/test/resources/hbase-site.xml 42 conf.set("hbase.regionserver.msginterval", "1000"); 43 conf.set("hbase.client.pause", "5000"); 44 conf.set("hbase.client.retries.number", "4"); 45 conf.set("hbase.master.meta.thread.rescanfrequency", "10000"); 46 conf.set("hbase.server.thread.wakefrequency", "1000"); 47 conf.set("hbase.regionserver.handler.count", "5"); 48 conf.set("hbase.master.info.port", "-1"); 49 conf.set("hbase.regionserver.info.port", "-1"); 50 conf.set("hbase.regionserver.info.port.auto", "true"); 51 conf.set("hbase.master.lease.thread.wakefrequency", "3000"); 52 conf.set("hbase.regionserver.optionalcacheflushinterval", "1000"); 53 conf.set("hbase.regionserver.safemode", "false"); 41 HBaseProxy.addHBaseTestProps(conf); 54 42 55 43 startMiniCluster(1);
Note: See TracChangeset
for help on using the changeset viewer.