Author: sebb
Date: Tue Apr 11 17:43:40 2006
New Revision: 393347
URL: http://svn.apache.org/viewcvs?rev=393347&view=rev
Log:
Add -S option - load system properties from file
Add -N option - define nonProxyHosts list
Added:
jakarta/jmeter/branches/rel-2-1/bin/system.properties (with props)
Modified:
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/JMeter.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/get-started.xml
Added: jakarta/jmeter/branches/rel-2-1/bin/system.properties
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/bin/system.properties?rev=393347&view=auto
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/bin/system.properties (added)
+++ jakarta/jmeter/branches/rel-2-1/bin/system.properties Tue Apr 11 17:43:40
2006
@@ -0,0 +1,7 @@
+# Sample system.properties file
+#
+#
+java.net.preferIPv4Stack=false
+java.net.preferIPv6Addresses=false
+networkaddress.cache.ttl=-1
+networkaddress.cache.negative.ttl=10
Propchange: jakarta/jmeter/branches/rel-2-1/bin/system.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/branches/rel-2-1/bin/system.properties
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision
Propchange: jakarta/jmeter/branches/rel-2-1/bin/system.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/JMeter.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/JMeter.java?rev=393347&r1=393346&r2=393347&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/JMeter.java
(original)
+++ jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/JMeter.java Tue
Apr 11 17:43:40 2006
@@ -89,39 +89,33 @@
public static final String HTTP_PROXY_USER = "http.proxyUser"; //
$NON-NLS-1$
- private static final int PROPFILE_OPT = 'p';// $NON-NLS-1$
- private static final int PROPFILE2_OPT = 'q'; // Bug 33920 - additional
prop files $NON-NLS-1$
+ private static final int PROXY_PASSWORD = 'a';// $NON-NLS-1$
+ private static final int JMETER_HOME_OPT = 'd';// $NON-NLS-1$
+ private static final int HELP_OPT = 'h';// $NON-NLS-1$
+ private static final int LOGFILE_OPT = 'l';// $NON-NLS-1$
+ private static final int NONGUI_OPT = 'n';// $NON-NLS-1$
+ private static final int PROPFILE_OPT = 'p';// $NON-NLS-1$
+ private static final int PROPFILE2_OPT = 'q';// $NON-NLS-1$
+ private static final int REMOTE_OPT = 'r';// $NON-NLS-1$
+ private static final int SERVER_OPT = 's';// $NON-NLS-1$
+ private static final int TESTFILE_OPT = 't';// $NON-NLS-1$
+ private static final int PROXY_USERNAME = 'u';// $NON-NLS-1$
+ private static final int VERSION_OPT = 'v';// $NON-NLS-1$
+
+ private static final int SYSTEM_PROPERTY = 'D';// $NON-NLS-1$
+ private static final int PROXY_HOST = 'H';// $NON-NLS-1$
+ private static final int JMETER_PROPERTY = 'J';// $NON-NLS-1$
+ private static final int LOGLEVEL = 'L';// $NON-NLS-1$
+ private static final int NONPROXY_HOSTS = 'N';// $NON-NLS-1$
+ private static final int PROXY_PORT = 'P';// $NON-NLS-1$
+ private static final int SYSTEM_PROPFILE = 'S';// $NON-NLS-1$
- private static final int TESTFILE_OPT = 't';// $NON-NLS-1$
- private static final int LOGFILE_OPT = 'l';// $NON-NLS-1$
- private static final int NONGUI_OPT = 'n';// $NON-NLS-1$
- private static final int HELP_OPT = 'h';// $NON-NLS-1$
- private static final int VERSION_OPT = 'v';// $NON-NLS-1$
- private static final int SERVER_OPT = 's';// $NON-NLS-1$
-
- private static final int PROXY_HOST = 'H';// $NON-NLS-1$
-
- private static final int PROXY_PORT = 'P';// $NON-NLS-1$
-
- private static final int PROXY_USERNAME = 'u';// $NON-NLS-1$
-
- private static final int PROXY_PASSWORD = 'a';// $NON-NLS-1$
-
- private static final int JMETER_PROPERTY = 'J';// $NON-NLS-1$
-
- private static final int SYSTEM_PROPERTY = 'D';// $NON-NLS-1$
-
- private static final int LOGLEVEL = 'L';// $NON-NLS-1$
-
- private static final int REMOTE_OPT = 'r';// $NON-NLS-1$
-
- private static final int JMETER_HOME_OPT = 'd';// $NON-NLS-1$
/**
* Define the understood options. Each CLOptionDescriptor contains:
@@ -159,17 +153,23 @@
"Set a proxy server for JMeter to use"),
new CLOptionDescriptor("proxyPort",
CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_PORT,
"Set proxy server port for JMeter to
use"),
+ new CLOptionDescriptor("nonProxyHosts",
CLOptionDescriptor.ARGUMENT_REQUIRED, NONPROXY_HOSTS,
+ "Set nonproxy host list (e.g. *.apache.org|localhost)"),
new CLOptionDescriptor("username",
CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_USERNAME,
"Set username for proxy server that
JMeter is to use"),
new CLOptionDescriptor("password",
CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_PASSWORD,
"Set password for proxy server that
JMeter is to use"),
new CLOptionDescriptor("jmeterproperty",
CLOptionDescriptor.DUPLICATES_ALLOWED
- |
CLOptionDescriptor.ARGUMENTS_REQUIRED_2, JMETER_PROPERTY, "Define additional
JMeter properties"),
+ |
CLOptionDescriptor.ARGUMENTS_REQUIRED_2, JMETER_PROPERTY,
+ "Define additional JMeter properties"),
new CLOptionDescriptor("systemproperty",
CLOptionDescriptor.DUPLICATES_ALLOWED
- |
CLOptionDescriptor.ARGUMENTS_REQUIRED_2, SYSTEM_PROPERTY, "Define additional
JMeter properties"),
+ |
CLOptionDescriptor.ARGUMENTS_REQUIRED_2, SYSTEM_PROPERTY,
+ "Define additional system properties"),
+ new CLOptionDescriptor("systemPropertyFile",
CLOptionDescriptor.ARGUMENT_REQUIRED, SYSTEM_PROPFILE,
+ "Define system properties from a file"),
new CLOptionDescriptor("loglevel",
CLOptionDescriptor.DUPLICATES_ALLOWED
|
CLOptionDescriptor.ARGUMENTS_REQUIRED_2, LOGLEVEL,
- "Define loglevel: [category=]level e.g.
jorphan=INFO or " + "jmeter.util=DEBUG"),
+ "[category=]level e.g. jorphan=INFO or
jmeter.util=DEBUG"),
new CLOptionDescriptor("runremote",
CLOptionDescriptor.ARGUMENT_DISALLOWED, REMOTE_OPT,
"Start remote servers from non-gui
mode"),
new CLOptionDescriptor("homedir",
CLOptionDescriptor.ARGUMENT_REQUIRED, JMETER_HOME_OPT,
@@ -328,8 +328,8 @@
Authenticator.setDefault(new
ProxyAuthenticator(u = parser.getArgumentById(PROXY_USERNAME)
.getArgument(), p =
parser.getArgumentById(PROXY_PASSWORD).getArgument()));
log.info("Set Proxy login: " + u + "/" + p);
- jmeterProps.setProperty(HTTP_PROXY_USER, u);
- jmeterProps.setProperty(HTTP_PROXY_PASS, p);
+ jmeterProps.setProperty(HTTP_PROXY_USER, u);//for Httpclient
+ jmeterProps.setProperty(HTTP_PROXY_PASS, p);//for Httpclient
} else {
String u;
Authenticator.setDefault(new
ProxyAuthenticator(u = parser.getArgumentById(PROXY_USERNAME)
@@ -339,15 +339,23 @@
}
}
if (parser.getArgumentById(PROXY_HOST) != null &&
parser.getArgumentById(PROXY_PORT) != null) {
- String h, p;
- System.setProperty("http.proxyHost", h =
parser.getArgumentById(PROXY_HOST).getArgument());// $NON-NLS-1$
- System.setProperty("https.proxyHost",
parser.getArgumentById(PROXY_HOST).getArgument());// $NON-NLS-1$
- System.setProperty("http.proxyPort", p =
parser.getArgumentById(PROXY_PORT).getArgument());// $NON-NLS-1$
- System.setProperty("https.proxyPort",
parser.getArgumentById(PROXY_PORT).getArgument());// $NON-NLS-1$
+ String h =
parser.getArgumentById(PROXY_HOST).getArgument();
+ String p = parser.getArgumentById(PROXY_PORT).getArgument();
+ System.setProperty("http.proxyHost", h );// $NON-NLS-1$
+ System.setProperty("https.proxyHost", h);// $NON-NLS-1$
+ System.setProperty("http.proxyPort", p);// $NON-NLS-1$
+ System.setProperty("https.proxyPort", p);// $NON-NLS-1$
log.info("Set http[s].proxyHost: " + h + " Port: " + p);
} else if (parser.getArgumentById(PROXY_HOST) != null ||
parser.getArgumentById(PROXY_PORT) != null) {
throw new
IllegalUserActionException(JMeterUtils.getResString("proxy_cl_error"));//
$NON-NLS-1$
}
+
+ if (parser.getArgumentById(NONPROXY_HOSTS) != null) {
+ String n = parser.getArgumentById(NONPROXY_HOSTS).getArgument();
+ System.setProperty("http.nonProxyHosts", n );// $NON-NLS-1$
+ System.setProperty("https.nonProxyHosts", n );// $NON-NLS-1$
+ log.info("Set http[s].nonProxyHosts: "+n);
+ }
}
private void initializeProperties(CLArgsParser parser) {
@@ -376,18 +384,42 @@
CLOption option = (CLOption) clOptions.get(i);
String name = option.getArgument(0);
String value = option.getArgument(1);
+ FileInputStream fis = null;
switch (option.getDescriptor().getId()) {
case PROPFILE2_OPT: // Bug 33920 - allow multiple props
- File f = new File(name);
try {
- jmeterProps.load(new
FileInputStream(f));
+ fis = new FileInputStream(new File(name));
+ jmeterProps.load(fis);
} catch (FileNotFoundException e) {
log.warn("Can't find additional
property file: " + name, e);
} catch (IOException e) {
log.warn("Error loading additional
property file: " + name, e);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
}
break;
+ case SYSTEM_PROPFILE:
+ log.info("Setting System propertyies from file: " + name);
+ try {
+ fis = new FileInputStream(new File(name));
+ System.getProperties().load(fis);
+ } catch (IOException e) {
+ log.warn("Cannot find system property file
"+e.getLocalizedMessage());
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ break;
case SYSTEM_PROPERTY:
if (value.length() > 0) { // Set it
log.info("Setting System property: " +
name + "=" + value);
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?rev=393347&r1=393346&r2=393347&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
Tue Apr 11 17:43:40 2006
@@ -21,10 +21,15 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
import java.util.zip.GZIPInputStream;
import org.apache.commons.httpclient.HostConfiguration;
@@ -42,7 +47,6 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.protocol.Protocol;
-
import org.apache.jmeter.JMeter;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.protocol.http.control.AuthManager;
@@ -54,9 +58,7 @@
import org.apache.jmeter.testelement.property.CollectionProperty;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.util.JMeterUtils;
-
import org.apache.jorphan.logging.LoggingManager;
-
import org.apache.log.Logger;
/**
@@ -71,6 +73,9 @@
private static final String PROXY_HOST =
System.getProperty("http.proxyHost",""); // $NON-NLS-1$
+ private static final String NONPROXY_HOSTS =
+ System.getProperty("http.nonProxyHosts",""); // $NON-NLS-1$
+
private static final int PROXY_PORT =
Integer.parseInt(System.getProperty("http.proxyPort", "80")); //
$NON-NLS-1$ $NON-NLS-2$
@@ -85,7 +90,35 @@
*/
private static final ThreadLocal httpClients = new ThreadLocal();
+ private static Set nonProxyHostFull = new HashSet();// www.apache.org
+ private static List nonProxyHostSuffix = new ArrayList();// .apache.org
+ private static final int nonProxyHostSuffixSize;
+
+ private static boolean isNonProxy(String host){
+ return nonProxyHostFull.contains(host) || isPartialMatch(host);
+ }
+
+ private static boolean isPartialMatch(String host) {
+ for (int i=0;i<nonProxyHostSuffixSize;i++){
+ if (host.endsWith((String)nonProxyHostSuffix.get(i)))
+ return true;
+ }
+ return false;
+ }
+
static {
+ if (NONPROXY_HOSTS.length() > 0){
+ StringTokenizer s = new StringTokenizer(NONPROXY_HOSTS,"|");//
$NON-NLS-1$
+ while (s.hasMoreTokens()){
+ String t = s.nextToken();
+ if (t.indexOf("*") ==0){// e.g. *.apache.org // $NON-NLS-1$
+ nonProxyHostSuffix.add(t.substring(1));
+ } else {
+ nonProxyHostFull.add(t);// e.g. www.apache.org
+ }
+ }
+ }
+ nonProxyHostSuffixSize=nonProxyHostSuffix.size();
// Set the default to Avalon Logkit, if not already defined:
if (System.getProperty("org.apache.commons.logging.Log") ==
null) { // $NON-NLS-1$
System.setProperty("org.apache.commons.logging.Log" //
$NON-NLS-1$
@@ -213,7 +246,10 @@
map.put(hc, httpClient);
}
- if (PROXY_HOST.length() > 0) {
+ if (PROXY_HOST.length() > 0 && !isNonProxy(host)) {
+ if (log.isDebugEnabled()){
+ log.debug("Setting proxy: "+PROXY_HOST+":"+PROXY_PORT);
+ }
hc.setProxy(PROXY_HOST, PROXY_PORT);
if (PROXY_USER.length() > 0){
httpClient.getState().setProxyCredentials(
Modified: jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml?rev=393347&r1=393346&r2=393347&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml Tue Apr 11 17:43:40 2006
@@ -79,6 +79,8 @@
sample, and the file name can be included in the sample log file.
</li>
<li>Change jmeter.bat DOS script so it works from any directory</li>
+<li>New -N option to define nonProxyHosts from command-line</li>
+<li>New -S option to define system properties from input file</li>
</ul>
<h4>Bug fixes:</h4>
Modified: jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/get-started.xml
URL:
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/get-started.xml?rev=393347&r1=393346&r2=393347&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/get-started.xml (original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/get-started.xml Tue Apr 11
17:43:40 2006
@@ -178,11 +178,14 @@
<p>If you are testing from behind a firewall/proxy server, you may need to
provide JMeter with
the firewall/proxy server hostname and port number. To do so, run the
jmeter.bat/jmeter file
from a command line with the following parameters:</p>
-<p>-H [proxy server hostname or ip address]<br/>
+<p>
+-H [proxy server hostname or ip address]<br/>
-P [proxy server port]<br/>
+-N [nonproxy hosts] (e.g. *.apache.org|localhost)<br/>
-u [username for proxy authentication - if required]<br/>
--a [password for proxy authentication - if required]</p>
-<p><b>Example</b>: jmeter -H my.proxy.server -P 8000 -u username -a
password</p>
+-a [password for proxy authentication - if required]<br/>
+</p>
+<p><b>Example</b>: jmeter -H my.proxy.server -P 8000 -u username -a password
-N localhost</p>
<p>Alternatively, you can use --proxyHost, --proxyPort, --username, and
--password</p>
<note>JMeter also has its own in-built <complink name="HTTP Proxy Server">HTTP
Proxy Server</complink>,
which can be used for recording HTTP (but not HTTPS) browser sessions.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]