001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: A_multi.java 3813 2003-12-03 13:01:20Z coqp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.stests.manac;
027:
028: /**
029: * This TestCase is a set of multithreaded clients accessing concurrently
030: * the set of accounts. For each test, an indicative Time (in millisec) is
031: * given, to have a rough idea of the relative time of the test case.
032: * (first value = CMP1, second value = CMP2)
033: */
034: public abstract class A_multi extends A_manac {
035:
036: // default values
037: int accounts = 20; // 20 accounts (nb of pre-created accounts)
038: int delay = 0; // no delay added
039: int loops = 1; // 1 loop
040: int amount = 10; // withdraw value : 10 (initial value is 1000)
041: int threads = 2; // 2 threads
042: int checklevel = 2; // check accounts after every test
043: int timeout = 12; // 12 seconds
044:
045: public A_multi(String name) {
046: super (name);
047: }
048:
049: public int getAccounts() {
050: return accounts;
051: }
052:
053: /*
054: * Simplest test with 2 threads : 1 loop, 2 threads, no rollback, no delay
055: * Time:
056: */
057: public void testBasic() throws Exception {
058: manac(accounts, delay, loops, amount, threads, checklevel,
059: timeout);
060: }
061:
062: /*
063: * 2 threads with possible rollback
064: * Time:
065: */
066: public void testRb() throws Exception {
067: int accounts = 6;
068: int loops = 10;
069: int amount = 400;
070: manac(accounts, delay, loops, amount, threads, checklevel,
071: timeout);
072: }
073:
074: /*
075: * add a delay
076: * Time:
077: */
078: public void testD3T3() throws Exception {
079: int accounts = 4;
080: int delay = 3;
081: int loops = 6;
082: int threads = 3;
083: manac(accounts, delay, loops, amount, threads, checklevel,
084: timeout);
085: }
086:
087: /*
088: * 4 threads
089: * Time:
090: */
091: public void testT4() throws Exception {
092: int loops = 12;
093: int threads = 4;
094: manac(accounts, delay, loops, amount, threads, checklevel,
095: timeout);
096: }
097:
098: /*
099: * 6 threads
100: * Time: 3,449 20,143 (or possible failure)
101: */
102: public void testT6() throws Exception {
103: int loops = 8;
104: int threads = 6;
105: manac(accounts, delay, loops, amount, threads, checklevel,
106: timeout);
107: }
108:
109: /*
110: * 6 threads with collisions
111: * Time: 27,967 52,204
112: */
113: public void testCollT6() throws Exception {
114: int accounts = 4;
115: int threads = 6;
116: manac(accounts, delay, loops, amount, threads, checklevel,
117: timeout);
118: }
119:
120: /*
121: * 8 threads
122: * Time: 73,842 failure
123: */
124: public void testT8() throws Exception {
125: int loops = 6;
126: int threads = 8;
127: manac(accounts, delay, loops, amount, threads, checklevel,
128: timeout);
129: }
130:
131: /*
132: * 8 threads with many collisions
133: * Time: 42,465 42,846
134: */
135: public void testCollT8() throws Exception {
136: int accounts = 4;
137: int threads = 8;
138: manac(accounts, delay, loops, amount, threads, checklevel,
139: timeout);
140: }
141:
142: /*
143: * 16 threads
144: * Time: 33,22 failure
145: */
146: public void testT16() throws Exception {
147: int threads = 16;
148: manac(accounts, delay, loops, amount, threads, checklevel,
149: timeout);
150: }
151:
152: /*
153: * more threads again
154: * failure failure
155: */
156: public void testT30() throws Exception {
157: int threads = 30;
158: manac(accounts, delay, loops, amount, threads, checklevel,
159: timeout);
160: }
161:
162: /*
163: * 4 threads and possible create
164: * Time: 3,706 3,227
165: */
166: public void testCreateT4() throws Exception {
167: int accounts = 200;
168: int loops = 12;
169: int threads = 4;
170: manac(accounts, delay, loops, amount, threads, checklevel,
171: timeout);
172: }
173:
174: /*
175: * 2 threads with possible rollback and create
176: * Time: 3,601 7,146
177: */
178: public void testCreateRbT2() throws Exception {
179: int accounts = 100;
180: int loops = 10;
181: int amount = 444;
182: manac(accounts, delay, loops, amount, threads, checklevel,
183: timeout);
184: }
185:
186: /*
187: * 4 threads with delay and possible create
188: * Time:
189: */
190: public void testCreateD2T4() throws Exception {
191: int accounts = 200;
192: int delay = 2;
193: int threads = 4;
194: manac(accounts, delay, loops, amount, threads, checklevel,
195: timeout);
196: }
197:
198: /*
199: * 6 threads and possible create
200: * Time:
201: */
202: public void testCreateT6() throws Exception {
203: int accounts = 400;
204: int loops = 8;
205: int threads = 6;
206: manac(accounts, delay, loops, amount, threads, checklevel,
207: timeout);
208: }
209:
210: /*
211: * 8 threads and possible create
212: * Time:
213: */
214: public void testCreateT8() throws Exception {
215: int accounts = 400;
216: int loops = 6;
217: int threads = 8;
218: manac(accounts, delay, loops, amount, threads, checklevel,
219: timeout);
220: }
221:
222: /*
223: * 16 threads and possible create
224: * Time: 5,381 15,261
225: */
226: public void testCreateT16() throws Exception {
227: int accounts = 800;
228: int threads = 16;
229: manac(accounts, delay, loops, amount, threads, checklevel,
230: timeout);
231: }
232:
233: /*
234: * 16 threads more loops
235: * Time: 14,431 14,239
236: */
237: public void testCreateD1T16() throws Exception {
238: int accounts = 300;
239: int delay = 1;
240: int threads = 16;
241: manac(accounts, delay, loops, amount, threads, checklevel,
242: timeout);
243: }
244:
245: /*
246: * Test many create in parallell
247: */
248: public void testConcurrentCreate() throws Exception {
249: int accounts = 40;
250: int threads = 30;
251: int loops = 1;
252: int timeout = 18;
253: manac(accounts, delay, loops, amount, threads, checklevel,
254: timeout);
255: }
256:
257: }
|