@Test public void execute() throws InvalidVariableException { Collection<CompoundVariable> parameters = new LinkedList<>(); parameters.add(new CompoundVariable("tstname")); parameters.add(new CompoundVariable("1")); parameters.add(new CompoundVariable("10")); parameters.add(new CompoundVariable("5")); TSTFeedback instance = new TSTFeedback(); instance.setParameters(parameters); String result; result = instance.execute(null, null); log.debug(result); assertEquals("1", result); JMeterUtils.setProperty("tstname_concurrency", String.valueOf(10)); JMeterUtils.setProperty("tstname_cntDelayed", String.valueOf(11)); JMeterUtils.setProperty("tstname_cntSent", String.valueOf(16)); JMeterUtils.setProperty("tstname_rps", String.valueOf(15.671562)); result = instance.execute(null, null); log.debug(result); assertEquals("5", result); JMeterUtils.setProperty("tstname_concurrency", String.valueOf(1)); JMeterUtils.setProperty("tstname_cntDelayed", String.valueOf(5)); JMeterUtils.setProperty("tstname_cntSent", String.valueOf(16)); JMeterUtils.setProperty("tstname_rps", String.valueOf(15.671562)); result = instance.execute(null, null); log.debug(result); assertEquals("1", result); JMeterUtils.setProperty("tstname_concurrency", String.valueOf(10)); JMeterUtils.setProperty("tstname_cntDelayed", String.valueOf(6)); JMeterUtils.setProperty("tstname_cntSent", String.valueOf(16)); JMeterUtils.setProperty("tstname_rps", String.valueOf(15.671562)); result = instance.execute(null, null); log.debug(result); assertEquals("9", result); JMeterUtils.setProperty("tstname_concurrency", String.valueOf(10)); JMeterUtils.setProperty("tstname_cntDelayed", String.valueOf(4)); JMeterUtils.setProperty("tstname_cntSent", String.valueOf(16)); JMeterUtils.setProperty("tstname_rps", String.valueOf(15.671562)); result = instance.execute(null, null); log.debug(result); assertEquals("10", result); }
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) { String tstName = values[0].execute(); String concName = tstName + "_concurrency"; if (justStarted) { JMeterUtils.setProperty(concName, String.valueOf(values[1].execute())); justStarted = false; } int limit = Integer.MAX_VALUE; if (values.length > 2) { try { limit = Integer.parseInt(values[2].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for limit, defaulting to infinity", exc); } } double spare = 0.1; if (values.length > 3) { try { spare = Double.parseDouble(values[3].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for spare ratio, defaulting to 0", exc); spare = 1; } } int con = Integer.parseInt(JMeterUtils.getPropDefault(concName, "1")); int delayed = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntDelayed", "0")); int sent = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntSent", "0")); float rps = Float.parseFloat(JMeterUtils.getPropDefault(tstName + "_rps", "0")); int needed = con; if (rps <= 0) { } else if (delayed > 0) { needed = decreaseNeeded(spare, con, delayed, needed); } else if (sent < rps) { needed = (int) Math.ceil(con * (2 - sent / rps)); } if (needed != con && log.isDebugEnabled()) { log.debug("Need to change " + concName + ": " + con + "=>" + needed + " (" + sent + "/" + rps + "/" + delayed + ")"); } if (needed <= 0) { log.warn("Got concurrency less than zero: " + needed); needed = 1; } if (needed > limit) { log.warn("Got concurrency more than limit: " + needed); needed = limit; } JMeterUtils.setProperty(concName, String.valueOf(needed)); JMeterUtils.setProperty(tstName + "_rps", "0"); return String.valueOf(needed); }
TSTFeedback extends AbstractFunction implements TestStateListener { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) { String tstName = values[0].execute(); String concName = tstName + "_concurrency"; if (justStarted) { JMeterUtils.setProperty(concName, String.valueOf(values[1].execute())); justStarted = false; } int limit = Integer.MAX_VALUE; if (values.length > 2) { try { limit = Integer.parseInt(values[2].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for limit, defaulting to infinity", exc); } } double spare = 0.1; if (values.length > 3) { try { spare = Double.parseDouble(values[3].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for spare ratio, defaulting to 0", exc); spare = 1; } } int con = Integer.parseInt(JMeterUtils.getPropDefault(concName, "1")); int delayed = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntDelayed", "0")); int sent = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntSent", "0")); float rps = Float.parseFloat(JMeterUtils.getPropDefault(tstName + "_rps", "0")); int needed = con; if (rps <= 0) { } else if (delayed > 0) { needed = decreaseNeeded(spare, con, delayed, needed); } else if (sent < rps) { needed = (int) Math.ceil(con * (2 - sent / rps)); } if (needed != con && log.isDebugEnabled()) { log.debug("Need to change " + concName + ": " + con + "=>" + needed + " (" + sent + "/" + rps + "/" + delayed + ")"); } if (needed <= 0) { log.warn("Got concurrency less than zero: " + needed); needed = 1; } if (needed > limit) { log.warn("Got concurrency more than limit: " + needed); needed = limit; } JMeterUtils.setProperty(concName, String.valueOf(needed)); JMeterUtils.setProperty(tstName + "_rps", "0"); return String.valueOf(needed); } }
TSTFeedback extends AbstractFunction implements TestStateListener { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) { String tstName = values[0].execute(); String concName = tstName + "_concurrency"; if (justStarted) { JMeterUtils.setProperty(concName, String.valueOf(values[1].execute())); justStarted = false; } int limit = Integer.MAX_VALUE; if (values.length > 2) { try { limit = Integer.parseInt(values[2].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for limit, defaulting to infinity", exc); } } double spare = 0.1; if (values.length > 3) { try { spare = Double.parseDouble(values[3].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for spare ratio, defaulting to 0", exc); spare = 1; } } int con = Integer.parseInt(JMeterUtils.getPropDefault(concName, "1")); int delayed = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntDelayed", "0")); int sent = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntSent", "0")); float rps = Float.parseFloat(JMeterUtils.getPropDefault(tstName + "_rps", "0")); int needed = con; if (rps <= 0) { } else if (delayed > 0) { needed = decreaseNeeded(spare, con, delayed, needed); } else if (sent < rps) { needed = (int) Math.ceil(con * (2 - sent / rps)); } if (needed != con && log.isDebugEnabled()) { log.debug("Need to change " + concName + ": " + con + "=>" + needed + " (" + sent + "/" + rps + "/" + delayed + ")"); } if (needed <= 0) { log.warn("Got concurrency less than zero: " + needed); needed = 1; } if (needed > limit) { log.warn("Got concurrency more than limit: " + needed); needed = limit; } JMeterUtils.setProperty(concName, String.valueOf(needed)); JMeterUtils.setProperty(tstName + "_rps", "0"); return String.valueOf(needed); }  }
TSTFeedback extends AbstractFunction implements TestStateListener { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) { String tstName = values[0].execute(); String concName = tstName + "_concurrency"; if (justStarted) { JMeterUtils.setProperty(concName, String.valueOf(values[1].execute())); justStarted = false; } int limit = Integer.MAX_VALUE; if (values.length > 2) { try { limit = Integer.parseInt(values[2].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for limit, defaulting to infinity", exc); } } double spare = 0.1; if (values.length > 3) { try { spare = Double.parseDouble(values[3].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for spare ratio, defaulting to 0", exc); spare = 1; } } int con = Integer.parseInt(JMeterUtils.getPropDefault(concName, "1")); int delayed = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntDelayed", "0")); int sent = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntSent", "0")); float rps = Float.parseFloat(JMeterUtils.getPropDefault(tstName + "_rps", "0")); int needed = con; if (rps <= 0) { } else if (delayed > 0) { needed = decreaseNeeded(spare, con, delayed, needed); } else if (sent < rps) { needed = (int) Math.ceil(con * (2 - sent / rps)); } if (needed != con && log.isDebugEnabled()) { log.debug("Need to change " + concName + ": " + con + "=>" + needed + " (" + sent + "/" + rps + "/" + delayed + ")"); } if (needed <= 0) { log.warn("Got concurrency less than zero: " + needed); needed = 1; } if (needed > limit) { log.warn("Got concurrency more than limit: " + needed); needed = limit; } JMeterUtils.setProperty(concName, String.valueOf(needed)); JMeterUtils.setProperty(tstName + "_rps", "0"); return String.valueOf(needed); }  @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc(); @Override void testStarted(); @Override void testStarted(String s); @Override void testEnded(); @Override void testEnded(String s); }
TSTFeedback extends AbstractFunction implements TestStateListener { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) { String tstName = values[0].execute(); String concName = tstName + "_concurrency"; if (justStarted) { JMeterUtils.setProperty(concName, String.valueOf(values[1].execute())); justStarted = false; } int limit = Integer.MAX_VALUE; if (values.length > 2) { try { limit = Integer.parseInt(values[2].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for limit, defaulting to infinity", exc); } } double spare = 0.1; if (values.length > 3) { try { spare = Double.parseDouble(values[3].execute()); } catch (NumberFormatException exc) { log.debug("Failed to parse value for spare ratio, defaulting to 0", exc); spare = 1; } } int con = Integer.parseInt(JMeterUtils.getPropDefault(concName, "1")); int delayed = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntDelayed", "0")); int sent = Integer.parseInt(JMeterUtils.getPropDefault(tstName + "_cntSent", "0")); float rps = Float.parseFloat(JMeterUtils.getPropDefault(tstName + "_rps", "0")); int needed = con; if (rps <= 0) { } else if (delayed > 0) { needed = decreaseNeeded(spare, con, delayed, needed); } else if (sent < rps) { needed = (int) Math.ceil(con * (2 - sent / rps)); } if (needed != con && log.isDebugEnabled()) { log.debug("Need to change " + concName + ": " + con + "=>" + needed + " (" + sent + "/" + rps + "/" + delayed + ")"); } if (needed <= 0) { log.warn("Got concurrency less than zero: " + needed); needed = 1; } if (needed > limit) { log.warn("Got concurrency more than limit: " + needed); needed = limit; } JMeterUtils.setProperty(concName, String.valueOf(needed)); JMeterUtils.setProperty(tstName + "_rps", "0"); return String.valueOf(needed); }  @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc(); @Override void testStarted(); @Override void testStarted(String s); @Override void testEnded(); @Override void testEnded(String s);  }