|
@@ -31,6 +31,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.server.records.Version;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
|
|
|
+import org.fusesource.leveldbjni.JniDBFactory;
|
|
|
import org.iq80.leveldb.DB;
|
|
|
import org.junit.After;
|
|
|
import org.junit.Before;
|
|
@@ -125,17 +126,27 @@ public class TestLeveldbRMStateStore extends RMStateStoreTestBase {
|
|
|
public void testCompactionCycle() throws Exception {
|
|
|
final DB mockdb = mock(DB.class);
|
|
|
conf.setLong(YarnConfiguration.RM_LEVELDB_COMPACTION_INTERVAL_SECS, 1);
|
|
|
- LeveldbRMStateStore store = new LeveldbRMStateStore() {
|
|
|
+ stateStore = new LeveldbRMStateStore() {
|
|
|
@Override
|
|
|
protected DB openDatabase() throws Exception {
|
|
|
return mockdb;
|
|
|
}
|
|
|
};
|
|
|
- store.init(conf);
|
|
|
- store.start();
|
|
|
+ stateStore.init(conf);
|
|
|
+ stateStore.start();
|
|
|
verify(mockdb, timeout(10000)).compactRange(
|
|
|
(byte[]) isNull(), (byte[]) isNull());
|
|
|
- store.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testBadKeyIteration() throws Exception {
|
|
|
+ stateStore = new LeveldbRMStateStore();
|
|
|
+ stateStore.init(conf);
|
|
|
+ stateStore.start();
|
|
|
+ DB db = stateStore.getDatabase();
|
|
|
+ // add an entry that appears at the end of the database when iterating
|
|
|
+ db.put(JniDBFactory.bytes("zzz"), JniDBFactory.bytes("z"));
|
|
|
+ stateStore.loadState();
|
|
|
}
|
|
|
|
|
|
class LeveldbStateStoreTester implements RMStateStoreHelper {
|