Search in sources :

Example 56 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class VariableThroughputTimer method getRPSForSecond.

/**
 * @param durationSinceStartOfTestSec Elapsed time since start of test in seconds
 * @return double RPS at that second or -1 if we're out of schedule
 */
public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) {
    JMeterProperty data = getData();
    if (data instanceof NullProperty) {
        return Pair.of(-1.0, 0L);
    }
    CollectionProperty rows = (CollectionProperty) data;
    PropertyIterator scheduleIT = rows.iterator();
    double newSec = elapsedSinceStartOfTestSec;
    double result = -1;
    boolean resultComputed = false;
    long totalDuration = 0;
    while (scheduleIT.hasNext()) {
        @SuppressWarnings("unchecked") List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue();
        int duration = getIntValue(curProp, DURATION_FIELD_NO);
        totalDuration += duration;
        if (!resultComputed) {
            double fromRps = getDoubleValue(curProp, FROM_FIELD_NO);
            double toRps = getDoubleValue(curProp, TO_FIELD_NO);
            if (newSec - duration <= 0) {
                result = fromRps + newSec * (toRps - fromRps) / (double) duration;
                resultComputed = true;
            } else {
                // We're not yet in the slot
                newSec -= duration;
            }
        }
    }
    return Pair.of(result, totalDuration);
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) List(java.util.List)

Example 57 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class VariableThroughputTimerGui method modifyTestElement.

@Override
public void modifyTestElement(TestElement tg) {
    // log.info("Modify test element");
    super.configureTestElement(tg);
    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }
    if (tg instanceof VariableThroughputTimer) {
        VariableThroughputTimer utg = (VariableThroughputTimer) tg;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, VariableThroughputTimer.DATA_PROPERTY);
        utg.setData(rows);
    }
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty)

Example 58 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class VariableThroughputTimerGuiTest method testModifyTestElement.

/**
 */
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    VariableThroughputTimer tg = new VariableThroughputTimer();
    VariableThroughputTimerGui instance = new VariableThroughputTimerGui();
    // instance.addRowButton.doClick();
    instance.modifyTestElement(tg);
    CollectionProperty data = (CollectionProperty) tg.getData();
    Assert.assertEquals(instance.grid.getModel().getRowCount(), data.size());
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty)

Example 59 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class VariableThroughputTimerTest method testDelay1000.

@Test
public void testDelay1000() throws InterruptedException {
    System.out.println("delay 1000");
    VariableThroughputTimer instance = new VariableThroughputTimerEmul();
    instance.setName("TEST");
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, VariableThroughputTimer.DATA_PROPERTY);
    instance.setData(prop);
    long start = System.currentTimeMillis();
    long result = 0;
    while (// 10 seconds test
    (System.currentTimeMillis() - start) < 10 * 1000) {
        try {
            result = instance.delay();
            assertEquals("9", JMeterUtils.getProperty("TEST_totalDuration"));
            assertEquals(0, result);
        } catch (RuntimeException ex) {
            if (!ex.getMessage().equals("Immediate stop")) {
                throw ex;
            }
        }
    }
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) Test(org.junit.Test)

Example 60 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class FirefoxDriverConfig method setExtensions.

public void setExtensions(PowerTableModel model) {
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(model, EXTENSIONS_TO_LOAD);
    setProperty(prop);
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty)

Aggregations

CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)91 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)29 ArrayList (java.util.ArrayList)19 NullProperty (org.apache.jmeter.testelement.property.NullProperty)13 Test (org.junit.Test)11 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)8 Test (org.junit.jupiter.api.Test)7 IOException (java.io.IOException)5 List (java.util.List)4 StringProperty (org.apache.jmeter.testelement.property.StringProperty)4 File (java.io.File)3 Argument (org.apache.jmeter.config.Argument)3 PowerTableModel (org.apache.jmeter.gui.util.PowerTableModel)3 TestPlan (org.apache.jmeter.testelement.TestPlan)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Field (java.lang.reflect.Field)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 UnknownHostException (java.net.UnknownHostException)2 LinkedList (java.util.LinkedList)2