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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/performance/synchronous/PerformanceTestCase.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
* 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.
 
6
*
 
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.
 
11
*
 
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.
 
16
*
 
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.
 
21
*/
 
22
 
 
23
package org.jboss.test.remoting.performance.synchronous;
 
24
 
 
25
import org.apache.log4j.Level;
 
26
import org.jboss.jrunit.harness.BenchmarkTestDriver;
 
27
 
 
28
/**
 
29
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
30
 */
 
31
public class PerformanceTestCase extends BenchmarkTestDriver //TestDriver
 
32
{
 
33
   protected int numberOfClients = 1;
 
34
 
 
35
   public static final String REMOTING_TRANSPORT = "remoting.transport";
 
36
   public static final String REMOTING_METADATA = "remoting.metadata";
 
37
   public static final String REMOTING_METADATA_CALLBACK = "remoting.metadata.callback";
 
38
   public static final String REMOTING_SERIALIZATION = "remoting.serialization";
 
39
   public static final String PAYLOAD_SIZE = "remoting.payload.size";
 
40
   public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients";
 
41
   public static final String NUMBER_OF_CALLS = "remoting.number_of_calls";
 
42
   public static final String JVM_MAX_HEAP_SIZE = "jvm.mx";
 
43
   public static final String RESULT_TIMEOUT = "jrunit.result_timeout";
 
44
   public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout";
 
45
   public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout";
 
46
   public static final String REMOTING_HOST = "remoting.host";
 
47
 
 
48
   public void declareTestClasses()
 
49
   {
 
50
      //**************** LOGGING ***********************
 
51
      //org.apache.log4j.BasicConfigurator.configure();
 
52
      //org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
 
53
      //org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
 
54
 
 
55
      //org.apache.log4j.SimpleLayout layout = new org.apache.log4j.SimpleLayout();
 
56
 
 
57
//      try
 
58
//      {
 
59
//         org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log");
 
60
//         fileAppender.setThreshold(Level.DEBUG);
 
61
//         fileAppender.setAppend(false);
 
62
//         org.apache.log4j.Category.getRoot().addAppender(fileAppender);
 
63
//      }
 
64
//      catch(IOException e)
 
65
//      {
 
66
//         e.printStackTrace();
 
67
//      }
 
68
      //*************** END LOGGING ***********************
 
69
 
 
70
 
 
71
      String numOfClients = System.getProperty(NUMBER_OF_CLIENTS);
 
72
      if(numOfClients != null && numOfClients.length() > 0)
 
73
      {
 
74
         try
 
75
         {
 
76
            numberOfClients = Integer.parseInt(numOfClients);
 
77
         }
 
78
         catch(NumberFormatException e)
 
79
         {
 
80
            e.printStackTrace();
 
81
         }
 
82
      }
 
83
 
 
84
      addTestClasses(getClientTestClass(),
 
85
                     numberOfClients,
 
86
                     PerformanceServerTest.class.getName());
 
87
   }
 
88
 
 
89
   protected String getClientTestClass()
 
90
   {
 
91
      return PerformanceClientTest.class.getName();
 
92
   }
 
93
 
 
94
   protected Level getTestHarnessLogLevel()
 
95
   {
 
96
      return Level.INFO;
 
97
      //return Level.DEBUG;
 
98
   }
 
99
 
 
100
   /**
 
101
    * The log level to run as for the test case.
 
102
    *
 
103
    * @return
 
104
    */
 
105
   protected Level getTestLogLevel()
 
106
   {
 
107
      return Level.INFO;
 
108
      //return Level.DEBUG;
 
109
   }
 
110
 
 
111
   /**
 
112
    * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness).
 
113
    * The default value is null.
 
114
    *
 
115
    * @return
 
116
    */
 
117
   protected String getClientJVMArguments()
 
118
   {
 
119
      return getJVMArguments();
 
120
//      String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 ";
 
121
//      args = args + getJVMArguments();
 
122
//      return args;
 
123
   }
 
124
 
 
125
   /**
 
126
    * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness).
 
127
    * The default value is null.
 
128
    *
 
129
    * @return
 
130
    */
 
131
   protected String getServerJVMArguments()
 
132
   {
 
133
      return getJVMArguments();
 
134
   }
 
135
 
 
136
   /**
 
137
    * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness).
 
138
    * The default value is null.
 
139
    *
 
140
    * @return
 
141
    */
 
142
   private String getJVMArguments()
 
143
   {
 
144
      String vmArgs = "";
 
145
 
 
146
      String transport = System.getProperty(REMOTING_TRANSPORT);
 
147
      if(transport != null && transport.length() > 0)
 
148
      {
 
149
         vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport;
 
150
      }
 
151
      String host = System.getProperty(REMOTING_HOST);
 
152
      if(host != null && host.length() > 0)
 
153
      {
 
154
         vmArgs = vmArgs + " -D" + REMOTING_HOST + "=" + host;
 
155
      }
 
156
      String serialization = System.getProperty(REMOTING_SERIALIZATION);
 
157
      if(serialization != null && serialization.length() > 0)
 
158
      {
 
159
         vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization;
 
160
      }
 
161
      String metadata = System.getProperty(REMOTING_METADATA);
 
162
      if(metadata != null && metadata.length() > 0)
 
163
      {
 
164
         vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata;
 
165
      }
 
166
      String callbackMetadata = System.getProperty(REMOTING_METADATA_CALLBACK);
 
167
      if(callbackMetadata != null && callbackMetadata.length() > 0)
 
168
      {
 
169
         vmArgs = vmArgs + " -D" + REMOTING_METADATA_CALLBACK + "=" + callbackMetadata;
 
170
      }
 
171
      String payloadSize = System.getProperty(PAYLOAD_SIZE);
 
172
      if(payloadSize != null && payloadSize.length() > 0)
 
173
      {
 
174
         vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize;
 
175
      }
 
176
      String numOfCalls = System.getProperty(NUMBER_OF_CALLS);
 
177
      if(numOfCalls != null && numOfCalls.length() > 0)
 
178
      {
 
179
         vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls;
 
180
      }
 
181
      String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE);
 
182
      if(jvmMx != null && jvmMx.length() > 0)
 
183
      {
 
184
         vmArgs = vmArgs + " -Xmx" + jvmMx + "m";
 
185
      }
 
186
 
 
187
      return vmArgs;
 
188
   }
 
