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

« back to all changes in this revision

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