2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23
package org.jboss.test.remoting.performance.raw.rmi;
25
import org.apache.log4j.Level;
26
import org.jboss.jrunit.harness.BenchmarkTestDriver;
28
import java.io.IOException;
31
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
33
public class RMIPerformanceTestCase extends BenchmarkTestDriver //TestDriver
35
protected int numberOfClients = 1;
37
public static final String REMOTING_TRANSPORT = "remoting.transport";
38
public static final String REMOTING_METADATA = "remoting.metadata";
39
public static final String REMOTING_SERIALIZATION = "remoting.serialization";
40
public static final String PAYLOAD_SIZE = "remoting.payload.size";
41
public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients";
42
public static final String NUMBER_OF_CALLS = "remoting.number_of_calls";
43
public static final String JVM_MAX_HEAP_SIZE = "jvm.mx";
44
public static final String RESULT_TIMEOUT = "jrunit.result_timeout";
45
public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout";
46
public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout";
47
public static final String REMOTING_HOST = "remoting.host";
50
public void declareTestClasses()
52
//**************** LOGGING ***********************
53
org.apache.log4j.BasicConfigurator.configure();
54
org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
55
//org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
57
org.apache.log4j.SimpleLayout layout = new org.apache.log4j.SimpleLayout();
61
org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log");
62
fileAppender.setThreshold(Level.DEBUG);
63
fileAppender.setAppend(false);
64
org.apache.log4j.Category.getRoot().addAppender(fileAppender);
70
//*************** END LOGGING ***********************
73
String numOfClients = System.getProperty(NUMBER_OF_CLIENTS);
74
if(numOfClients != null && numOfClients.length() > 0)
78
numberOfClients = Integer.parseInt(numOfClients);
80
catch(NumberFormatException e)
86
addTestClasses(getClientTestClass(),
88
RMIPerformanceServer.class.getName());
91
protected String getClientTestClass()
93
return RMIPerformanceClient.class.getName();
96
protected Level getTestHarnessLogLevel()
103
* The log level to run as for the test case.
107
protected Level getTestLogLevel()
110
//return Level.DEBUG;
114
* Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness).
115
* The default value is null.
119
protected String getClientJVMArguments()
121
return getJVMArguments();
122
// String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 ";
123
// args = args + getJVMArguments();
128
* Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness).
129
* The default value is null.
133
protected String getServerJVMArguments()
135
return getJVMArguments();
139
* Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness).
140
* The default value is null.
144
private String getJVMArguments()
148
String transport = System.getProperty(REMOTING_TRANSPORT);
149
if(transport != null && transport.length() > 0)
151
vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport;
153
String host = System.getProperty(REMOTING_HOST);
154
if(host != null && host.length() > 0)
156
vmArgs = "-D" + REMOTING_HOST + "=" + host;
158
String serialization = System.getProperty(REMOTING_SERIALIZATION);
159
if(serialization != null && serialization.length() > 0)
161
vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization;
163
String metadata = System.getProperty(REMOTING_METADATA);
164
if(metadata != null && metadata.length() > 0)
166
vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata;
168
String payloadSize = System.getProperty(PAYLOAD_SIZE);
169
if(payloadSize != null && payloadSize.length() > 0)
171
vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize;
173
String numOfCalls = System.getProperty(NUMBER_OF_CALLS);
174
if(numOfCalls != null && numOfCalls.length() > 0)
176
vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls;
178
String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE);
179
if(jvmMx != null && jvmMx.length() > 0)
181
vmArgs = vmArgs + " -Xmx" + jvmMx + "m";
188
* How long to wait for test results to be returned from the client(s). If goes longer than the
189
* specified limit, will throw an exception and kill the running test cases. Default value is
194
protected long getResultsTimeout()
196
long defaultTimeout = 600000; // default to 10 minutes
198
String timeout = System.getProperty(RESULT_TIMEOUT);
199
if(timeout != null && timeout.length() > 0)
203
defaultTimeout = Long.parseLong(timeout);
205
catch(NumberFormatException e)
207
System.out.println("Can not use " + timeout + " as timeout value as is not a number");
210
return defaultTimeout;
214
* How long for the server test case to wait for tear down message. If exceeds timeout,
215
* will throw exception. The default value is TEARDOWN_TIMEOUT.
219
protected long getTearDownTimeout()
221
long defaultTimeout = 600000; // default to 10 minutes
223
String timeout = System.getProperty(TEAR_DOWN_TIMEOUT);
224
if(timeout != null && timeout.length() > 0)
228
defaultTimeout = Long.parseLong(timeout);
230
catch(NumberFormatException e)
232
System.out.println("Can not use " + timeout + " as timeout value as is not a number");
235
return defaultTimeout;
239
* How long to allow each of the test cases to run their tests. If exceeds this timeout
240
* will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
244
protected long getRunTestTimeout()
246
long defaultTimeout = 600000; // default to 10 minutes
248
String timeout = System.getProperty(RUN_TEST_TIMEOUT);
249
if(timeout != null && timeout.length() > 0)
253
defaultTimeout = Long.parseLong(timeout);
255
catch(NumberFormatException e)
257
System.out.println("Can not use " + timeout + " as timeout value as is not a number");
260
return defaultTimeout;