org.apache.jmeter.threads.ListenerNotifier Java Examples
The following examples show how to use
org.apache.jmeter.threads.ListenerNotifier.
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: JMeterThreadParallelTest.java From jmeter-bzm-plugins with Apache License 2.0 | 7 votes |
@Test public void testStopParentThread() { DummyThreadGroup monitor = new DummyThreadGroup(); ListenerNotifier listenerNotifier = new ListenerNotifier(); HashTree tree = new HashTree(); LoopControllerExt loopControllerExt = new LoopControllerExt(); tree.add(loopControllerExt); JMeterThreadExt parentThread = new JMeterThreadExt(tree, monitor, listenerNotifier); parentThread.setThreadGroup(monitor); JMeterContextService.getContext().setThread(parentThread); JMeterThreadParallel parallel = new JMeterThreadParallel(tree, monitor, listenerNotifier, true); parallel.setThreadGroup(monitor); loopControllerExt.thread = parallel; parallel.run(); assertTrue(parentThread.isStopped); }
Example #2
Source File: ConcurrencyThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test(timeout = 25000) public void testSetDoneThreadsAfterHold() throws Exception { Object[] objects = createTestPlan(); ListedHashTree hashTree = (ListedHashTree) objects[0]; ConcurrencyThreadGroupExt ctg = (ConcurrencyThreadGroupExt) objects[1]; ListenerNotifier notifier = new ListenerNotifier(); long startTime = System.currentTimeMillis(); ctg.start(1, notifier, hashTree, new StandardJMeterEngine()); Thread threadStarter = ctg.getThreadStarter(); threadStarter.join(); long endTime = System.currentTimeMillis(); // wait when all thread stopped Thread.sleep(5000); assertTrue((endTime - startTime) < 20000); // ALL threads must be stopped assertEquals(0, ctg.getNumberOfThreads()); }
Example #3
Source File: ConcurrencyThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void testCachingOfProperties() throws InterruptedException { Object[] objects = createTestPlan(); ListedHashTree hashTree = (ListedHashTree) objects[0]; ConcurrencyThreadGroupExt ctg = (ConcurrencyThreadGroupExt) objects[1]; ConcurrencyThreadStarter starter = new ConcurrencyThreadStarter(0, new ListenerNotifier(), hashTree, new StandardJMeterEngine(), ctg); long lastCachedTime = starter.getLastCachedTime(); Thread.sleep(ConcurrencyThreadStarter.CACHING_VALIDITY_MS / 2); // NOSONAR Intentional starter.checkNeedsPropertiesReloading(System.currentTimeMillis()); assertEquals(lastCachedTime, starter.getLastCachedTime()); Thread.sleep(ConcurrencyThreadStarter.CACHING_VALIDITY_MS * 2); // NOSONAR Intentional starter.checkNeedsPropertiesReloading(System.currentTimeMillis()); assertNotEquals(lastCachedTime, starter.getLastCachedTime()); }
Example #4
Source File: AbstractSimpleThreadGroup.java From jmeter-plugins with Apache License 2.0 | 6 votes |
private JMeterThread makeThread(int groupNum, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine, int threadNum, JMeterContext context) { // N.B. Context needs to be fetched in the correct thread boolean onErrorStopTest = getOnErrorStopTest(); boolean onErrorStopTestNow = getOnErrorStopTestNow(); boolean onErrorStopThread = getOnErrorStopThread(); boolean onErrorStartNextLoop = getOnErrorStartNextLoop(); String groupName = getName(); String distributedPrefix = JMeterUtils.getPropDefault(THREAD_GROUP_DISTRIBUTED_PREFIX_PROPERTY_NAME, ""); final String threadName = distributedPrefix + (distributedPrefix.isEmpty() ? "" : "-") + groupName + " " + groupNum + "-" + (threadNum + 1); final JMeterThread jmeterThread = new JMeterThread(cloneTree(threadGroupTree), this, notifier); jmeterThread.setThreadNum(threadNum); jmeterThread.setThreadGroup(this); jmeterThread.setInitialContext(context); jmeterThread.setThreadName(threadName); jmeterThread.setEngine(engine); jmeterThread.setOnErrorStopTest(onErrorStopTest); jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow); jmeterThread.setOnErrorStopThread(onErrorStopThread); jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop); return jmeterThread; }
Example #5
Source File: AbstractSimpleThreadGroup.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public void start(int groupNum, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine) { running = true; int numThreads = getNumThreads(); log.info("Starting thread group number " + groupNum + " threads " + numThreads); long now = System.currentTimeMillis(); // needs to be same time for all threads in the group final JMeterContext context = JMeterContextService.getContext(); for (int i = 0; running && i < numThreads; i++) { JMeterThread jmThread = makeThread(groupNum, notifier, threadGroupTree, engine, i, context); scheduleThread(jmThread, now); // set start and end time Thread newThread = new Thread(jmThread, jmThread.getThreadName()); registerStartedThread(jmThread, newThread); newThread.start(); } log.info("Started thread group number " + groupNum); }
Example #6
Source File: DebuggingThreadGroup.java From jmeter-debugger with Apache License 2.0 | 6 votes |
private DebuggingThread makeThread(int groupCount, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine, int i, JMeterContext context) { // had to copy whole method because of this line DebuggingThread jmeterThread = new DebuggingThread(threadGroupTree, this, notifier, context); boolean onErrorStopTest = getOnErrorStopTest(); boolean onErrorStopTestNow = getOnErrorStopTestNow(); boolean onErrorStopThread = getOnErrorStopThread(); boolean onErrorStartNextLoop = getOnErrorStartNextLoop(); String groupName = getName(); jmeterThread.setThreadNum(i); jmeterThread.setThreadGroup(this); jmeterThread.setInitialContext(context); String threadName = groupName + " " + (groupCount) + "-" + (i + 1); jmeterThread.setThreadName(threadName); jmeterThread.setEngine(engine); jmeterThread.setOnErrorStopTest(onErrorStopTest); jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow); jmeterThread.setOnErrorStopThread(onErrorStopThread); jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop); return jmeterThread; }
Example #7
Source File: ArrivalsThreadGroup.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void start(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree testTree, StandardJMeterEngine engine) { super.start(groupIndex, listenerNotifier, testTree, engine); synchronized (this) { try { wait(); log.info("Got first arrival"); } catch (InterruptedException e) { log.warn("Interrupted start", e); } } }
Example #8
Source File: AbstractThreadStarter.java From jmeter-plugins with Apache License 2.0 | 5 votes |
public AbstractThreadStarter(int groupIndex, AbstractDynamicThreadGroup owner, ListedHashTree listedHashTree, ListenerNotifier listenerNotifier, StandardJMeterEngine standardJMeterEngine) { super(); this.owner = owner; this.treeClone = cloneTree(listedHashTree); // it needs owner inside this.engine = standardJMeterEngine; this.groupIndex = groupIndex; this.threadGroupTree = listedHashTree; this.notifier = listenerNotifier; this.context = JMeterContextService.getContext(); setDaemon(true); }
Example #9
Source File: ConcurrencyThreadStarter.java From jmeter-plugins with Apache License 2.0 | 5 votes |
public ConcurrencyThreadStarter(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree testTree, StandardJMeterEngine engine, ConcurrencyThreadGroup concurrencyThreadGroup) { super(groupIndex, concurrencyThreadGroup, testTree, listenerNotifier, engine); concurrTG = concurrencyThreadGroup; // We cache values this.rampUp = owner.getRampUpSeconds(); this.hold = owner.getHoldSeconds(); this.steps = owner.getStepsAsLong(); this.maxConcurr = owner.getTargetLevelAsDouble(); this.defaultShiftRampup = JMeterUtils.getPropDefault("dynamic_tg.shift_rampup_start", 0L); this.lastCachedTime = System.currentTimeMillis(); }
Example #10
Source File: DebuggingThreadGroup.java From jmeter-debugger with Apache License 2.0 | 5 votes |
@Override public void start(int groupCount, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine) { JMeterContext context = JMeterContextService.getContext(); DebuggingThread jmThread = makeThread(groupCount, notifier, threadGroupTree, engine, 0, context); Thread newThread = new Thread(jmThread, jmThread.getThreadName()); if (engine instanceof DebuggerEngine) { DebuggerEngine dbgEngine = (DebuggerEngine) engine; dbgEngine.setTarget(jmThread); dbgEngine.setThread(newThread); this.jmeterThread = jmThread; this.osThread = newThread; } newThread.start(); }
Example #11
Source File: AbstractDynamicThreadGroup.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void start(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree testTree, StandardJMeterEngine engine) { running = true; threadStarter = getThreadStarter(groupIndex, listenerNotifier, testTree, engine); threadStarter.setName(getName() + "-ThreadStarter"); threadStarter.start(); }
Example #12
Source File: AbstractSimpleThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test public void testStart() { System.out.println("start"); int groupCount = 0; ListenerNotifier notifier = null; ListedHashTree threadGroupTree = null; StandardJMeterEngine engine = null; AbstractSimpleThreadGroup instance = new AbstractSimpleThreadGroupImpl(); instance.start(groupCount, notifier, threadGroupTree, engine); }
Example #13
Source File: DynamicThread.java From jmeter-plugins with Apache License 2.0 | 4 votes |
public DynamicThread(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note) { super(test, monitor, note); }
Example #14
Source File: FreeFormArrivalsThreadStarterTest.java From jmeter-plugins with Apache License 2.0 | 4 votes |
public FreeFormArrivalsThreadStarterEmul(FreeFormArrivalsThreadGroup atg) { super(0, new ListenerNotifier(), new ListedHashTree(), new EmulatorJmeterEngine(), atg); startTime = System.currentTimeMillis() / 1000; rollingTime = System.currentTimeMillis(); }
Example #15
Source File: ConcurrencyThreadGroup.java From jmeter-plugins with Apache License 2.0 | 4 votes |
@Override protected Thread getThreadStarter(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree testTree, StandardJMeterEngine engine) { return new ConcurrencyThreadStarter(groupIndex, listenerNotifier, testTree, engine, this); }
Example #16
Source File: ConcurrencyThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 4 votes |
@Test public void testStartNextLoop() throws Exception { JMeterContextService.getContext().setVariables(new JMeterVariables()); TestSampleListener listener = new TestSampleListener(); DebugSampler beforeSampler = new DebugSamplerExt(); beforeSampler.setName("Before Test Action sampler"); TestAction testAction = new TestAction(); testAction.setAction(TestAction.RESTART_NEXT_LOOP); DebugSampler afterSampler = new DebugSamplerExt(); afterSampler.setName("After Test Action sampler"); ConcurrencyThreadGroup ctg = new ConcurrencyThreadGroup(); ctg.setProperty(new StringProperty(AbstractThreadGroup.ON_SAMPLE_ERROR, AbstractThreadGroup.ON_SAMPLE_ERROR_CONTINUE)); ctg.setRampUp("0"); ctg.setTargetLevel("1"); ctg.setSteps("0"); ctg.setHold("5"); // TODO: increase this value for debugging ctg.setIterationsLimit("10"); ctg.setUnit("S"); ListedHashTree hashTree = new ListedHashTree(); hashTree.add(ctg); hashTree.add(ctg, beforeSampler); hashTree.add(ctg, testAction); hashTree.add(ctg, afterSampler); hashTree.add(ctg, listener); TestCompiler compiler = new TestCompiler(hashTree); hashTree.traverse(compiler); ListenerNotifier notifier = new ListenerNotifier(); ctg.start(1, notifier, hashTree, new StandardJMeterEngine()); ctg.waitThreadsStopped(); for (SampleEvent event : listener.events) { assertEquals("Before Test Action sampler", event.getResult().getSampleLabel()); } }
Example #17
Source File: ArrivalsThreadStarter.java From jmeter-plugins with Apache License 2.0 | 4 votes |
public ArrivalsThreadStarter(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree listedHashTree, StandardJMeterEngine standardJMeterEngine, ArrivalsThreadGroup owner) { super(groupIndex, owner, listedHashTree, listenerNotifier, standardJMeterEngine); arrivalsTG = owner; }
Example #18
Source File: ArrivalsThreadGroup.java From jmeter-plugins with Apache License 2.0 | 4 votes |
@Override protected Thread getThreadStarter(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree testTree, StandardJMeterEngine engine) { return new ArrivalsThreadStarter(groupIndex, listenerNotifier, testTree, engine, this); }
Example #19
Source File: FreeFormArrivalsThreadGroup.java From jmeter-plugins with Apache License 2.0 | 4 votes |
@Override protected Thread getThreadStarter(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree testTree, StandardJMeterEngine engine) { return new FreeFormArrivalsThreadStarter(groupIndex, listenerNotifier, testTree, engine, this); }
Example #20
Source File: FreeFormArrivalsThreadStarter.java From jmeter-plugins with Apache License 2.0 | 4 votes |
public FreeFormArrivalsThreadStarter(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree listedHashTree, StandardJMeterEngine standardJMeterEngine, FreeFormArrivalsThreadGroup owner) { super(groupIndex, listenerNotifier, listedHashTree, standardJMeterEngine, owner); this.arrivalsTG = owner; }
Example #21
Source File: WeightedSwitchControllerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Test public void testResetTransactionControllerUnderSimpleController() throws Exception { JMeterContextService.getContext().setVariables(new JMeterVariables()); TestSampleListener listener = new TestSampleListener(); // top WSC WeightedSwitchController topWSC = new WeightedSwitchController(); PowerTableModel topPTM = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class}); topPTM.addRow(new String[]{"simple1", "100"}); topPTM.addRow(new String[]{"simple2", "100"}); topWSC.setData(topPTM); GenericController simple1 = new GenericController(); simple1.setName("simple1"); GenericController simple2 = new GenericController(); simple2.setName("simple2"); // first child: transaction controller TransactionController ex1 = new TransactionController(); ex1.setName("ex1"); DebugSampler example1_1 = new DebugSampler(); example1_1.setName("example1_1"); DebugSampler example1_2 = new DebugSampler(); example1_2.setName("example1_2"); // second child: transaction controller TransactionController ex2 = new TransactionController(); ex2.setName("ex2"); DebugSampler example2_1 = new DebugSampler(); example2_1.setName("example2_1"); DebugSampler example2_2 = new DebugSampler(); example2_2.setName("example2_2"); // main loop LoopController loop = new LoopController(); loop.setLoops(4); loop.setContinueForever(false); // test tree ListedHashTree hashTree = new ListedHashTree(); hashTree.add(loop); hashTree.add(loop, topWSC); hashTree.add(topWSC, listener); hashTree.add(topWSC, simple1); hashTree.add(simple1, ex1); hashTree.add(ex1, example1_1); hashTree.add(ex1, example1_2); hashTree.add(ex1, listener); hashTree.add(topWSC, simple2); hashTree.add(simple2, ex2); hashTree.add(ex2, example2_1); hashTree.add(ex2, example2_2); hashTree.add(ex2, listener); TestCompiler compiler = new TestCompiler(hashTree); hashTree.traverse(compiler); ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setNumThreads(1); ListenerNotifier notifier = new ListenerNotifier(); JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier); thread.setThreadGroup(threadGroup); thread.setOnErrorStopThread(true); thread.run(); Map<String, Integer> totalResults = new HashMap<>(); for (SampleEvent event : listener.events) { String label = event.getResult().getSampleLabel(); if (totalResults.containsKey(label)) { totalResults.put(label, totalResults.get(label) + 1); } else { totalResults.put(label, 1); } } assertEquals(12, listener.events.size()); assertEquals(2, (int) totalResults.get("example1_1")); assertEquals(2, (int) totalResults.get("example1_2")); assertEquals(2, (int) totalResults.get("example2_1")); assertEquals(2, (int) totalResults.get("example2_2")); assertEquals(2, (int) totalResults.get("ex1")); // transaction result assertEquals(2, (int) totalResults.get("ex2")); // transaction result }
Example #22
Source File: WeightedSwitchControllerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Test public void testNestedTransactionControllers() throws Exception { JMeterContextService.getContext().setVariables(new JMeterVariables()); TestSampleListener listener = new TestSampleListener(); // top WSC WeightedSwitchController topWSC = new WeightedSwitchController(); PowerTableModel topPTM = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class}); topPTM.addRow(new String[]{"ex1", "10"}); topPTM.addRow(new String[]{"ex2", "20"}); topWSC.setData(topPTM); // first child: transaction controller TransactionController ex1 = new TransactionController(); ex1.setName("ex1"); DebugSampler example1_1 = new DebugSampler(); example1_1.setName("example1_1"); DebugSampler example1_2 = new DebugSampler(); example1_2.setName("example1_2"); // second child: transaction controller TransactionController ex2 = new TransactionController(); ex2.setName("ex2"); DebugSampler example2_1 = new DebugSampler(); example2_1.setName("example2_1"); DebugSampler example2_2 = new DebugSampler(); example2_2.setName("example2_2"); // main loop LoopController loop = new LoopController(); loop.setLoops(3); loop.setContinueForever(false); // test tree ListedHashTree hashTree = new ListedHashTree(); hashTree.add(loop); hashTree.add(loop, topWSC); hashTree.add(topWSC, listener); hashTree.add(topWSC, ex1); hashTree.add(ex1, example1_1); hashTree.add(ex1, example1_2); hashTree.add(ex1, listener); hashTree.add(topWSC, ex2); hashTree.add(ex2, example2_1); hashTree.add(ex2, example2_2); hashTree.add(ex2, listener); TestCompiler compiler = new TestCompiler(hashTree); hashTree.traverse(compiler); ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setNumThreads(1); ListenerNotifier notifier = new ListenerNotifier(); JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier); thread.setThreadGroup(threadGroup); thread.setOnErrorStopThread(true); thread.run(); Map<String, Integer> totalResults = new HashMap<>(); for (SampleEvent event : listener.events) { String label = event.getResult().getSampleLabel(); if (totalResults.containsKey(label)) { totalResults.put(label, totalResults.get(label) + 1); } else { totalResults.put(label, 1); } } assertEquals(9, listener.events.size()); assertEquals(1, (int) totalResults.get("example1_1")); assertEquals(1, (int) totalResults.get("example1_2")); assertEquals(2, (int) totalResults.get("example2_1")); assertEquals(2, (int) totalResults.get("example2_2")); assertEquals(1, (int) totalResults.get("ex1")); // transaction result assertEquals(2, (int) totalResults.get("ex2")); // transaction result }
Example #23
Source File: WeightedSwitchControllerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Test public void testNestedSimpleControllers() throws Exception { JMeterContextService.getContext().setVariables(new JMeterVariables()); TestSampleListener listener = new TestSampleListener(); // top WSC WeightedSwitchController topWSC = new WeightedSwitchController(); PowerTableModel topPTM = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class}); topPTM.addRow(new String[]{"ex1", "10"}); topPTM.addRow(new String[]{"ex2", "20"}); topWSC.setData(topPTM); // first child: simple controller GenericController ex1 = new GenericController(); ex1.setName("ex1"); DebugSampler example1_1 = new DebugSampler(); example1_1.setName("example1_1"); DebugSampler example1_2 = new DebugSampler(); example1_2.setName("example1_2"); // second child: simple controller GenericController ex2 = new GenericController(); ex2.setName("ex2"); DebugSampler example2_1 = new DebugSampler(); example2_1.setName("example2_1"); DebugSampler example2_2 = new DebugSampler(); example2_2.setName("example2_2"); // main loop LoopController loop = new LoopController(); loop.setLoops(60); loop.setContinueForever(false); // test tree ListedHashTree hashTree = new ListedHashTree(); hashTree.add(loop); hashTree.add(loop, topWSC); hashTree.add(topWSC, listener); hashTree.add(topWSC, ex1); hashTree.add(ex1, example1_1); hashTree.add(ex1, example1_2); hashTree.add(ex1, listener); hashTree.add(topWSC, ex2); hashTree.add(ex2, example2_1); hashTree.add(ex2, example2_2); hashTree.add(ex2, listener); TestCompiler compiler = new TestCompiler(hashTree); hashTree.traverse(compiler); ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setNumThreads(1); ListenerNotifier notifier = new ListenerNotifier(); JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier); thread.setThreadGroup(threadGroup); thread.setOnErrorStopThread(true); thread.run(); Map<String, Integer> totalResults = new HashMap<>(); for (SampleEvent event : listener.events) { String label = event.getResult().getSampleLabel(); if (totalResults.containsKey(label)) { totalResults.put(label, totalResults.get(label) + 1); } else { totalResults.put(label, 1); } } assertEquals(120, listener.events.size()); assertEquals(20, (int) totalResults.get("example1_1")); assertEquals(20, (int) totalResults.get("example1_2")); assertEquals(40, (int) totalResults.get("example2_1")); assertEquals(40, (int) totalResults.get("example2_2")); }
Example #24
Source File: WeightedSwitchControllerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Test public void testNestedWSC() throws Exception { JMeterContextService.getContext().setVariables(new JMeterVariables()); TestSampleListener listener = new TestSampleListener(); // top WSC WeightedSwitchController topWSC = new WeightedSwitchController(); PowerTableModel topPTM = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class}); topPTM.addRow(new String[]{"wsc1", "2"}); topPTM.addRow(new String[]{"wsc2", "2"}); topPTM.addRow(new String[]{"D_#1", "1"}); topPTM.addRow(new String[]{"D_#2", "1"}); topWSC.setData(topPTM); DebugSampler d1 = new DebugSampler(); d1.setName("D_#1"); DebugSampler d2 = new DebugSampler(); d2.setName("D_#2"); // first child WSC of top WSC WeightedSwitchController childWSC1 = new WeightedSwitchController(); childWSC1.setName("wsc1"); PowerTableModel childPTM1 = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class}); childPTM1.addRow(new String[]{"D1_#1", "1"}); childPTM1.addRow(new String[]{"D1_#2", "1"}); childWSC1.setData(childPTM1); DebugSampler d1_1 = new DebugSampler(); d1_1.setName("D1_#1"); DebugSampler d1_2 = new DebugSampler(); d1_2.setName("D1_#2"); // second child WSC of top WSC WeightedSwitchController childWSC2 = new WeightedSwitchController(); childWSC2.setName("wsc2"); PowerTableModel childPTM2 = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class}); childPTM2.addRow(new String[]{"D2_#1", "1"}); childPTM2.addRow(new String[]{"D2_#2", "1"}); childWSC2.setData(childPTM2); DebugSampler d2_1 = new DebugSampler(); d2_1.setName("D2_#1"); DebugSampler d2_2 = new DebugSampler(); d2_2.setName("D2_#2"); // main loop LoopController loop = new LoopController(); loop.setLoops(6); loop.setContinueForever(false); // test tree ListedHashTree hashTree = new ListedHashTree(); hashTree.add(loop); hashTree.add(loop, topWSC); hashTree.add(topWSC, listener); hashTree.add(topWSC, childWSC1); hashTree.add(childWSC1, d1_1); hashTree.add(childWSC1, d1_2); hashTree.add(childWSC1, listener); hashTree.add(topWSC, childWSC2); hashTree.add(childWSC2, d2_1); hashTree.add(childWSC2, d2_2); hashTree.add(childWSC2, listener); hashTree.add(topWSC, d1); hashTree.add(topWSC, d2); TestCompiler compiler = new TestCompiler(hashTree); hashTree.traverse(compiler); ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setNumThreads(1); ListenerNotifier notifier = new ListenerNotifier(); JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier); thread.setThreadGroup(threadGroup); thread.setOnErrorStopThread(true); thread.run(); assertEquals(6, listener.events.size()); List<String> labels = new ArrayList<>(); labels.add("D_#1"); labels.add("D_#2"); labels.add("D1_#1"); labels.add("D1_#2"); labels.add("D2_#1"); labels.add("D2_#2"); for (SampleEvent event : listener.events) { assertTrue(labels.contains(event.getResult().getSampleLabel())); } }
Example #25
Source File: JMeterThreadParallelTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
public JMeterThreadExt(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note) { super(test, monitor, note); }
Example #26
Source File: ParallelSamplerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Test(timeout=3000) public void testInfinityStopTest() { JMeterContextService.getContext().setVariables(new JMeterVariables()); TestSampleListener listener = new TestSampleListener(); TestAction action = new TestAction(); action.setAction(0); action.setTarget(2); WhileController whileController = new WhileController(); ParallelSampler sampler = new ParallelSampler(); sampler.setGenerateParent(true); LoopController loop = new LoopController(); loop.setLoops(1); loop.setContinueForever(false); // test tree ListedHashTree hashTree = new ListedHashTree(); hashTree.add(loop); hashTree.add(loop, sampler); hashTree.add(sampler, listener); hashTree.add(sampler, whileController); hashTree.add(whileController, action); hashTree.add(whileController, listener); TestCompiler compiler = new TestCompiler(hashTree); hashTree.traverse(compiler); ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setNumThreads(1); ListenerNotifier notifier = new ListenerNotifier(); JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier); thread.setThreadGroup(threadGroup); thread.setOnErrorStopThread(true); thread.setEngine(new StandardJMeterEngine()); thread.run(); assertEquals(1, listener.events.size()); }
Example #27
Source File: ParallelSamplerTest.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
@Test(timeout=3000) public void testStartNextIteration() { JMeterContextService.getContext().setVariables(new JMeterVariables()); TestSampleListener listener = new TestSampleListener(); TestAction action = new TestAction(); action.setAction(3); DebugSampler samplerBefore = new DebugSampler(); samplerBefore.setName("samplerBefore"); DebugSampler samplerAfter = new DebugSampler(); samplerAfter.setName("samplerAfter"); WhileController whileController = new WhileController(); ParallelSampler sampler = new ParallelSampler(); sampler.setGenerateParent(true); LoopController loop = new LoopController(); loop.setLoops(2); loop.setContinueForever(false); // parallel subtree ListedHashTree parallelTree = new ListedHashTree(); parallelTree.add(samplerBefore); parallelTree.add(action); // while subtree ListedHashTree whileTree = new ListedHashTree(); whileTree.add(whileController, parallelTree); // parallel Sampler subtree ListedHashTree parallelSamplerTree = new ListedHashTree(); parallelSamplerTree.add(sampler, whileTree); // TG sub tree ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setNumThreads(1); threadGroup.setSamplerController(loop); ListedHashTree loopTree = new ListedHashTree(); loopTree.add(threadGroup, parallelSamplerTree); loopTree.add(threadGroup, samplerAfter); loopTree.add(threadGroup, listener); TestCompiler compiler = new TestCompiler(loopTree); loopTree.traverse(compiler); ListenerNotifier notifier = new ListenerNotifier(); JMeterThread thread = new JMeterThread(loopTree, threadGroup, notifier); thread.setThreadGroup(threadGroup); thread.setEngine(new StandardJMeterEngine()); thread.setOnErrorStopThread(true); thread.run(); assertEquals(2, listener.events.size()); }
Example #28
Source File: DummyThreadGroup.java From jmeter-bzm-plugins with Apache License 2.0 | 2 votes |
@Override public void start(int i, ListenerNotifier listenerNotifier, ListedHashTree listedHashTree, StandardJMeterEngine standardJMeterEngine) { }
Example #29
Source File: AbstractDynamicThreadGroup.java From jmeter-plugins with Apache License 2.0 | votes |
protected abstract Thread getThreadStarter(int groupIndex, ListenerNotifier listenerNotifier, ListedHashTree testTree, StandardJMeterEngine engine);