From ed0e77f78a78ffd2fbf387d57902eda693071ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Chlup?= Date: Tue, 26 Sep 2023 16:24:49 +0200 Subject: [PATCH 1/3] test: Drop httpd_shutdown function, tweak httpd_all_clean --- test/includes/common.sh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/test/includes/common.sh b/test/includes/common.sh index 91e50d931..0d0b5516b 100644 --- a/test/includes/common.sh +++ b/test/includes/common.sh @@ -29,7 +29,7 @@ run_test() { docker cp ${httpd_cont}:/usr/local/apache2/logs/access_log "logs/${2:-$1}-httpd_access.log" > /dev/null fi # Clean all after run - httpd_shutdown > /dev/null 2>&1 + httpd_all_clean > /dev/null 2>&1 tomcat_all_remove > /dev/null 2>&1 return $ret } @@ -49,7 +49,7 @@ httpd_create() { # Build and run httpd container httpd_run() { # if httpd is already running for some reason, end it - httpd_shutdown || true + httpd_all_clean || true if [ $DEBUG ]; then echo "httpd mod_proxy_cluster image config:" echo " CONF: ${MPC_CONF:-httpd/mod_proxy_cluster.conf}" @@ -79,19 +79,8 @@ httpd_wait_until_ready() { echo "httpd ready after $i attempts" } -httpd_shutdown() { - docker ps --format "{{.Names}}" | grep ${MPC_NAME:-httpd-mod_proxy_cluster} - if [ $? = 0 ]; then - docker stop ${MPC_NAME:-httpd-mod_proxy_cluster} - fi - docker ps -a --format "{{.Names}}" | grep ${MPC_NAME:-httpd-mod_proxy_cluster} - if [ $? = 0 ]; then - docker rm ${MPC_NAME:-httpd-mod_proxy_cluster} - fi -} - httpd_all_clean() { - for i in $(docker ps -a | grep "$HTTPD_IMG\|MODCLUSTER\|JBCS" | cut -f1 -d' '); + for i in $(docker ps -a | grep "$HTTPD_IMG\|MODCLUSTER\|JBCS\|${MPC_NAME:-httpd-mod_proxy_cluster}" | cut -f1 -d' '); do docker stop $i docker rm $i From 6f7077159c91accb5a18bd6268294f76267f9d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Chlup?= Date: Tue, 26 Sep 2023 16:29:02 +0200 Subject: [PATCH 2/3] Add note about tests, tweak dependencies script --- README.md | 5 +++++ test/setup-dependencies.sh | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2355dc5a..bffa5807c 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ enclose the corresponding part of code like this The style check will ignore everything between the two comments. (Please, don't abuse it.) +Tests +----- + +The project contains some tests too. You can find them with a separate README in the `test` subdirectory. + License ------- diff --git a/test/setup-dependencies.sh b/test/setup-dependencies.sh index 93fb52ad7..dd2cc58df 100644 --- a/test/setup-dependencies.sh +++ b/test/setup-dependencies.sh @@ -2,7 +2,9 @@ TEST_DIR=$(pwd) cd ../.. # get websocket demo repository -git clone https://github.com/jfclere/httpd_websocket +if [ ! -d httpd_websocket ]; then + git clone https://github.com/jfclere/httpd_websocket +fi cd httpd_websocket git pull --rebase mvn install || exit 1 @@ -10,7 +12,9 @@ cp target/websocket-hello-0.0.1.war $TEST_DIR/tomcat/ cd .. # get mod_cluster (Java/Tomcat part) -git clone https://github.com/modcluster/mod_cluster +if [ ! -d mod_cluster ]; then + git clone https://github.com/modcluster/mod_cluster +fi cd mod_cluster git pull --rebase mvn install || exit 2 From 71b962b0e7d35b9ab212094285611cb41435b314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Chlup?= Date: Mon, 2 Oct 2023 11:40:20 +0200 Subject: [PATCH 3/3] test: Remove additional unused files --- test/Advertise.c | 125 ----------------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 test/Advertise.c diff --git a/test/Advertise.c b/test/Advertise.c deleted file mode 100644 index 8a5501e3e..000000000 --- a/test/Advertise.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Advertise (test for multicast) - * - * 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 - */ - -#include "apr.h" -#include "apr_network_io.h" -#include "apr_strings.h" -#include "apr_thread_proc.h" - -static apr_sockaddr_t *ma_mgroup_sa; -static apr_socket_t *ma_mgroup_socket; - -static void * APR_THREAD_FUNC parent_thread(apr_thread_t *thd, void *data) { - char buf[20]; - apr_size_t n; - char *s; - apr_status_t rv; - apr_pool_t *pool = data; - - apr_sleep(APR_TIME_C(100000)); - s = apr_psprintf(pool, "to %pI", ma_mgroup_sa); - printf("apr_socket_sendto %s\n", s); - - n = apr_snprintf(buf, 20, "Advertize !!!\n"); - rv = apr_socket_sendto(ma_mgroup_socket, - ma_mgroup_sa, 0, buf, &n); - if (rv != APR_SUCCESS) { - printf("apr_socket_sendto failed %d %s\n", n, apr_strerror(rv, buf, 20)); - return; - } - return; -} -int main(int argc, char **argv) -{ - apr_pool_t *pool; - apr_status_t rv; - apr_sockaddr_t *ma_listen_sa; - apr_sockaddr_t *ma_niface_sa; - apr_thread_t *tp; - - apr_initialize(); - atexit(apr_terminate); - - apr_pool_create(&pool, NULL); - - rv = apr_sockaddr_info_get(&ma_mgroup_sa, "224.0.1.105", APR_INET, 23364, APR_UNSPEC, pool); - if (rv != APR_SUCCESS) { - printf("apr_sockaddr_info_get failed %d\n", rv); - return 1; - } - rv = apr_sockaddr_info_get(&ma_listen_sa, NULL, ma_mgroup_sa->family, 0, APR_UNSPEC, pool); - if (rv != APR_SUCCESS) { - printf("apr_sockaddr_info_get(NULL) failed %d\n", rv); - return 1; - } - rv = apr_sockaddr_info_get(&ma_niface_sa, NULL, ma_mgroup_sa->family, 0, APR_UNSPEC, pool); - if (rv != APR_SUCCESS) { - printf("apr_sockaddr_info_get(NULL) failed %d\n", rv); - return 1; - } - - rv = apr_socket_create(&ma_mgroup_socket, ma_mgroup_sa->family, SOCK_DGRAM, APR_PROTO_UDP, pool); - if (rv != APR_SUCCESS) { - printf("apr_socket_create failed %d\n", rv); - return 1; - } - rv = apr_socket_bind(ma_mgroup_socket, ma_listen_sa); - if (rv != APR_SUCCESS) { - printf("apr_socket_bind failed %d\n", rv); - return 1; - } - char *s; - s = apr_psprintf(pool, "on %pI", ma_listen_sa); - printf("apr_socket_bind %s\n", s); - s = apr_psprintf(pool, "on %pI", ma_niface_sa); - printf("apr_mcast_join %s\n", s); - - rv = apr_mcast_join(ma_mgroup_socket, ma_mgroup_sa, ma_niface_sa, NULL); - if (rv != APR_SUCCESS) { - printf("apr_mcast_join failed %d\n", rv); - return 1; - } -/* - rv = apr_mcast_loopback(ma_mgroup_socket, 1); - if (rv != APR_SUCCESS) { - printf("apr_mcast_loopback failed %d\n", rv); - return 1; - } - */ - rv = apr_mcast_hops(ma_mgroup_socket, 10); - if (rv != APR_SUCCESS) { - printf("apr_mcast_hops failed %d\n", rv); - return 1; - } - rv = apr_thread_create(&tp, NULL, parent_thread, pool, pool); - if (rv != APR_SUCCESS) { - printf("apr_thread_create failed %d\n", rv); - return 1; - } - apr_thread_detach(tp); - apr_sleep(APR_TIME_C(150000)); - return 0; -}