org.apache.jmeter.testelement.TestPlan Java Examples
The following examples show how to use
org.apache.jmeter.testelement.TestPlan.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JmxTestPlan.java From postman2jmx with MIT License | 5 votes |
public static TestPlan newInstance(String name) { TestPlan testPlan = new TestPlan(); testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName()); testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName()); testPlan.setName(name); testPlan.setEnabled(true); testPlan.setFunctionalMode(false); testPlan.setComment(""); testPlan.setSerialized(false); testPlan.setTestPlanClasspath(""); testPlan.setUserDefinedVariables(new Arguments()); return testPlan; }
Example #2
Source File: JmeterTestPlanTask.java From ambari-metrics with Apache License 2.0 | 5 votes |
public JmeterTestPlanTask(List<AppGetMetric> appGetMetrics, Properties amsJmeterProperties) { this.appGetMetrics = appGetMetrics; this.amsJmeterProperties = amsJmeterProperties; amsTestPlanTree = new HashTree(); amsTestPlan = new TestPlan("AMS JMeter Load Test plan"); System.out.println("Starting AMS Jmeter load testing"); }
Example #3
Source File: JmeterTestPlanTask.java From ambari-metrics with Apache License 2.0 | 5 votes |
private void createThreadGroupHashTree(int appIndex, Properties amsJmeterProperties, HashTree amsTestPlanTree, TestPlan amsTestPlan) { AppGetMetric appGetMetric = appGetMetrics.get(appIndex); String app = appGetMetric.getApp(); int interval = appGetMetric.getInterval(); //Read and validate AMS information. String[] amsHostPort = amsJmeterProperties.getProperty("ams-host-port").split(":"); String amsHost = amsHostPort[0]; String amsPath = amsJmeterProperties.getProperty("ams-path"); int amsPort = Integer.valueOf(amsHostPort[1]); int numLoops = Integer.valueOf(amsJmeterProperties.getProperty("num-get-calls-per-app")); LoopController loopController = createLoopController(app + " GET loop controller", numLoops, false); for (GetMetricRequestInfo request : appGetMetric.getMetricRequests()) { ThreadGroup threadGroup = createThreadGroup(app + " GET threadGroup", 1, 0, loopController); HashTree threadGroupHashTree = amsTestPlanTree.add(amsTestPlan, threadGroup); Map<String, String> parametersMap = getAppSpecificParameters(app, request, amsJmeterProperties); HTTPSampler sampler = createGetSampler("GET " + app + " metrics", amsHost, amsPort, amsPath, null, parametersMap); if (numLoops > 1) { threadGroupHashTree.add(createConstantTimer(interval)); } threadGroupHashTree.add(sampler); } }
Example #4
Source File: DebuggerDialogBase.java From jmeter-debugger with Apache License 2.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { int selRow = tree.getRowForLocation(e.getX(), e.getY()); if (tree.getPathForLocation(e.getX(), e.getY()) != null) { final TreePath currentPath = tree.getPathForLocation(e.getX(), e.getY()); if (selRow != -1 && currentPath != null) { if (isRightClick(e)) { if (tree.getSelectionCount() < 2) { tree.setSelectionPath(currentPath); } final JMeterTreeNode node = (JMeterTreeNode) currentPath.getLastPathComponent(); TestElement te = (TestElement) node.getUserObject(); if (te instanceof ConfigElement || te instanceof TestPlan || te instanceof ThreadGroup || te instanceof WorkBench) { log.debug("No breakpoint possible for " + te); return; } JPopupMenu popup = getPopup(te); popup.pack(); popup.show(tree, e.getX(), e.getY()); popup.setVisible(true); popup.requestFocusInWindow(); } } } }
Example #5
Source File: TestPlanCheckTool.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void addNode(Object node, HashTree subTree) { if (node instanceof AbstractThreadGroup) { tGroups++; } else if (node instanceof Controller) { controllers++; } else if (node instanceof Sampler) { samplers++; } else if (node instanceof AbstractListenerElement) { listeners++; } else if (node instanceof PreProcessor) { preProc++; } else if (node instanceof PostProcessor) { postProc++; } else if (node instanceof Assertion) { assertions++; } else if (node instanceof Timer) { timers++; } else if (node instanceof ConfigElement) { configs++; } else if (node instanceof TestPlan) { log.debug("Ok, we got the root of test plan"); } else if (node instanceof WorkBench) { log.debug("Ok, we got the root of test plan"); } else { log.warn("Strange object in tree: " + node); others++; } }
Example #6
Source File: ParallelSamplerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Test public void testThreadSafeCookieManager() throws Exception { CookieManager cookieManager = new CookieManager(); Cookie c = new Cookie(); c.setName("name"); c.setValue("value"); c.setDomain("blazedemo.com"); c.setPath(""); cookieManager.add(c); HashTree hashtree = createTestTree(cookieManager); TestPlan testPlan = new TestPlan(); HashTree testPlanHashTree = new HashTree(); testPlanHashTree.put(testPlan, hashtree); StandardJMeterEngine engine = new StandardJMeterEngine(); engine.configure(testPlanHashTree); EmulatorThreadMonitor monitor = new EmulatorThreadMonitor(); JMeterThread thread = new JMeterThread(hashtree, monitor, null); thread.setThreadName("test thread"); JMeterContextService.getContext().setThread(thread); ParallelSampler parallel = new ParallelSampler(); parallel.testStarted(); Field field = StandardJMeterEngine.class.getDeclaredField("test"); field.setAccessible(true); HashTree testTree = (HashTree) field.get(engine); assertTrue("CookieManager should be changed to ThreadSafeCookieManager", testTree.toString().contains("ThreadSafeCookieManager")); ListedHashTree loop = (ListedHashTree) (testTree.values().toArray()[0]); ListedHashTree threadSafeManager = ((ListedHashTree) (loop.values().toArray()[0])); CookieManager mgr = (CookieManager) threadSafeManager.getArray()[0]; assertTrue(mgr instanceof ThreadSafeCookieManager); assertEquals(1, mgr.getCookieCount()); JMeterProperty property = mgr.getCookies().get(0); assertEquals("name", property.getName()); assertEquals("blazedemo.com\tTRUE\t\tFALSE\t0\tname\tvalue", property.getStringValue()); }
Example #7
Source File: WebSocketSamplerTest.java From jmeter-websocket with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { JMeterUtils.setJMeterHome("src/test/resources/"); JMeterUtils.loadJMeterProperties("src/test/resources/jmeter.properties"); JMeterUtils.setProperty("saveservice_properties", "saveservice.properties"); JMeterUtils.setProperty("search_paths", "ApacheJMeter_functions-2.9.jar"); JMeterUtils.setLocale(Locale.JAPAN); JMeterEngine engine = new StandardJMeterEngine(); HashTree config = new ListedHashTree(); TestPlan testPlan = new TestPlan("websocket test"); testPlan.setFunctionalMode(false); testPlan.setSerialized(false); testPlan.setProperty(new BooleanProperty(TestElement.ENABLED, true)); testPlan.setUserDefinedVariables(new Arguments()); ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setNumThreads(300); threadGroup.setRampUp(20); threadGroup.setDelay(0); threadGroup.setDuration(0); threadGroup.setProperty(new StringProperty(ThreadGroup.ON_SAMPLE_ERROR, "continue")); threadGroup.setScheduler(false); threadGroup.setName("Group1"); threadGroup.setProperty(new BooleanProperty(TestElement.ENABLED, true)); LoopController controller = new LoopController(); controller.setLoops(10); controller.setContinueForever(false); controller.setProperty(new BooleanProperty(TestElement.ENABLED, true)); threadGroup.setProperty(new TestElementProperty(ThreadGroup.MAIN_CONTROLLER, controller)); CSVDataSet csvDataSet = new CSVDataSet(); csvDataSet.setProperty(new StringProperty("filename", "src/test/resources/users.csv")); csvDataSet.setProperty(new StringProperty("variableNames", "USER_NAME")); csvDataSet.setProperty(new StringProperty("delimiter", ",")); csvDataSet.setProperty(new StringProperty("shareMode", "shareMode.all")); csvDataSet.setProperty("quoted", false); csvDataSet.setProperty("recycle", true); csvDataSet.setProperty("stopThread", false); WebSocketSampler sampler = new WebSocketSampler(); sampler.setName("WebSocket Test"); sampler.setProperty(new BooleanProperty(TestElement.ENABLED, true)); sampler.addNonEncodedArgument("name", "${USER_NAME}", "="); sampler.setContentEncoding("UTF-8"); sampler.setProtocol("ws"); sampler.setDomain("localhost"); sampler.setPort(9090); sampler.setPath("/", "UTF-8"); sampler.setSendMessage("${__RandomString(50,ABCDEFGHIJKLMNOPQRSTUVWXYZ)}"); sampler.setRecvMessage("\"name\":\"${USER_NAME}\""); OnceOnlyController onceOnlyController = new OnceOnlyController(); Summariser summariser = new Summariser(); HashTree tpConfig = config.add(testPlan); HashTree tgConfig = tpConfig.add(threadGroup); HashTree oocConfig = tgConfig.add(onceOnlyController); oocConfig.add(csvDataSet); UniformRandomTimer randomTimer = new UniformRandomTimer(); randomTimer.setRange(3000); HashTree samplerConfig = tgConfig.add(sampler); samplerConfig.add(summariser); tgConfig.add(randomTimer); engine.configure(config); engine.runTest(); }