Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ns

  • Loading branch information...
commit 9921795889365d606dcc3ec9f8837bd95be41c70 1 parent 25b574b
Bela Ban authored February 18, 2013
2  conf/testng/testng-tcp.xml
@@ -4,7 +4,7 @@
4 4
        thread-count="5"
5 5
         >
6 6
 
7  
-    <test name="tcp" junit="false" time-out="60000">
  7
+    <test name="tcp" junit="false" time-out="1200000">
8 8
         <parameter name="channel.conf" value="tcp.xml"/>
9 9
         <groups>
10 10
             <run>
6  tests/junit/org/jgroups/tests/ChannelTestBase.java
@@ -348,11 +348,7 @@ public String getName() {
348 348
         public void cleanup() {
349 349
             if (thread != null && thread.isAlive())
350 350
                 thread.interrupt();
351  
-            try {
352  
-                channel.close();
353  
-            } catch (Throwable t) {
354  
-                log.warn("Exception while closing channel " + getName(), t);
355  
-            }
  351
+            Util.close(channel);
356 352
         }
357 353
 
358 354
         public String getEventSequence() {
156  tests/junit/org/jgroups/tests/FlushTest.java
@@ -20,10 +20,9 @@
20 20
  * 
21 21
  * @author Bela Ban
22 22
  */
23  
-@Test(groups = Global.FLUSH, sequential = false)
  23
+@Test(groups = Global.FLUSH, sequential = true)
24 24
 public class FlushTest extends ChannelTestBase {
25 25
 
26  
-    @Test
27 26
     public void testSingleChannel() throws Exception {
28 27
         Semaphore s = new Semaphore(1);
29 28
         FlushTestReceiver receivers[] ={ new FlushTestReceiver("c1", s, 0, FlushTestReceiver.CONNECT_ONLY) };
@@ -34,155 +33,129 @@ public void testSingleChannel() throws Exception {
34 33
         Channel[] tmp = new Channel[receivers.length];
35 34
         for (int i = 0; i < receivers.length; i++)
36 35
             tmp[i] = receivers[i].getChannel();
37  
-        Util.waitUntilAllChannelsHaveSameSize(60000, 1000, tmp);
  36
+        Util.waitUntilAllChannelsHaveSameSize(10000, 1000, tmp);
38 37
 
39  
-        // Reacquire the semaphore tickets; when we have them all
40  
-        // we know the threads are done
41  
-        s.tryAcquire(1, 60, TimeUnit.SECONDS);
  38
+        // Reacquire the semaphore tickets; when we have them all we know the threads are done
  39
+        s.tryAcquire(1, 10, TimeUnit.SECONDS);
42 40
         receivers[0].cleanup();
43 41
         Util.sleep(1000);
44 42
 
45 43
         checkEventStateTransferSequence(receivers[0]);
46 44
     }
47 45
 
48  
-    /**
49  
-     * Tests issue #1 in http://jira.jboss.com/jira/browse/JGRP-335
50  
-     * 
51  
-     * @throws Exception
52  
-     */
53  
-    @Test
  46
+    /** Tests issue #1 in http://jira.jboss.com/jira/browse/JGRP-335 */
54 47
     public void testJoinFollowedByUnicast() throws Exception {
55  
-        JChannel c1 = null;
56  
-        JChannel c2 = null;
  48
+        JChannel a = null;
  49
+        JChannel b = null;
57 50
         try {
58  
-            c1 = createChannel(true, 2);
59  
-            c1.setReceiver(new SimpleReplier(c1, true));
60  
-            c1.connect("testJoinFollowedByUnicast");
  51
+            a = createChannel(true, 2, "A");
  52
+            a.setReceiver(new SimpleReplier(a,true));
  53
+            a.connect("testJoinFollowedByUnicast");
61 54
 
62  
-            Address target = c1.getAddress();
  55
+            Address target = a.getAddress();
63 56
             Message unicast_msg = new Message(target);
64 57
 
65  
-            c2 = createChannel(c1);
66  
-            c2.setReceiver(new SimpleReplier(c2, false));
67  
-            c2.connect("testJoinFollowedByUnicast");
  58
+            b = createChannel(a, "B");
  59
+            b.setReceiver(new SimpleReplier(b,false));
  60
+            b.connect("testJoinFollowedByUnicast");
68 61
 
69 62
             // now send unicast, this might block as described in the case
70  
-            c2.send(unicast_msg);
  63
+            b.send(unicast_msg);
71 64
             // if we don't get here this means we'd time out
72 65
         } finally {
73  
-            Util.close(c2, c1);
  66
+            Util.close(b, a);
74 67
         }
75 68
     }
76 69
 
77 70
     /**
78 71
      * Tests issue #2 in http://jira.jboss.com/jira/browse/JGRP-335
79  
-     * 
80  
-     * @throws Exception
81 72
      */
82  
-    @Test
83 73
     public void testStateTransferFollowedByUnicast() throws Exception {
84  
-        JChannel c1 = null;
85  
-        JChannel c2 = null;
  74
+        JChannel a = null;
  75
+        JChannel b = null;
86 76
         try {
87  
-            c1 = createChannel(true, 2);
88  
-            c1.setReceiver(new SimpleReplier(c1, true));
89  
-            c1.connect("testStateTransferFollowedByUnicast");
  77
+            a = createChannel(true, 2, "A");
  78
+            a.setReceiver(new SimpleReplier(a,true));
  79
+            a.connect("testStateTransferFollowedByUnicast");
90 80
 
91  
-            Address target = c1.getAddress();
  81
+            Address target = a.getAddress();
92 82
             Message unicast_msg = new Message(target);
93 83
 
94  
-            c2 = createChannel(c1);
95  
-            c2.setReceiver(new SimpleReplier(c2, false));
96  
-            c2.connect("testStateTransferFollowedByUnicast");
  84
+            b = createChannel(a, "B");
  85
+            b.setReceiver(new SimpleReplier(b,false));
  86
+            b.connect("testStateTransferFollowedByUnicast");
97 87
 
98 88
             System.out.println("\n** Getting the state **");
99  
-            c2.getState(null, 10000);
  89
+            b.getState(null,10000);
100 90
             // now send unicast, this might block as described in the case
101  
-            c2.send(unicast_msg);
  91
+            b.send(unicast_msg);
102 92
         } finally {
103  
-            Util.close(c2, c1);
  93
+            Util.close(b, a);
104 94
         }
105 95
     }
106 96
     
107  
-    @Test
108 97
     public void testSequentialFlushInvocation() throws Exception {
109  
-        Channel channel = null, channel2 = null, channel3 = null;
  98
+        Channel a=null, b= null, c=null;
110 99
         try {
111  
-            channel = createChannel(true, 3);
112  
-            channel.setName("A");
  100
+            a = createChannel(true, 3, "A");
  101
+            a.connect("testSequentialFlushInvocation");
113 102
 
114  
-            channel2 = createChannel((JChannel) channel);
115  
-            channel2.setName("B");
  103
+            b = createChannel((JChannel) a, "B");
  104
+            b.connect("testSequentialFlushInvocation");
116 105
 
117  
-            channel3 = createChannel((JChannel) channel);
118  
-            channel3.setName("C");
  106
+            c = createChannel((JChannel) a, "C");
  107
+            c.connect("testSequentialFlushInvocation");
119 108
 
120  
-            channel.connect("x");
121  
-            channel2.connect("x");
122  
-            channel3.connect("x");
  109
+            Util.waitUntilAllChannelsHaveSameSize(10000, 1000, a,b,c);
123 110
             
124  
-            //we need to sleep here since coordinator (channel)
125  
-            //might be unblocked before channel3.connect() returns
126  
-            Util.sleep(500);
127  
-
128 111
             for (int i = 0; i < 100; i++) {
129 112
                 System.out.print("flush #" + i + ": ");
130  
-                long start = System.currentTimeMillis();
131  
-                channel.startFlush(false);
132  
-                channel.stopFlush();
133  
-                long diff = System.currentTimeMillis() - start;
  113
+                a.startFlush(false);
  114
+                a.stopFlush();
134 115
             }
135 116
         } finally {
136  
-            Util.close(channel, channel2, channel3);
  117
+            Util.close(a, b, c);
137 118
         }
138 119
     }
139 120
 
140  
-    @Test
141 121
     public void testFlushWithCrashedFlushCoordinator() throws Exception {
142  
-        JChannel c1 = null;
143  
-        JChannel c2 = null;
144  
-        JChannel c3 = null;
145  
-
  122
+        JChannel a = null, b = null, c = null;
146 123
         try {
147  
-            c1 = createChannel(true, 3, "C1"); changeProps(c1);
148  
-            c1.connect("testFlushWithCrashedFlushCoordinator");
  124
+            a = createChannel(true, 3, "A"); changeProps(a);
  125
+            a.connect("testFlushWithCrashedFlushCoordinator");
149 126
 
150  
-            c2 = createChannel(c1, "C2"); changeProps(c2);
151  
-            c2.connect("testFlushWithCrashedFlushCoordinator");
152  
-
153  
-            c3 = createChannel(c1, "C3"); changeProps(c3);
154  
-            c3.connect("testFlushWithCrashedFlushCoordinator");
  127
+            b = createChannel(a, "B"); changeProps(b);
  128
+            b.connect("testFlushWithCrashedFlushCoordinator");
155 129
 
  130
+            c = createChannel(a, "C"); changeProps(c);
  131
+            c.connect("testFlushWithCrashedFlushCoordinator");
156 132
 
157 133
 
  134
+            System.out.println("shutting down flush coordinator B");
  135
+            b.down(new Event(Event.SUSPEND_BUT_FAIL)); // send out START_FLUSH and then return
158 136
 
159  
-            System.out.println("shutting down flush coordinator C2");
160  
-            // send out START_FLUSH and then return
161  
-            c2.down(new Event(Event.SUSPEND_BUT_FAIL));
162  
-
163  
-            // now shut down C2. This means, after failure detection kicks in and the new coordinator takes over
164  
-            // (either C1 or C3), that the current flush started by C2 will be cancelled and a new flush (by C1 or C3)
  137
+            // now shut down B. This means, after failure detection kicks in and the new coordinator takes over
  138
+            // (either A or C), that the current flush started by B will be cancelled and a new flush (by A or C)
165 139
             // will be started
166  
-            Util.shutdown(c2);
  140
+            Util.shutdown(b);
167 141
 
168  
-            c1.getProtocolStack().findProtocol(FLUSH.class).setLevel("debug");
169  
-            c3.getProtocolStack().findProtocol(FLUSH.class).setLevel("debug");
  142
+            a.getProtocolStack().findProtocol(FLUSH.class).setLevel("debug");
  143
+            c.getProtocolStack().findProtocol(FLUSH.class).setLevel("debug");
170 144
 
171  
-            Util.waitUntilAllChannelsHaveSameSize(10000, 500, c1, c3);
  145
+            Util.waitUntilAllChannelsHaveSameSize(10000, 500, a, c);
172 146
 
173 147
             // cluster should not hang and two remaining members should have a correct view
174  
-            assertTrue("correct view size", c1.getView().size() == 2);
175  
-            assertTrue("correct view size", c3.getView().size() == 2);
  148
+            assertTrue("correct view size", a.getView().size() == 2);
  149
+            assertTrue("correct view size", c.getView().size() == 2);
176 150
 
177  
-            c1.getProtocolStack().findProtocol(FLUSH.class).setLevel("warn");
178  
-            c3.getProtocolStack().findProtocol(FLUSH.class).setLevel("warn");
  151
+            a.getProtocolStack().findProtocol(FLUSH.class).setLevel("warn");
  152
+            c.getProtocolStack().findProtocol(FLUSH.class).setLevel("warn");
179 153
 
180 154
         } finally {
181  
-            Util.close(c3, c2, c1);
  155
+            Util.close(c, b, a);
182 156
         }
183 157
     }
184 158
 
185  
-    @Test
186 159
     public void testFlushWithCrashedParticipant() throws Exception {
187 160
         JChannel c1 = null;
188 161
         JChannel c2 = null;
@@ -221,7 +194,6 @@ public void testFlushWithCrashedParticipant() throws Exception {
221 194
         }
222 195
     }
223 196
 
224  
-    @Test
225 197
     public void testFlushWithCrashedParticipants() throws Exception {
226 198
         JChannel c1 = null;
227 199
         JChannel c2 = null;
@@ -256,10 +228,7 @@ public void testFlushWithCrashedParticipants() throws Exception {
256 228
 
257 229
     /**
258 230
      * Tests http://jira.jboss.com/jira/browse/JGRP-661
259  
-     * 
260  
-     * @throws Exception
261 231
      */
262  
-    @Test
263 232
     public void testPartialFlush() throws Exception {
264 233
         JChannel c1 = null;
265 234
         JChannel c2 = null;
@@ -285,21 +254,18 @@ public void testPartialFlush() throws Exception {
285 254
     }
286 255
 
287 256
     /** Tests the emition of block/unblock/get|set state events */
288  
-    @Test
289 257
     public void testBlockingNoStateTransfer() throws Exception {
290 258
         String[] names = { "A", "B", "C", "D" };
291 259
         _testChannels(names, FlushTestReceiver.CONNECT_ONLY);
292 260
     }
293 261
 
294 262
     /** Tests the emition of block/unblock/get|set state events */
295  
-    @Test
296 263
     public void testBlockingWithStateTransfer() throws Exception {
297 264
         String[] names = { "A", "B", "C", "D" };
298 265
         _testChannels(names, FlushTestReceiver.CONNECT_AND_SEPARATE_GET_STATE);
299 266
     }
300 267
 
301 268
     /** Tests the emition of block/unblock/get|set state events */
302  
-    @Test
303 269
     public void testBlockingWithConnectAndStateTransfer() throws Exception {
304 270
         String[] names = { "A", "B", "C", "D" };
305 271
         _testChannels(names, FlushTestReceiver.CONNECT_AND_GET_STATE);
@@ -379,7 +345,7 @@ private static void changeProps(JChannel ... channels) {
379 345
     }
380 346
 
381 347
     private class FlushTestReceiver extends PushChannelApplicationWithSemaphore {
382  
-        private int connectMethod;
  348
+        private final int connectMethod;
383 349
 
384 350
         public static final int CONNECT_ONLY = 1;
385 351
 
@@ -447,7 +413,7 @@ protected void useChannel() throws Exception {
447 413
         }
448 414
     }
449 415
 
450  
-    private class SimpleReplier extends ReceiverAdapter {
  416
+    private static class SimpleReplier extends ReceiverAdapter {
451 417
         Channel channel;
452 418
 
453 419
         boolean handle_requests = false;

0 notes on commit 9921795

Please sign in to comment.
Something went wrong with that request. Please try again.