mirror of https://github.com/apache/jmeter.git
Take scheduler into account when calcuting delay for Synchronizing Timer
Bugzilla Id: 62637
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1838648 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: 42d5a9f509
This commit is contained in:
parent
80c06fe50e
commit
d7e3eaa91b
|
|
@ -171,14 +171,17 @@ public class SyncTimer extends AbstractTestElement implements Timer, Serializabl
|
|||
if(getGroupSize()>=0) {
|
||||
int arrival = 0;
|
||||
try {
|
||||
if(timeoutInMs==0) {
|
||||
arrival = this.barrier.await();
|
||||
} else if(timeoutInMs > 0){
|
||||
arrival = this.barrier.await(timeoutInMs, TimeUnit.MILLISECONDS);
|
||||
if (timeoutInMs == 0) {
|
||||
arrival = this.barrier.await(TimerService.getInstance().adjustDelay(Long.MAX_VALUE), TimeUnit.MILLISECONDS);
|
||||
} else if (timeoutInMs > 0) {
|
||||
arrival = this.barrier.await(TimerService.getInstance().adjustDelay(timeoutInMs), TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Negative value for timeout:"+timeoutInMs+" in Synchronizing Timer "+getName());
|
||||
}
|
||||
} catch (InterruptedException | BrokenBarrierException e) {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return 0;
|
||||
} catch (BrokenBarrierException e) {
|
||||
return 0;
|
||||
} catch (TimeoutException e) {
|
||||
if (log.isWarnEnabled()) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.jmeter.timers
|
||||
|
||||
import org.apache.jmeter.threads.JMeterContext
|
||||
import org.apache.jmeter.threads.JMeterContextService
|
||||
import org.apache.jmeter.threads.JMeterThread
|
||||
|
||||
import spock.lang.Specification
|
||||
|
||||
class SyncTimerSpec extends Specification {
|
||||
|
||||
def "timer with scheduled end point"() {
|
||||
setup:
|
||||
def timer = new SyncTimer()
|
||||
def context = Stub(JMeterContext)
|
||||
def thread = Stub(JMeterThread)
|
||||
|
||||
thread.getEndTime() >> System.currentTimeMillis() + 100L
|
||||
context.getThread() >> thread
|
||||
|
||||
JMeterContextService.replaceContext(context)
|
||||
timer.groupSize = 2
|
||||
timer.testStarted()
|
||||
when:
|
||||
def start = System.currentTimeMillis();
|
||||
def delay = timer.delay()
|
||||
def elapsed = System.currentTimeMillis() - start
|
||||
then:
|
||||
delay == 0
|
||||
elapsed < 10 * 100L
|
||||
}
|
||||
|
||||
def "timer with scheduled end point and shorter max timeout in ms"() {
|
||||
setup:
|
||||
def timer = new SyncTimer()
|
||||
timer.setTimeoutInMs(100L)
|
||||
def context = Stub(JMeterContext)
|
||||
def thread = Stub(JMeterThread)
|
||||
|
||||
thread.getEndTime() >> System.currentTimeMillis() + 2000L
|
||||
context.getThread() >> thread
|
||||
|
||||
JMeterContextService.replaceContext(context)
|
||||
timer.groupSize = 2
|
||||
timer.testStarted()
|
||||
when:
|
||||
def start = System.currentTimeMillis();
|
||||
def delay = timer.delay()
|
||||
def elapsed = System.currentTimeMillis() - start
|
||||
then:
|
||||
delay == 0
|
||||
elapsed < 10 * 100L
|
||||
}
|
||||
|
||||
def "timer with scheduled end point and longer max timeout in ms"() {
|
||||
setup:
|
||||
def timer = new SyncTimer()
|
||||
timer.setTimeoutInMs(2000L)
|
||||
def context = Stub(JMeterContext)
|
||||
def thread = Stub(JMeterThread)
|
||||
|
||||
thread.getEndTime() >> System.currentTimeMillis() + 100L
|
||||
context.getThread() >> thread
|
||||
|
||||
JMeterContextService.replaceContext(context)
|
||||
timer.groupSize = 2
|
||||
timer.testStarted()
|
||||
when:
|
||||
def start = System.currentTimeMillis();
|
||||
def delay = timer.delay()
|
||||
def elapsed = System.currentTimeMillis() - start
|
||||
then:
|
||||
delay == 0
|
||||
elapsed < 10 * 100L
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -227,6 +227,7 @@ this behaviour, set <code>httpclient.reset_state_on_thread_group_iteration=false
|
|||
<li><bug>62252</bug>HTTP header merging logic does not correspond to the documentation</li>
|
||||
<li><bug>62554</bug>BoundaryExtractor : Field to check is not reset</li>
|
||||
<li><bug>62553</bug>Random element might return same value even if property "Per thread user (User)" is set to TRUE</li>
|
||||
<li><bug>62637</bug>Take scheduler into account when calcuting delay for Synchronizing Timer</li>
|
||||
</ul>
|
||||
|
||||
<h3>Functions</h3>
|
||||
|
|
|
|||
Loading…
Reference in New Issue