You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2007/10/22 03:43:53 UTC

svn commit: r586982 - in /jakarta/jmeter/trunk: src/core/org/apache/jmeter/JMeter.java xdocs/changes.xml xdocs/usermanual/get-started.xml xdocs/usermanual/remote-test.xml

Author: sebb
Date: Sun Oct 21 18:43:49 2007
New Revision: 586982

URL: http://svn.apache.org/viewvc?rev=586982&view=rev
Log:
Add -X flag - exit remote servers at end of non-GUI test run

Modified:
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/usermanual/get-started.xml
    jakarta/jmeter/trunk/xdocs/usermanual/remote-test.xml

Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/JMeter.java?rev=586982&r1=586981&r2=586982&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/JMeter.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/JMeter.java Sun Oct 21 18:43:49 2007
@@ -116,6 +116,7 @@
 	private static final int PROXY_PORT         = 'P';// $NON-NLS-1$
     private static final int REMOTE_OPT_PARAM   = 'R';// $NON-NLS-1$
     private static final int SYSTEM_PROPFILE    = 'S';// $NON-NLS-1$
+    private static final int REMOTE_STOP        = 'X';// $NON-NLS-1$
 
 
 
@@ -184,7 +185,10 @@
 			new CLOptionDescriptor("remotestart", CLOptionDescriptor.ARGUMENT_REQUIRED, REMOTE_OPT_PARAM,
 					"Start these remote servers (overrides remote_hosts)"),
 			new CLOptionDescriptor("homedir", CLOptionDescriptor.ARGUMENT_REQUIRED, JMETER_HOME_OPT,
-					"the jmeter home directory to use"), };
+					"the jmeter home directory to use"), 
+			new CLOptionDescriptor("remoteexit", CLOptionDescriptor.ARGUMENT_DISALLOWED, REMOTE_STOP,
+			"Exit the remote servers at end of test (non-GUI)"), 
+					};
 
 	public JMeter() {
 	}
@@ -196,6 +200,8 @@
 	
 	private Properties remoteProps; // Properties to be sent to remote servers
 
+	private boolean remoteStop; // should remote engines be stopped at end of GUI test?
+
 	/**
 	 * Starts up JMeter in GUI mode
 	 */
@@ -596,6 +602,9 @@
 					LoggingManager.setPriority(name);
 				}
 				break;
+			case REMOTE_STOP:
+				remoteStop = true;
+				break;
 			}
 		}
 	
@@ -624,6 +633,7 @@
 		}
 		JMeter driver = new JMeter();// TODO - why does it create a new instance?
 		driver.remoteProps = this.remoteProps;
+		driver.remoteStop = this.remoteStop;
 		driver.parent = this;
 		PluginManager.install(this, false);
 
@@ -695,7 +705,8 @@
 				Summariser summer = new Summariser(summariserName);
 				tree.add(tree.getArray()[0], summer);
 			}
