Author: jfrederic.clere(a)jboss.com
Date: 2009-01-29 08:43:23 -0500 (Thu, 29 Jan 2009)
New Revision: 2242
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
Log:
Arrange trace and random sleeps.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2009-01-28 21:28:05 UTC
(rev 2241)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2009-01-29 13:43:23 UTC
(rev 2242)
@@ -30,6 +30,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
+import java.util.Random;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
@@ -49,6 +50,7 @@
private int nbtest = 10;
private int delay = 1000;
+ private Random rand = null;
private boolean checkcookie = true;
private boolean checknode = true;
private boolean success = true;
@@ -169,7 +171,7 @@
httpClient.getState().setCredentials(org.apache.commons.httpclient.auth.AuthScope.ANY,
cred);
}
- System.out.println("Connecting to " + URL);
+ // System.out.println("Connecting to " + URL);
Integer connectionTimeout = 40000;
bm.getParams().setParameter("http.socket.timeout",
connectionTimeout);
@@ -177,7 +179,7 @@
httpClient.getParams().setParameter("http.socket.timeout",
connectionTimeout);
httpClient.getParams().setParameter("http.connection.timeout",
connectionTimeout);
if (jsessionid != null) {
- System.out.println("jsessionid: " + jsessionid);
+ // System.out.println("jsessionid: " + jsessionid);
bm.setRequestHeader("Cookie", "JSESSIONID=" +
jsessionid);
}
@@ -188,15 +190,13 @@
httpResponseCode = httpClient.executeMethod(gm);
}
- System.out.println("response: " + httpResponseCode);
- System.out.println("response: " + bm.getStatusLine());
if (httpResponseCode == 200) {
Cookie[] cookies = httpClient.getState().getCookies();
- System.out.println( "Cookies: " + cookies);
+ // System.out.println( "Cookies: " + cookies);
if (cookies != null && cookies.length!=0) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
- System.out.println( "Cookie: " +
cookie.getName() + ", Value: " + cookie.getValue());
+ // System.out.println( "Cookie: " +
cookie.getName() + ", Value: " + cookie.getValue());
if (cookie.getName().equals("JSESSIONID")) {
if (jsessionid == null) {
jsessionid = cookie.getValue();
@@ -207,12 +207,12 @@
bm.releaseConnection();
return 0; // first time ok.
} else {
- System.out.println("cookie second time:
" + jsessionid);
if (jsessionid.compareTo(cookie.getValue()) == 0)
{
System.out.println("cookie ok");
bm.releaseConnection();
return 0;
} else {
+ System.out.println("cookie
\"second\" time: " + cookie.getValue());
System.out.println("cookie
changed");
bm.releaseConnection();
if (checkcookie)
@@ -253,7 +253,8 @@
requestedSessionId = null;
}
} else {
- System.out.println("Not 200");
+ System.out.println("response: " + httpResponseCode);
+ System.out.println("response: " + bm.getStatusLine());
success = false;
}
// System.out.println("response:\n" +
bm.getResponseBodyAsString(len));
@@ -266,6 +267,8 @@
return httpResponseCode;
}
public void run() {
+ if (rand == null)
+ rand = new Random();
try {
sleep(delay);
} catch (InterruptedException e) {}
@@ -276,11 +279,15 @@
success = false;
return;
}
- sleep((int)(Math.random() * 1000));
+ sleep((int)(rand.nextInt(100) * 10));
} catch (InterruptedException e) {
+ e.printStackTrace();
success = false;
+ return;
} catch (Exception e) {
+ e.printStackTrace();
success = false;
+ return;
}
}
System.out.println("DONE!");
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2009-01-28 21:28:05
UTC (rev 2241)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2009-01-29 13:43:23
UTC (rev 2242)
@@ -41,7 +41,7 @@
public class TestBase extends TestCase {
- /* Test */
+ /* Test that the sessions are really sticky */
public void testBase() {
boolean clienterror = false;
@@ -96,7 +96,7 @@
// Wait for it.
try {
- client.runit("/ROOT/MyCount", 10, true);
+ client.runit("/ROOT/MyCount", 20, true);
client.start();
client.join();
} catch (Exception ex) {
Show replies by date