You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2018/08/22 15:29:50 UTC
svn commit: r1838648 - in /jmeter/trunk:
src/components/org/apache/jmeter/timers/SyncTimer.java
test/src/org/apache/jmeter/timers/SyncTimerSpec.groovy xdocs/changes.xml
Author: fschumacher
Date: Wed Aug 22 15:29:50 2018
New Revision: 1838648
URL: http://svn.apache.org/viewvc?rev=1838648&view=rev
Log:
Take scheduler into account when calcuting delay for Synchronizing Timer
Bugzilla Id: 62637
Added:
jmeter/trunk/test/src/org/apache/jmeter/timers/SyncTimerSpec.groovy (with props)
Modified:
jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java?rev=1838648&r1=1838647&r2=1838648&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java Wed Aug 22 15:29:50 2018
@@ -171,14 +171,17 @@ public class SyncTimer extends AbstractT
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()) {
Added: jmeter/trunk/test/src/org/apache/jmeter/timers/SyncTimerSpec.groovy
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/timers/SyncTimerSpec.groovy?rev=1838648&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/timers/SyncTimerSpec.groovy (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/timers/SyncTimerSpec.groovy Wed Aug 22 15:29:50 2018
@@ -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
+ }
+
+}
\ No newline at end of file
Propchange: jmeter/trunk/test/src/org/apache/jmeter/timers/SyncTimerSpec.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1838648&r1=1838647&r2=1838648&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Wed Aug 22 15:29:50 2018
@@ -227,6 +227,7 @@ this behaviour, set <code>httpclient.res
<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>