Search in sources :

Example 1 with ConstantTimer

use of org.apache.jmeter.timers.ConstantTimer in project jmeter-plugins by undera.

the class ConcurrencyThreadGroupTest method testSetDoneThreadsAfterHold.

// WAP-9261
@Test(timeout = 25000)
public void testSetDoneThreadsAfterHold() throws Exception {
    JMeterContextService.getContext().setVariables(new JMeterVariables());
    TestSampleListener listener = new TestSampleListener();
    DebugSampler sampler = new DebugSampler();
    sampler.setName("Sampler");
    ConstantTimer timer = new ConstantTimer();
    timer.setDelay("2000");
    timer.setName("timer");
    LoopController loopController = new LoopController();
    loopController.setContinueForever(true);
    loopController.setLoops(-1);
    loopController.setName("loop c");
    ConcurrencyThreadGroupExt ctg = new ConcurrencyThreadGroupExt();
    ctg.setName("CTG");
    ctg.setRampUp("5");
    ctg.setTargetLevel("3");
    ctg.setSteps("1");
    // TODO: increase this value for debugging
    ctg.setHold("10");
    ctg.setIterationsLimit("");
    ctg.setUnit("S");
    ListedHashTree loopTree = new ListedHashTree();
    loopTree.add(loopController, timer);
    loopTree.add(loopController, sampler);
    loopTree.add(loopController, listener);
    ListedHashTree hashTree = new ListedHashTree();
    hashTree.add(ctg, loopTree);
    TestCompiler compiler = new TestCompiler(hashTree);
    // this hashTree can be save to *jmx
    hashTree.traverse(compiler);
    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.currentThread().sleep(5000);
    assertTrue((endTime - startTime) < 20000);
    // ALL threads must be stopped
    assertEquals(0, ctg.getNumberOfThreads());
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) ListedHashTree(org.apache.jorphan.collections.ListedHashTree) DebugSampler(org.apache.jmeter.sampler.DebugSampler) TestCompiler(org.apache.jmeter.threads.TestCompiler) StandardJMeterEngine(org.apache.jmeter.engine.StandardJMeterEngine) ConstantTimer(org.apache.jmeter.timers.ConstantTimer) LoopController(org.apache.jmeter.control.LoopController) ListenerNotifier(org.apache.jmeter.threads.ListenerNotifier) ArrivalsThreadGroupTest(com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroupTest) Test(org.junit.Test)

Example 2 with ConstantTimer

use of org.apache.jmeter.timers.ConstantTimer in project jmeter by apache.

the class ConstantTimerGui method createTestElement.

/**
 * Create the test element underlying this GUI component.
 *
 * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
 */
@Override
public TestElement createTestElement() {
    ConstantTimer timer = new ConstantTimer();
    modifyTestElement(timer);
    return timer;
}
Also used : ConstantTimer(org.apache.jmeter.timers.ConstantTimer)

Aggregations

ConstantTimer (org.apache.jmeter.timers.ConstantTimer)2 ArrivalsThreadGroupTest (com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroupTest)1 LoopController (org.apache.jmeter.control.LoopController)1 StandardJMeterEngine (org.apache.jmeter.engine.StandardJMeterEngine)1 DebugSampler (org.apache.jmeter.sampler.DebugSampler)1 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)1 ListenerNotifier (org.apache.jmeter.threads.ListenerNotifier)1 TestCompiler (org.apache.jmeter.threads.TestCompiler)1 ListedHashTree (org.apache.jorphan.collections.ListedHashTree)1 Test (org.junit.Test)1