Author: jfrederic.clere(a)jboss.com
Date: 2009-01-21 11:47:05 -0500 (Wed, 21 Jan 2009)
New Revision: 2193
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java
Log:
Arrange the tests (wait between tests!).
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2009-01-21 16:29:10
UTC (rev 2192)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2009-01-21 16:47:05
UTC (rev 2193)
@@ -167,4 +167,48 @@
}
return result;
}
+ /* Check that the nodes are returned by the INFO command */
+ static boolean checkProxyInfo(LifecycleListener lifecycle, String [] nodes) {
+ String result = getProxyInfo(lifecycle);
+ if (result == null) {
+ if (nodes == null)
+ return true;
+ else
+ return false;
+ }
+ /* create array to check the nodes */
+ boolean [] n = null;
+ if (nodes != null && nodes.length>0) {
+ n = new boolean[nodes.length];
+ for (int i=0; i<nodes.length; i++) {
+ n[i] = false;
+ }
+ }
+
+ String [] records = result.split("\n");
+ int l = 0;
+ for (int i=0; i<records.length; i++) {
+ String [] results = records[i].split(",");
+ /* result[0] should be Node: [n] */
+ String [] data = results[0].split(": ");
+ if ("Node".equals(data[0])) {
+ if (n == null)
+ return false; /* we shouldn't have a node */
+ /* result[1] should be Name: node_name */
+ data = results[1].split(": ");
+ for (int j=0; j<nodes.length; j++) {
+ if (nodes[j].equals(data[1])) {
+ n[j] = true; /* found it */
+ }
+ }
+ }
+ }
+ if (n == null)
+ return true; /* done */
+ for (int j=0; j<nodes.length; j++) {
+ if (! n[j])
+ return false; /* not found */
+ }
+ return true;
+ }
}
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-21 16:29:10
UTC (rev 2192)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2009-01-21 16:47:05
UTC (rev 2193)
@@ -76,10 +76,15 @@
wait.start();
// Wait until httpd as received the nodes information.
- try {
- Thread.sleep(30000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
+ String [] nodes = new String[2];
+ nodes[0] = "node1";
+ nodes[1] = "node2";
+ while (!Maintest.checkProxyInfo(cluster, nodes)) {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
}
// Start the client and wait for it.
@@ -117,11 +122,13 @@
fail("Client error");
// Wait until httpd as received the stop messages.
+ while (!Maintest.checkProxyInfo(cluster, null)) {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
System.gc();
- try {
- Thread.sleep(20000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
}
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java 2009-01-21
16:29:10 UTC (rev 2192)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java 2009-01-21
16:47:05 UTC (rev 2193)
@@ -56,11 +56,11 @@
try {
// server = (StandardServer) ServerFactory.getServer();
- service = new JBossWeb("node3", "localhost");
+ service = new JBossWeb("sticky3", "localhost");
connector = service.addConnector(8009);
server.addService(service);
- service2 = new JBossWeb("node4", "localhost");
+ service2 = new JBossWeb("sticky4", "localhost");
connector2 = service2.addConnector(8888);
server.addService(service2);
@@ -78,10 +78,15 @@
wait.start();
// Wait until httpd as received the nodes information.
- try {
- Thread.sleep(30000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
+ String [] nodes = new String[2];
+ nodes[0] = "sticky3";
+ nodes[1] = "sticky4";
+ while (!Maintest.checkProxyInfo(cluster, nodes)) {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
}
// Start the client and wait for it.
@@ -98,11 +103,11 @@
// Stop the connector that has received the request...
String node = client.getnode();
- if ("node4".equals(node)) {
+ if ("sticky4".equals(node)) {
connector = connector2;
- node = "node3";
+ node = "sticky3";
} else {
- node = "node4";
+ node = "sticky4";
}
if (connector != null) {
try {
@@ -149,6 +154,15 @@
} catch (InterruptedException ex) {
ex.printStackTrace();
}
+/* In fact it doesn't stop correctly ... Something needs to be fixed
+ while (!Maintest.checkProxyInfo(cluster, null)) {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ */
// Test client result.
if ( !clienterror && client.httpResponseCode != 503 )
Show replies by date