Author: jfrederic.clere(a)jboss.com
Date: 2008-10-17 07:44:06 -0400 (Fri, 17 Oct 2008)
New Revision: 1960
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
Log:
Arrange the Failover tests.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java 2008-10-17 11:42:06
UTC (rev 1959)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/JBossWeb.java 2008-10-17 11:44:06
UTC (rev 1960)
@@ -172,15 +172,15 @@
copyFile(fdin, fd);
}
- public void addConnector(int port) throws IOException {
- addConnector(port, "http");
+ public Connector addConnector(int port) throws IOException {
+ return addConnector(port, "ajp");
}
- public void addConnector(int port, String scheme) throws IOException {
- addConnector(port, scheme, null);
+ public Connector addConnector(int port, String scheme) throws IOException {
+ return addConnector(port, scheme, null);
}
- public void addConnector(int port, String scheme, String address) throws IOException
{
+ public Connector addConnector(int port, String scheme, String address) throws
IOException {
Connector connector = createConnector( address,
@@ -188,6 +188,8 @@
// Look in StandardService to see why it works ;-)
addConnector( connector );
+
+ return connector;
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-10-17 11:42:06
UTC (rev 1959)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2008-10-17 11:44:06
UTC (rev 1960)
@@ -115,6 +115,11 @@
return createClusterListener(groupa, groupp, ssl, null);
}
static LifecycleListener createClusterListener(String groupa, int groupp, boolean
ssl, String domain) {
+ return createClusterListener(groupa, groupp, ssl, domain, true, false, true);
+ }
+ static LifecycleListener createClusterListener(String groupa, int groupp, boolean
ssl, String domain,
+ boolean stickySession, boolean
stickySessionRemove,
+ boolean stickySessionForce) {
LifecycleListener lifecycle = null;
ClusterListener jcluster = null;
org.jboss.modcluster.ClusterListener pcluster = null;
@@ -125,6 +130,9 @@
jcluster.setAdvertisePort(groupp);
jcluster.setSsl(ssl);
jcluster.setDomain(domain);
+ jcluster.setStickySession(stickySession);
+ jcluster.setStickySessionRemove(stickySessionRemove);
+ jcluster.setStickySessionForce(stickySessionForce);
lifecycle = jcluster;
} else {
pcluster = new org.jboss.modcluster.ClusterListener();
@@ -132,6 +140,9 @@
pcluster.setAdvertisePort(groupp);
pcluster.setSsl(ssl);
pcluster.setDomain(domain);
+ pcluster.setStickySession(stickySession);
+ pcluster.setStickySessionRemove(stickySessionRemove);
+ pcluster.setStickySessionForce(stickySessionForce);
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-10-17
11:42:06 UTC (rev 1959)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2008-10-17
11:44:06 UTC (rev 1960)
@@ -49,14 +49,21 @@
boolean clienterror = false;
server = Maintest.getServer();
JBossWeb service = null;
+ JBossWeb service2 = null;
+ Connector connector = null;
+ Connector connector2 = null;
LifecycleListener cluster = null;
try {
// server = (StandardServer) ServerFactory.getServer();
service = new JBossWeb("node3", "localhost");
- service.addConnector(8009);
+ connector = service.addConnector(8009);
server.addService(service);
+ service2 = new JBossWeb("node4", "localhost");
+ connector2 = service2.addConnector(8000);
+ server.addService(service2);
+
cluster = Maintest.createClusterListener("232.0.0.2", 23364, false,
"dom1");
server.addLifecycleListener(cluster);
Maintest.listServices();
@@ -89,40 +96,28 @@
clienterror = true;
}
- // Stop jboss.
- try {
- wait.stopit();
- wait.join();
- server.removeService(service);
- server.removeLifecycleListener(cluster);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- fail("can't stop server");
+ // Stop the connector that has received the request...
+ String node = client.getnode();
+ if ("node4".equals(node)) {
+ connector = connector2;
+ node = "node3";
+ } else {
+ node = "node4";
}
+ if (connector != null) {
+ try {
+ connector.stop();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("can't stop connector");
+ }
+ }
if (clienterror)
fail("Client error");
- // Start a new one.
- try {
- service = new JBossWeb("node4", "localhost");
- service.addConnector(8000);
- server.addService(service);
-
- cluster = Maintest.createClusterListener("232.0.0.2", 23364,
false);
- server.addLifecycleListener(cluster);
-
- } catch(IOException ex) {
- ex.printStackTrace();
- fail("Server start() failed");
- }
-
- // Start a server thread.
- wait = new ServerThread(3000, server);
- wait.start();
-
// Run a test on it. (it waits until httpd as received the nodes information).
- client.setnode("node4");
+ client.setnode(node);
try {
client.setdelay(30000);
client.start();