@Override public void generateErrorSample(String label, String errorMsg) { AWSMonSampleResult res = new AWSMonSampleResult(); res.setSampleLabel(label); res.setValue(-1L); res.setResponseMessage(errorMsg); res.setSuccessful(false); SampleEvent e = new SampleEvent(res, AWSMON); super.sampleOccurred(e); log.error("AWSmon plugin error: " + errorMsg); }
@Override public void testEnded(String host) { workerThread.interrupt(); shutdownConnectors(); // reset autoFileName for next test run autoFileBaseName = null; counter = 0; super.testEnded(host); }
// need floating point precision for memory and cpu @Override public void generateSample(double value, String label) { if (value != AWSConnector.AGENT_ERROR) { AWSMonSampleResult res = new AWSMonSampleResult(); res.setSampleLabel(label); res.setValue(value); res.setSuccessful(true); SampleEvent e = new SampleEvent(res, AWSMON); super.sampleOccurred(e); } }
@Override public void testStarted(String host) { // if we run in non gui mode, ensure the data will be saved if (GuiPackage.getInstance() == null) { if (getProperty(FILENAME) == null || getProperty(FILENAME).getStringValue().trim().length() == 0) { if (autoGenerateFiles) { setupSaving(); } else { log.warn( "AWSMon metrics will not be recorded! Please run the test with -JforcePerfmonFile=true"); } } else { log.info("AWSMon metrics will be stored in " + getProperty(FILENAME)); } } initiateConnectors(); workerThread = new Thread(this); workerThread.start(); super.testStarted(host); }
public boolean runTestPlan(String testPlanFilename) { jmeterResults = ""; createJmeterEngine(); File f = new File(testPlanFilename); if (!f.exists() || !f.isFile()) { jmeterResults += "Could not open " + testPlanFilename; System.out.println(jmeterResults); return false; } FileInputStream reader = null; try { reader = new FileInputStream(new File(testPlanFilename)); currentHashTree = SaveService.loadTree(reader); // store log file in ./FitNesseRoot/files/testResults/testPlanFilename.log String logFile = new File(jmeterLogPath, (new File(testPlanFilename).getName() + ".log")) .getCanonicalPath(); lastJmeterLog = logFile; @SuppressWarnings("deprecation") // Deliberate use of deprecated ctor JMeterTreeModel treeModel = new JMeterTreeModel(new Object()); // Create non-GUI version to avoid headless problems JMeterTreeNode root = (JMeterTreeNode) treeModel.getRoot(); treeModel.addSubTree(currentHashTree, root); // Hack to resolve ModuleControllers in non GUI mode SearchByClass<ReplaceableController> replaceableControllers = new SearchByClass<ReplaceableController>(ReplaceableController.class); currentHashTree.traverse(replaceableControllers); Collection<ReplaceableController> replaceableControllersRes = replaceableControllers.getSearchResults(); for (Iterator<ReplaceableController> iter = replaceableControllersRes.iterator(); iter.hasNext(); ) { ReplaceableController replaceableController = iter.next(); replaceableController.resolveReplacementSubTree(root); } // Remove the disabled items // For GUI runs this is done in Start.java JMeter.convertSubTree(currentHashTree); Summariser summer = null; String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary"); // $NON-NLS-1$ if (summariserName.length() > 0) { // log.info("Creating summariser <" + summariserName + ">"); // println("Creating summariser <" + summariserName + ">"); summer = new Summariser(summariserName); } if (logFile != null) { ResultCollector logger = new ResultCollector(summer); logger.setFilename(logFile); currentHashTree.add(currentHashTree.getArray()[0], logger); } else { // only add Summariser if it can not be shared with the ResultCollector if (summer != null) { currentHashTree.add(currentHashTree.getArray()[0], summer); } } // Used for remote notification of threads start/stop,see BUG 54152 // Summariser uses this feature to compute correctly number of threads // when NON GUI mode is used currentHashTree.add(currentHashTree.getArray()[0], new RemoteThreadsListenerTestElement()); jEngine.configure(currentHashTree); jEngine.runTest(); // reader.close(); JOrphanUtils.closeQuietly(reader); Util.waitForFileToExists(logFile, 5); // wait up to 5 seconds for file to exist String logStr = Util.fileToString(logFile); // logStr = logStr.replaceAll("\n", "<br/>\n"); jmeterResults += logStr; jmeterResults += "Test " + testPlanFilename + " completed."; System.out.println("Test " + testPlanFilename + " completed."); } catch (Exception e) { e.printStackTrace(); jmeterResults += "\r\nException: " + e.getMessage(); return false; } return true; }