public void testOverwriteFaults() { FaultManager fm = null; try { fm = FaultManager.create(conf); fm.inject(this.getClass(), "testInjectAndGetFault", TestFault.class); fm.inject(this.getClass(), "testInjectAndGetFault", TestFault2.class); Fault fault = fm.getFault(this.getClass(), "testInjectAndGetFault"); assertEquals(TestFault2.class, fault.getClass()); fm.clear(this.getClass(), "testInjectAndGetFault"); assertNull(fm.getFault(this.getClass(), "testInjectAndGetFault")); } catch (InterruptedException e) { assertTrue(false); } catch (IOException e) { e.printStackTrace(); assertTrue(false); } finally { if (fm != null) { fm.close(); } } }
public void testFaultManagerInstance() { try { FaultManager fm = FaultManager.create(conf); assertNotNull(fm.zk); FaultManager fm2 = FaultManager.create(conf); assertTrue(fm != fm2); fm.close(); assertNull(fm.zk); try { fm.inject(this.getClass(), "dummyMethod", null); assertTrue(false); } catch (IOException e) { } catch (InterruptedException e) { assertTrue(false); } fm2.close(); } catch (IOException e) { e.printStackTrace(); assertTrue(false); } }
public void testClearAllFaults() { FaultManager fm1 = null; FaultManager fm2 = null; try { fm1 = FaultManager.create(conf); fm1.inject(this.getClass(), "testShareWithOtherFaultManager", TestFault.class); fm2 = FaultManager.create(conf); fm2.clearAllFaults(); Thread.sleep(1000); assertNull(fm1.getFault(this.getClass(), "testShareWithOtherFaultManager")); } catch (InterruptedException e) { assertTrue(false); } catch (IOException e) { e.printStackTrace(); assertTrue(false); } }
public void testInjectClearAndGetFaultInDifferentFM() { FaultManager fm1 = null; FaultManager fm2 = null; try { fm1 = FaultManager.create(conf); fm1.inject(this.getClass(), "testInjectAndGetFault", TestFault.class); Fault fault = fm1.getFault(this.getClass(), "testInjectAndGetFault"); assertNotNull(fault); assertEquals(TestFault.class, fault.getClass()); fm2 = FaultManager.create(conf); Fault fault2 = fm2.getFault(this.getClass(), "testInjectAndGetFault"); assertNotNull(fault2); fm2.clear(this.getClass(), "testInjectAndGetFault"); Thread.sleep(1000); assertNull(fm1.getFault(this.getClass(), "testInjectAndGetFault")); assertNull(fm2.getFault(this.getClass(), "testInjectAndGetFault")); } catch (InterruptedException e) { assertTrue(false); } catch (IOException e) { e.printStackTrace(); assertTrue(false); } finally { if (fm1 != null) { fm1.close(); } if (fm2 != null) { fm2.close(); } } }
public void testShareWithOtherFaultManager() { FaultManager fm1 = null; FaultManager fm2 = null; try { fm1 = FaultManager.create(conf); fm1.inject(this.getClass(), "testShareWithOtherFaultManager", TestFault.class); // sleep을 할 필요가 없다. 왜냐하면, FaultManager가 create되면서 // Pleiades의 모든 fault 정보를 Load하기 때문이다. fm2 = FaultManager.create(conf); Fault fault = fm2.getFault(this.getClass(), "testShareWithOtherFaultManager"); assertNotNull(fault); assertEquals(TestFault.class, fault.getClass()); assertNull(fm1.getFault(TestFault.class, "methodHaha")); fm2.inject(TestFault.class, "methodHaha", TestFault2.class); Thread.sleep(1000); fault = fm1.getFault(TestFault.class, "methodHaha"); assertNotNull(fault); assertEquals(TestFault2.class, fault.getClass()); } catch (InterruptedException e) { assertTrue(false); } catch (IOException e) { e.printStackTrace(); assertTrue(false); } finally { if (fm1 != null) { fm1.close(); } if (fm2 != null) { fm2.close(); } } }