~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIPerformanceTestCase.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************
 
2
 *                                     *
 
3
 *  JBoss: The OpenSource J2EE WebOS   *
 
4
 *                                     *
 
5
 *  Distributable under LGPL license.  *
 
6
 *  See terms of license at gnu.org.   *
 
7
 *                                     *
 
8
 ***************************************/
 
9
package org.jboss.test.remoting.performance.spring.rmi;
 
10
 
 
11
import org.apache.log4j.Level;
 
12
import org.jboss.jrunit.harness.BenchmarkTestDriver;
 
13
import org.jboss.logging.Logger;
 
14
 
 
15
import java.io.IOException;
 
16
 
 
17
/**
 
18
 * @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
 
19
 */
 
20
public class SpringRMIPerformanceTestCase extends BenchmarkTestDriver
 
21
{
 
22
   protected int numberOfClients = 1;
 
23
 
 
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);
 
36
 
 
37
   public void declareTestClasses()
 
38
   {
 
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);
 
43
 
 
44
      org.apache.log4j.SimpleLayout layout = new org.apache.log4j.SimpleLayout();
 
45
 
 
46
      try
 
47
      {
 
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);
 
52
      }
 
53
      catch(IOException e)
 
54
      {
 
55
         e.printStackTrace();
 
56
      }
 
57
      //*************** END LOGGING ***********************
 
58
 
 
59
 
 
60
      String numOfClients = System.getProperty(NUMBER_OF_CLIENTS);
 
61
      if(numOfClients != null && numOfClients.length() > 0)
 
62
      {
 
63
         try
 
64
         {
 
65
            numberOfClients = Integer.parseInt(numOfClients);
 
66
         }
 
67
         catch(NumberFormatException e)
 
68
         {
 
69
            e.printStackTrace();
 
70
         }
 
71
      }
 
72
 
 
73
      addTestClasses(getClientTestClass(),
 
74
                     numberOfClients,
 
75
                     SpringRMIPerformanceServer.class.getName());
 
76
   }
 
77
 
 
78
   protected String getClientTestClass()
 
79
   {
 
80
      return SpringRMIPerformanceClient.class.getName();
 
81
   }
 
82
 
 
83
   protected Level getTestHarnessLogLevel()
 
84
   {
 
85
      return Level.INFO;
 
86
      //return Level.DEBUG;
 
87
   }
 
88
 
 
89
   /**
 
90
    * The log level to run as for the test case.
 
91
    *
 
92
    * @return
 
93
    */
 
94
   protected Level getTestLogLevel()
 
95
   {
 
96
      return Level.INFO;
 
97
      //return Level.DEBUG;
 
98
   }
 
99
 
 
100
   /**
 
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.
 
103
    *
 
104
    * @return
 
105
    */
 
106
   protected String getClientJVMArguments()
 
107
   {
 
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();
 
111
//      return args;
 
112
   }
 
113
 
 
114
   /**
 
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.
 
117
    *
 
118
    * @return
 
119
    */
 
120
   protected String getServerJVMArguments()
 
121
   {
 
122
      return getJVMArguments();
 
123
   }
 
124
 
 
125
   /**
 
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.
 
128
    *
 
129
    * @return
 
130
    */
 
131
   private String getJVMArguments()
 
132
   {
 
133
      String vmArgs = "";
 
134
 
 
135
      String transport = System.getProperty(REMOTING_TRANSPORT);
 
136
      if(transport != null && transport.length() > 0)
 
137
      {
 
138
         vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport;
 
139
      }
 
140
      String host = System.getProperty(REMOTING_HOST);
 
141
      if(host != null && host.length() > 0)
 
142
      {
 
143
         vmArgs = "-D" + REMOTING_HOST + "=" + host;
 
144
      }
 
145
      String serialization = System.getProperty(REMOTING_SERIALIZATION);
 
146
      if(serialization != null && serialization.length() > 0)
 
147
      {
 
148
         vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization;
 
149
      }
 
150
      String metadata = System.getProperty(REMOTING_METADATA);
 
151
      if(metadata != null && metadata.length() > 0)
 
152
      {
 
153
         vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata;
 
154
      }
 
155
      String payloadSize = System.getProperty(PAYLOAD_SIZE);
 
156
      if(payloadSize != null && payloadSize.length() > 0)
 
157
      {
 
158
         vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize;
 
159
      }
 
160
      String numOfCalls = System.getProperty(NUMBER_OF_CALLS);
 
161
      if(numOfCalls != null && numOfCalls.length() > 0)
 
162
      {
 
163
         vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls;
 
164
      }
 
165
      String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE);
 
166
      if(jvmMx != null && jvmMx.length() > 0)
 
167
      {
 
168
         vmArgs = vmArgs + " -Xmx" + jvmMx + "m";
 
169
      }
 
170
          log.info(vmArgs);
 
171
      return vmArgs;
 
172
   }
 
173
 
 
174
   /**
 
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
 
177
    * RESULTS_TIMEOUT.
 
178
    *
 
179
    * @return
 
180
    */
 
181
   protected long getResultsTimeout()
 
182
   {
 
183
      long defaultTimeout = 6000000; // default to 100 minutes
 
184
 
 
185
      String timeout = System.getProperty(RESULT_TIMEOUT);
 
186
      if(timeout != null && timeout.length() > 0)
 
187
      {
 
188
         try
 
189
         {
 
190
            defaultTimeout = Long.parseLong(timeout);
 
191
         }
 
192
         catch(NumberFormatException e)
 
193
         {
 
194
            System.out.println("Can not use " + timeout + " as timeout value as is not a number");
 
195
         }
 
196
      }
 
197
      return defaultTimeout;
 
198
   }
 
199
 
 
200
   /**
 
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.
 
203
    *
 
204
    * @return
 
205
    */
 
206
   protected long getTearDownTimeout()
 
207
   {
 
208
      long defaultTimeout = 6000000; // default to 100 minutes
 
209
 
 
210
      String timeout = System.getProperty(TEAR_DOWN_TIMEOUT);
 
211
      if(timeout != null && timeout.length() > 0)
 
212
      {
 
213
         try
 
214
         {
 
215
            defaultTimeout = Long.parseLong(timeout);
 
216
         }
 
217
         catch(NumberFormatException e)
 
218
         {
 
219
            System.out.println("Can not use " + timeout + " as timeout value as is not a number");
 
220
         }
 
221
      }
 
222
      return defaultTimeout;
 
223
   }
 
224
 
 
225
   /**
 
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.
 
228
    *
 
229
    * @return
 
230
    */
 
231
   protected long getRunTestTimeout()
 
232
   {
 
233
      long defaultTimeout = 6000000; // default to 100 minutes
 
234
 
 
235
      String timeout = System.getProperty(RUN_TEST_TIMEOUT);
 
236
      if(timeout != null && timeout.length() > 0)
 
237
      {
 
238
         try
 
239
         {
 
240
            defaultTimeout = Long.parseLong(timeout);
 
241
         }
 
242
         catch(NumberFormatException e)
 
243
         {
 
244
            System.out.println("Can not use " + timeout + " as timeout value as is not a number");
 
245
         }
 
246
      }
 
247
      return defaultTimeout;
 
248
   }
 
249
 
 
250
 
 
251
}
 
 
b'\\ No newline at end of file'