@Test public void testSampleOccurred() throws InterruptedException { System.out.println("sampleOccurred"); SampleResult res = new SampleResult(); res.setLatency(500); SampleEvent se = new SampleEvent(res, ""); AutoStop instance = new AutoStop(); instance.setResponseTime("10"); instance.setResponseTimeSecs("3"); instance.setErrorRate("0"); instance.sampleOccurred(se); for (int n = 0; n < 5; n++) { synchronized (this) { wait(1000); } instance.sampleOccurred(se); } }
@Override public void sampleOccurred(SampleEvent se) { long sec = System.currentTimeMillis() / 1000; if (curSec != sec) { if (testValueRespTime > 0) { if (avgRespTime.getValue() > testValueRespTime) { if (sec - respTimeExceededStart >= testValueRespTimeSec) { log.info("Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respTimeExceededStart = sec; } } if (testValueRespLatency > 0) { if (avgRespLatency.getValue() > testValueRespLatency) { if (sec - respLatencyExceededStart >= testValueRespLatencySec) { log.info("Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respLatencyExceededStart = sec; } } if (testValueError > 0) { if (errorRate.getValue() > testValueError) { if (sec - errRateExceededStart >= testValueErrorSec) { log.info("Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { errRateExceededStart = sec; } } curSec = sec; avgRespTime = new GraphPanelChartAverageElement(); avgRespLatency = new GraphPanelChartAverageElement(); errorRate = new GraphPanelChartAverageElement(); } avgRespTime.add(se.getResult().getTime()); avgRespLatency.add(se.getResult().getLatency()); errorRate.add(se.getResult().isSuccessful() ? 0 : 1); }
AutoStop extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent se) { long sec = System.currentTimeMillis() / 1000; if (curSec != sec) { if (testValueRespTime > 0) { if (avgRespTime.getValue() > testValueRespTime) { if (sec - respTimeExceededStart >= testValueRespTimeSec) { log.info("Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respTimeExceededStart = sec; } } if (testValueRespLatency > 0) { if (avgRespLatency.getValue() > testValueRespLatency) { if (sec - respLatencyExceededStart >= testValueRespLatencySec) { log.info("Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respLatencyExceededStart = sec; } } if (testValueError > 0) { if (errorRate.getValue() > testValueError) { if (sec - errRateExceededStart >= testValueErrorSec) { log.info("Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { errRateExceededStart = sec; } } curSec = sec; avgRespTime = new GraphPanelChartAverageElement(); avgRespLatency = new GraphPanelChartAverageElement(); errorRate = new GraphPanelChartAverageElement(); } avgRespTime.add(se.getResult().getTime()); avgRespLatency.add(se.getResult().getLatency()); errorRate.add(se.getResult().isSuccessful() ? 0 : 1); } }
AutoStop extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent se) { long sec = System.currentTimeMillis() / 1000; if (curSec != sec) { if (testValueRespTime > 0) { if (avgRespTime.getValue() > testValueRespTime) { if (sec - respTimeExceededStart >= testValueRespTimeSec) { log.info("Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respTimeExceededStart = sec; } } if (testValueRespLatency > 0) { if (avgRespLatency.getValue() > testValueRespLatency) { if (sec - respLatencyExceededStart >= testValueRespLatencySec) { log.info("Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respLatencyExceededStart = sec; } } if (testValueError > 0) { if (errorRate.getValue() > testValueError) { if (sec - errRateExceededStart >= testValueErrorSec) { log.info("Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { errRateExceededStart = sec; } } curSec = sec; avgRespTime = new GraphPanelChartAverageElement(); avgRespLatency = new GraphPanelChartAverageElement(); errorRate = new GraphPanelChartAverageElement(); } avgRespTime.add(se.getResult().getTime()); avgRespLatency.add(se.getResult().getLatency()); errorRate.add(se.getResult().isSuccessful() ? 0 : 1); } AutoStop(); }
AutoStop extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent se) { long sec = System.currentTimeMillis() / 1000; if (curSec != sec) { if (testValueRespTime > 0) { if (avgRespTime.getValue() > testValueRespTime) { if (sec - respTimeExceededStart >= testValueRespTimeSec) { log.info("Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respTimeExceededStart = sec; } } if (testValueRespLatency > 0) { if (avgRespLatency.getValue() > testValueRespLatency) { if (sec - respLatencyExceededStart >= testValueRespLatencySec) { log.info("Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respLatencyExceededStart = sec; } } if (testValueError > 0) { if (errorRate.getValue() > testValueError) { if (sec - errRateExceededStart >= testValueErrorSec) { log.info("Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { errRateExceededStart = sec; } } curSec = sec; avgRespTime = new GraphPanelChartAverageElement(); avgRespLatency = new GraphPanelChartAverageElement(); errorRate = new GraphPanelChartAverageElement(); } avgRespTime.add(se.getResult().getTime()); avgRespLatency.add(se.getResult().getLatency()); errorRate.add(se.getResult().isSuccessful() ? 0 : 1); } AutoStop(); @Override void sampleOccurred(SampleEvent se); @Override void sampleStarted(SampleEvent se); @Override void sampleStopped(SampleEvent se); @Override void testStarted(); @Override void testStarted(String string); @Override void testEnded(); @Override void testEnded(String string); }
AutoStop extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent se) { long sec = System.currentTimeMillis() / 1000; if (curSec != sec) { if (testValueRespTime > 0) { if (avgRespTime.getValue() > testValueRespTime) { if (sec - respTimeExceededStart >= testValueRespTimeSec) { log.info("Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Response Time is more than " + getResponseTime() + " for " + getResponseTimeSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respTimeExceededStart = sec; } } if (testValueRespLatency > 0) { if (avgRespLatency.getValue() > testValueRespLatency) { if (sec - respLatencyExceededStart >= testValueRespLatencySec) { log.info("Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Average Latency Time is more than " + getResponseLatency() + " for " + getResponseLatencySecs() + "s. Auto-shutdown test..."); stopTest(); } } else { respLatencyExceededStart = sec; } } if (testValueError > 0) { if (errorRate.getValue() > testValueError) { if (sec - errRateExceededStart >= testValueErrorSec) { log.info("Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); System.out.println("AutoStop - Error rate more than " + getErrorRate() + " for " + getErrorRateSecs() + "s. Auto-shutdown test..."); stopTest(); } } else { errRateExceededStart = sec; } } curSec = sec; avgRespTime = new GraphPanelChartAverageElement(); avgRespLatency = new GraphPanelChartAverageElement(); errorRate = new GraphPanelChartAverageElement(); } avgRespTime.add(se.getResult().getTime()); avgRespLatency.add(se.getResult().getLatency()); errorRate.add(se.getResult().isSuccessful() ? 0 : 1); } AutoStop(); @Override void sampleOccurred(SampleEvent se); @Override void sampleStarted(SampleEvent se); @Override void sampleStopped(SampleEvent se); @Override void testStarted(); @Override void testStarted(String string); @Override void testEnded(); @Override void testEnded(String string);  }