1
/***************************************
3
* JBoss: The OpenSource J2EE WebOS *
5
* Distributable under LGPL license. *
6
* See terms of license at gnu.org. *
8
***************************************/
9
package org.jboss.test.remoting.performance.spring.rmi;
11
import org.apache.log4j.Level;
12
import org.jboss.jrunit.harness.BenchmarkTestDriver;
13
import org.jboss.logging.Logger;
15
import java.io.IOException;
18
* @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
20
public class SpringRMIPerformanceTestCase extends BenchmarkTestDriver
22
protected int numberOfClients = 1;
24
public static final String REMOTING_TRANSPORT = "remoting.transport";
25
public static final String REMOTING_METADATA = "remoting.metadata";
26
public static final String REMOTING_SERIALIZATION = "remoting.serialization";
27
public static final String PAYLOAD_SIZE = "remoting.payload.size";
28
public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients";
29
public static final String NUMBER_OF_CALLS = "remoting.number_of_calls";
30
public static final String JVM_MAX_HEAP_SIZE = "jvm.mx";
31
public static final String RESULT_TIMEOUT = "jrunit.result_timeout";
32
public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout";
33
public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout";
34
public static final String REMOTING_HOST = "remoting.host";
35
private static Logger log = Logger.getLogger(SpringRMIPerformanceTestCase.class);
37
public void declareTestClasses()
39
//**************** LOGGING ***********************
40
org.apache.log4j.BasicConfigurator.configure();
41
org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
42
//org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
44
org.apache.log4j.SimpleLayout layout = new org.apache.log4j.SimpleLayout();
48
org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log");
49
fileAppender.setThreshold(Level.DEBUG);
50
fileAppender.setAppend(false);
51
org.apache.log4j.Category.getRoot().addAppender(fileAppender);
57
//*************** END LOGGING ***********************
60
String numOfClients = System.getProperty(NUMBER_OF_CLIENTS);
61
if(numOfClients != null && numOfClients.length() > 0)
65
numberOfClients = Integer.parseInt(numOfClients);
67
catch(NumberFormatException e)
73
addTestClasses(getClientTestClass(),
75
SpringRMIPerformanceServer.class.getName());
78
protected String getClientTestClass()
80
return SpringRMIPerformanceClient.class.getName();
83
protected Level getTestHarnessLogLevel()
90
* The log level to run as for the test case.
94
protected Level getTestLogLevel()
101
* Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness).
102
* The default value is null.
106
protected String getClientJVMArguments()
108
return getJVMArguments();
109
// String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 ";
110
// args = args + getJVMArguments();
115
* Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness).
116
* The default value is null.
120
protected String getServerJVMArguments()
122
return getJVMArguments();
126
* Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness).
127
* The default value is null.
131
private String getJVMArguments()
135
String transport = System.getProperty(REMOTING_TRANSPORT);
136
if(transport != null && transport.length() > 0)
138
vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport;
140
String host = System.getProperty(REMOTING_HOST);
141
if(host != null && host.length() > 0)
143
vmArgs = "-D" + REMOTING_HOST + "=" + host;
145
String serialization = System.getProperty(REMOTING_SERIALIZATION);
146
if(serialization != null && serialization.length() > 0)
148
vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization;
150
String metadata = System.getProperty(REMOTING_METADATA);
151
if(metadata != null && metadata.length() > 0)
153
vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata;
155
String payloadSize = System.getProperty(PAYLOAD_SIZE);
156
if(payloadSize != null && payloadSize.length() > 0)
158
vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize;
160
String numOfCalls = System.getProperty(NUMBER_OF_CALLS);
161
if(numOfCalls != null && numOfCalls.length() > 0)
163
vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls;
165
String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE);
166
if(jvmMx != null && jvmMx.length() > 0)
168
vmArgs = vmArgs + " -Xmx" + jvmMx + "m";
175
* How long to wait for test results to be returned from the client(s). If goes longer than the
176
* specified limit, will throw an exception and kill the running test cases. Default value is
181
protected long getResultsTimeout()
183
long defaultTimeout = 6000000; // default to 100 minutes
185
String timeout = System.getProperty(RESULT_TIMEOUT);
186
if(timeout != null && timeout.length() > 0)
190
defaultTimeout = Long.parseLong(timeout);
192
catch(NumberFormatException e)
194
System.out.println("Can not use " + timeout + " as timeout value as is not a number");
197
return defaultTimeout;
201
* How long for the server test case to wait for tear down message. If exceeds timeout,
202
* will throw exception. The default value is TEARDOWN_TIMEOUT.
206
protected long getTearDownTimeout()
208
long defaultTimeout = 6000000; // default to 100 minutes
210
String timeout = System.getProperty(TEAR_DOWN_TIMEOUT);
211
if(timeout != null && timeout.length() > 0)
215
defaultTimeout = Long.parseLong(timeout);
217
catch(NumberFormatException e)
219
System.out.println("Can not use " + timeout + " as timeout value as is not a number");
222
return defaultTimeout;
226
* How long to allow each of the test cases to run their tests. If exceeds this timeout
227
* will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
231
protected long getRunTestTimeout()
233
long defaultTimeout = 6000000; // default to 100 minutes
235
String timeout = System.getProperty(RUN_TEST_TIMEOUT);
236
if(timeout != null && timeout.length() > 0)
240
defaultTimeout = Long.parseLong(timeout);
242
catch(NumberFormatException e)
244
System.out.println("Can not use " + timeout + " as timeout value as is not a number");
247
return defaultTimeout;
b'\\ No newline at end of file'