@After public void tearDown() throws Exception { MockStatsSource.delay = 0; StatsAgent.OPS_COLLECTION_TIMEOUT = 60 * 1000; m_mvoltdb.shutdown(null); VoltDB.replaceVoltDBInstanceForTest(null); }
@Test public void testLoader() { VoltDB.Configuration configuration = new VoltDB.Configuration(); configuration.m_noLoadLibVOLTDB = true; MockVoltDB mockvolt = new MockVoltDB(); VoltDB.ignoreCrash = true; VoltDB.replaceVoltDBInstanceForTest(mockvolt); mockvolt.m_noLoadLib = true; assertFalse(EELibraryLoader.loadExecutionEngineLibrary(false)); assertFalse(VoltDB.wasCrashCalled); boolean threw = false; try { assertFalse(EELibraryLoader.loadExecutionEngineLibrary(true)); } catch (AssertionError ae) { threw = true; } assertTrue(threw); assertTrue(VoltDB.wasCrashCalled); VoltDB.wasCrashCalled = false; VoltDB.initialize(configuration); assertFalse(EELibraryLoader.loadExecutionEngineLibrary(true)); assertFalse(VoltDB.wasCrashCalled); // Now test SUCCESS case configuration = new VoltDB.Configuration(); VoltDBInterface mockitovolt = mock(VoltDBInterface.class); VoltDBInterface realvolt = new RealVoltDB(); when(mockitovolt.getEELibraryVersionString()).thenReturn(realvolt.getEELibraryVersionString()); CatalogContext catContext = mock(CatalogContext.class); Cluster cluster = mock(Cluster.class); when(cluster.getVoltroot()).thenReturn(System.getProperty("java.io.tmpdir")); when(catContext.getCluster()).thenReturn(cluster); when(mockitovolt.getCatalogContext()).thenReturn(catContext); VoltDB.replaceVoltDBInstanceForTest(mockitovolt); VoltDB.initialize(configuration); assertTrue(EELibraryLoader.loadExecutionEngineLibrary(true)); }
@Before public void setUp() throws Exception { // Set up CI with the mock objects. m_volt = mock(VoltDBInterface.class); m_statsAgent = mock(StatsAgent.class); m_sysinfoAgent = mock(SystemInformationAgent.class); m_messenger = mock(HostMessenger.class); m_handler = mock(ClientInputHandler.class); m_cartographer = mock(Cartographer.class); m_zk = mock(ZooKeeper.class); m_cxn = mock(Connection.class); /* * Setup the mock objects so that they return expected objects in CI * construction */ VoltDB.replaceVoltDBInstanceForTest(m_volt); doReturn(m_statsAgent).when(m_volt).getStatsAgent(); doReturn(m_statsAgent).when(m_volt).getOpsAgent(OpsSelector.STATISTICS); doReturn(m_sysinfoAgent).when(m_volt).getOpsAgent(OpsSelector.SYSTEMINFORMATION); doReturn(mock(SnapshotCompletionMonitor.class)).when(m_volt).getSnapshotCompletionMonitor(); doReturn(m_messenger).when(m_volt).getHostMessenger(); doReturn(mock(VoltNetworkPool.class)).when(m_messenger).getNetwork(); doReturn(m_zk).when(m_messenger).getZK(); doReturn(mock(Configuration.class)).when(m_volt).getConfig(); doReturn(32L).when(m_messenger).getHSIdForLocalSite(HostMessenger.ASYNC_COMPILER_SITE_ID); doAnswer( new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { return null; } }) .when(m_cxn) .queueTask(any(Runnable.class)); m_ci = spy( new ClientInterface( null, VoltDB.DEFAULT_PORT, VoltDB.DEFAULT_ADMIN_PORT, m_context, m_messenger, ReplicationRole.NONE, m_cartographer, m_allPartitions)); m_ci.bindAdapter(m_cxn); // m_mb = m_ci.m_mailbox; }
@Test public void testLoader() { final VoltDB.Configuration configuration = new VoltDB.Configuration(); configuration.m_noLoadLibVOLTDB = true; MockVoltDB mockvolt = new MockVoltDB(); VoltDB.replaceVoltDBInstanceForTest(mockvolt); assert (EELibraryLoader.loadExecutionEngineLibrary(false)); // assertEquals(0, mockvolt.getCrashCount()); assert (EELibraryLoader.loadExecutionEngineLibrary(true)); // assertEquals(1, mockvolt.getCrashCount()); // VoltDB.initialize(configuration); // assertFalse(EELibraryLoader.loadExecutionEngineLibrary(true)); // assertEquals(1, mockvolt.getCrashCount()); }
@Before public void setUp() throws Exception { m_mvoltdb = new MockVoltDB(); VoltDB.replaceVoltDBInstanceForTest(m_mvoltdb); }