This is an automated email from the ASF dual-hosted git repository. vladimirsitnikov pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jmeter.git
commit bf02362adca5d75f66525fde6fde4c98a05b2d2b Author: Vladimir Sitnikov <[email protected]> AuthorDate: Mon Nov 24 11:02:16 2025 +0500 feat: add ConstantThroughputTimerSchema and use it in ConstantThroughputTimer --- .../java/org/apache/jmeter/config/CSVDataSet.java | 52 +++++++++++---- .../apache/jmeter/config/CSVDataSetBeanInfo.java | 21 +----- .../jmeter/timers/ConstantThroughputTimer.java | 76 ++++++++++++++-------- .../timers/ConstantThroughputTimerBeanInfo.java | 10 ++- .../jmeter/timers/ConstantThroughputTimerSchema.kt | 39 +++++++++++ .../ConstantThroughputTimerResources.properties | 2 +- .../ConstantThroughputTimerResources_de.properties | 2 +- .../ConstantThroughputTimerResources_es.properties | 2 +- .../ConstantThroughputTimerResources_fr.properties | 2 +- .../ConstantThroughputTimerResources_ko.properties | 2 +- ...nstantThroughputTimerResources_pt_BR.properties | 2 +- .../ConstantThroughputTimerResources_tr.properties | 2 +- ...nstantThroughputTimerResources_zh_CN.properties | 2 +- .../jmeter/timers/ConstantThroughputTimerTest.java | 14 +++- 14 files changed, 156 insertions(+), 72 deletions(-) diff --git a/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java b/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java index d641edc2e8..05f5f8f6f0 100644 --- a/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java +++ b/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java @@ -29,13 +29,14 @@ import org.apache.jmeter.services.FileServer; import org.apache.jmeter.testbeans.TestBean; import org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer; import org.apache.jmeter.testelement.property.JMeterProperty; -import org.apache.jmeter.testelement.property.StringProperty; import org.apache.jmeter.threads.JMeterContext; import org.apache.jmeter.threads.JMeterVariables; import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.util.EnumUtils; import org.apache.jorphan.util.JMeterStopThreadException; import org.apache.jorphan.util.JOrphanUtils; import org.apache.jorphan.util.StringUtilities; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,6 +69,24 @@ import org.slf4j.LoggerFactory; @TestElementMetadata(labelResource = "displayName") public class CSVDataSet extends ConfigTestElement implements TestBean, LoopIterationListener, NoConfigMerge { + + public enum ShareMode { + ALL("shareMode.all"), + GROUP("shareMode.group"), + THREAD("shareMode.thread"); + + private final String value; + + ShareMode(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + } + private static final Logger log = LoggerFactory.getLogger(CSVDataSet.class); private static final long serialVersionUID = 233L; @@ -119,9 +138,10 @@ public class CSVDataSet extends ConfigTestElement public void setProperty(JMeterProperty property) { String propName = property.getName(); if ("shareMode".equals(propName)) { - String enumLabel = GenericTestBeanCustomizer.normalizeEnumStringValue(getClass(), CSVDataSetBeanInfo.ShareMode.class, property); - if (enumLabel != null && (!(property instanceof StringProperty) || !enumLabel.equals(property.getStringValue()))) { - super.setProperty(propName, enumLabel); + JMeterProperty shareMode = + GenericTestBeanCustomizer.normalizeEnumProperty(getClass(), ShareMode.class, property); + if (shareMode != null) { + super.setProperty(shareMode); return; } } @@ -193,13 +213,15 @@ public class CSVDataSet extends ConfigTestElement } private void setAlias(final JMeterContext context, String alias) { - String mode = getShareMode(); - int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode); - this.alias = switch(modeInt){ - case CSVDataSetBeanInfo.SHARE_ALL -> alias; - case CSVDataSetBeanInfo.SHARE_GROUP -> alias + "@" + System.identityHashCode(context.getThreadGroup()); - case CSVDataSetBeanInfo.SHARE_THREAD -> alias + "@" + System.identityHashCode(context.getThread()); - default -> alias + "@" + mode; // user-specified key + ShareMode modeEnum = getShareModeAsEnum(); + if (modeEnum == null) { + this.alias = alias + "@" + getShareMode(); // user-specified key + return; + } + this.alias = switch (modeEnum) { + case ALL -> alias; + case GROUP -> alias + "@" + System.identityHashCode(context.getThreadGroup()); + case THREAD -> alias + "@" + System.identityHashCode(context.getThread()); }; } @@ -294,6 +316,14 @@ public class CSVDataSet extends ConfigTestElement return shareMode; } + @Nullable ShareMode getShareModeAsEnum() { + String shareMode = getShareMode(); + if (shareMode == null) { + return null; + } + return GenericTestBeanCustomizer.normalizeEnumStringValue(shareMode, getClass(), ShareMode.class); + } + public void setShareMode(String value) { this.shareMode = value; } diff --git a/src/components/src/main/java/org/apache/jmeter/config/CSVDataSetBeanInfo.java b/src/components/src/main/java/org/apache/jmeter/config/CSVDataSetBeanInfo.java index cdd0dccc04..15c27b60b4 100644 --- a/src/components/src/main/java/org/apache/jmeter/config/CSVDataSetBeanInfo.java +++ b/src/components/src/main/java/org/apache/jmeter/config/CSVDataSetBeanInfo.java @@ -39,31 +39,12 @@ public class CSVDataSetBeanInfo extends BeanInfoSupport { private static final String QUOTED_DATA = "quotedData"; //$NON-NLS-1$ private static final String SHAREMODE = "shareMode"; //$NON-NLS-1$ - // Access needed from CSVDataSet - enum ShareMode { - ALL("shareMode.all"), - GROUP("shareMode.group"), - THREAD("shareMode.thread"); - - private final String value; - - ShareMode(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } - } private static final String[] SHARE_TAGS = new String[3]; static final int SHARE_ALL = 0; - static final int SHARE_GROUP = 1; - static final int SHARE_THREAD = 2; // Store the resource keys static { - for (ShareMode value : ShareMode.values()) { + for (CSVDataSet.ShareMode value : CSVDataSet.ShareMode.values()) { @SuppressWarnings("EnumOrdinal") int index = value.ordinal(); SHARE_TAGS[index] = value.toString(); diff --git a/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimer.java b/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimer.java index 2834eebc46..21a6edb7ae 100644 --- a/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimer.java +++ b/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimer.java @@ -26,23 +26,26 @@ import org.apache.jmeter.gui.TestElementMetadata; import org.apache.jmeter.testbeans.TestBean; import org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer; import org.apache.jmeter.testelement.AbstractTestElement; -import org.apache.jmeter.testelement.property.DoubleProperty; -import org.apache.jmeter.testelement.property.IntegerProperty; import org.apache.jmeter.testelement.property.JMeterProperty; -import org.apache.jmeter.testelement.property.StringProperty; +import org.apache.jmeter.testelement.schema.PropertiesAccessor; import org.apache.jmeter.threads.AbstractThreadGroup; import org.apache.jmeter.threads.JMeterContextService; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.collections.IdentityKey; +import org.apache.jorphan.util.EnumUtils; +import org.apiguardian.api.API; /** * This class implements a constant throughput timer. A Constant Throughput * Timer paces the samplers under its influence so that the total number of * samples per unit of time approaches a given constant as much as possible. * + * <p> * There are two different ways of pacing the requests: - * - delay each thread according to when it last ran - * - delay each thread according to when any thread last ran + * <ul> + * <li>delay each thread according to when it last ran</li> + * <li>delay each thread according to when any thread last ran</li> + * </ul> */ @GUIMenuSortOrder(4) @TestElementMetadata(labelResource = "displayName") @@ -62,6 +65,8 @@ public class ConstantThroughputTimer extends AbstractTestElement implements Time // TODO: most props use class simpleName as prefix but that would break backward compatiblity here public static final String THROUGHPUT = "throughput"; public static final String CALC_MODE = "calcMode"; + @API(status = API.Status.INTERNAL, since = "6.0.0") + public static final String MODE = "mode"; /** * This enum defines the calculation modes used by the ConstantThroughputTimer. @@ -75,8 +80,6 @@ public class ConstantThroughputTimer extends AbstractTestElement implements Time ; private final String propertyName; // The property name to be used to look up the display string - // Enum#values() clones the array, and we don't want to pay that cost as we know we don't modify the array - private static final Mode[] CACHED_VALUES = values(); Mode(String name) { this.propertyName = name; @@ -108,6 +111,16 @@ public class ConstantThroughputTimer extends AbstractTestElement implements Time public ConstantThroughputTimer() { } + @Override + public ConstantThroughputTimerSchema getSchema() { + return ConstantThroughputTimerSchema.INSTANCE; + } + + @Override + public PropertiesAccessor<? extends ConstantThroughputTimer, ? extends ConstantThroughputTimerSchema> getProps() { + return new PropertiesAccessor<>(this, getSchema()); + } + /** * Sets the desired throughput. * @@ -115,7 +128,7 @@ public class ConstantThroughputTimer extends AbstractTestElement implements Time * Desired sampling rate, in samples per minute. */ public void setThroughput(double throughput) { - setProperty(new DoubleProperty(THROUGHPUT, throughput)); + getSchema().getThroughput().set(this, throughput); } /** @@ -124,18 +137,39 @@ public class ConstantThroughputTimer extends AbstractTestElement implements Time * @return the rate at which samples should occur, in samples per minute. */ public double getThroughput() { - return getPropertyAsDouble(THROUGHPUT); + return getSchema().getThroughput().get(this); } + @Deprecated @SuppressWarnings("EnumOrdinal") public int getCalcMode() { - return getPropertyAsInt(CALC_MODE, DEFAULT_CALC_MODE.ordinal()); + Mode mode = getMode(); + if (mode == null) { + mode = DEFAULT_CALC_MODE; + } + return mode.ordinal(); + } + + @API(status = API.Status.MAINTAINED, since = "6.0.0") + public Mode getMode() { + String value = getSchema().getCalcMode().get(this); + Mode enumValue = EnumUtils.valueOf(Mode.class, value); + if (enumValue != null) { + return enumValue; + } + return DEFAULT_CALC_MODE; } + @Deprecated @SuppressWarnings("EnumOrdinal") public void setCalcMode(int mode) { - Mode resolved = Mode.CACHED_VALUES[mode]; - setProperty(new IntegerProperty(CALC_MODE, resolved.ordinal())); + setMode(EnumUtils.values(Mode.class).get(mode)); + } + + @SuppressWarnings("EnumOrdinal") + @API(status = API.Status.MAINTAINED, since = "6.0.0") + public void setMode(Mode newMode) { + getSchema().getCalcMode().set(this, newMode.toString()); } /** @@ -266,24 +300,12 @@ public class ConstantThroughputTimer extends AbstractTestElement implements Time public void setProperty(JMeterProperty property) { String propertyName = property.getName(); if (propertyName.equals("calcMode")) { - String enumLabel = GenericTestBeanCustomizer.normalizeEnumStringValue(getClass(), Mode.class, property); - if (enumLabel != null && (!(property instanceof StringProperty) || !enumLabel.equals(property.getStringValue()))) { - super.setProperty(propertyName, enumLabel); + JMeterProperty mode = GenericTestBeanCustomizer.normalizeEnumProperty(getClass(), Mode.class, property); + if (mode != null) { + super.setProperty(mode); return; } } super.setProperty(property); } - - // For access from test code - Mode getMode() { - int mode = getCalcMode(); - return Mode.CACHED_VALUES[mode]; - } - - // For access from test code - @SuppressWarnings("EnumOrdinal") - void setMode(Mode newMode) { - setCalcMode(newMode.ordinal()); - } } diff --git a/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java b/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java index 0288460bb3..4f75ceaa70 100644 --- a/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java +++ b/src/components/src/main/java/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java @@ -32,14 +32,18 @@ public class ConstantThroughputTimerBeanInfo extends BeanInfoSupport { createPropertyGroup("delay", //$NON-NLS-1$ new String[] { ConstantThroughputTimer.THROUGHPUT, //$NON-NLS-1$ - ConstantThroughputTimer.CALC_MODE }); //$NON-NLS-1$ + ConstantThroughputTimer.MODE }); //$NON-NLS-1$ PropertyDescriptor p = property(ConstantThroughputTimer.THROUGHPUT); //$NON-NLS-1$ p.setValue(NOT_UNDEFINED, true); p.setValue(DEFAULT, 0.0); - p = property(ConstantThroughputTimer.CALC_MODE, ConstantThroughputTimer.Mode.class); //$NON-NLS-1$ - p.setValue(DEFAULT, ConstantThroughputTimer.Mode.ThisThreadOnly.ordinal()); + // Hide old parameter that used index (setCalcMode(int); int getCalcMode()) + p = property(ConstantThroughputTimer.CALC_MODE); + p.setHidden(true); + + p = property(ConstantThroughputTimer.MODE, ConstantThroughputTimer.Mode.class); //$NON-NLS-1$ + p.setValue(DEFAULT, ConstantThroughputTimer.Mode.ThisThreadOnly); p.setValue(NOT_UNDEFINED, true); // must be defined } diff --git a/src/components/src/main/kotlin/org/apache/jmeter/timers/ConstantThroughputTimerSchema.kt b/src/components/src/main/kotlin/org/apache/jmeter/timers/ConstantThroughputTimerSchema.kt new file mode 100644 index 0000000000..865e1b21b7 --- /dev/null +++ b/src/components/src/main/kotlin/org/apache/jmeter/timers/ConstantThroughputTimerSchema.kt @@ -0,0 +1,39 @@ +/* + * 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.testelement.TestElementSchema +import org.apache.jmeter.testelement.schema.DoublePropertyDescriptor +import org.apache.jmeter.testelement.schema.StringPropertyDescriptor +import org.apiguardian.api.API + +/** + * Lists properties of a [ConstantThroughputTimer]. + * @see ConstantThroughputTimer + * @since 6.0 + */ +@API(status = API.Status.EXPERIMENTAL, since = "6.0.0") +public abstract class ConstantThroughputTimerSchema : TestElementSchema() { + public companion object INSTANCE : ConstantThroughputTimerSchema() + + public val throughput: DoublePropertyDescriptor<ConstantThroughputTimerSchema> + by double("throughput") + + public val calcMode: StringPropertyDescriptor<ConstantThroughputTimerSchema> + by string("calcMode") +} diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources.properties index 13851ae9e7..eb9a4e3439 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources.properties @@ -20,7 +20,7 @@ calcMode.2=all active threads calcMode.3=all active threads in current thread group calcMode.4=all active threads (shared) calcMode.5=all active threads in current thread group (shared) -calcMode.displayName=Calculate Throughput based on +mode.displayName=Calculate Throughput based on calcMode.shortDescription=The Constant Throughput Timer used to delay each thread as though it was the only thread in the test. Now, it calculates the delay taking into account the number of active threads in the test or the thread group. delay.displayName=Delay before each affected sampler displayName=Constant Throughput Timer diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_de.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_de.properties index 314e49a21d..feef94cda3 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_de.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_de.properties @@ -20,7 +20,7 @@ calcMode.2=Alle aktiven Threads calcMode.3=Alle aktiven Threads in der aktuellen Thread-Gruppe calcMode.4=Alle aktiven Threads (Gemeinsam) calcMode.5=Alle aktiven Threads in der aktuellen Thread-Gruppe (gemeinsam) -calcMode.displayName=Berechne Durchsatz basierend auf +mode.displayName=Berechne Durchsatz basierend auf calcMode.shortDescription=Es war der einzige Thread im Test. Nun wird die Pause unter Berücksichtigung der aktiven Threads oder der Thread-Gruppe berechnet. delay.displayName=Pause bevor eine Probe genommen wird displayName=Konstanter Durchsatz-Timer (Zeitgeber) diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_es.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_es.properties index e565d811f3..62dde978fd 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_es.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_es.properties @@ -19,7 +19,7 @@ calcMode.1=solamente este hilo calcMode.2=todos los hilos activos calcMode.3=todos los hilos activos en el grupo de hilos actual -calcMode.displayName=Calcular el rendimiento basado en +mode.displayName=Calcular el rendimiento basado en calcMode.shortDescription=El Temporizador para Rendimiento Constante introducía un retardo como si este fuera el unico hilo en la prueba. Ahora calcula el retardo teniendo en cuenta el número de hilos activos en la prueba o el grupo de hilos. delay.displayName=Retardo antes de cada muestreador afectado displayName=Temporizador de Rendimiento Constante diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_fr.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_fr.properties index 4cf3190c06..c122320e3e 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_fr.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_fr.properties @@ -20,7 +20,7 @@ calcMode.2=toutes les unités actives calcMode.3=toutes les unités actives dans le groupe d'unités courant calcMode.4=toutes les unités actives (partagé) calcMode.5=toutes les unités actives dans le groupe d'unités courant (partagé) -calcMode.displayName=Calculer le débit sur la base de +mode.displayName=Calculer le débit sur la base de calcMode.shortDescription=Compteur de temps utilisé par le Compteur de débit constant pour décaler chaque thread comme s'il était le seul dans le test. Maintenant, le délai est calculé en prenant en compte le nombre de threads actifs dans le test ou le groupe d'unités. delay.displayName=Délai avant chaque échantillon affecté displayName=Compteur de débit constant diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_ko.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_ko.properties index 17ad6bcd8c..04728f1639 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_ko.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_ko.properties @@ -20,7 +20,7 @@ calcMode.2=모든 활성화된 쓰레드들 calcMode.3=현 쓰레드 그룹 내의 모든 활성화된 쓰레드들 calcMode.4=모드 활성화된 쓰레드들 (공유) calcMode.5=현 쓰레드 그룹 내의 모든 활성화된 쓰레드들 (공유) -calcMode.displayName=처리량을 다음에 기반하여\: +mode.displayName=처리량을 다음에 기반하여\: calcMode.shortDescription=상수 처리량 타이머는, 마치 테스트에 단 하나의 쓰레드만 있는 것마냥, 각 쓰레드를 지연시키기 위해 사용됩니다. 단 실제 계산 시에는 전체 테스트 또는 쓰레드 그룹에 존재하는 활성화된 쓰레드들의 갯수를 고려하여 계산합니다. delay.displayName=영향을 받는 각 표본추출기 직전에 지연 displayName=상수 처리량 타이머 diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_pt_BR.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_pt_BR.properties index a3d0b2d90e..6a9d12b97c 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_pt_BR.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_pt_BR.properties @@ -20,7 +20,7 @@ calcMode.2=todos usuários virtuais (threads) ativos calcMode.3=todos usuários virtuais ativos no grupo de usuários corrente calcMode.4=todos usuários virtuais ativos (compartilhado) calcMode.5=todos usuários virtuais no grupo de usuários atual (compartillhado) -calcMode.displayName=Calcular Vazão baseada em +mode.displayName=Calcular Vazão baseada em calcMode.shortDescription=O Temporizador de Vazão Constante era usado para atrasar cada usuário virtual como se ele fosse o único usuário virtual no teste. Agora, ele calcula o atraso levando em consideração o número de usuários virtuais ativos no teste ou no grupo de usuários. delay.displayName=Atraso antes de cada testador afetado displayName=Temporizador de Vazão Constante diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_tr.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_tr.properties index 7b230d2d26..4ee091bae3 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_tr.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_tr.properties @@ -21,7 +21,7 @@ calcMode.2=bütün aktif iş parçacıkları calcMode.3=bu iş parçacığı grubundaki tüm aktif iş parçacıkları calcMode.4=tüm iş parçacıkları (paylaşımlı) calcMode.5=bu iş paçacığı grubundaki tüm aktif iş parçacıkları (paylaşımlı) -calcMode.displayName=transfer oranı hesabının yapılacağı temel +mode.displayName=transfer oranı hesabının yapılacağı temel calcMode.shortDescription=Sabit Transfer Oranı Zamanlayıcı eskiden her bir iş parçacığı için, testteki tek iş parçacığıymışcasına gecikirken; şimdi gecikme hesabı testteki veya iş parçacığı grubundaki aktif iş parçacığı sayısına göre yapılmakta. delay.displayName=Etkilenen her örnekleyiciden önce gecikme displayName=Sabit Transfer Oranı Zamanlayıcı diff --git a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_zh_CN.properties b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_zh_CN.properties index e541a0a3a3..4da2ad9509 100644 --- a/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_zh_CN.properties +++ b/src/components/src/main/resources/org/apache/jmeter/timers/ConstantThroughputTimerResources_zh_CN.properties @@ -21,7 +21,7 @@ calcMode.2=所有活动线程 calcMode.3=当前线程组中的所有活动线程 calcMode.4=所有活动线程(共享) calcMode.5=当前线程组中的所有活动线程(共享) -calcMode.displayName=基于计算吞吐量 +mode.displayName=基于计算吞吐量 calcMode.shortDescription=用于延迟每个线程的恒定吞吐量定时器,就好像它是测试中唯一的线程一样。现在,它根据测试或线程组的活动线程的数量计算延迟。 delay.displayName=在每个受影响的采样器之前延迟 displayName=常数吞吐量定时器 diff --git a/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java b/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java index 38e6e511fc..640e6fa9f5 100644 --- a/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java +++ b/src/components/src/test/java/org/apache/jmeter/timers/ConstantThroughputTimerTest.java @@ -34,7 +34,10 @@ class ConstantThroughputTimerTest { @Test void testTimer1() throws Exception { ConstantThroughputTimer timer = new ConstantThroughputTimer(); - assertEquals(0, timer.getCalcMode());// Assume this thread only + @SuppressWarnings("deprecation") + int calcMode = timer.getCalcMode(); + assertEquals(0, calcMode);// Assume this thread only + assertEquals(ConstantThroughputTimer.Mode.ThisThreadOnly, timer.getMode());// Assume this thread only timer.setThroughput(60.0);// 1 per second long start = System.currentTimeMillis(); long delay = timer.delay(); // Initialise @@ -64,7 +67,9 @@ class ConstantThroughputTimerTest { @Test void testTimer2() throws Exception { ConstantThroughputTimer timer = new ConstantThroughputTimer(); - assertEquals(0, timer.getCalcMode());// Assume this thread only + @SuppressWarnings("deprecation") + int calcMode = timer.getCalcMode(); + assertEquals(0, calcMode);// Assume this thread only timer.setThroughput(60.0);// 1 per second assertEquals(1000, timer.calculateCurrentTarget(0)); // Should delay for 1 second timer.setThroughput(60000.0);// 1 per milli-second @@ -75,7 +80,10 @@ class ConstantThroughputTimerTest { void testTimer3() throws Exception { ConstantThroughputTimer timer = new ConstantThroughputTimer(); timer.setMode(ConstantThroughputTimer.Mode.AllActiveThreads); //$NON-NLS-1$ - all threads - assertEquals(1, timer.getCalcMode());// All threads + @SuppressWarnings("deprecation") + int calcMode = timer.getCalcMode(); + assertEquals(1, calcMode);// All threads + assertEquals(ConstantThroughputTimer.Mode.AllActiveThreads, timer.getMode());// All threads for(int i=1; i<=10; i++){ TestJMeterContextService.incrNumberOfThreads(); }
