0) {
- nonce = nnonce.substring(0, k);
- break;
- }
- }
- } else {
- System.out.println("response: " + httpResponseCode);
- System.out.println("response: " + bm.getStatusLine());
- throw(new Exception("Reponse notok"));
- }
- // System.out.println("response:\n" + bm.getResponseBodyAsString(len));
- } catch(HttpException e) {
- System.out.println("error: " + e);
- throw(e);
- }
- bm.releaseConnection();
- }
- /*
- * Disable a Node
- */
- public void disable(String node) throws Exception {
- String DURL = URL + "?nonce=" + nonce + "&Cmd=DISABLE-APP&Range=NODE&JVMRoute=" + node;
- DoCmd(DURL);
- }
- /* Disable a Context */
- public void disable(String node, String host, String context) throws Exception {
- String DURL = URL + "?nonce=" + nonce + "&Cmd=DISABLE-APP&Range=CONTEXT&JVMRoute=" + node +
- "&Alias=" + host +
- "&Context=" + context;
- DoCmd(DURL);
- }
-
- private String DoCmd(String DURL) throws Exception {
- GetMethod gm = new GetMethod(DURL);
- try {
- httpResponseCode = httpClient.executeMethod(gm);
-
- if (httpResponseCode == 200) {
- String result = gm.getResponseBodyAsString();
- gm.releaseConnection();
- return result;
- }
- } catch (HttpException e) {
- System.out.println("error: " + e);
- throw(e);
- }
- gm.releaseConnection();
- throw(new Exception("Reponse notok"));
-
- }
- public String getProxyInfo() throws Exception {
- String DURL = URL + "?nonce=" + nonce + "&Cmd=INFO&Range=ALL";
- return DoCmd(DURL);
- }
- public boolean isApacheHttpd() throws Exception {
- GetMethod gm = new GetMethod(URL);
- try {
- httpResponseCode = httpClient.executeMethod(gm);
- } catch (HttpException e) {
- System.out.println("error: " + e);
- throw(e);
- }
- gm.releaseConnection();
- Header head = gm.getResponseHeader("Server");
- if (head != null)
- return head.toString().contains("Apache/2");
- return false;
- }
-}
diff --git a/test/java/src/main/java/org/jboss/mod_cluster/MyCount.java b/test/java/src/main/java/org/jboss/mod_cluster/MyCount.java
deleted file mode 100644
index ba73da4dd..000000000
--- a/test/java/src/main/java/org/jboss/mod_cluster/MyCount.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright(c) 2006 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision: 420067 $, $Date: 2006-07-08 09:16:58 +0200 (sub, 08 srp 2006) $
- */
-
-import java.io.*;
-import java.text.*;
-import java.util.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-
-
-/**
- * Example servlet showing cookies handling (counter).
- *
- */
-
-public class MyCount extends HttpServlet {
-
- public void init(ServletConfig config) throws ServletException {
- String swait = config.getInitParameter("wait");
- int wait = 0;
- if (swait != null) {
- Integer iwait = new Integer(swait);
- wait = iwait.intValue();
- }
-
- if (wait != 0) {
- Thread me = Thread.currentThread();
- try {
- me.sleep(wait);
- } catch(Exception e) {
- throw new ServletException("sleep interrupted");
- }
- }
- }
-
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException
- {
- response.setContentType("text/html");
-
- PrintWriter out = response.getWriter();
- out.println("");
- out.println("");
- out.println("");
-
- String title = "sessions.title";
- out.println("" + title + "");
- out.println("");
- out.println("");
-
- out.println("" + title + "
");
- HttpSession session = request.getSession(false);
- Integer ii = new Integer(0);
- if (session == null) {
- // Create it.
- out.println("create");
- session = request.getSession(true);
- session.setAttribute("count", ii);
- }
- out.println("sessions.id " + session.getId());
- out.println("
");
- out.println("sessions.created ");
- out.println(new Date(session.getCreationTime()) + "
");
- out.println("sessions.lastaccessed ");
- out.println(new Date(session.getLastAccessedTime()));
- out.println("sessions.count ");
- out.println(session.getAttribute("count"));
-
- ii = (Integer) session.getAttribute("count");
- int i = 0;
- if (ii != null)
- i = ii.intValue();
- i++;
- ii = new Integer(i); // JAVA5 : ii.valueOf(i);
- session.setAttribute("count", ii);
-
- out.println("");
- out.println("sessions.data
");
- Enumeration names = session.getAttributeNames();
- while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
- String value = session.getAttribute(name).toString();
- out.println(name + " = " + value + "
");
- // response.addHeader(name, value);
- }
-
- out.println("
");
- out.print("
");
-
- out.println("GET based form:
");
- out.print("
");
-
- out.print("URL encoded ");
-
- out.println("");
- out.println("");
-
- out.println("");
- out.println("");
-
- /* Use headers */
- response.setHeader("RequestedSessionId", request.getRequestedSessionId());
-
- }
-
- public void doPost(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException
- {
- doGet(request, response);
- }
-
-}
diff --git a/test/java/src/main/java/org/jboss/mod_cluster/MyTest.java b/test/java/src/main/java/org/jboss/mod_cluster/MyTest.java
deleted file mode 100644
index b2cc80460..000000000
--- a/test/java/src/main/java/org/jboss/mod_cluster/MyTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright(c) 2009 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision: 420067 $, $Date: 2006-07-08 09:16:58 +0200 (sub, 08 srp 2006) $
- */
-
-import java.io.*;
-import java.text.*;
-import java.util.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-
-
-/**
- * Test servlet for mod_cluster tests.
- *
- */
-
-public class MyTest extends HttpServlet {
-
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException
- {
- response.setContentType("text/html");
-
- PrintWriter out = response.getWriter();
- out.println("");
- out.println("
");
- out.println("");
-
- String title = request.getContextPath() + "/Test servlet";
- out.println("" + title + "");
- out.println("");
- out.println("");
-
- out.println(" request.getContextPath(): " + request.getContextPath() + "
");
- out.println(" request.getQueryString(): " + request.getQueryString() + "
");
-
- String test = request.getParameter("test");
- if (test !=null && test.equalsIgnoreCase("timeout")) {
- Thread me = Thread.currentThread();
- try {
- me.sleep(15000);
- } catch(Exception e) {
- throw new ServletException("sleep interrupted");
- }
- }
-
- out.println("");
- out.println("");
-
- }
-
- public void doPost(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException
- {
- doGet(request, response);
- }
-
-}
diff --git a/test/java/src/main/java/org/jboss/mod_cluster/NodeInfo.java b/test/java/src/main/java/org/jboss/mod_cluster/NodeInfo.java
deleted file mode 100644
index 89588279c..000000000
--- a/test/java/src/main/java/org/jboss/mod_cluster/NodeInfo.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * mod_cluster
- *
- * Copyright(c) 2008 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision$
- */
-
-package org.jboss.mod_cluster;
-
-import java.util.ArrayList;
-
-public class NodeInfo {
- String JVMRoute;
- int lbfactor;
- int elected;
-
- /**
- * Check that nodes in nodeinfos corresponds to nodes in nodenames
- */
- static public boolean check(ArrayList nodes, String [] nodenames)
- {
- boolean [] in = new boolean[nodenames.length];
-
- if (nodes == null || nodenames == null) {
- System.out.println("No nodes or no names");
- return false;
- }
-
- NodeInfo [] nodeinfos = new NodeInfo[nodes.size()];
- for (int i=0; i= 0; read = in.read(buffer))
- System.out.write(buffer, 0, read);
- out.close();
- in.close();
- socket.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("can't send message");
- }
-
- // Read the result.
- String result = Maintest.getProxyInfo(cluster);
- System.out.println("INFO: " + result);
- if (result.indexOf("ModCluster349")==-1)
- fail("can't find ModCluster349 in: " + result);
-
- // Stop the jboss and remove the services.
- try {
- wait.stopit();
- wait.join();
-
- server.removeService(service);
- server.removeService(service2);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- fail("can't stop service");
- }
- if (clienterror)
- fail("Client error");
-
- // Wait until httpd as received the stop messages.
- countinfo = 0;
- nodes = null;
- while ((!Maintest.checkProxyInfo(cluster, nodes)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
- Maintest.StopClusterListener();
- System.gc();
- System.out.println("Test349 Done");
- }
-}
diff --git a/test/java/src/test/java/org/jboss/mod_cluster/TestAddDel.java b/test/java/src/test/java/org/jboss/mod_cluster/TestAddDel.java
deleted file mode 100644
index 43ed086fb..000000000
--- a/test/java/src/test/java/org/jboss/mod_cluster/TestAddDel.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * mod_cluster
- *
- * Copyright(c) 2008 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision$
- */
-
-package org.jboss.mod_cluster;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-
-import junit.framework.TestCase;
-
-import org.apache.catalina.Engine;
-import org.apache.catalina.Service;
-import org.jboss.modcluster.ModClusterService;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardServer;
-
-public class TestAddDel extends TestCase {
-
- /* Test */
- public void testAddDel() {
-
- boolean clienterror = false;
- int numbnodes = 10;
- String [] nodenames = new String [numbnodes];
- JBossWeb [] service = new JBossWeb[numbnodes];
- ModClusterService lifecycle = null;
-
- System.out.println("TestAddDel Started");
- System.setProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "false");
- StandardServer server = new StandardServer();
- for (int i=0; i1) {
- // Check that the last alias is also working.
- client = new Client();
- client.setVirtualHost(Aliases2[Aliases2.length-1]);
- try {
- if (client.runit(url, 10, false, true) != 0)
- clienterror = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (clienterror)
- fail("Client fail (long host: " +Aliases2[Aliases2.length-1] + ")");
- }
-
- // Start the client and wait for it.
- client = new Client();
- clienterror = false;
-
- // Wait for it.
- try {
- if (client.runit(url, 10, false, true) != 0)
- clienterror = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (clienterror)
- fail("Client error");
-
- // Test the other nodes
- if (virtualhosts != null)
- testVirtualHosts(virtualhosts);
-
- // Stop the connector that has received the request...
- url = "";
- if (webapps != null)
- url = "/test";
- node = client.getnode();
- if ("node4".equals(node)) {
- service2.removeContext(url);
- node = "node3";
- } else {
- service.removeContext(url);
- node = "node4";
- }
-
- // Run a test on it. (it waits until httpd as received the nodes information).
- client.setnode(node);
- try {
- client.setdelay(30000);
- client.start();
- client.join();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- if (client.getresultok())
- System.out.println("Test DONE");
- else {
- System.out.println("Test FAILED");
- clienterror = true;
- }
-
- // Test the other nodes
- if (virtualhosts != null) {
- if (virtualhosts.length == 2)
- test2VirtualHosts(virtualhosts, service, service2);
- else
- testVirtualHosts(virtualhosts);
- }
-
- // Stop the server or services.
- try {
- wait.stopit();
- wait.join();
- server.removeService(service);
- server.removeService(service2);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
-
- // Wait until httpd as received the stop messages.
- if (!Maintest.TestForNodes(cluster, null))
- fail("Can't stop nodes");
- Maintest.StopClusterListener();
-
- // Test client result.
- if (clienterror)
- fail("Client test failed");
-
- Maintest.testPort(8013);
- Maintest.testPort(8014);
- System.out.println("TestAliases Done");
- }
- private void myAliases(String [] Aliases,String [] Aliases2, VirtualHost [] virtualhosts) {
- myAliases(Aliases, Aliases2, virtualhosts, null);
- }
-
- private void testVirtualHosts(VirtualHost[] virtualhosts) {
- for (int i=0; i< virtualhosts.length; i++) {
- Client client = new Client();
- client.setVirtualHost(virtualhosts[i].host);
- // Wait for it.
- boolean clienterror = false;
- try {
- if (client.runit("/" + virtualhosts[i].context + "/" + virtualhosts[i].servletname, 10, false, true) != 0)
- clienterror = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (clienterror)
- fail("Client failed (" + virtualhosts[i].host + ")");
- System.out.println("Tested " + virtualhosts[i].host + " OK");
- }
-
- }
-
- /*
- * Tests:
- * v1 v1 app1 VirtualHost[0]
- * v2 v1 app2 VirtualHost[1]
- */
- private void test2VirtualHosts(VirtualHost[] virtualhosts, JBossWeb service, JBossWeb service2 ) {
- Client client = new Client();
- client.setVirtualHost(virtualhosts[0].host);
- // Wait for it.
- boolean clienterror = false;
- try {
- if (client.runit("/" + virtualhosts[0].context + "/" + virtualhosts[0].servletname, 10, false, true) != 0)
- clienterror = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (clienterror)
- fail("Client failed (" + virtualhosts[0].host + ")");
-
- // Now try the app2 on VirtualHost[0]
- client = new Client();
- client.setVirtualHost(virtualhosts[0].host);
- // Wait for it.
- clienterror = false;
- try {
- if (client.runit("/" + virtualhosts[0].context + "/" + virtualhosts[1].servletname, 10, false, true) != 0) {
- // Make sure the answer comes from JBossWeb
- if (client.getResponse().indexOf("JBoss Web") ==-1)
- fail("Got 404 from httpd");
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (clienterror)
- fail("Client failed (" + virtualhosts[0].host + ")");
-
- // Now stop the context on one virtuahost
- if (virtualhosts[1].addtofirst)
- service.removeContext("/" + virtualhosts[1].context, virtualhosts[1].host);
- else
- service2.removeContext("/" + virtualhosts[1].context, virtualhosts[1].host);
-
- // Now try the app2 on VirtualHost[1]
- client = new Client();
- client.setVirtualHost(virtualhosts[1].host);
- // Wait for it.
- clienterror = false;
- try {
- if (client.runit("/" + virtualhosts[1].context + "/" + virtualhosts[1].servletname, 10, false, true) != 0) {
- // Make sure the answer comes from httpd
- if (client.getResponse().indexOf("JBoss Web") ==-1)
- clienterror = true;
- else
- fail("Got 404 from JBoss Web");
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (!clienterror)
- fail("Client should have failed (" + virtualhosts[1].host + ")");
-
-
- client = new Client();
- client.setVirtualHost(virtualhosts[0].host);
- // Wait for it.
- clienterror = false;
- try {
- if (client.runit("/" + virtualhosts[0].context + "/" + virtualhosts[0].servletname, 10, false, true) != 0)
- clienterror = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (clienterror)
- fail("Client failed (" + virtualhosts[0].host + ")");
-
-
- }
-
-
- private void addVirtualHosts(JBossWeb service, JBossWeb service2, VirtualHost[] virtualhosts) throws IOException {
- for (int i=0; i< virtualhosts.length; i++) {
- if (virtualhosts[i].addtofirst) {
- service.AddHost( virtualhosts[i].host, virtualhosts[i].aliases);
- String path = "/"+virtualhosts[i].context;
- service.AddContext(path, path, virtualhosts[i].servletname, false, virtualhosts[i].host);
- } else {
- service2.AddHost( virtualhosts[i].host, virtualhosts[i].aliases);
- String path = "/"+virtualhosts[i].context;
- service2.AddContext(path, path, virtualhosts[i].servletname, false, virtualhosts[i].host);
- }
- }
-
- }
- public class VirtualHost {
- String host; // Name of the Host = 1 first Alias.
- String [] aliases; // Alias for the Host.
- boolean addtofirst; // node (well service) to add the virtualhost and context.
- String servletname; // Servlet to map. (MyCount or MyTest)
- String context; // context where the Servlet is deployed.
- }
-
-}
diff --git a/test/java/src/test/java/org/jboss/mod_cluster/TestAliasesSize.java b/test/java/src/test/java/org/jboss/mod_cluster/TestAliasesSize.java
deleted file mode 100644
index 4ae745866..000000000
--- a/test/java/src/test/java/org/jboss/mod_cluster/TestAliasesSize.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * mod_cluster
- *
- * Copyright(c) 2012 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision$
- */
-
-package org.jboss.mod_cluster;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.catalina.Engine;
-import org.apache.catalina.Service;
-import org.jboss.modcluster.ModClusterService;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardServer;
-
-public class TestAliasesSize extends TestCase {
-
- /* Test testAliasesSize (we test the MCMP maxsize here in fact) */
- public void testAliasesSize() {
-
- boolean clienterror = false;
- StandardServer server = new StandardServer();
- JBossWeb service = null;
- Connector connector = null;
- ModClusterService cluster = null;
- System.out.println("TestAliasesSize Started");
- System.setProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "false");
- try {
- String [] Aliases = new String[19];
- /* HOSTALIASZ is 100 that should be enough */
- for (int i=0; i < Aliases.length; i++) {
- Aliases[i] = "alias0123456789012345678901234567890123456789012345678901234567890123456789012345out" + i;
- }
- /* ~ 87 * 19 ~ 1740 :D */
-
- service = new JBossWeb("node3", "localhost", false, "ROOT", Aliases);
- connector = service.addConnector(8013);
- service.AddContext("/test", "/test");
- server.addService(service);
-
- cluster = Maintest.createClusterListener(server, "224.0.1.105", 23364, false, "dom1", true, false, true, "secret");
-
- } catch(Exception ex) {
- ex.printStackTrace();
- fail("can't start service");
- }
-
- // start the server thread.
- ServerThread wait = new ServerThread(3000, server);
- wait.start();
-
- // Wait until we are able to connect to httpd.
- int tries = Maintest.WaitForHttpd(cluster, 60);
- if (tries == -1) {
- fail("can't find PING-RSP in proxy response");
- }
-
- // Wait until 2 nodes are created in httpd.
- String [] nodes = new String[1];
- nodes[0] = "node3";
- Maintest.TestForNodes(cluster, nodes);
-
- // Test wrong Hostname.
- Client client = new Client();
- client.setVirtualHost("mycluster.domain.com");
-
- // Wait for it.
- try {
- if (client.runit("/test/MyCount", 10, false, true) != 0)
- clienterror = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (!clienterror)
- fail("Client should fail (wrong host)");
-
- // Test long Hostname.
- client = new Client();
- client.setVirtualHost("alias0123456789012345678901234567890123456789012345678901234567890123456789012345out18");
- clienterror = false;
-
- // Wait for it.
- try {
- if (client.runit("/test/MyCount", 10, false, true) != 0)
- clienterror = true;
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (clienterror)
- fail("Client fail (long host)");
-
- // Stop the server or services.
- try {
- wait.stopit();
- wait.join();
- server.removeService(service);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
-
- // Wait until httpd as received the stop messages.
- Maintest.TestForNodes(cluster, null);
- Maintest.StopClusterListener();
-
- // Test client result.
- if (clienterror)
- fail("Client test failed");
-
- Maintest.testPort(8013);
- System.out.println("TestAliasesSize Done");
- }
-}
diff --git a/test/java/src/test/java/org/jboss/mod_cluster/TestBalancers.java b/test/java/src/test/java/org/jboss/mod_cluster/TestBalancers.java
deleted file mode 100644
index f528ea8d3..000000000
--- a/test/java/src/test/java/org/jboss/mod_cluster/TestBalancers.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * mod_cluster
- *
- * Copyright(c) 2012 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision$
- */
-
-package org.jboss.mod_cluster;
-
-import junit.framework.TestCase;
-
-import org.jboss.modcluster.ModClusterService;
-import org.apache.catalina.core.StandardServer;
-
-public class TestBalancers extends TestCase {
- /* Test that the sessions are really sticky */
- public void testBalancers() {
- myBalancers(null, null, null, null);
- }
- public void testBalancers2() {
- myBalancers("balancer", "dom1", "balancer", "dom1");
- }
- public void testBalancers3() {
- myBalancers("balancer", "dom1", "balancer", "dom2");
- }
-
- /* We need 2 different applications if we have 2 balancers */
- public void testBalancers4() {
- myBalancers("balancer1", "dom1", "/app1", "balancer2", "dom2", "/app2", false);
- }
-
- /* Use Aliases and 2 balancers */
- public void testBalancers5() {
- myBalancers("balancer", "dom1", null, "balancer", "dom2", null, true);
- }
-
- private void myBalancers(String balancer, String loadBalancingGroup, String balancer2, String loadBalancingGroup2) {
- myBalancers(balancer, loadBalancingGroup, null, balancer2, loadBalancingGroup2, null, false);
- }
- private void myBalancers(String balancer, String loadBalancingGroup, String app, String balancer2, String loadBalancingGroup2, String app2, boolean testAlias) {
- boolean clienterror = false;
- System.setProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "false");
- StandardServer server = new StandardServer();
- StandardServer server2 = new StandardServer();
- JBossWeb service = null;
- JBossWeb service2 = null;
- ModClusterService cluster = null;
- ModClusterService cluster2 = null;
-
- System.out.println("TestBalancers Started");
-
- Maintest.waitForFreePorts(8011, 2);
-
- try {
-
- if (testAlias) {
- String [] Aliases = new String[1];
- Aliases[0] = "alias1";
- service = new JBossWeb("node1", "localhost", false, "ROOT", Aliases);
- } else
- service = new JBossWeb("node1", "localhost");
- service.addConnector(8011);
- if (app != null)
- service.AddContext(app, app, "MyCount", false);
- server.addService(service);
-
- if (testAlias) {
- String [] Aliases = new String[1];
- Aliases[0] = "alias2";
- service2 = new JBossWeb("node2", "localhost", false, "ROOT", Aliases);
- } else
- service2 = new JBossWeb("node2", "localhost");
- service2.addConnector(8012);
- if (app2 != null)
- service2.AddContext(app2, app2, "MyCount", false);
- server2.addService(service2);
-
- cluster = Maintest.createClusterListener(server, "224.0.1.105", 23364, false, null, true, false, true, "secret", balancer, loadBalancingGroup);
- cluster2 = Maintest.createClusterListener(server2, "224.0.1.105", 23364, false, null, true, false, true, "secret", balancer2, loadBalancingGroup2);
-
- } catch(Exception ex) {
- ex.printStackTrace();
- fail("can't start service");
- }
-
- // start the server thread.
- ServerThread wait = new ServerThread(3000, server);
- wait.start();
- ServerThread wait2 = new ServerThread(3000, server2);
- wait2.start();
-
- // Wait until httpd as received the nodes information.
- String [] nodes = new String[1];
- nodes[0] = "node1";
- int countinfo = 0;
- while ((!Maintest.checkProxyInfo(cluster, nodes)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
- if (countinfo == 20)
- fail("Can't start node1");
- nodes[0] = "node2";
- countinfo = 0;
- while ((!Maintest.checkProxyInfo(cluster2, nodes)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
- if (countinfo == 20)
- fail("Can't start node2");
-
- // Start the client and wait for it.
- Client client = new Client();
- String node = null;
- try {
- if (app == null)
- client.runit("/MyCount", 20, true);
- else
- client.runit(app + "/MyCount", 20, true);
- node = client.getnode();
- } catch (Exception e) {
- e.printStackTrace();
- clienterror = true;
- }
- countinfo = 0;
- while (client.getnode().equals(node) && !clienterror && countinfo < 20) {
- Client client2 = new Client();
- String url = "/MyCount";
- // We try to test that the other node on the other balancer is working too.
- if (client.getnode().equals("node1")) {
- if (app2 != null)
- url = app2 + "/MyCount";
- if (testAlias)
- client.setVirtualHost("node2");
- }
- if (client.getnode().equals("node2")) {
- if (app != null)
- url = app + "/MyCount";
- if (testAlias)
- client.setVirtualHost("node1");
- }
-
- try {
- client2.runit(url, 20, true);
- client.start();
- client.join();
- } catch (Exception e) {
- e.printStackTrace();
- clienterror = true;
- }
- client = client2;
- countinfo++;
- }
- if (countinfo == 20)
- fail("Can't connect to " + node);
-
- // Wait for it.
- try {
- client.start();
- client.join();
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (client.getresultok())
- System.out.println("Test DONE");
- else {
- System.out.println("Test FAILED");
- clienterror = true;
- }
-
- // Stop the jboss and remove the services.
- try {
- wait.stopit();
- wait.join();
- wait2.stopit();
- wait2.join();
-
- server.removeService(service);
- server2.removeService(service2);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- fail("can't stop service");
- }
- if (clienterror)
- fail("Client error");
-
- // Wait until httpd as received the stop messages.
- countinfo = 0;
- nodes = null;
- while ((!Maintest.checkProxyInfo(cluster, nodes)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
- Maintest.StopClusterListener();
-
- System.gc();
- System.out.println("TestBalancers Done");
- }
-}
diff --git a/test/java/src/test/java/org/jboss/mod_cluster/TestBase.java b/test/java/src/test/java/org/jboss/mod_cluster/TestBase.java
deleted file mode 100644
index 0969f7375..000000000
--- a/test/java/src/test/java/org/jboss/mod_cluster/TestBase.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * mod_cluster
- *
- * Copyright(c) 2008 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision$
- */
-
-package org.jboss.mod_cluster;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.catalina.Engine;
-import org.apache.catalina.Service;
-import org.jboss.modcluster.ModClusterService;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardServer;
-
-public class TestBase extends TestCase {
-
- /* Test that the sessions are really sticky */
- public void testBase() {
-
- boolean clienterror = false;
- StandardServer server = new StandardServer();
- JBossWeb service = null;
- JBossWeb service2 = null;
- ModClusterService cluster = null;
-
- System.out.println("TestBase Started");
- System.setProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "false");
- try {
-
- service = new JBossWeb("node1", "localhost");
- service.addConnector(8011);
- server.addService(service);
-
- service2 = new JBossWeb("node2", "localhost");
- service2.addConnector(8010);
- server.addService(service2);
-
- cluster = Maintest.createClusterListener(server, "224.0.1.105", 23364, false, null, true, false, true, "secret");
-
- } catch(Exception ex) {
- ex.printStackTrace();
- fail("can't start service");
- }
-
- // start the server thread.
- ServerThread wait = new ServerThread(3000, server);
- wait.start();
-
- // Wait until httpd as received the nodes information.
- String [] nodes = new String[2];
- nodes[0] = "node1";
- nodes[1] = "node2";
- int countinfo = 0;
- while ((!Maintest.checkProxyInfo(cluster, nodes)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
-
- // Start the client and wait for it.
- Client client = new Client();
-
- // Wait for it.
- try {
- client.runit("/MyCount", 20, true);
- client.start();
- client.join();
- } catch (Exception ex) {
- ex.printStackTrace();
- clienterror = true;
- }
- if (client.getresultok())
- System.out.println("Test DONE");
- else {
- System.out.println("Test FAILED");
- clienterror = true;
- }
-
- // Stop the jboss and remove the services.
- try {
- wait.stopit();
- wait.join();
-
- server.removeService(service);
- server.removeService(service2);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- fail("can't stop service");
- }
- if (clienterror)
- fail("Client error");
-
- // Wait until httpd as received the stop messages.
- countinfo = 0;
- nodes = null;
- while ((!Maintest.checkProxyInfo(cluster, nodes)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
- Maintest.StopClusterListener();
-
- System.gc();
- System.out.println("TestBase Done");
- }
-}
diff --git a/test/java/src/test/java/org/jboss/mod_cluster/TestBaseJgroups.java b/test/java/src/test/java/org/jboss/mod_cluster/TestBaseJgroups.java
deleted file mode 100644
index 939adb9f8..000000000
--- a/test/java/src/test/java/org/jboss/mod_cluster/TestBaseJgroups.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * mod_cluster
- *
- * Copyright(c) 2012 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision$
- */
-
-package org.jboss.mod_cluster;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.catalina.Engine;
-import org.apache.catalina.Service;
-import org.jboss.modcluster.ModClusterService;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardServer;
-
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-
-public class TestBaseJgroups extends TestCase {
-
- /* Test that the sessions are really sticky */
- public void testBase() {
- System.out.println("TestBaseJgroups doing nothing for the moment...");
- }
- public void NotestBase() {
-
- boolean clienterror = false;
- StandardServer server = new StandardServer();
- ModClusterService cluster = null;
- JBossWeb service = null;
-
- System.out.println("TestBaseJgroups Started");
- System.setProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "false");
- try {
- service = new JBossWeb("node1", "localhost");
- service.addConnector(8011);
- server.addService(service);
- cluster = Maintest.createClusterListener(server, "224.0.1.105", 23364, false, null, true, false, true, "secret");
- } catch(Exception ex) {
- ex.printStackTrace();
- fail("can't start service");
- }
-
- // start the server thread.
- ServerThread wait = new ServerThread(3000, server);
- wait.start();
-
- // Wait until httpd we know about httpd.
- String [] nodes = new String[1];
- nodes[0] = "node1";
- int countinfo = 0;
- while ((!Maintest.checkProxyInfo(cluster, nodes)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
-
- // Create 2 JGroups ID and query the result and remove them.
- String proxy = Maintest.getProxyAddress(cluster);
- String URL = "http://" + proxy + "/";
- HttpClient httpClient = new HttpClient();
- PostMethod pm = null;
- pm = (PostMethod) new AddIdMethod(URL);
- pm.addParameter("JGroupUuid", "ID1");
- pm.addParameter("JGroupData", "DATA1");
- String response = processrequest(pm, httpClient);
- if (response == null)
- fail("ADDID(1) failed on: " + URL);
-
- pm = (PostMethod) new AddIdMethod(URL);
- pm.addParameter("JGroupUuid", "ID2");
- pm.addParameter("JGroupData", "DATA2");
- response = processrequest(pm, httpClient);
- if (response == null)
- fail("ADDID(2) failed");
-
- pm = (PostMethod) new QueryMethod(URL);
- pm.addParameter("JGroupUuid", "*");
- response = processrequest(pm, httpClient);
- if (response == null)
- fail("QUERY failed");
- System.out.println("Response:\n" + response);
- String [] records = response.split("\n");
- if (records.length != 2)
- fail("QUERY return " + records.length + " JGroupUuid instead 2");
-
- pm = (PostMethod) new RemoveIdMethod(URL);
- pm.addParameter("JGroupUuid", "ID2");
- response = processrequest(pm, httpClient);
- if (response == null)
- fail("REMOVE(ID2) failed");
-
- pm = (PostMethod) new RemoveIdMethod(URL);
- pm.addParameter("JGroupUuid", "ID1");
- response = processrequest(pm, httpClient);
- if (response == null)
- fail("REMOVE(ID1) failed");
-
-/* See MODCLUSTER-282 it doesn't work on all hudson boxes.
- pm = (PostMethod) new QueryMethod(URL);
- pm.addParameter("JGroupUuid", "*");
- response = processrequest(pm, httpClient);
- if (response == null)
- fail("QUERY failed");
- System.out.println("Response:\n" + response);
- if (response.length() == 0)
- System.out.println("AddId + Remove OK");
- else
- fail("QUERY returns " + response + " instead nothing");
- */
-
- // Stop the jboss and remove the services.
- try {
- wait.stopit();
- wait.join();
- server.removeService(service);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- fail("can't stop service");
- }
- if (clienterror)
- fail("Client error");
-
- // Wait until httpd as received the stop messages.
- countinfo = 0;
- while ((!Maintest.checkProxyInfo(cluster, null)) && countinfo < 20) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- countinfo++;
- }
- Maintest.StopClusterListener();
-
- System.gc();
- System.out.println("TestBaseJgroups Done");
- }
-
- public static String processrequest(PostMethod pm, HttpClient httpClient)
- {
- Integer connectionTimeout = 40000;
- pm.getParams().setParameter("http.socket.timeout", connectionTimeout);
- pm.getParams().setParameter("http.connection.timeout", connectionTimeout);
- httpClient.getParams().setParameter("http.socket.timeout", connectionTimeout);
- httpClient.getParams().setParameter("http.connection.timeout", connectionTimeout);
-
- int httpResponseCode = 0;
- try {
- httpResponseCode = httpClient.executeMethod(pm);
- System.out.println("response: " + httpResponseCode);
- System.out.println("response: " + pm.getStatusLine());
- if (httpResponseCode == 500) {
- System.out.println(pm.getResponseHeader("Version"));
- System.out.println(pm.getResponseHeader("Type"));
- System.out.println(pm.getResponseHeader("Mess"));
- return null;
- }
- if (httpResponseCode == 200) {
- int len = (int) pm.getResponseContentLength();
- if (len != -1)
- return pm.getResponseBodyAsString(len);
- else
- return pm.getResponseBodyAsString();
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public class AddIdMethod extends PostMethod {
- public String getName() {
- return "ADDID";
- }
- public AddIdMethod(String uri) {
- super(uri);
- }
- }
- public class RemoveIdMethod extends PostMethod {
- public String getName() {
- return "REMOVEID";
- }
- public RemoveIdMethod(String uri) {
- super(uri);
- }
- }
- public class QueryMethod extends PostMethod {
- public String getName() {
- return "QUERY";
- }
- public QueryMethod(String uri) {
- super(uri);
- }
- }
-}
diff --git a/test/java/src/test/java/org/jboss/mod_cluster/TestChunkedMCPM.java b/test/java/src/test/java/org/jboss/mod_cluster/TestChunkedMCPM.java
deleted file mode 100644
index 830812b73..000000000
--- a/test/java/src/test/java/org/jboss/mod_cluster/TestChunkedMCPM.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * mod_cluster
- *
- * Copyright(c) 2012 Red Hat Middleware, LLC,
- * and individual contributors as indicated by the @authors tag.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * @author Jean-Frederic Clere
- * @version $Revision$
- */
-
-package org.jboss.mod_cluster;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-
-import junit.framework.TestCase;
-
-import org.apache.catalina.Engine;
-import org.apache.catalina.Service;
-import org.jboss.modcluster.ModClusterService;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardServer;
-
-public class TestChunkedMCPM extends TestCase {
-
- /* Test */
- public void testChunkedMCPM() {
-
- boolean clienterror = true;
- int numbnodes = 30;
- String [] nodenames = new String [numbnodes];
- JBossWeb [] service = new JBossWeb[numbnodes];
- ModClusterService lifecycle = null;
-
- System.out.println("TestChunkedMCPM Started");
- System.setProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "false");
- StandardServer server = new StandardServer();
- for (int i=0; i&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
+if [ "${SESSIONCO}" == "" ];then
+ echo "Failed no sessionid in curl output..."
+ curl -v http://localhost:8000/testapp/test.jsp
+fi
+echo ${SESSIONCO}
+NEWCO=$(curl -v --cookie "${SESSIONCO}" http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
+if [ "${NEWCO}" != "" ]; then
+ echo "Failed not sticky received : ${NEWCO}???"
+ clean_and_exit
+fi
+
+# Copy testapp and wait for starting
+docker cp testapp tomcat8080:/usr/local/tomcat/webapps
+sleep 10
+
+# Sticky (yes there are 2 apps now)
+echotestlabel "sticky 2 app"
+SESSIONCO=$(curl -v http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
+NODE=$(echo ${SESSIONCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
+echo "first: ${SESSIONCO} node: ${NODE}"
+NEWCO=$(curl -v http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
+NEWNODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
+echo "second: ${NEWCO} node: ${NEWNODE}"
+echo "Checking we can reach the 2 nodes"
+i=0
+while [ "${NODE}" == "${NEWNODE}" ]
+do
+ NEWCO=$(curl -v http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
+ NEWNODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
+ i=$(expr $i + 1)
+ if [ $i -gt 40 ]; then
+ echo "Can't find the 2 webapps"
+ clean_and_exit
+ fi
+ if [ "${NEWNODE}" == "" ]; then
+ echo "Can't find node in request"
+ clean_and_exit
+ fi
+ echo "trying other webapp try: ${i}"
+ clean_and_exit
+done
+echo "${i} try gives: ${NEWCO} node: ${NEWNODE}"
+
+# Still sticky
+CO=$(curl -v --cookie "${SESSIONCO}" http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
+if [ "${CO}" != "" ]; then
+ echo "Failed not sticky received : ${CO}???"
+ clean_and_exit
+fi
+CO=$(curl -v --cookie "${NEWCO}" http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
+if [ "${CO}" != "" ]; then
+ echo "Failed not sticky received : ${CO}???"
+ clean_and_exit
+fi
+
+# Stop one of the while running requests.
+echotestlabel "sticky: stopping one node and doing requests..."
+NODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
+echo $NODE
+PORT=$(curl http://localhost:6666/mod_cluster_manager | grep Node | grep $NODE | sed 's:)::' | awk -F : '{ print $3 } ')
+echo "Will stop ${PORT} corresponding to ${NODE} and cookie: ${NEWCO}"
+CODE="200"
+i=0
+while [ "$CODE" == "200" ]
+do
+ if [ $i -gt 100 ]; then
+ echo "Done remaining tomcat still answering!"
+ break
+ fi
+ CODE=$(curl -s -o /dev/null -w "%{http_code}" --cookie "${NEWCO}" http://localhost:8000/testapp/test.jsp)
+ if [ $i -eq 0 ]; then
+ # stop the tomcat
+ echo "tomcat${PORT} being stopped"
+ docker stop tomcat${PORT}
+ docker container rm tomcat${PORT}
+ fi
+ i=$(expr $i + 1)
+done
+if [ ${CODE} != "200" ]; then
+ echo "Something was wrong... got: ${CODE}"
+ curl -v --cookie "${NEWCO}" http://localhost:8000/testapp/test.jsp
+ clean_and_exit
+fi
+
+# Restart the tomcat
+nohup docker run --network=host -e tomcat_port=${PORT} -e tomcat_shutdown_port=true --name tomcat${PORT} ${IMG} &
+
+# Now try to test the websocket
+echotestlabel "testing websocket"
+# The websocket-hello app is at: https://github.com/jfclere/httpd_websocket
+mvn dependency:copy -U -Dartifact=org.apache.tomcat:websocket:hello:0.0.1:war -DoutputDirectory=.
+if [ $? -ne 0 ]; then
+ echo "Something was wrong... can't find org.apache.tomcat:websocket:hello:0.0.1:war"
+ cp $HOME/.m2/repository/org/apache/tomcat/websocket-hello/0.0.1/websocket-hello-0.0.1.war .
+ if [ $? -ne 0 ]; then
+ clean_and_exit
+ fi
+fi
+docker cp websocket-hello-0.0.1.war tomcat8080:/usr/local/tomcat/webapps
+docker cp websocket-hello-0.0.1.war tomcat8081:/usr/local/tomcat/webapps
+# Put the testapp in the tomcat we restarted.
+docker cp testapp tomcat${PORT}:/usr/local/tomcat/webapps
+sleep 10
+mvn -f pom-groovy.xml install
+java -jar target/test-1.0.jar WebSocketsTest
+if [ $? -ne 0 ]; then
+ echo "Something was wrong... with websocket tests"
+ clean_and_exit
+fi
+
+#
+# Test a keepalived connection finds the 2 webapps on each tomcat
+echotestlabel "Testing keepalived with 2 webapps on each tomcat"
+docker cp testapp tomcat8080:/usr/local/tomcat/webapps/testapp1
+docker cp testapp tomcat8081:/usr/local/tomcat/webapps/testapp2
+sleep 10
+java -jar target/test-1.0.jar HTTPTest
+if [ $? -ne 0 ]; then
+ echo "Something was wrong... with HTTP tests"
+ clean_and_exit
+fi
+
+#
+# Test virtual host
+echotestlabel "Testing virtual hosts"
+docker cp tomcat8081:/usr/local/tomcat/conf/server.xml .
+sed '/Host name=.*/i ' server.xml > new.xml
+docker cp new.xml tomcat8081:/usr/local/tomcat/conf/server.xml
+docker cp examples tomcat8081:/usr/local/tomcat
+docker commit tomcat8081 quay.io/${USER}/tomcat_mod_cluster-examples
+docker stop tomcat8081
+docker container rm tomcat8081
+tomcat_wait_for_n_nodes 1
+# Start the node.
+nohup docker run --network=host -e tomcat_port=8081 -e tomcat_shutdown_port=true --name tomcat8081 quay.io/${USER}/tomcat_mod_cluster-examples &
+tomcat_wait_for_n_nodes 2 || exit 1
+# Basically curl --header "Host: example.com" http://127.0.0.1:8000/test/test.jsp gives 200
+# in fact the headers are:
+# X-Forwarded-For: 127.0.0.1
+# X-Forwarded-Host: example.com
+# X-Forwarded-Server: fe80::faf4:935b:9dda:2adf
+# therefore don't forget ProxyPreserveHost On (otherwise UseAlias On failed...)
+#
+CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: example.com" http://127.0.0.1:8000/test/test.jsp)
+if [ ${CODE} != "200" ]; then
+ echo "Failed can't rearch webapp at example.com: ${CODE}"
+ clean_and_exit
+fi
+# Basically curl --header "Host: localhost" http://127.0.0.1:8000/test/test.jsp gives 400
+CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: localhost" http://127.0.0.1:8000/test/test.jsp)
+if [ ${CODE} != "404" ]; then
+ echo "Failed should NOT rearch webapp at localhost: ${CODE}"
+ clean_and_exit
+fi
+# Same using localhost/testapp2 and curl --header "Host: localhost" http://127.0.0.1:8000/testapp2/test.jsp
+CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: localhost" http://127.0.0.1:8000/testapp2/test.jsp)
+if [ ${CODE} != "200" ]; then
+ echo "Failed can't rearch webapp at localhost: ${CODE}"
+ clean_and_exit
+fi
+# Basically curl --header "Host: example.com" http://127.0.0.1:8000/testapp2/test.jsp gives 400
+CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: example.com" http://127.0.0.1:8000/testapp2/test.jsp)
+if [ ${CODE} != "404" ]; then
+ echo "Failed should NOT rearch webapp at localhost: ${CODE}"
+ exit 1
+fi
+
+# Shutdown the 2 tomcats
+docker exec -it tomcat8080 /usr/local/tomcat/bin/shutdown.sh
+docker exec -it tomcat8081 /usr/local/tomcat/bin/shutdown.sh
+tomcat_wait_for_n_nodes 0
+docker container rm tomcat8080
+docker container rm tomcat8081
+
+echotestlabel "Done with the tests!!!"
diff --git a/test/native/MODCLUSTER-640/testit.sh b/test/native/MODCLUSTER-640/testit.sh
deleted file mode 100755
index 623d63335..000000000
--- a/test/native/MODCLUSTER-640/testit.sh
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/bash
-source ../includes/script.bash
-
-# Shell to test MODCLUSTER-640
-
-# check IMG...
-if [ -z ${IMG} ]; then
- echo "IMG needs to defined, please try"
- echo "export IMG=quay.io/${USER}/tomcat_mod_cluster"
- exit 1
-fi
-
-# first stop any previously running tests.
-stoptomcats
-removetomcats
-
-# and httpd
-docker stop MODCLUSTER-640
-docker rm MODCLUSTER-640
-
-# build httpd + mod_proxy_cluster
-rm -f nohup.out
-nohup docker run --network=host -e HTTPD=https://dlcdn.apache.org/httpd/httpd-2.4.54.tar.gz -e SOURCES=https://github.com/jfclere/mod_proxy_cluster -e BRANCH=main -e CONF=https://raw.githubusercontent.com/modcluster/mod_proxy_cluster/main/test/native/MODCLUSTER-640/mod_proxy_cluster.conf --name MODCLUSTER-640 quay.io/${USER}/mod_cluster_httpd &
-
-# wait until httpd is started
-waitforhttpd || exit 1
-
-# start 2 tomcats
-starttomcats
-
-# wait until the tomcats are in mod_proxy_cluster tables
-waitnodes 2
-
-# copy the webapp in the tomcats
-docker cp webapp1 tomcat8080:/usr/local/tomcat/webapps/webapp1
-docker cp webapp1 tomcat8081:/usr/local/tomcat/webapps/webapp1
-
-sleep 10
-
-# test the URL
-code=`/usr/bin/curl -o /dev/null --silent --write-out '%{http_code}' http://localhost:8000/webapp1/index.html`
-if [ "${code}" != "200" ]; then
- echo "nocanon test failed, we get ${code} on http://localhost:8000/webapp1/index.html"
- exit 1
-fi
-curl -v "http://localhost:8000/webapp1/jsr%3aroot/toto" | grep "jsr:root"
-if [ $? -eq 0 ]; then
- echo "nocanon test failed, we get \"jsr:root\"!!!"
- exit 1
-fi
-
-# Test without UseNocanon On
-sed 's:UseNocanon On::' mod_proxy_cluster.conf > mod_proxy_cluster_new.conf
-
-docker cp mod_proxy_cluster_new.conf MODCLUSTER-640:/usr/local/apache2/conf/mod_proxy_cluster.conf
-docker exec -it MODCLUSTER-640 /usr/local/apache2/bin/apachectl restart
-
-# wait until the tomcats are back in mod_proxy_cluster tables
-waitnodes 2
-
-# test the URL
-code=`/usr/bin/curl -o /dev/null --silent --write-out '%{http_code}' http://localhost:8000/webapp1/index.html`
-if [ "${code}" != "200" ]; then
- echo "nocanon test failed, we get ${code} on http://localhost:8000/webapp1/index.html"
- exit 1
-fi
-curl -v "http://localhost:8000/webapp1/jsr%3aroot/toto" | grep "jsr:root"
-if [ $? -ne 0 ]; then
- echo "NO nocanon test failed, we don't get \"jsr:root\"!!!"
- exit 1
-fi
-
-# Test for just a proxypass / nocanon
-sed 's:UseNocanon On::' mod_proxy_cluster.conf > mod_proxy_cluster_new.conf
-echo "ProxyPass / balancer://mycluster/ nocanon" >> mod_proxy_cluster_new.conf
-
-docker cp mod_proxy_cluster_new.conf MODCLUSTER-640:/usr/local/apache2/conf/mod_proxy_cluster.conf
-docker exec -it MODCLUSTER-640 /usr/local/apache2/bin/apachectl restart
-
-# wait until the tomcats are back in mod_proxy_cluster tables
-waitnodes 2
-
-# test the URL
-code=`/usr/bin/curl -o /dev/null --silent --write-out '%{http_code}' http://localhost:8000/webapp1/index.html`
-if [ "${code}" != "200" ]; then
- echo "nocanon test failed, we get ${code} on http://localhost:8000/webapp1/index.html"
- exit 1
-fi
-curl -v "http://localhost:8000/webapp1/jsr%3aroot/toto" | grep "jsr:root"
-if [ $? -eq 0 ]; then
- echo "nocanon test failed, we get \"jsr:root\"!!!"
- exit 1
-fi
-# stop the previous test
-#stopprevioustest
diff --git a/test/native/MODCLUSTER-734/testit.sh b/test/native/MODCLUSTER-734/testit.sh
deleted file mode 100755
index 10ed331b8..000000000
--- a/test/native/MODCLUSTER-734/testit.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-source ../includes/script.bash
-
-# check IMG...
-if [ -z ${IMG} ]; then
- echo "IMG needs to defined, please try"
- echo "export IMG=quay.io/${USER}/tomcat_mod_cluster"
- exit 1
-fi
-
-# first stop any previously running tests.
-stoptomcats
-removetomcats
-
-# and httpd
-docker stop MODCLUSTER-734
-docker rm MODCLUSTER-734
-
-# build httpd + mod_proxy_cluster
-rm -f nohup.out
-nohup docker run --network=host -e HTTPD=https://dlcdn.apache.org/httpd/httpd-2.4.54.tar.gz -e SOURCES=https://github.com/modcluster/mod_proxy_cluster -e BRANCH=main -e CONF=https://raw.githubusercontent.com/modcluster/mod_proxy_cluster/main/test/native/MODCLUSTER-734/mod_proxy_cluster.conf --name MODCLUSTER-734 quay.io/${USER}/mod_cluster_httpd &
-
-# wait until httpd is started
-waitforhttpd || exit 1
-#docker cp mod_proxy_cluster.conf MODCLUSTER-734:/usr/local/apache2/conf/mod_proxy_cluster.conf
-#docker exec -it MODCLUSTER-734 /usr/local/apache2/bin/apachectl restart
-
-# start tomcat8080 and tomcat8081.
-starttomcats
-
-# wait until they are in mod_proxy_cluster tables
-waitnodes 2
-
-# copy the test page in ROOT to tomcat8080
-docker cp ROOT tomcat8080:/usr/local/tomcat/webapps/ROOT
-docker cp ROOT_OK tomcat8081:/usr/local/tomcat/webapps/ROOT
-
-# after a while the health check will get the Under maintenance status.jsp
-# and mark the node not OK.
-sleep 15
-curl -s http://localhost:6666/mod_cluster_manager | grep "Status: NOTOK"
-if [ $? -eq 0 ]; then
- echo "MODCLUSTER-734 Done!"
-else
- echo "MODCLUSTER-734 Failed!"
- exit 1
-fi
diff --git a/test/native/Makefile b/test/native/Makefile
deleted file mode 100644
index 136ffc04a..000000000
--- a/test/native/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-APACHE_BASE ?= /usr/local/apache
-APACHE_INC ?= ${APACHE_BASE}/include
-IMG ?= quay.io/${USER}/tomcat_mod_cluster:latest
-MOD_CLUSTER_VERSION ?= 2.0.2.Final-SNAPSHOT
-
-Advertise: Advertise.c
- cc -c -I$(APACHE_INC) Advertise.c
- cc -o Advertise Advertise.o -L$(APACHE_BASE)/lib -lapr-1
-
-jars:
- mvn dependency:copy-dependencies
-
-docker-build: jars
- docker build -t ${IMG} .
-
-docker-push: ## Push docker image with the manager.
- docker push ${IMG}
-
-setup-httpd:
- cd httpd
- docker build -t quay.io/${USER}/mod_cluster_httpd .
- docker run -d --network=host quay.io/${USER}/mod_cluster_httpd
- cd ..
-
-tests:
- IMG=${IMG} sh tests.sh
diff --git a/test/native/README.md b/test/native/README.md
deleted file mode 100644
index 76628ab23..000000000
--- a/test/native/README.md
+++ /dev/null
@@ -1,111 +0,0 @@
-# tomcat_mod_cluster
-Tomcat9 image with mod_cluster enabled.
-Start Apache Httpd with mod cluster enabled.
-
-Make sure you have checkout and build mod_cluster in sub directory at the same level you checkout mod_proxy_cluster.
-
-There are two variables worth setting: `APACHE_BASE` which is by default set to `/usr/local/apache` and which should
-correspond to the path where apache is present, then `IMG` which is set by default to
-`quay.io/${USER}/tomcat_mod_cluster`.
-
-If your setup differs, set those variables to appropriate values simply by running `export APACHE_BASE=/your/path`.
-
-## Building and pushing the image
-
-You can build the image by running
-
-```
-make docker-build
-```
-and then push it by
-
-```
-make docker-push
-```
-
-Do not forget to log into quay.io before you run those commands. You can log in using `docker login quay.io`.
-
-If you use `podman` instead of `docker`, you can use `podman-docker` package if it is available for you platform.
-
-## Running the image
-```
-docker run --network=host -e tomcat_port=[port1] -e cluster_port=[port3] [image]
-Or
-docker run --network=host -e tomcat_ajp_port=[port1] -e cluster_port=[port3] [image]
-# You can also add the variable -e tomcat_shutdown_port=true if u want to have a shutdown port
-```
-
-To load webapps into the container:
-```
-docker cp webapp.war :/usr/local/tomcat/webapps/
-```
-
-# mod_cluster_tests
-Tests can be run by invoking `make tests` or manually by running `sh tests.sh` but in that case
-make sure you have exported the IMG variable as described above.
-
-The docker image should be build and you might push it before, make sure you have exported the IMG variable.
-```
-export IMG=quay.io/${USER}/tomcat_mod_cluster
-```
-# Testing websocket
-Using com.ning.http.client.ws.WebSocketTextListener
-To be able to run the test please use https://github.com/jfclere/httpd_websocket just build it:
-```
-git clone https://github.com/jfclere/httpd_websocket
-cd https://github.com/jfclere/httpd_websocket
-mvn install
-cd ..
-```
-Build the groovy jar
-```
-mvn install
-```
-run the groovy stuff
-```
-java -jar target/test-1.0.jar
-```
-
-*NOTE: You'll probably need an older JAVA version – version 11 should be ok. You can change it via JAVA env variable.*
-
-# Running tests
-You need an Apache httpd with the mod_cluster.so installed and running. You can run it in docker -- checkout the `httpd/`
-subdirectory or simply run `make setup-httpd`. You should have following piece in httpd.conf/mod_proxy_cluster.conf:
-
-```
-LoadModule manager_module modules/mod_manager.so
-LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
-
-ServerName localhost
-Listen 6666
-ManagerBalancerName mycluster
-EnableWsTunnel
-WSUpgradeHeader "websocket"
-
-
- Require ip 127.0.0.1
-
-
- KeepAliveTimeout 300
- MaxKeepAliveRequests 0
-
- EnableMCPMReceive
-
- Require ip 127.0.0.1
-
-
-```
-
-Make sure you disable `mod_proxy` module.
-
-You can run tests running `sh tests.sh`. There are a few variables by which you can influence the duration/number of
-repetitions (those are printed out with their respective values right after executions starts).
-
-If tests fail or you interupt them, make sure that docker tomcat container that were created are removed first
-(you need to run `docker container stop ` and `docker container rm `).
-
-# Testing with miniserver
-There is also a python script that can be run to check mod_proxy_cluster. You can find it within `includes` directory
-as `miniserver.py`. Execute it simply as `./includes/miniserver.py `.
-
-You must have `httpd` with `mod_proxy_cluster` running.
diff --git a/test/native/includes/script.bash b/test/native/includes/script.bash
deleted file mode 100644
index b00d97054..000000000
--- a/test/native/includes/script.bash
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/bin/bash
-
-#
-# first stop running tomcats
-stoptomcat() {
-docker ps -a | grep $1
-if [ $? -eq 0 ]; then
- echo "Stopping $1"
- docker stop $1
- if [ $? -ne 0 ]; then
- echo "Can't stop $1"
- exit 1
- fi
-fi
-}
-stoptomcats () {
-for i in `docker ps -a --format "{{.Names}}" | grep tomcat`
-do
- stoptomcat $i
-done
-}
-
-#
-# Wait the nodes to go away or start
-waitnodes () {
-nodes=$1
-curl -s http://localhost:6666/mod_cluster_manager -o /dev/null
-if [ $? -ne 0 ]; then
- echo "httpd no started or something VERY wrong"
- exit 1
-fi
-NBNODES=-1
-i=0
-while [ ${NBNODES} != ${nodes} ]
-do
- NBNODES=`curl -s http://localhost:6666/mod_cluster_manager | grep Node | awk ' { print $3} ' | wc -l`
- sleep 10
- echo "Waiting for ${nodes} node to be ready: `date`"
- i=`expr $i + 1`
- if [ $i -gt 120 ]; then
- echo "Timeout the node(s) number is NOT ${nodes} but ${NBNODES}"
- exit 1
- fi
- # check if the nodes are OK
- if [ ${NBNODES} = ${nodes} ]; then
- NBNODESOK=`curl -s http://localhost:6666/mod_cluster_manager | grep "Status: OK" | wc -l`
- if [ $NBNODESOK != ${nodes} ]; then
- echo "Some nodes are not in OK state..."
- exit 1
- fi
- fi
-done
-curl -s http://localhost:6666/mod_cluster_manager -o /dev/null
-if [ $? -ne 0 ]; then
- echo "httpd no started or something VERY wrong"
- exit 1
-fi
-echo "Waiting for the node DONE: `date`"
-}
-
-#
-# remove them
-removetomcatname () {
-docker ps -a | grep $1
-if [ $? -eq 0 ]; then
- echo "Stopping $1"
- docker stop $1
- if [ $? -ne 0 ]; then
- echo "Can't stop $1"
- fi
- echo "Removing $1"
- docker rm $1
- if [ $? -ne 0 ]; then
- echo "Can't remove $1"
- fi
-fi
-}
-removetomcats () {
-for i in `docker ps -a --format "{{.Names}}" | grep tomcat`
-do
- removetomcatname $i
-done
-}
-
-#
-# Start them again
-starttomcats() {
-echo "Starting tomcat8080..."
-nohup docker run --network=host -e tomcat_port=8080 -e tomcat_shutdown_port=true --name tomcat8080 ${IMG} &
-if [ $? -ne 0 ]; then
- echo "Can't start tomcat8080"
- exit 1
-fi
-sleep 10
-echo "Starting tomcat8081..."
-nohup docker run --network=host -e tomcat_port=8081 -e tomcat_shutdown_port=true --name tomcat8081 ${IMG} &
-if [ $? -ne 0 ]; then
- echo "Can't start tomcat8081"
- exit 1
-fi
-echo "2 Tomcats started..."
-}
-
-# wait until httpd is started
-waitforhttpd () {
- while true
- do
- sleep 10
- grep "cannot open" nohup.out | grep error_log
- if [ $? -eq 0 ]; then
- echo "httpd start failed"
- exit 1
- fi
-
- grep "resuming normal operations" nohup.out
- if [ $? -eq 0 ]; then
- break
- fi
- done
-
- # httpd started
- curl -v http://localhost:8000/
- if [ $? -ne 0 ]; then
- echo "Httpd not running???"
- exit 1
- fi
-}
-
-# Start tomcat$1 container on 127.0.0.$1
-starttomcat() {
- ADDR="127.0.0.$1"
- AJPPORT="8010"
- HTTPPORT=""
- if [ "x$2" != "x" ]; then
- if [ $2 -ne 0 ];then
- echo "Starting tomcat$1 on 127.0.0.$2"
- ADDR="127.0.0.$2"
- fi
- fi
- if [ "x$3" != "x" ]; then
- if [ $3 -ne 0 ];then
- echo "Starting tomcat$1 on 127.0.0.$2 with http on port $3"
- AJPPORT=""
- HTTPPORT="$3"
- fi
- fi
- echo "Doing: docker run --network=host -e tomcat_ajp_port=${AJPPORT} -e tomcat_port=${HTTPPORT} -e tomcat_address=$ADDR -e tomcat_shutdown_port=8005 -e jvm_route=tomcat$1 --name tomcat$1 ${IMG}"
- nohup docker run --network=host -e tomcat_ajp_port=${AJPPORT} -e tomcat_port=${HTTPPORT} -e tomcat_address=$ADDR -e tomcat_shutdown_port=8005 -e jvm_route=tomcat$1 --name tomcat$1 ${IMG} &
- ps -q $! > /dev/null
- if [[ $? -ne 0 ]]; then
- echo "docker run failed"
- exit 1
- fi
-}
-
diff --git a/test/native/tests.sh b/test/native/tests.sh
deleted file mode 100644
index b543063a1..000000000
--- a/test/native/tests.sh
+++ /dev/null
@@ -1,877 +0,0 @@
-#!/bin/bash
-
-# configuration of variables
-# if you want tests to pass much faster, decrease these values
-if [ -z ${FOREVER_PAUSE+x} ]; then
- FOREVER_PAUSE=3600 # sleep period length during which tomcats are run & stopped
-fi
-if [ -z ${TOMCAT_CYCLE_COUNT+x} ]; then
- TOMCAT_CYCLE_COUNT=100 # the number of repetitions of a test cycle
-fi
-if [ -z ${ITERATION_COUNT+x} ]; then
- ITERATION_COUNT=50 # the number of iteration of starting/stopping a tomcat
-fi
-if [ -z ${IMG+x} ]; then
- IMG=quay.io/$USER/tomcat_mod_cluster
-fi
-
-echo -n "Test values are FOREVER_PAUSE=$FOREVER_PAUSE, TOMCAT_CYCLE_COUNT=$TOMCAT_CYCLE_COUNT,"
-echo " ITERATION_COUNT=$ITERATION_COUNT, IMG=$IMG"
-
-#
-# Stop running given dockered tomcat
-stoptomcat() {
- docker ps | grep $1
- if [ $? -eq 0 ]; then
- echo "Stopping $1"
- docker stop $1
- if [ $? -ne 0 ]; then
- echo "Can't stop $1"
- exit 1
- fi
- else
- echo "$1 is not running"
- fi
-}
-
-#
-# Stop running all dockered tomcats
-stoptomcats() {
- for i in $(docker ps -a --format "{{.Names}}" | grep tomcat)
- do
- stoptomcat $i
- done
-}
-
-#
-# Wait until there are $1 nodes (i.e., some will start or go away if the count is different)
-waitnodes() {
- nodes=$1
- curl -s http://localhost:6666/mod_cluster_manager -o /dev/null
- if [ $? -ne 0 ]; then
- echo "httpd no started or something VERY wrong"
- exit 1
- fi
- NBNODES=-1
- i=0
- while [ ${NBNODES} != ${nodes} ]
- do
- NBNODES=$(curl -s http://localhost:6666/mod_cluster_manager | grep "Status: OK" | awk ' { print $3} ' | wc -l)
- sleep 10
- echo "Waiting for ${nodes} node to be ready: $(date)"
- i=$(expr $i + 1)
- if [ $i -gt 120 ]; then
- echo "Timeout the node(s) number is NOT ${nodes} but ${NBNODES}"
- exit 1
- fi
- done
- curl -s http://localhost:6666/mod_cluster_manager -o /dev/null
- if [ $? -ne 0 ]; then
- echo "httpd no started or something VERY wrong"
- exit 1
- fi
- echo "Waiting for the node DONE: $(date)"
-}
-
-#
-# Stop and remove tomcat docker container of a given name
-removetomcatname() {
- docker ps -a | grep $1
- if [ $? -eq 0 ]; then
- echo "Stopping $1"
- docker stop $1
- if [ $? -ne 0 ]; then
- echo "Can't stop $1"
- fi
- echo "Removing $1"
- docker rm $1
- if [ $? -ne 0 ]; then
- echo "Can't remove $1"
- fi
- fi
-}
-
-#
-# Remove all tomcat containers and images
-removetomcats() {
- for i in $(docker ps -a --format "{{.Names}}" | grep tomcat)
- do
- removetomcatname $i
- done
-}
-
-#
-# Start them again
-starttwotomcats() {
- echo "Starting tomcat8080..."
- nohup docker run --network=host -e tomcat_port=8080 -e tomcat_shutdown_port=true --name tomcat8080 ${IMG} &
- if [ $? -ne 0 ]; then
- echo "Can't start tomcat8080"
- exit 1
- fi
- sleep 10
- echo "Starting tomcat8081..."
- nohup docker run --network=host -e tomcat_port=8081 -e tomcat_shutdown_port=true --name tomcat8081 ${IMG} &
- if [ $? -ne 0 ]; then
- echo "Can't start tomcat8081"
- exit 1
- fi
- echo "2 Tomcats started..."
-}
-
-#
-# Echo test label message in order to know where we are
-echotestlabel() {
- MESS=$1
- echo "***************************************************************"
- echo "Doing test: $MESS"
- echo "***************************************************************"
-}
-
-# This should suspend the tomcat for ~ 1000 seconds ~ causing it gets removed afterwhile.
-jdbsuspend() {
- rm -f /tmp/testpipein
- mkfifo /tmp/testpipein
- rm -f /tmp/testpipeout
- mkfifo /tmp/testpipeout
- sleep 1000 > /tmp/testpipein &
- jdb -attach 6660 < /tmp/testpipein > /tmp/testpipeout &
- echo "suspend" > /tmp/testpipein
- cat < /tmp/testpipeout &
-}
-
-jdbexit() {
- cat > /tmp/testpipeout &
- echo "exit" > /tmp/testpipein
-}
-
-# Start tomcat$1 container on 127.0.0.$1
-starttomcat() {
- ADDR="127.0.0.$1"
- if [ $2 -ne 0 ];then
- echo "Starting tomcat$1 on 127.0.0.$2"
- ADDR="127.0.0.$2"
- fi
- echo "Doing: docker run --network=host -e tomcat_ajp_port=8010 -e tomcat_address=$ADDR -e tomcat_shutdown_port=8005 -e jvm_route=tomcat$1 --name tomcat$1 ${IMG}"
- nohup docker run --network=host -e tomcat_ajp_port=8010 -e tomcat_address=$ADDR -e tomcat_shutdown_port=8005 -e jvm_route=tomcat$1 --name tomcat$1 ${IMG} &
- ps -q $! > /dev/null
- if [[ $? -ne 0 ]]; then
- echo "docker run failed"
- exit 1
- fi
-}
-
-# Start the webapp on the given tomcat
-# wait for the tomcat to start.
-startwebapptomcat() {
- while true
- do
- docker ps --format "{{.Names}}" | grep tomcat$1
- if [ $? -eq 0 ]; then
- break
- fi
- sleep 2
- done
- docker cp testapp tomcat$1:/usr/local/tomcat/webapps/tomcat$1 || exit 1
-}
-
-# Send a shutdown packet to a tomcat$1 container
-shutdowntomcat() {
- ADDR="127.0.0.$1"
- if [ $2 -ne 0 ];then
- ADDR="127.0.0.$2"
- fi
-
- echo "shutdowntomcat at $ADDR"
- echo "SHUTDOWN" | nc $ADDR 8005
-}
-
-# Remove the docker image tomcat$1
-# Note: To succesfully remove an image it needs to be stopped
-removetomcat() {
- docker rm tomcat$1
-}
-
-# Test whether the webapp is working (responding)
-testtomcat() {
- CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/tomcat$1/test.jsp)
- if [ ${CODE} != "200" ]; then
- echo "Failed can't reach $tomcat$1: ${CODE}"
- exit 1
- fi
-}
-
-#
-# Run testtomcat for tomcat containers [2..$1]
-testtomcats() {
- tc=2
- while true
- do
- testtomcat $tc || exit 1
- tc=$(expr $tc + 1)
- if [ $tc -gt $1 ]; then
- echo "testtomcats $tc Done!"
- break
- fi
- done
-}
-
-#
-# Run a load test for the given tomcat$1 using ab
-abtomcat() {
- ab -c10 -n10 http://localhost:8000/tomcat$1/test.jsp > /dev/null
- if [ $? -ne 0 ]; then
- echo "abtomcat: Loading tomcat$1 failed"
- exit 1
- fi
-}
-
-#
-# Run abtomcat for tomcat containers [2..$1]
-abtomcats() {
- tc=2
- while true
- do
- abtomcat $tc || exit 1
- tc=$(expr $tc + 1)
- if [ $tc -gt $1 ]; then
- echo "abtomcats: Done!"
- break
- fi
- done
-}
-
-#
-# Start a bunch ($1, or 6 if no argument is given) of tomcat
-# containers, then test them and stop them
-runtomcatbatch() {
- if [ $1 ]; then
- t=$1
- else
- t=5 # default value when no argument is given
- fi
- tomcatcount=$t
- # TODO: Change those whiles with arbitrary break to for cycles
- while true
- do
- starttomcat $t 0
- t=$(expr $t + 1)
- if [ $t -gt 10 ]; then
- break
- fi
- done
- waitnodes 9 || exit 1
- t=$tomcatcount
- while true
- do
- startwebapptomcat $t || exit 1
- t=$(expr $t + 1)
- if [ $t -gt 10 ]; then
- break
- fi
- done
-
- # test the tomcats
- sleep 20
- testtomcats 9
- if [ $? -ne 0 ];then
- echo "runtomcatbatch testtomcats 9 FAILED!"
- exit 1
- fi
-
- # "load test" 9 of them
- abtomcats 9
- if [ $? -ne 0 ];then
- echo "runtomcatbatch abtomcats 9 FAILED!"
- exit 1
- fi
-
- # retest
- testtomcats 9
- if [ $? -ne 0 ];then
- echo "runtomcatbatch testtomcats 9 FAILED!"
- exit 1
- fi
-
- # stop the tomcats
- t=$tomcatcount
- while true
- do
- shutdowntomcat $t 0
- t=$(expr $t + 1)
- if [ $t -gt 10 ]; then
- break
- fi
- done
-
- waitnodes 3
- if [ $? -ne 0 ];then
- echo "runtomcatbatch waitnodes 3 FAILED!"
- exit 1
- fi
-
- # remove the tomcats
- t=5
- while true
- do
- removetomcat $t
- t=$(expr $t + 1)
- if [ $t -gt 10 ]; then
- break
- fi
- done
- echo "runtomcatbatch Done!"
-}
-
-# single tomcat testing
-# we start the tomcat, put the webapp, test it and later stop and clean up
-singlecycle() {
- echo "singlecycle: Testing tomcat$1"
- R=$1
- if [ "X$2" = "Xuseran" ]; then
- R=$(echo $((1 + $RANDOM % 10)))
- R=$(expr $R + 2)
- starttomcat $1 $R || exit 1
- else
- R=0
- starttomcat $1 $R || exit 1
- fi
- # Wait for it to start
- echo "Testing(0) tomcat$1 waiting..."
- while true
- do
- curl -s http://localhost:6666/mod_cluster_manager | grep Node | grep tomcat$1 > /dev/null
- if [ $? -eq 0 ]; then
- break
- fi
- sleep 1
- done
- echo "Testing(0) tomcat$1 started"
- startwebapptomcat $1 || exit 1
- echo "Testing(0) tomcat$1 with webapp"
- while true
- do
- curl -s http://localhost:6666/mod_cluster_manager | grep /tomcat$1 > /dev/null
- if [ $? -eq 0 ]; then
- break
- fi
- curl -s http://localhost:6666/mod_cluster_manager | grep /tomcat$1
- sleep 1
- done
- echo "Testing(1) tomcat$1"
- testtomcat $1 || exit 1
- echo "Testing(2) tomcat$1"
- testtomcat $1 || exit 1
- abtomcat $1 || exit 1
- echo "Testing(3) tomcat$1"
- shutdowntomcat $1 $R || exit 1
- while true
- do
- curl -s http://localhost:6666/mod_cluster_manager | grep Node | grep tomcat$1 > /dev/null
- if [ $? -ne 0 ]; then
- break
- fi
- sleep 1
- done
- removetomcat $1 || exit 1
- echo "singlecycle Done tomcat$1"
-}
-
-# Run neverending testing loop of a single tomcat
-looptomcatforever() {
- while true
- do
- singlecycle $1 || exit 1
- done
-}
-
-# Start a bunch of looping tomcats and kill them after $FOREVER_PAUSE (default is 3600 seconds)
-forevertomcat() {
- (looptomcatforever 12) &
- pid12=$!
- (looptomcatforever 13) &
- pid13=$!
- # wait a little to prevent synchronization
- sleep 5
- (looptomcatforever 14) &
- pid14=$!
- (looptomcatforever 15) &
- pid15=$!
- (looptomcatforever 16) &
- pid16=$!
-
- sleep $FOREVER_PAUSE
-
- echo "Doing: kill -15 $pid12 $pid13 $pid14 $pid15 $pid16"
- kill -15 $pid12 $pid13 $pid14 $pid15 $pid16
- if [ $? -ne 0 ]; then
- echo "kill -15 $pid12 $pid13 $pid14 $pid15 $pid16 failed"
- exit 1
- fi
- echo "Tests done, cleaning"
- # stop & remove the containers
- removetomcatname tomcat12
- removetomcatname tomcat13
- removetomcatname tomcat14
- removetomcatname tomcat15
- removetomcatname tomcat16
- sleep 10
-}
-
-# Start and stop successively (one after another) $1 tomcats
-cyclestomcats() {
- i=1
- while true
- do
- i=$(expr $i + 1)
- if [ $i -gt $1 ]; then
- echo "Looks OK, Done!"
- break
- fi
- singlecycle $i useran || exit 1
- done
-}
-
-# run test for https://issues.redhat.com/browse/JBCS-1236
-# basically start and stop random tomcats...
-runjbcs1236() {
- # start 3 tomcats
- starttomcat 2 0
- starttomcat 3 0
- starttomcat 4 0
- waitnodes 3 || exit 1
- # check them
- startwebapptomcat 2 || exit 1
- startwebapptomcat 3 || exit 1
- startwebapptomcat 4 || exit 1
- sleep 20
- testtomcat 2 || exit 1
- testtomcat 3 || exit 1
- testtomcat 4 || exit 1
-
- # start a bunch of tomcats, test, shutdown, remove and try in a loop.
- runjbcs1236=0
- while true
- do
- runjbcs1236=$(expr $runjbcs1236 + 1)
- if [ $runjbcs1236 -gt 2 ]; then
- echo "Looks OK, runjbcs1236 stopping!"
- break
- fi
- # cycle the tomcats
- runtomcatbatch
- if [ $? -ne 0 ]; then
- echo "runtomcatbatch: runjbcs1236 Failed!"
- exit 1
- fi
- shutdowntomcat 2 0
- waitnodes 2
- if [ $? -ne 0 ]; then
- echo "waitnodes 2: runjbcs1236 Failed!"
- exit 1
- fi
- removetomcat 2
- starttomcat 5 0
- waitnodes 3
- if [ $? -ne 0 ]; then
- echo "waitnodes 3: runjbcs1236 Failed!"
- exit 1
- fi
- startwebapptomcat 5
- if [ $? -ne 0 ]; then
- echo "startwebapptomcat 5: runjbcs1236 Failed!"
- exit 1
- fi
- sleep 20
- testtomcat 5
- if [ $? -ne 0 ]; then
- echo "testtomcat 5: runjbcs1236 Failed!"
- exit 1
- fi
- # we have 5 3 4 in shared memory
- # readd 2
- starttomcat 2 0
- waitnodes 4
- if [ $? -ne 0 ]; then
- echo "waitnodes 4: runjbcs1236 Failed!"
- exit 1
- fi
- startwebapptomcat 2
- if [ $? -ne 0 ]; then
- echo "startwebapptomcat 2: runjbcs1236 Failed!"
- exit 1
- fi
- sleep 20
- testtomcat 2
- if [ $? -ne 0 ]; then
- echo "testtomcat 2: runjbcs1236 Failed!"
- exit 1
- fi
- # we have 5 3 4 2 in shared memory
- # if something was wrong 2 points to 5
- shutdowntomcat 5 0
- waitnodes 3
- if [ $? -ne 0 ]; then
- echo "waitnodes 3: runjbcs1236 Failed!"
- exit 1
- fi
- removetomcat 5
-
- testtomcat 2 || exit 1
- if [ $? -ne 0 ]; then
- echo "testtomcat 2: runjbcs1236 Failed!"
- exit 1
- fi
-
- testtomcat 3 || exit 1
- if [ $? -ne 0 ]; then
- echo "testtomcat 3: runjbcs1236 Failed!"
- exit 1
- fi
-
- testtomcat 4 || exit 1
- if [ $? -ne 0 ]; then
- echo "testtomcat 4: runjbcs1236 Failed!"
- exit 1
- fi
- echotestlabel "runjbcs1236 loop: $runjbcs1236"
- done
-
- # cleanup
- shutdowntomcat 4 0
- shutdowntomcat 3 0
- shutdowntomcat 2 0
- waitnodes 0 || exit 1
- removetomcat 2
- removetomcat 3
- removetomcat 4
-}
-
-#
-# Main piece -- tests start here
-echotestlabel "Starting tests!!!"
-if [ -z ${IMG} ]; then
- echo "IMG needs to defined, please try"
- echo "export IMG=quay.io/${USER}/tomcat_mod_cluster"
- exit 1
-fi
-
-# Create files we need
-cat << EOF > continue.txt
-cont
-exit
-EOF
-cat << EOF > hang.txt
-suspend all
-exit
-EOF
-
-# Clean up possible existing containers before starting...
-stoptomcats
-waitnodes 0 || exit 1
-removetomcats
-
-# JBCS-1236
-echotestlabel "JBCS-1236"
-cyclestomcats $TOMCAT_CYCLE_COUNT
-if [ $? -ne 0 ]; then
- echotestlabel "JBCS-1236 cyclestomcats 100 FAILED!"
- exit 1
-fi
-forevertomcat
-if [ $? -ne 0 ]; then
- echotestlabel "JBCS-1236 forevertomcat FAILED!"
- exit 1
-fi
-runjbcs1236
-if [ $? -ne 0 ]; then
- echotestlabel "JBCS-1236 runjbcs1236 FAILED!"
- exit 1
-fi
-
-# Start 2 tomcats, on 8080 and 8081
-starttwotomcats || exit 1
-waitnodes 2 || exit 1
-
-# Copy testapp and wait for its start
-docker cp testapp tomcat8081:/usr/local/tomcat/webapps
-sleep 10
-
-# Basic 200 and 404 tests.
-echotestlabel "basic 200 and 404 tests"
-CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/testapp/test.jsp)
-if [ ${CODE} != "200" ]; then
- echo "Failed can't reach webapp: ${CODE}"
- exit 1
-fi
-CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/testapp/toto.jsp)
-if [ ${CODE} != "404" ]; then
- echo "Failed should get 404"
- exit 1
-fi
-
-# Sticky (yes, there is only one app!!!)
-echotestlabel "sticky one app"
-SESSIONCO=$(curl -v http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
-if [ "${SESSIONCO}" == "" ];then
- echo "Failed no sessionid in curl output..."
- curl -v http://localhost:8000/testapp/test.jsp
-fi
-echo ${SESSIONCO}
-NEWCO=$(curl -v --cookie "${SESSIONCO}" http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
-if [ "${NEWCO}" != "" ]; then
- echo "Failed not sticky received : ${NEWCO}???"
- exit 1
-fi
-
-# Copy testapp and wait for starting
-docker cp testapp tomcat8080:/usr/local/tomcat/webapps
-sleep 10
-
-# Sticky (yes there are 2 apps now)
-echotestlabel "sticky 2 app"
-SESSIONCO=$(curl -v http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
-NODE=$(echo ${SESSIONCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
-echo "first: ${SESSIONCO} node: ${NODE}"
-NEWCO=$(curl -v http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
-NEWNODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
-echo "second: ${NEWCO} node: ${NEWNODE}"
-echo "Checking we can reach the 2 nodes"
-i=0
-while [ "${NODE}" == "${NEWNODE}" ]
-do
- NEWCO=$(curl -v http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
- NEWNODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
- i=$(expr $i + 1)
- if [ $i -gt 40 ]; then
- echo "Can't find the 2 webapps"
- exit 1
- fi
- if [ "${NEWNODE}" == "" ]; then
- echo "Can't find node in request"
- exit 1
- fi
- echo "trying other webapp try: ${i}"
- sleep 1
-done
-echo "${i} try gives: ${NEWCO} node: ${NEWNODE}"
-
-# Still sticky
-CO=$(curl -v --cookie "${SESSIONCO}" http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
-if [ "${CO}" != "" ]; then
- echo "Failed not sticky received : ${CO}???"
- exit 1
-fi
-CO=$(curl -v --cookie "${NEWCO}" http://localhost:8000/testapp/test.jsp -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::')
-if [ "${CO}" != "" ]; then
- echo "Failed not sticky received : ${CO}???"
- exit 1
-fi
-
-# Stop one of the while running requests.
-echotestlabel "sticky: stopping one node and doing requests..."
-NODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }')
-echo $NODE
-PORT=$(curl http://localhost:6666/mod_cluster_manager | grep Node | grep $NODE | sed 's:)::' | awk -F : '{ print $3 } ')
-echo "Will stop ${PORT} corresponding to ${NODE} and cookie: ${NEWCO}"
-CODE="200"
-i=0
-while [ "$CODE" == "200" ]
-do
- if [ $i -gt 100 ]; then
- echo "Done remaining tomcat still answering!"
- break
- fi
- CODE=$(curl -s -o /dev/null -w "%{http_code}" --cookie "${NEWCO}" http://localhost:8000/testapp/test.jsp)
- if [ $i -eq 0 ]; then
- # stop the tomcat
- echo "tomcat${PORT} being stopped"
- docker stop tomcat${PORT}
- docker container rm tomcat${PORT}
- fi
- i=$(expr $i + 1)
-done
-if [ ${CODE} != "200" ]; then
- echo "Something was wrong... got: ${CODE}"
- curl -v --cookie "${NEWCO}" http://localhost:8000/testapp/test.jsp
- exit 1
-fi
-
-# Restart the tomcat
-nohup docker run --network=host -e tomcat_port=${PORT} -e tomcat_shutdown_port=true --name tomcat${PORT} ${IMG} &
-
-# Now try to test the websocket
-echotestlabel "testing websocket"
-# The websocket-hello app is at: https://github.com/jfclere/httpd_websocket
-mvn dependency:copy -U -Dartifact=org.apache.tomcat:websocket:hello:0.0.1:war -DoutputDirectory=.
-if [ $? -ne 0 ]; then
- echo "Something was wrong... can't find org.apache.tomcat:websocket:hello:0.0.1:war"
- cp $HOME/.m2/repository/org/apache/tomcat/websocket-hello/0.0.1/websocket-hello-0.0.1.war .
- if [ $? -ne 0 ]; then
- exit 1
- fi
-fi
-docker cp websocket-hello-0.0.1.war tomcat8080:/usr/local/tomcat/webapps
-docker cp websocket-hello-0.0.1.war tomcat8081:/usr/local/tomcat/webapps
-# Put the testapp in the tomcat we restarted.
-docker cp testapp tomcat${PORT}:/usr/local/tomcat/webapps
-sleep 10
-mvn -f pom-groovy.xml install
-java -jar target/test-1.0.jar WebSocketsTest
-if [ $? -ne 0 ]; then
- echo "Something was wrong... with websocket tests"
- exit 1
-fi
-
-#
-# Test a keepalived connection finds the 2 webapps on each tomcat
-echotestlabel "Testing keepalived with 2 webapps on each tomcat"
-docker cp testapp tomcat8080:/usr/local/tomcat/webapps/testapp1
-docker cp testapp tomcat8081:/usr/local/tomcat/webapps/testapp2
-sleep 10
-java -jar target/test-1.0.jar HTTPTest
-if [ $? -ne 0 ]; then
- echo "Something was wrong... with HTTP tests"
- exit 1
-fi
-
-#
-# Test virtual host
-echotestlabel "Testing virtual hosts"
-docker cp tomcat8081:/usr/local/tomcat/conf/server.xml .
-sed '/Host name=.*/i ' server.xml > new.xml
-docker cp new.xml tomcat8081:/usr/local/tomcat/conf/server.xml
-docker cp examples tomcat8081:/usr/local/tomcat
-docker commit tomcat8081 quay.io/${USER}/tomcat_mod_cluster-examples
-docker stop tomcat8081
-docker container rm tomcat8081
-waitnodes 1
-# Start the node.
-nohup docker run --network=host -e tomcat_port=8081 -e tomcat_shutdown_port=true --name tomcat8081 quay.io/${USER}/tomcat_mod_cluster-examples &
-waitnodes 2 || exit 1
-# Basically curl --header "Host: example.com" http://127.0.0.1:8000/test/test.jsp gives 200
-# in fact the headers are:
-# X-Forwarded-For: 127.0.0.1
-# X-Forwarded-Host: example.com
-# X-Forwarded-Server: fe80::faf4:935b:9dda:2adf
-# therefore don't forget ProxyPreserveHost On (otherwise UseAlias On failed...)
-#
-CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: example.com" http://127.0.0.1:8000/test/test.jsp)
-if [ ${CODE} != "200" ]; then
- echo "Failed can't rearch webapp at example.com: ${CODE}"
- exit 1
-fi
-# Basically curl --header "Host: localhost" http://127.0.0.1:8000/test/test.jsp gives 400
-CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: localhost" http://127.0.0.1:8000/test/test.jsp)
-if [ ${CODE} != "404" ]; then
- echo "Failed should NOT rearch webapp at localhost: ${CODE}"
- exit 1
-fi
-# Same using localhost/testapp2 and curl --header "Host: localhost" http://127.0.0.1:8000/testapp2/test.jsp
-CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: localhost" http://127.0.0.1:8000/testapp2/test.jsp)
-if [ ${CODE} != "200" ]; then
- echo "Failed can't rearch webapp at localhost: ${CODE}"
- exit 1
-fi
-# Basically curl --header "Host: example.com" http://127.0.0.1:8000/testapp2/test.jsp gives 400
-CODE=$(curl -s -o /dev/null -w "%{http_code}" --header "Host: example.com" http://127.0.0.1:8000/testapp2/test.jsp)
-if [ ${CODE} != "404" ]; then
- echo "Failed should NOT rearch webapp at localhost: ${CODE}"
- exit 1
-fi
-
-# Shutdown the 2 tomcats
-docker exec -it tomcat8080 /usr/local/tomcat/bin/shutdown.sh
-docker exec -it tomcat8081 /usr/local/tomcat/bin/shutdown.sh
-waitnodes 0
-docker container rm tomcat8080
-docker container rm tomcat8081
-
-# Loop stopping starting the same tomcat
-iter=0
-while [ $iter -lt $ITERATION_COUNT ]
-do
- echo "Loop stopping starting the same tomcat iter: $iter"
- nohup docker run --network=host -e tomcat_port=8080 --name tomcat8080 ${IMG} &
- sleep 10
- waitnodes 1 || exit 1
- docker exec -it tomcat8080 /usr/local/tomcat/bin/shutdown.sh
- waitnodes 0 || exit 1
- docker container rm tomcat8080
- iter=$(expr $iter + 1)
-done
-
-# Check that hanging tomcat will be removed
-echotestlabel "hanging a tomcat checking it is removed after a while no requests"
-PORT=8081
-nohup docker run --network=host -e tomcat_port=${PORT} -e tomcat_shutdown_port=true --name tomcat${PORT} ${IMG} &
-PORT=8080
-nohup docker run --network=host -e tomcat_port=${PORT} -e tomcat_shutdown_port=true --name tomcat${PORT} ${IMG} &
-sleep 10
-waitnodes 2 || exit 1
-# curlloop.sh checks for http://localhost:8000/testapp/test.jsp
-docker cp testapp tomcat8080:/usr/local/tomcat/webapps
-docker cp testapp tomcat8081:/usr/local/tomcat/webapps
-docker cp setenv.sh tomcat${PORT}:/usr/local/tomcat/bin
-docker commit tomcat${PORT} quay.io/${USER}/tomcat_mod_cluster-debug
-docker stop tomcat${PORT}
-waitnodes 1
-docker container rm tomcat${PORT}
-# Start the node.
-nohup docker run --network=host -e tomcat_port=${PORT} -e tomcat_shutdown_port=true --name tomcat${PORT} quay.io/${USER}/tomcat_mod_cluster-debug &
-sleep 10
-docker exec tomcat${PORT} jdb -attach 6660 < continue.txt
-waitnodes 2 || exit 1
-echo "2 tomcat started"
-# Hang the node,
-# jdb and a pipe to hang the tomcat.
-jdbsuspend
-waitnodes 1 || exit 1
-echo "1 tomcat hanging and gone"
-jdbexit
-# The tomcat is comming up again
-waitnodes 2 || exit 1
-echo "the tomcat is back"
-
-# Same test with requests, make them in a loop
-echotestlabel "hanging tomcat removed after a while with requests"
-bash curlloop.sh 200 000 &
-jdbsuspend
-waitnodes 1 || exit 1
-ps -ef | grep curlloop | grep -v grep
-if [ $? -ne 0 ]; then
- echo "curlloop.sh FAILED!"
- exit 1
-fi
-ps -ef | grep curlloop | grep -v grep | awk ' { print $2 } ' | xargs kill
-jdbexit
-# The tomcat is comming up again
-waitnodes 2 || exit 1
-
-# Same test with requets but stop the other tomcat
-echotestlabel "single hanging tomcat removed after a while with requests"
-PORT=8081
-docker stop tomcat${PORT}
-docker container rm tomcat${PORT}
-waitnodes 1 || exit 1
-jdbsuspend
-sleep 10
-bash curlloop.sh 000 404 503 &
-waitnodes 0 || exit 1
-ps -ef | grep curlloop | grep -v grep
-if [ $? -ne 0 ]; then
- echo "curlloop.sh FAILED!"
- exit 1
-fi
-ps -ef | grep curlloop | grep -v grep | awk ' { print $2 } ' | xargs kill
-jdbexit
-# The tomcat is comming up again
-waitnodes 1 || exit 1
-
-# Cleanup at the end
-stoptomcats
-waitnodes 0 || exit 1
-removetomcats
-echotestlabel "Done with the tests!!!"
-echo "Done!"
-
diff --git a/test/native/pom-groovy.xml b/test/pom-groovy.xml
similarity index 100%
rename from test/native/pom-groovy.xml
rename to test/pom-groovy.xml
diff --git a/test/native/pom.xml b/test/pom.xml
similarity index 96%
rename from test/native/pom.xml
rename to test/pom.xml
index 88ee4b8b4..509829d26 100644
--- a/test/native/pom.xml
+++ b/test/pom.xml
@@ -9,7 +9,7 @@
4.0.0
org.jboss.mod_cluster
mod_cluster_test
- 2.0.2.Final-SNAPSHOT
+ 2.0.3.Final-SNAPSHOT
pom
@@ -65,7 +65,7 @@
copy-dependencies
- target
+ tomcat/target
false
true
true
diff --git a/test/native/setenv.sh b/test/setenv.sh
similarity index 100%
rename from test/native/setenv.sh
rename to test/setenv.sh
diff --git a/test/setup-dependencies.sh b/test/setup-dependencies.sh
new file mode 100644
index 000000000..089ca467d
--- /dev/null
+++ b/test/setup-dependencies.sh
@@ -0,0 +1,18 @@
+# Run this from the same directory
+TEST_DIR=$(pwd)
+cd ../..
+# get websocket demo repository
+git clone https://github.com/jfclere/httpd_websocket
+cd httpd_websocket
+mvn install || exit 1
+cp target/websocket-hello-0.0.1.war $TEST_DIR
+cd ..
+
+# get mod_cluster (Java/Tomcat part)
+git clone https://github.com/modcluster/mod_cluster
+cd mod_cluster
+mvn install || exit 2
+cd $TEST_DIR
+
+# prepare jars
+mvn dependency:copy-dependencies
diff --git a/test/native/src/main/gvy/org/jboss/modcluster/Main.gvy b/test/src/main/gvy/org/jboss/modcluster/Main.gvy
similarity index 100%
rename from test/native/src/main/gvy/org/jboss/modcluster/Main.gvy
rename to test/src/main/gvy/org/jboss/modcluster/Main.gvy
diff --git a/test/native/src/main/gvy/org/jboss/modcluster/WebHTTPTest.gvy b/test/src/main/gvy/org/jboss/modcluster/WebHTTPTest.gvy
similarity index 100%
rename from test/native/src/main/gvy/org/jboss/modcluster/WebHTTPTest.gvy
rename to test/src/main/gvy/org/jboss/modcluster/WebHTTPTest.gvy
diff --git a/test/native/src/main/gvy/org/jboss/modcluster/WebSocketsTest.gvy b/test/src/main/gvy/org/jboss/modcluster/WebSocketsTest.gvy
similarity index 100%
rename from test/native/src/main/gvy/org/jboss/modcluster/WebSocketsTest.gvy
rename to test/src/main/gvy/org/jboss/modcluster/WebSocketsTest.gvy
diff --git a/test/native/testapp/test-750.jsp b/test/testapp/test-750.jsp
similarity index 100%
rename from test/native/testapp/test-750.jsp
rename to test/testapp/test-750.jsp
diff --git a/test/native/testapp/test.jsp b/test/testapp/test.jsp
similarity index 100%
rename from test/native/testapp/test.jsp
rename to test/testapp/test.jsp
diff --git a/test/testsuite.sh b/test/testsuite.sh
new file mode 100644
index 000000000..b4b8c3d3a
--- /dev/null
+++ b/test/testsuite.sh
@@ -0,0 +1,69 @@
+#!/usr/bin/sh
+
+# configuration of variables
+# if you want tests to pass much faster, decrease these values
+if [ -z ${FOREVER_PAUSE+x} ]; then
+ export FOREVER_PAUSE=3600 # sleep period length during which tomcats are run & stopped
+fi
+if [ -z ${TOMCAT_CYCLE_COUNT+x} ]; then
+ export TOMCAT_CYCLE_COUNT=100 # the number of repetitions of a test cycle
+fi
+if [ -z ${ITERATION_COUNT+x} ]; then
+ export ITERATION_COUNT=50 # the number of iteration of starting/stopping a tomcat
+fi
+if [ -z ${IMG+x} ]; then
+ export IMG=quay.io/$USER/tomcat_mod_cluster
+fi
+if [ -z ${HTTPD_IMG+x} ]; then
+ export HTTPD_IMG=quay.io/${USER}/httpd_mod_cluster
+fi
+
+echo "Test parameters are:"
+echo " FOREVER_PAUSE=$FOREVER_PAUSE"
+echo " TOMCAT_CYCLE_COUNT=$TOMCAT_CYCLE_COUNT"
+echo " ITERATION_COUNT=$ITERATION_COUNT"
+echo " IMG=$IMG"
+echo " HTTPD_IMG=$HTTPD_IMG"
+
+if [ ! -d logs ]; then
+ mkdir logs
+fi
+
+. includes/common.sh
+
+httpd_create > /dev/null 2>&1 || exit 2
+tomcat_create > /dev/null 2>&1 || exit 3
+
+# clean everything at first
+httpd_all_clean
+tomcat_all_remove
+
+res=0
+
+run_test basetests.sh "Basic tests"
+res=$(expr $res + $?)
+run_test hangingtests.sh "Hanging tests"
+res=$(expr $res + $?)
+run_test maintests.sh "Main tests"
+res=$(expr $res + $?)
+run_test JBCS-1236/testit.sh "JBCS-1236"
+res=$(expr $res + $?)
+run_test MODCLUSTER-640/testit.sh "MODCLUSTER-640"
+res=$(expr $res + $?)
+run_test MODCLUSTER-734/testit.sh "MODCLUSTER-734"
+res=$(expr $res + $?)
+run_test MODCLUSTER-755/testit.sh "MODCLUSTER-755"
+res=$(expr $res + $?)
+run_test MODCLUSTER-785/testit.sh "MODCLUSTER-785"
+res=$(expr $res + $?)
+
+echo "Clean remaining httpd containers"
+httpd_all_clean
+
+if [ $res -eq 0 ]; then
+ echo "Tests finished successfully!"
+else
+ echo "Tests finished, but some failed."
+fi
+
+exit $res
diff --git a/test/native/Dockerfile b/test/tomcat/Dockerfile
similarity index 72%
rename from test/native/Dockerfile
rename to test/tomcat/Dockerfile
index 40b72bd31..1fe94bd85 100644
--- a/test/native/Dockerfile
+++ b/test/tomcat/Dockerfile
@@ -3,9 +3,9 @@ FROM tomcat:8.5
WORKDIR /usr/local/tomcat
COPY target/*.jar ./lib/
-COPY ./files/server.xml ./conf/
-COPY ./files/context.xml ./conf/
-COPY ./files/start.sh ./
+COPY server.xml ./conf/
+COPY context.xml ./conf/
+COPY start.sh ./
RUN chmod +x start.sh
diff --git a/test/tomcat/README.md b/test/tomcat/README.md
new file mode 100644
index 000000000..7a13f86f0
--- /dev/null
+++ b/test/tomcat/README.md
@@ -0,0 +1,25 @@
+# Build the image
+```bash
+docker build -t quay.io/${USER}/mod_cluster_tomcat .
+```
+
+# Run image
+**Note the ENV variables:**
+
+* tomcat_port: port on which tomcat will listen (default: 8080)
+* tomcat_shutdown_port: port on which tomcat will listen to SHUTDOWN command (default 8005)
+* tomcat_ajp_port: port on which AJP will be listener (default: 8009)
+* cluster_port: port on which the httpd counterpart listens (default: 6666)
+* jvm_route: route name of the tomcat
+* tomcat_address: ip address of the tomcat
+
+For example:
+```bash
+docker run --network=host -e tomcat_ajp_port=8010 -e tomcat_address=127.0.0.15 -e jvm_route=tomcat15 --name tomcat15 quay.io/${USER}/mod_cluster_tomcat
+```
+
+then you can uload a webapp into your running instance by executing
+
+```bash
+docker cp webapp.war tomcat1:/usr/local/tomcat/webapps/
+```
diff --git a/test/native/files/context.xml b/test/tomcat/context.xml
similarity index 100%
rename from test/native/files/context.xml
rename to test/tomcat/context.xml
diff --git a/test/native/files/server.xml b/test/tomcat/server.xml
similarity index 100%
rename from test/native/files/server.xml
rename to test/tomcat/server.xml
diff --git a/test/native/files/start.sh b/test/tomcat/start.sh
similarity index 89%
rename from test/native/files/start.sh
rename to test/tomcat/start.sh
index 80cbe8e11..10b5c9c96 100644
--- a/test/native/files/start.sh
+++ b/test/tomcat/start.sh
@@ -41,19 +41,19 @@ else
fi
-if [ ${cluster_port}==0 ]; then
+if [ "${cluster_port}" -eq "0" ]; then
cluster_port=6666
fi
sed -i "s/proxyport/${cluster_port}/" ./conf/server.xml
sed -i "s/proxyaddress/127.0.0.1/" ./conf/server.xml
-echo "jvm_route: ${jvm_route} and tomcat_port: ${tomcat_port}"
+echo "jvm_route: ${jvm_route} and tomcat_port: ${tomcat_port} and tomcat_address: ${tomcat_address}"
if [ ! -z ${jvm_route} ]; then
sed -i "/" ./conf/server.xml
fi
# copy webapp war file.
-mv *.war webapps/ || true
+mv *.war webapps/ || true
catalina.sh run