@Test public void testScheduleThread() { System.out.println("scheduleThread"); HashTree hashtree = new HashTree(); hashtree.add(new LoopController()); JMeterThread thread = new JMeterThread(hashtree, null, null); CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY); instance.setData(prop); instance.testStarted(); instance.scheduleThread(thread); assertTrue(thread.getStartTime() > 0); assertTrue(thread.getEndTime() > thread.getStartTime()); }
@Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { log.debug("Scheduling thread: " + thread.getThreadName()); if (threadsToSchedule < 1) { if (!scheduleIT.hasNext()) { throw new RuntimeException("Not enough schedule records for thread #" + thread.getThreadName()); } currentRecord = (CollectionProperty) scheduleIT.next(); threadsToSchedule = currentRecord.get(0).getIntValue(); } int numThreads = currentRecord.get(START_THREADS_CNT_FIELD_NO).getIntValue(); int initialDelay = currentRecord.get(INIT_DELAY_FIELD_NO).getIntValue(); int startRampUp = currentRecord.get(STARTUP_TIME_FIELD_NO).getIntValue(); int flightTime = currentRecord.get(HOLD_LOAD_FOR_FIELD_NO).getIntValue(); int endRampUp = currentRecord.get(SHUTDOWN_TIME_FIELD_NO).getIntValue(); long ascentPoint = tgStartTime + 1000 * initialDelay; final int rampUpDelayForThread = (int) Math.floor(1000 * startRampUp * (double) threadsToSchedule / numThreads); long startTime = ascentPoint + rampUpDelayForThread; long descentPoint = startTime + 1000 * flightTime + 1000 * startRampUp - rampUpDelayForThread; thread.setStartTime(startTime); thread.setEndTime(descentPoint + (int) Math.floor(1000 * endRampUp * (double) threadsToSchedule / numThreads)); thread.setScheduled(true); threadsToSchedule--; }
UltimateThreadGroup extends AbstractSimpleThreadGroup implements Serializable, TestStateListener { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { log.debug("Scheduling thread: " + thread.getThreadName()); if (threadsToSchedule < 1) { if (!scheduleIT.hasNext()) { throw new RuntimeException("Not enough schedule records for thread #" + thread.getThreadName()); } currentRecord = (CollectionProperty) scheduleIT.next(); threadsToSchedule = currentRecord.get(0).getIntValue(); } int numThreads = currentRecord.get(START_THREADS_CNT_FIELD_NO).getIntValue(); int initialDelay = currentRecord.get(INIT_DELAY_FIELD_NO).getIntValue(); int startRampUp = currentRecord.get(STARTUP_TIME_FIELD_NO).getIntValue(); int flightTime = currentRecord.get(HOLD_LOAD_FOR_FIELD_NO).getIntValue(); int endRampUp = currentRecord.get(SHUTDOWN_TIME_FIELD_NO).getIntValue(); long ascentPoint = tgStartTime + 1000 * initialDelay; final int rampUpDelayForThread = (int) Math.floor(1000 * startRampUp * (double) threadsToSchedule / numThreads); long startTime = ascentPoint + rampUpDelayForThread; long descentPoint = startTime + 1000 * flightTime + 1000 * startRampUp - rampUpDelayForThread; thread.setStartTime(startTime); thread.setEndTime(descentPoint + (int) Math.floor(1000 * endRampUp * (double) threadsToSchedule / numThreads)); thread.setScheduled(true); threadsToSchedule--; } }
UltimateThreadGroup extends AbstractSimpleThreadGroup implements Serializable, TestStateListener { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { log.debug("Scheduling thread: " + thread.getThreadName()); if (threadsToSchedule < 1) { if (!scheduleIT.hasNext()) { throw new RuntimeException("Not enough schedule records for thread #" + thread.getThreadName()); } currentRecord = (CollectionProperty) scheduleIT.next(); threadsToSchedule = currentRecord.get(0).getIntValue(); } int numThreads = currentRecord.get(START_THREADS_CNT_FIELD_NO).getIntValue(); int initialDelay = currentRecord.get(INIT_DELAY_FIELD_NO).getIntValue(); int startRampUp = currentRecord.get(STARTUP_TIME_FIELD_NO).getIntValue(); int flightTime = currentRecord.get(HOLD_LOAD_FOR_FIELD_NO).getIntValue(); int endRampUp = currentRecord.get(SHUTDOWN_TIME_FIELD_NO).getIntValue(); long ascentPoint = tgStartTime + 1000 * initialDelay; final int rampUpDelayForThread = (int) Math.floor(1000 * startRampUp * (double) threadsToSchedule / numThreads); long startTime = ascentPoint + rampUpDelayForThread; long descentPoint = startTime + 1000 * flightTime + 1000 * startRampUp - rampUpDelayForThread; thread.setStartTime(startTime); thread.setEndTime(descentPoint + (int) Math.floor(1000 * endRampUp * (double) threadsToSchedule / numThreads)); thread.setScheduled(true); threadsToSchedule--; } UltimateThreadGroup(); }
UltimateThreadGroup extends AbstractSimpleThreadGroup implements Serializable, TestStateListener { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { log.debug("Scheduling thread: " + thread.getThreadName()); if (threadsToSchedule < 1) { if (!scheduleIT.hasNext()) { throw new RuntimeException("Not enough schedule records for thread #" + thread.getThreadName()); } currentRecord = (CollectionProperty) scheduleIT.next(); threadsToSchedule = currentRecord.get(0).getIntValue(); } int numThreads = currentRecord.get(START_THREADS_CNT_FIELD_NO).getIntValue(); int initialDelay = currentRecord.get(INIT_DELAY_FIELD_NO).getIntValue(); int startRampUp = currentRecord.get(STARTUP_TIME_FIELD_NO).getIntValue(); int flightTime = currentRecord.get(HOLD_LOAD_FOR_FIELD_NO).getIntValue(); int endRampUp = currentRecord.get(SHUTDOWN_TIME_FIELD_NO).getIntValue(); long ascentPoint = tgStartTime + 1000 * initialDelay; final int rampUpDelayForThread = (int) Math.floor(1000 * startRampUp * (double) threadsToSchedule / numThreads); long startTime = ascentPoint + rampUpDelayForThread; long descentPoint = startTime + 1000 * flightTime + 1000 * startRampUp - rampUpDelayForThread; thread.setStartTime(startTime); thread.setEndTime(descentPoint + (int) Math.floor(1000 * endRampUp * (double) threadsToSchedule / numThreads)); thread.setScheduled(true); threadsToSchedule--; } UltimateThreadGroup(); JMeterProperty getData(); void setData(CollectionProperty rows); @Override int getNumThreads(); @Override void testStarted(); @Override void testStarted(String host); @Override void testEnded(); @Override void testEnded(String host); }
UltimateThreadGroup extends AbstractSimpleThreadGroup implements Serializable, TestStateListener { @Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { log.debug("Scheduling thread: " + thread.getThreadName()); if (threadsToSchedule < 1) { if (!scheduleIT.hasNext()) { throw new RuntimeException("Not enough schedule records for thread #" + thread.getThreadName()); } currentRecord = (CollectionProperty) scheduleIT.next(); threadsToSchedule = currentRecord.get(0).getIntValue(); } int numThreads = currentRecord.get(START_THREADS_CNT_FIELD_NO).getIntValue(); int initialDelay = currentRecord.get(INIT_DELAY_FIELD_NO).getIntValue(); int startRampUp = currentRecord.get(STARTUP_TIME_FIELD_NO).getIntValue(); int flightTime = currentRecord.get(HOLD_LOAD_FOR_FIELD_NO).getIntValue(); int endRampUp = currentRecord.get(SHUTDOWN_TIME_FIELD_NO).getIntValue(); long ascentPoint = tgStartTime + 1000 * initialDelay; final int rampUpDelayForThread = (int) Math.floor(1000 * startRampUp * (double) threadsToSchedule / numThreads); long startTime = ascentPoint + rampUpDelayForThread; long descentPoint = startTime + 1000 * flightTime + 1000 * startRampUp - rampUpDelayForThread; thread.setStartTime(startTime); thread.setEndTime(descentPoint + (int) Math.floor(1000 * endRampUp * (double) threadsToSchedule / numThreads)); thread.setScheduled(true); threadsToSchedule--; } UltimateThreadGroup(); JMeterProperty getData(); void setData(CollectionProperty rows); @Override int getNumThreads(); @Override void testStarted(); @Override void testStarted(String host); @Override void testEnded(); @Override void testEnded(String host); static final String DATA_PROPERTY; static final String EXTERNAL_DATA_PROPERTY; static final int START_THREADS_CNT_FIELD_NO; static final int INIT_DELAY_FIELD_NO; static final int STARTUP_TIME_FIELD_NO; static final int HOLD_LOAD_FOR_FIELD_NO; static final int SHUTDOWN_TIME_FIELD_NO; }