1 24 25 package org.objectweb.cjdbc.scenario.horizontal; 26 27 import java.sql.Connection ; 28 import java.util.ArrayList ; 29 import java.util.HashMap ; 30 import java.util.Map ; 31 32 import org.objectweb.cjdbc.common.util.Constants; 33 import org.objectweb.cjdbc.scenario.templates.HorizontalWithRecoveryTemplate; 34 import org.objectweb.cjdbc.scenario.tools.ScenarioUtility; 35 import org.objectweb.cjdbc.scenario.tools.testlet.UpdateTestLet; 36 37 45 public class TransferBackendAfterFailureScenario 46 extends HorizontalWithRecoveryTemplate 47 { 48 private static final String DUMP_NAME = "dump1"; 49 private static final String BACKUP_LOGIN = "user"; 50 private static final String BACKUP_PASSWORD = ""; 51 private static final String BACKUPER = "Octopus"; 52 private static final String BACKUP_PATH = "../backup"; 53 54 59 public void testDataIntegrity() throws Exception 60 { 61 Connection con = getCJDBCConnection("25323"); 63 ScenarioUtility.displaySingleQueryResult("select * from PRODUCT", con); 64 65 mainVdb1.backupBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD, 67 DUMP_NAME, BACKUPER, BACKUP_PATH, null); 68 69 controller2.shutdown(Constants.SHUTDOWN_WAIT); 71 72 for (int i = 0; i < 10; i++) 75 { 76 Thread.sleep(100); 77 con.createStatement().execute("update PRODUCT set name='loose'"); 78 } 79 80 Map map1 = new HashMap (); 82 map1.put("url", "jdbc:hsqldb:hsql://localhost:9003"); 83 mainVdb1.replicateBackend("localhost", "localhost3", map1); 84 Map map2 = new HashMap (); 85 map2.put("url", "jdbc:hsqldb:hsql://localhost:9004"); 86 mainVdb1.replicateBackend("localhost", "localhost4", map2); 87 88 mainVdb1.restoreDumpOnBackend("localhost3", BACKUP_LOGIN, BACKUP_PASSWORD, 90 DUMP_NAME, null); 91 mainVdb1.restoreDumpOnBackend("localhost4", BACKUP_LOGIN, BACKUP_PASSWORD, 92 DUMP_NAME, null); 93 94 mainVdb1.enableBackendFromCheckpoint("localhost3"); 96 mainVdb1.enableBackendFromCheckpoint("localhost4"); 97 98 UpdateTestLet let = new UpdateTestLet(con); 100 let.execute(); 101 102 Connection con1 = getHypersonicConnection(9001); 104 Connection con2 = getHypersonicConnection(9002); 105 Connection con3 = getHypersonicConnection(9003); 106 Connection con4 = getHypersonicConnection(9004); 107 ArrayList list1 = ScenarioUtility.getSingleQueryResult( 108 "select * from PRODUCT", con1); 109 ArrayList list2 = ScenarioUtility.getSingleQueryResult( 110 "select * from PRODUCT", con2); 111 ArrayList list3 = ScenarioUtility.getSingleQueryResult( 112 "select * from PRODUCT", con3); 113 ArrayList list4 = ScenarioUtility.getSingleQueryResult( 114 "select * from PRODUCT", con4); 115 116 assertEquals(list1, list2); 118 assertEquals(list1, list3); 119 assertEquals(list1, list4); 120 } 121 } | Popular Tags |