189
 
 
190
   /**
 
191
    * How long to wait for test results to be returned from the client(s).  If goes longer than the
 
192
    * specified limit, will throw an exception and kill the running test cases.  Default value is
 
193
    * RESULTS_TIMEOUT.
 
194
    *
 
195
    * @return
 
196
    */
 
197
   protected long getResultsTimeout()
 
198
   {
 
199
      long defaultTimeout = 600000; // default to 10 minutes
 
200
 
 
201
      String timeout = System.getProperty(RESULT_TIMEOUT);
 
202
      if(timeout != null && timeout.length() > 0)
 
203
      {
 
204
         try
 
205
         {
 
206
            defaultTimeout = Long.parseLong(timeout);
 
207
         }
 
208
         catch(NumberFormatException e)
 
209
         {
 
210
            System.out.println("Can not use " + timeout + " as timeout value as is not a number");
 
211
         }
 
212
      }
 
213
      return defaultTimeout;
 
214
   }
 
215
 
 
216
   /**
 
217
    * How long for the server test case to wait for tear down message.  If exceeds timeout,
 
218
    * will throw exception.  The default value is TEARDOWN_TIMEOUT.
 
219
    *
 
220
    * @return
 
221
    */
 
222
   protected long getTearDownTimeout()
 
223
   {
 
224
      long defaultTimeout = 600000; // default to 10 minutes
 
225
 
 
226
      String timeout = System.getProperty(TEAR_DOWN_TIMEOUT);
 
227
      if(timeout != null && timeout.length() > 0)
 
228
      {
 
229
         try
 
230
         {
 
231
            defaultTimeout = Long.parseLong(timeout);
 
232
         }
 
233
         catch(NumberFormatException e)
 
234
         {
 
235
            System.out.println("Can not use " + timeout + " as timeout value as is not a number");
 
236
         }
 
237
      }
 
238
      return defaultTimeout;
 
239
   }
 
240
 
 
241
   /**
 
242
    * How long to allow each of the test cases to run their tests.  If exceeds this timeout
 
243
    * will throw exception and kill tests.  The default value is RUN_TEST_TIMEOUT.
 
244
    *
 
245
    * @return
 
246
    */
 
247
   protected long getRunTestTimeout()
 
248
   {
 
249
      long defaultTimeout = 600000; // default to 10 minutes
 
250
 
 
251
      String timeout = System.getProperty(RUN_TEST_TIMEOUT);
 
252
      if(timeout != null && timeout.length() > 0)
 
253
      {
 
254
         try
 
255
         {
 
256
            defaultTimeout = Long.parseLong(timeout);
 
257
         }
 
258
         catch(NumberFormatException e)
 
259
         {
 
260
            System.out.println("Can not use " + timeout + " as timeout value as is not a number");
 
261
         }
 
262
      }
 
263
      return defaultTimeout;
 
264
   }
 
265
 
 
266
}