Author: jfrederic.clere(a)jboss.com
Date: 2008-09-28 04:00:42 -0400 (Sun, 28 Sep 2008)
New Revision: 1912
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
Log:
Improve tests.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2008-09-26 22:23:13 UTC
(rev 1911)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Client.java 2008-09-28 08:00:42 UTC
(rev 1912)
@@ -48,7 +48,9 @@
private int nbtest = 10;
private int delay = 1000;
private boolean checkcookie = true;
+ private boolean checknode = true;
private boolean success = true;
+ private String node = null;
/*
*
* Usage:
@@ -108,7 +110,11 @@
this.pass = pass;
return runit(URL, nbtest, checkcookie);
}
-
+ public int runit(String URL, int nbtest, boolean checkcookie, boolean checknode)
throws Exception
+ {
+ this.checknode = checknode;
+ return runit(URL, nbtest, checkcookie);
+ }
public int runit(String URL, int nbtest, boolean checkcookie) throws Exception
{
this.URL = URL;
@@ -186,6 +192,9 @@
if (cookie.getName().equals("JSESSIONID")) {
if (jsessionid == null) {
jsessionid = cookie.getValue();
+ String nodes[] =
jsessionid.split("\\.");
+ if (nodes.length == 2)
+ node = nodes[1];
System.out.println("cookie first time:
" + jsessionid);
bm.releaseConnection();
return 0; // first time ok.
@@ -195,6 +204,26 @@
System.out.println("cookie ok");
bm.releaseConnection();
return 0;
+ } else {
+ System.out.println("cookie
changed");
+ bm.releaseConnection();
+ if (checkcookie)
+ return -1;
+ else
+ if (checknode) {
+ String nodes[] =
cookie.getValue().split("\\.");
+ if (nodes.length != 2) {
+
System.out.println("Can't find node in cookie");
+ return -1;
+ }
+ if (nodes[1].compareTo(node) == 0) {
+ return 0;
+ } else {
+ System.out.println("node
changed too");
+ return -1;
+ }
+ } else
+ return 0;
}
}
}
@@ -247,5 +276,10 @@
public void setdelay(int delay) {
this.delay = delay;
}
-
+ public void setnode(String node) {
+ this.node = node;
+ }
+ public String getnode() {
+ return(node);
+ }
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-09-26 22:23:13
UTC (rev 1911)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-09-28 08:00:42
UTC (rev 1912)
@@ -112,6 +112,9 @@
}
}
static LifecycleListener createClusterListener(String groupa, int groupp, boolean
ssl) {
+ return createClusterListener(groupa, groupp, ssl, null);
+ }
+ static LifecycleListener createClusterListener(String groupa, int groupp, boolean
ssl, String domain) {
LifecycleListener lifecycle = null;
ClusterListener jcluster = null;
org.jboss.modcluster.ClusterListener pcluster = null;
@@ -121,12 +124,14 @@
jcluster.setAdvertiseGroupAddress(groupa);
jcluster.setAdvertisePort(groupp);
jcluster.setSsl(ssl);
+ jcluster.setDomain(domain);
lifecycle = jcluster;
} else {
pcluster = new org.jboss.modcluster.ClusterListener();
pcluster.setAdvertiseGroupAddress(groupa);
pcluster.setAdvertisePort(groupp);
pcluster.setSsl(ssl);
+ pcluster.setDomain(domain);
lifecycle = pcluster;
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2008-09-26
22:23:13 UTC (rev 1911)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2008-09-28
08:00:42 UTC (rev 1912)
@@ -57,7 +57,7 @@
service.addConnector(8009);
server.addService(service);
- cluster = Maintest.createClusterListener("232.0.0.2", 23364,
false);
+ cluster = Maintest.createClusterListener("232.0.0.2", 23364, false,
"dom1");
server.addLifecycleListener(cluster);
Maintest.listServices();
@@ -82,7 +82,7 @@
// Wait for it.
try {
- if (client.runit("http://localhost:7779/ROOT/MyCount", 10, true) !=
0)
+ if (client.runit("http://localhost:7779/ROOT/MyCount", 10, false,
true) != 0)
clienterror = true;
} catch (Exception ex) {
ex.printStackTrace();
@@ -122,6 +122,7 @@
wait.start();
// Run a test on it. (it waits until httpd as received the nodes information).
+ client.setnode("node4");
try {
client.setdelay(30000);
client.start();