You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/01/16 20:07:02 UTC
svn commit: r1779097 - in /jmeter/trunk:
src/components/org/apache/jmeter/thinktime/
src/core/org/apache/jmeter/gui/action/
src/core/org/apache/jmeter/gui/action/thinktime/
src/core/org/apache/jmeter/gui/util/ src/core/org/apache/jmeter/resources/
src/...
Author: pmouawad
Date: Mon Jan 16 20:07:01 2017
New Revision: 1779097
URL: http://svn.apache.org/viewvc?rev=1779097&view=rev
Log:
Bug 58943 - Create a Better Think Time experience
Contributed by UbikLoadPack
Bugzilla Id: 58943
Added:
jmeter/trunk/src/components/org/apache/jmeter/thinktime/
jmeter/trunk/src/components/org/apache/jmeter/thinktime/DefaultThinkTimeCreator.java (with props)
jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java (with props)
jmeter/trunk/src/core/org/apache/jmeter/gui/action/thinktime/
jmeter/trunk/src/core/org/apache/jmeter/gui/action/thinktime/ThinkTimeCreator.java (with props)
Modified:
jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java
jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/properties_reference.xml
Added: jmeter/trunk/src/components/org/apache/jmeter/thinktime/DefaultThinkTimeCreator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/thinktime/DefaultThinkTimeCreator.java?rev=1779097&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/thinktime/DefaultThinkTimeCreator.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/thinktime/DefaultThinkTimeCreator.java Mon Jan 16 20:07:01 2017
@@ -0,0 +1,83 @@
+/*
+ * 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.thinktime;
+
+import org.apache.jmeter.exceptions.IllegalUserActionException;
+import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.gui.action.thinktime.ThinkTimeCreator;
+import org.apache.jmeter.gui.tree.JMeterTreeNode;
+import org.apache.jmeter.sampler.TestAction;
+import org.apache.jmeter.sampler.gui.TestActionGui;
+import org.apache.jmeter.timers.RandomTimer;
+import org.apache.jmeter.timers.gui.UniformRandomTimerGui;
+import org.apache.jmeter.util.JMeterUtils;
+
+/**
+ * Default implementation of {@link ThinkTimeCreator}
+ * @since 3.2
+ */
+public class DefaultThinkTimeCreator implements ThinkTimeCreator {
+ private static final String DEFAULT_TIMER_IMPLEMENTATION =
+ JMeterUtils.getPropDefault(
+ "think_time_creator.default_timer_implementation",
+ UniformRandomTimerGui.class.getName());
+
+ private static final String DEFAULT_PAUSE =
+ JMeterUtils.getPropDefault(
+ "think_time_creator.default_constant_pause",
+ "1000");
+
+ private static final String DEFAULT_RANGE =
+ JMeterUtils.getPropDefault(
+ "think_time_creator.default_range",
+ "100");
+
+ /**
+ */
+ public DefaultThinkTimeCreator() {
+ super();
+ }
+
+ /**
+ *
+ * @param guiPackage {@link GuiPackage}
+ * @param parentNode {@link JMeterTreeNode}
+ * @return array of {@link JMeterTreeNode}
+ * @throws IllegalUserActionException
+ */
+ @Override
+ public JMeterTreeNode[] createThinkTime(GuiPackage guiPackage, JMeterTreeNode parentNode)
+ throws IllegalUserActionException {
+ TestAction testAction = (TestAction) guiPackage.createTestElement(TestActionGui.class.getName());
+ testAction.setAction(TestAction.PAUSE);
+ testAction.setDuration("0");
+ JMeterTreeNode thinkTimeNode = new JMeterTreeNode(testAction, guiPackage.getTreeModel());
+ thinkTimeNode.setName("Think Time");
+ RandomTimer randomTimer = (RandomTimer)
+ guiPackage.createTestElement(DEFAULT_TIMER_IMPLEMENTATION);
+ randomTimer.setDelay(DEFAULT_PAUSE);
+ randomTimer.setRange(DEFAULT_RANGE);
+ randomTimer.setName("Pause");
+
+ JMeterTreeNode urtNode = new JMeterTreeNode(randomTimer, guiPackage.getTreeModel());
+ return new JMeterTreeNode[] {
+ thinkTimeNode,
+ urtNode
+ };
+ }
+}
Propchange: jmeter/trunk/src/components/org/apache/jmeter/thinktime/DefaultThinkTimeCreator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java?rev=1779097&r1=1779096&r2=1779097&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java Mon Jan 16 20:07:01 2017
@@ -34,6 +34,7 @@ public final class ActionNames {
public static final String ADD_ALL = "add_all"; // $NON-NLS-1$
public static final String ADD_PARENT = "Add Parent"; // $NON-NLS-1$
public static final String ANALYZE_FILE = "Analyze File"; // $NON-NLS-1$
+ public static final String ADD_THINK_TIME_BETWEEN_EACH_STEP = "Add Think Time between each step"; // $NON-NLS-1$
public static final String CHANGE_LANGUAGE = "change_language"; // $NON-NLS-1$
public static final String CHANGE_PARENT = "Change Parent"; // $NON-NLS-1$
public static final String CHECK_DIRTY = "check_dirty"; // $NON-NLS-1$
Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java?rev=1779097&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java Mon Jan 16 20:07:01 2017
@@ -0,0 +1,152 @@
+/*
+ * 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.gui.action;
+
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.jmeter.control.Controller;
+import org.apache.jmeter.exceptions.IllegalUserActionException;
+import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.gui.action.thinktime.ThinkTimeCreator;
+import org.apache.jmeter.gui.tree.JMeterTreeNode;
+import org.apache.jmeter.samplers.Sampler;
+import org.apache.jmeter.threads.ThreadGroup;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * Add ThinkTime (TestAction + UniformRandomTimer)
+ * @since 3.2
+ */
+public class AddThinkTimeBetweenEachStep extends AbstractAction {
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ private static final Set<String> commands = new HashSet<>();
+
+ private static final String DEFAULT_IMPLEMENTATION =
+ JMeterUtils.getPropDefault("think_time_creator.impl",
+ "org.apache.jmeter.thinktime.DefaultThinkTimeCreator");
+ static {
+ commands.add(ActionNames.ADD_THINK_TIME_BETWEEN_EACH_STEP);
+ }
+
+ /**
+ *
+ */
+ public AddThinkTimeBetweenEachStep() {
+ super();
+ }
+
+ @Override
+ public void doAction(ActionEvent e) {
+ GuiPackage guiPackage = GuiPackage.getInstance();
+ JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
+ if (!
+ (currentNode.getUserObject() instanceof Controller ||
+ currentNode.getUserObject() instanceof ThreadGroup)
+ ) {
+ Toolkit.getDefaultToolkit().beep();
+ return;
+ }
+ try {
+ addThinkTimeToChildren(guiPackage, currentNode);
+ } catch (Exception err) {
+ Toolkit.getDefaultToolkit().beep();
+ log.error("Failed to add think times", err);
+ JMeterUtils.reportErrorToUser("Failed to add think times", err);
+ }
+ }
+
+ /**
+ * Add Think Time to children of parentNode
+ * @param guiPackage {@link GuiPackage}
+ * @param parentNode Parent node of elements on which we add think times
+ * @throws IllegalUserActionException
+ */
+ private void addThinkTimeToChildren(GuiPackage guiPackage,
+ JMeterTreeNode parentNode) throws IllegalUserActionException {
+ guiPackage.updateCurrentNode();
+ boolean insertThinkTime = false;
+ try {
+ int index = 0;
+ while(true) {
+ if(index == parentNode.getChildCount()) {
+ index++;
+ break;
+ }
+ JMeterTreeNode childNode = (JMeterTreeNode) parentNode.getChildAt(index);
+ Object userObject = childNode.getUserObject();
+ if(userObject instanceof Sampler ||
+ userObject instanceof Controller) {
+ insertThinkTime = true;
+ }
+ if(insertThinkTime) {
+ JMeterTreeNode[] nodes = createThinkTime(guiPackage, parentNode);
+ if(nodes.length != 2) {
+ throw new IllegalArgumentException("Invalid Think Time, expected 2 nodes, got:"+nodes.length);
+ }
+ index++;
+ addNodesToTreeHierachically(guiPackage, parentNode, nodes, index);
+ insertThinkTime = false;
+ }
+ index++;
+ }
+ } catch(Exception ex) {
+ throw new IllegalUserActionException("Cannot add think times", ex);
+ }
+ }
+
+ /**
+ * add nodes to JMeter Tree
+ * @param guiPackage {@link GuiPackage}
+ * @param parentNode {@link JMeterTreeNode}
+ * @param childNodes Child nodes
+ * @param index insertion index
+ */
+ private void addNodesToTreeHierachically(GuiPackage guiPackage,
+ JMeterTreeNode parentNode,
+ JMeterTreeNode[] childNodes,
+ int index) {
+ guiPackage.getTreeModel().insertNodeInto(childNodes[0], parentNode, index);
+ guiPackage.getTreeModel().insertNodeInto(childNodes[1], childNodes[0], 0);
+ }
+
+ /**
+ *
+ * @param guiPackage {@link GuiPackage}
+ * @param parentNode {@link JMeterTreeNode}
+ * @return array of {@link JMeterTreeNode}
+ * @throws IllegalUserActionException
+ */
+ private JMeterTreeNode[] createThinkTime(GuiPackage guiPackage, JMeterTreeNode parentNode)
+ throws Exception {
+ Class<?> clazz = Class.forName(DEFAULT_IMPLEMENTATION);
+ ThinkTimeCreator thinkTimeCreator = (ThinkTimeCreator) clazz.newInstance();
+ return thinkTimeCreator.createThinkTime(guiPackage, parentNode);
+ }
+
+ @Override
+ public Set<String> getActionNames() {
+ return commands;
+ }
+}
Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/thinktime/ThinkTimeCreator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/thinktime/ThinkTimeCreator.java?rev=1779097&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/thinktime/ThinkTimeCreator.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/thinktime/ThinkTimeCreator.java Mon Jan 16 20:07:01 2017
@@ -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.gui.action.thinktime;
+
+import org.apache.jmeter.exceptions.IllegalUserActionException;
+import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.gui.tree.JMeterTreeNode;
+
+/**
+ * Interface for a ThinkTime creator
+ * @since 3.2
+ */
+public interface ThinkTimeCreator {
+
+ /**
+ * Create think time
+ * @param guiPackage {@link GuiPackage}
+ * @param parentNode {@link JMeterTreeNode}
+ * @return array of 2 nodes
+ * @throws IllegalUserActionException
+ */
+ JMeterTreeNode[] createThinkTime(GuiPackage guiPackage, JMeterTreeNode parentNode) throws IllegalUserActionException;
+}
Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/thinktime/ThinkTimeCreator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java?rev=1779097&r1=1779096&r2=1779097&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java Mon Jan 16 20:07:01 2017
@@ -287,12 +287,16 @@ public final class MenuFactory {
pop.add(MenuFactory.makeMenus(MENU_ADD_CONTROLLER,
JMeterUtils.getResString("add"),// $NON-NLS-1$
ActionNames.ADD));
- pop.add(makeMenus(MENU_PARENT_CONTROLLER,
- JMeterUtils.getResString("insert_parent"),// $NON-NLS-1$
- ActionNames.ADD_PARENT));
+ pop.add(MenuFactory.makeMenuItemRes("add_think_times",// $NON-NLS-1$
+ ActionNames.ADD_THINK_TIME_BETWEEN_EACH_STEP));
+
pop.add(makeMenus(MENU_PARENT_CONTROLLER,
JMeterUtils.getResString("change_parent"),// $NON-NLS-1$
ActionNames.CHANGE_PARENT));
+
+ pop.add(makeMenus(MENU_PARENT_CONTROLLER,
+ JMeterUtils.getResString("insert_parent"),// $NON-NLS-1$
+ ActionNames.ADD_PARENT));
MenuFactory.addEditMenu(pop, true);
MenuFactory.addFileMenu(pop);
return pop;
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1779097&r1=1779096&r2=1779097&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Mon Jan 16 20:07:01 2017
@@ -32,6 +32,7 @@ add_test=Add Test
add_user=Add User
add_value=Add Value
addtest=Add test
+add_think_times=Add Think Times to children
aggregate_graph=Statistical Graphs
aggregate_graph_choose_color=Choose color
aggregate_graph_choose_foreground_color=Foreground color
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1779097&r1=1779096&r2=1779097&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Mon Jan 16 20:07:01 2017
@@ -23,6 +23,7 @@ add_from_suggested_excludes=Ajouter excl
add_parameter=Ajouter un param\u00E8tre
add_pattern=Ajouter un motif \:
add_test=Ajout
+add_think_times=Add Think Times to children
add_user=Ajouter un utilisateur
add_value=Ajouter valeur
addtest=Ajout
Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java?rev=1779097&r1=1779096&r2=1779097&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/gui/AbstractThreadGroupGui.java Mon Jan 16 20:07:01 2017
@@ -38,7 +38,6 @@ import org.apache.jmeter.gui.util.MenuFa
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.threads.AbstractThreadGroup;
-import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.util.JMeterUtils;
public abstract class AbstractThreadGroupGui extends AbstractJMeterGuiComponent {
@@ -86,6 +85,13 @@ public abstract class AbstractThreadGrou
// Check test is not started already
!JMeterUtils.isTestRunning()) {
pop.addSeparator();
+
+ JMenuItem addThinkTimesToChildren = new JMenuItem(JMeterUtils.getResString("add_think_times"));
+ addThinkTimesToChildren.setName("add_think_times");
+ addThinkTimesToChildren.addActionListener(ActionRouter.getInstance());
+ addThinkTimesToChildren.setActionCommand(ActionNames.ADD_THINK_TIME_BETWEEN_EACH_STEP);
+ pop.add(addThinkTimesToChildren);
+
JMenuItem runTg = new JMenuItem(JMeterUtils.getResString("run_threadgroup"));
runTg.setName("run_threadgroup");
runTg.addActionListener(ActionRouter.getInstance());
@@ -103,6 +109,7 @@ public abstract class AbstractThreadGrou
validateTg.addActionListener(ActionRouter.getInstance());
validateTg.setActionCommand(ActionNames.VALIDATE_TG);
pop.add(validateTg);
+
}
MenuFactory.addEditMenu(pop, true);
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1779097&r1=1779096&r2=1779097&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Mon Jan 16 20:07:01 2017
@@ -133,6 +133,7 @@ JMeter now requires Java 8. Ensure you u
<ul>
<li><bug>60154</bug>User Parameters GUI: allow rows to be moved up & down in the list. Contributed by Murdecai777 (https://github.com/Murdecai777).</li>
<li><bug>60507</bug>Added '<code>Or</code>' Function into ResponseAssertion. Based on a contribution from \u5ffb\u9686 (298015902 at qq.com)</li>
+ <li><bug>58943</bug>Create a Better Think Time experience. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
</ul>
<h3>Functions</h3>
Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1779097&r1=1779096&r2=1779097&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Mon Jan 16 20:07:01 2017
@@ -1791,6 +1791,23 @@ log_level.org.apache.http.client=DEBUG
</ul>
Defaults to: <code>1.0f</code>
</property>
+<property name="think_time_creator.impl">
+ Default implementation that create the Timer structure to add to Test Plan.
+ Implementation of interface org.apache.jmeter.gui.action.thinktime.ThinkTimeCreator
+ Defaults to: <code><a href="../api/org/apache/jmeter/thinktime/DefaultThinkTimeCreator.html"><code>org.apache.jmeter.thinktime.DefaultThinkTimeCreator</code></a></code>
+</property>
+<property name="think_time_creator.default_timer_implementation">
+ Default Timer GUI class added to Test Plan by DefaultThinkTimeCreator
+ Defaults to: <code><a href="../api/org/apache/jmeter/timers/gui/UniformRandomTimerGui.html"><code>org.apache.jmeter.timers.gui.UniformRandomTimerGui</code></a></code>
+</property>
+<property name="think_time_creator.default_constant_pause">
+ Default constant pause of Timer
+ Defaults to: <code>1000</code>
+</property>
+<property name="think_time_creator.default_range">
+ Default range pause of Timer
+ Defaults to: <code>100</code>
+</property>
</properties>
<a href="#">^</a>
</section>