-			tree.add(tree.getArray()[0], new ListenToTest(parent));
+			List engines = new LinkedList();
+			tree.add(tree.getArray()[0], new ListenToTest(parent, (remoteStart && remoteStop) ? engines : null));
 			println("Created the tree successfully");
 			JMeterEngine engine = null;
 			if (!remoteStart) {
@@ -706,7 +717,6 @@
 				engine.runTest();
 			} else {
 				java.util.StringTokenizer st = new java.util.StringTokenizer(remote_hosts_string, ",");//$NON-NLS-1$
-				List engines = new LinkedList();
 				while (st.hasMoreElements()) {
 					String el = (String) st.nextElement();
 					println("Configuring remote engine for " + el);
@@ -816,12 +826,13 @@
 	private static class ListenToTest implements TestListener, Runnable, Remoteable {
 		private int started = 0; // keep track of remote tests
 
-		private boolean remote = false; // Are we running a remote test?
-
 		//NOT YET USED private JMeter _parent;
 
-		private ListenToTest(JMeter parent) {
+		private List engines;
+		
+		public ListenToTest(JMeter parent, List engines) {
 			//_parent = parent;
+			this.engines=engines;
 		}
 
 		public synchronized void testEnded(String host) {
@@ -829,16 +840,15 @@
 			long now=System.currentTimeMillis();
 			log.info("Finished remote host: " + host + " ("+now+")");
 			if (started <= 0) {
-				remote=true;
 				Thread stopSoon = new Thread(this);
 				stopSoon.start();
 			}
 		}
 
 		public void testEnded() {
-			remote = false;
-			Thread stopSoon = new Thread(this);
-			stopSoon.start();
+			long now = System.currentTimeMillis();
+			println("Tidying up ...    @ "+new Date(now)+" ("+now+")");
+			println("... end of run");
 		}
 
 		public synchronized void testStarted(String host) {
@@ -867,16 +877,20 @@
              * of a remote test, a Timer thread seems to be generated by the Naming.lookup()
              * method, and it does not die.
              */
-			if (remote){
-				try {
-					Thread.sleep(5000); // Allow listeners to close files
-				} catch (InterruptedException ignored) {
+			if (engines!=null){ // it will be null unless remoteStop = true
+				System.out.println("Exitting remote servers");
+				Iterator it = engines.iterator();
+				while(it.hasNext()){
+					JMeterEngine e = (JMeterEngine) it.next();
+					e.exit();
 				}
 			}
-			println("... end of run");
-			if (remote){
-				System.exit(0);
+			try {
+				Thread.sleep(5000); // Allow listeners to close files
+			} catch (InterruptedException ignored) {
 			}
+			println("... end of run");
+			System.exit(0);
 		}
 
 		/**

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=586982&r1=586981&r2=586982&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sun Oct 21 18:43:49 2007
@@ -78,6 +78,7 @@
 <li>HTTP Sampler now supports using MIME Type field to specify content-type request header when body is constructed from parameter values</li>
 <li>Enable exit after a single server test - define JMeter property server.exitaftertest=true</li>
 <li>Added -G option to set properties in remote servers</li>
+<li>Added -X option to stop remote servers after non-GUI run</li>
 </ul>
 
 <h4>Non-functional Improvements</h4>

Modified: jakarta/jmeter/trunk/xdocs/usermanual/get-started.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/get-started.xml?rev=586982&r1=586981&r2=586982&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/get-started.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/get-started.xml Sun Oct 21 18:43:49 2007
@@ -256,12 +256,21 @@
 <subsection name="&sect-num;.4.4 Server Mode" anchor="server">
 <p>For <a href="remote-test.html">distributed testing</a>, run JMeter in server mode on the remote node(s), and then control the server(s) from the GUI.
 You can also use non-GUI mode to run remote tests.
-
-Run jmeter-server/jmeter-server.bat, plus these optional commands:</p>
+To start the server(s), run jmeter-server/jmeter-server.bat on each server host.</p>
 <p>The script also lets you specify the optional firewall/proxy server information:</p>
 <p>-H [proxy server hostname or ip address]<br/>
 -P [proxy server port]</p>
 <p><b>Example</b>: jmeter-server -H my.proxy.server -P 8000</p>
+<p>If you want the server to exit after a single test has been run, then define the JMeter property server.exitaftertest=true.
+</p>
+<p>To run the test from the client in non-GUI mode, use the following command:</p>
+<pre>
+jmeter -n -t testplan.jmx -r [-Gprop=val] [-Z]
+where:
+-G is used to define JMeter properties to be set in the servers
+-X means exit the servers at the end of the test
+-Rserver1,server2 - can be used instead of -r to provide a list of servers (overrides remote_hosts)
+</pre>
 </subsection>
 
 <subsection name="&sect-num;.4.5 Overriding Properties Via The Command Line" anchor="override">
@@ -366,6 +375,8 @@
                 Start these remote servers (overrides remote_hosts)
         -d, --homedir {argument}
                 the jmeter home directory to use
+        -X, --remoteexit
+                Exit the remote servers at end of test (non-GUI)
 </pre>
 </subsection>
 </section>

Modified: jakarta/jmeter/trunk/xdocs/usermanual/remote-test.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/remote-test.xml?rev=586982&r1=586981&r2=586982&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/remote-test.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/remote-test.xml Sun Oct 21 18:43:49 2007
@@ -66,9 +66,12 @@
 <p><b>Step 2: Add the server IP to your client's Properties File</b></p>
 <p>Edit the properties file <i>on the controlling JMeter machine</i>.  In /bin/jmeter.properties, find the property named, "remote_hosts", and   
 add the value of your running JMeter server's IP address.  Multiple such servers can be added, comma-delimited.</p>
-<p>Note that you can also use the -J <a href="get-started.html#override">command line option</a> to specify the remote host(s) to use.
-	E.g. jmeter -Jremote_hosts=host1,127.0.0.1,host2</p>
-
+<p>Note that you can use the -R <a href="get-started.html#override">command line option</a>
+instead to specify the remote host(s) to use. This has the same effect as using -r and -Jremote_hosts={serverlist}.
+	E.g. jmeter -Rhost1,127.0.0.1,host2</p>
+<p>If you define the JMeter property server.exitaftertest=true, then the server will exit after it runs a single test.
+See also the -X flag (described below)
+</p>
 <p><b>Step 3a: Start the JMeter Client from a GUI client</b></p>
 <p>Now you are ready to start the controlling JMeter client. For MS-Windows, start the client with the script "bin/jmeter.bat".  For UNIX, 
 use the script "bin/jmeter".  You will notice that the Run menu contains two new sub-menus: "Remote Start" and "Remote Stop" 
@@ -84,14 +87,15 @@
 jmeter -n -t script.jmx -r
 or
 jmeter -n -t script.jmx -R server1,server2...
+
+Other flags that may be useful:
+-Gproperty=value - define a property in all the servers (may appear more than once)
+-Z - Exit remote servers at the end of the test.
 </pre>
 The first example will start whatever servers are defined in the JMeter property remote_hosts;
 the second example will define remote_hosts from the list of servers and then run the remote servers.
 <br/>
 The command-line client will exit when all the remote servers have stopped.
-<note>
-There is currently no way to stop the remote servers gracefully from the command-line.
-</note>
 </p>
 
 <subsection name="&sect-num;.1 Doing it Manually" anchor="detail_instructions">



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org