public void setUp() throws Exception { super.setUp(); tempDirPath = getTempDir().getAbsolutePath() + File.separator; theDaemon = getMockLockssDaemon(); theDaemon.getAlertManager(); theDaemon.getPluginManager().setLoadablePluginsReady(true); theDaemon.getHashService(); MockSystemMetrics metrics = new MyMockSystemMetrics(); metrics.initService(theDaemon); theDaemon.setSystemMetrics(metrics); theDaemon.setDaemonInited(true); Properties props = new Properties(); props.setProperty(SystemMetrics.PARAM_HASH_TEST_DURATION, "1000"); props.setProperty(SystemMetrics.PARAM_HASH_TEST_BYTE_STEP, "1024"); props.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath); ConfigurationUtil.setCurrentConfigFromProps(props); pluginMgr = theDaemon.getPluginManager(); pluginMgr.startService(); theDaemon.getHashService().startService(); metrics.startService(); metrics.setHashSpeed(100); simPlugin = PluginTestUtil.findPlugin(SimulatedPlugin.class); }
public void tearDown() throws Exception { theDaemon.getLockssRepository(sau1).stopService(); theDaemon.getNodeManager(sau1).stopService(); theDaemon.getPluginManager().stopService(); theDaemon.getHashService().stopService(); theDaemon.getSystemMetrics().stopService(); theDaemon.stopDaemon(); super.tearDown(); }
/** * tearDown method for test case * * @throws Exception if removePoll failed */ public void tearDown() throws Exception { pollmanager.stopService(); theDaemon.getLockssRepository(testau).stopService(); theDaemon.getHashService().stopService(); theDaemon.getDatagramRouterManager().stopService(); theDaemon.getRouterManager().stopService(); theDaemon.getSystemMetrics().stopService(); TimeBase.setReal(); for (int i = 0; i < testV1msg.length; i++) { if (testV1msg[i] != null) pollmanager.removePoll(testV1msg[i].getKey()); } super.tearDown(); }
private void initRequiredServices() { theDaemon = getMockLockssDaemon(); pollmanager = new LocalPollManager(); pollmanager.initService(theDaemon); theDaemon.setPollManager(pollmanager); theDaemon.getPluginManager(); testau = PollTestPlugin.PTArchivalUnit.createFromListOfRootUrls(rootV1urls); PluginTestUtil.registerArchivalUnit(testau); String tempDirPath = null; try { tempDirPath = getTempDir().getAbsolutePath() + File.separator; } catch (IOException ex) { fail("unable to create a temporary directory"); } Properties p = new Properties(); p.setProperty(IdentityManager.PARAM_IDDB_DIR, tempDirPath + "iddb"); p.setProperty(LockssRepositoryImpl.PARAM_CACHE_LOCATION, tempDirPath); p.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath); p.setProperty(IdentityManager.PARAM_LOCAL_IP, "127.0.0.1"); p.setProperty(ConfigManager.PARAM_NEW_SCHEDULER, "false"); // XXX we need to disable verification of votes because the // voter isn't really there p.setProperty(V1Poll.PARAM_AGREE_VERIFY, "0"); p.setProperty(V1Poll.PARAM_DISAGREE_VERIFY, "0"); ConfigurationUtil.setCurrentConfigFromProps(p); idmgr = theDaemon.getIdentityManager(); idmgr.startService(); // theDaemon.getSchedService().startService(); theDaemon.getHashService().startService(); theDaemon.getDatagramRouterManager().startService(); theDaemon.getRouterManager().startService(); theDaemon.getSystemMetrics().startService(); theDaemon.getActivityRegulator(testau).startService(); theDaemon.setNodeManager(new MockNodeManager(), testau); pollmanager.startService(); }
private void measureHashSpeed(SimulatedArchivalUnit sau) throws Exception { MessageDigest dig = null; try { dig = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException ex) { fail("No algorithm."); } CachedUrlSet set = sau.getAuCachedUrlSet(); CachedUrlSetHasher hasher = set.getContentHasher(dig); SystemMetrics metrics = theDaemon.getSystemMetrics(); int estimate = metrics.getBytesPerMsHashEstimate(hasher, dig); // should be protected against this being zero by MyMockSystemMetrics, // but otherwise use the proper calculation. This avoids test failure // due to really slow machines assertTrue(estimate > 0); long estimatedTime = set.estimatedHashDuration(); long size = ((Long) PrivilegedAccessor.getValue(set, "totalNodeSize")).longValue(); assertTrue(size > 0); System.out.println("b/ms: " + estimate); System.out.println("size: " + size); System.out.println("estimate: " + estimatedTime); assertEquals(estimatedTime, theDaemon.getHashService().padHashEstimate(size / estimate)); }