static void do_test()
{
Console.WriteLine("ReplTest1 startup...");
LayerManager raw_db = new LayerManager(InitMode.NEW_REGION, @"C:\BENDtst\repl");
StepsDatabase db_factory = new StepsDatabase(raw_db);
Console.WriteLine("----------------[ init two servers together, write some records ]-----------------");
ReplHandler repl_1 = db_factory.getReplicatedDatabase_Fresh("guid1");
waitUntilActive(raw_db, repl_1);
repl_1.setValueParsed("a/1", "1");
ReplHandler repl_2 = db_factory.getReplicatedDatabase_Join("guid2", repl_1.getServerGuid());
waitUntilActive(raw_db, repl_2);
repl_2.setValueParsed("a/2", "5");
Console.WriteLine("-----------------");
raw_db.debugDump();
repl_2.setValueParsed("a/2", "6");
Thread.Sleep(7000);
raw_db.debugDump();
Console.WriteLine("-----------------[ remove one server, write some records ]----------------");
repl_2.Shutdown();
// wait until repl2 is really shutdown
waitUntilState(raw_db, repl_2, ReplState.shutdown);
// make sure our log does not continue from repl_2 logs
repl_1.setValueParsed("c/1", "10");
repl_1.truncateLogs_Hack();
raw_db.debugDump();
Console.WriteLine("----------------[ reinit server 2 ]-----------------------------");
repl_2 = db_factory.getReplicatedDatabase_Resume("guid2");
waitUntilActive(raw_db, repl_2);
Thread.Sleep(7000);
raw_db.debugDump();
Thread.Sleep(7000);
// Environment.Exit(1); // exit
repl_2.setValueParsed("d/1", "20");
repl_1.setValueParsed("c/1", "10");
Thread.Sleep(1000);
repl_2.truncateLogs_Hack();
Thread.Sleep(1000);
repl_1.truncateLogs_Hack();
Console.WriteLine("----------------[ both logs should be truncated ]-----------------------------");
raw_db.debugDump();
Console.WriteLine("----------------[ create server 3 ]-----------------------------");
ReplHandler repl_3 = db_factory.getReplicatedDatabase_Join("guid3", "guid2");
Thread.Sleep(7000);
raw_db.debugDump();
repl_3.setValueParsed("q/1", "10");
Thread.Sleep(7000);
raw_db.debugDump();
Console.WriteLine("quitting..");
Environment.Exit(0);
}