From fbed081eab315a178a392ccdd7e4eb3991dac8e7 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 7 Nov 2013 00:42:42 +0000 Subject: QPID-5306: Improve c++ tests some more: Add options to run_test script: --working-dir - run the test in this directory --build-dir - set the top of the build tree --source-dir - set the top of the source tree --python - run a python test --start-broker - start/stop broker before and after test --broker-options - allow non default broker options Remove a bunch of now obsolete testing related scripts git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1539510 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/CMakeLists.txt | 34 ++-- qpid/cpp/src/tests/legacystore/CMakeLists.txt | 8 +- qpid/cpp/src/tests/legacystore/tests_env.sh | 260 -------------------------- qpid/cpp/src/tests/run_header_test | 6 - qpid/cpp/src/tests/run_msg_group_tests | 9 - qpid/cpp/src/tests/run_queue_flow_limit_tests | 29 +-- qpid/cpp/src/tests/run_test | 89 +++++++-- qpid/cpp/src/tests/start_broker | 24 --- qpid/cpp/src/tests/start_broker.ps1 | 60 ------ qpid/cpp/src/tests/stop_broker | 41 ---- qpid/cpp/src/tests/stop_broker.ps1 | 56 ------ qpid/cpp/src/tests/test_env.sh.in | 1 + qpid/cpp/src/tests/test_wrap | 48 ----- 13 files changed, 96 insertions(+), 569 deletions(-) delete mode 100644 qpid/cpp/src/tests/legacystore/tests_env.sh delete mode 100755 qpid/cpp/src/tests/start_broker delete mode 100644 qpid/cpp/src/tests/start_broker.ps1 delete mode 100755 qpid/cpp/src/tests/stop_broker delete mode 100644 qpid/cpp/src/tests/stop_broker.ps1 delete mode 100755 qpid/cpp/src/tests/test_wrap (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt index 4acd976a38..012f135c73 100644 --- a/qpid/cpp/src/tests/CMakeLists.txt +++ b/qpid/cpp/src/tests/CMakeLists.txt @@ -135,7 +135,8 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows) set (shell "powershell") endif (CMAKE_SYSTEM_NAME STREQUAL Windows) -set(test_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix}) +set(test_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR}) +set(python_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR} --python) if (BUILD_TESTING_UNITTESTS) @@ -225,7 +226,7 @@ target_link_libraries (unit_test set_target_properties (unit_test PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER) remember_location(unit_test) -add_test (unit_test ${test_wrap} ${unit_test_LOCATION}) +add_test (unit_test ${test_wrap} -- ${unit_test_LOCATION}) endif (BUILD_TESTING_UNITTESTS) @@ -319,33 +320,34 @@ if (BUILD_SASL) add_test(ssl_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/ssl_test${test_script_suffix}) endif (BUILD_SSL) endif (BUILD_SASL) -add_test (start_broker ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/start_broker${test_script_suffix}) -add_test (qpid-client-test ${test_wrap} ${qpid-client-test_LOCATION}) -add_test (quick_perftest ${test_wrap} ${qpid-perftest_LOCATION} --summary --count 100) -add_test (quick_topictest ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix}) -add_test (quick_txtest ${test_wrap} ${qpid-txtest_LOCATION} --queues 4 --tx-count 10 --quiet) -add_test (msg_group_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_msg_group_tests${test_script_suffix}) +add_test (qpid-client-test ${test_wrap} --start-broker -- ${qpid-client-test_LOCATION}) +add_test (quick_perftest ${test_wrap} --start-broker -- ${qpid-perftest_LOCATION} --summary --count 100) +add_test (quick_topictest ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix}) +add_test (quick_txtest ${test_wrap} --start-broker -- ${qpid-txtest_LOCATION} --queues 4 --tx-count 10 --quiet) +add_test (msg_group_tests ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_msg_group_tests${test_script_suffix}) if (PYTHON_EXECUTABLE) - add_test (run_header_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix}) - add_test (python_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix}) + add_test (run_header_test ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix}) + add_test (python_tests ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix}) endif (PYTHON_EXECUTABLE) -add_test (stop_broker ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/stop_broker${test_script_suffix}) if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) # paged queue not yet implemented for windows add_test (paged_queue_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_paged_queue_tests${test_script_suffix}) endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) if (PYTHON_EXECUTABLE) - add_test (ha_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/ha_tests.py) - add_test (qpidd_qmfv2_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/qpidd_qmfv2_tests.py) + add_test (ha_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/ha_tests.py) + add_test (qpidd_qmfv2_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/qpidd_qmfv2_tests.py) if (BUILD_AMQP) - add_test (interlink_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py) + add_test (interlink_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py) endif (BUILD_AMQP) - add_test (swig_python_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/swig_python_tests${test_script_suffix}) + add_test (swig_python_tests ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/swig_python_tests${test_script_suffix}) endif (PYTHON_EXECUTABLE) add_test (ipv6_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/ipv6_test${test_script_suffix}) add_test (federation_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_federation_tests${test_script_suffix}) add_test (federation_sys_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_federation_sys_tests${test_script_suffix}) -add_test (queue_flow_limit_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_flow_limit_tests${test_script_suffix}) +add_test (queue_flow_limit_tests + ${test_wrap} + --start-broker "--broker-options=--default-flow-stop-threshold=80 --default-flow-resume-threshold=70 -t --log-to-stderr=no --log-to-stdout=no" + ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_flow_limit_tests${test_script_suffix}) if (BUILD_ACL) add_test (acl_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_acl_tests${test_script_suffix}) endif (BUILD_ACL) diff --git a/qpid/cpp/src/tests/legacystore/CMakeLists.txt b/qpid/cpp/src/tests/legacystore/CMakeLists.txt index 2067ab87cd..7df50d1398 100644 --- a/qpid/cpp/src/tests/legacystore/CMakeLists.txt +++ b/qpid/cpp/src/tests/legacystore/CMakeLists.txt @@ -28,6 +28,8 @@ endif (QPID_LINK_BOOST_DYNAMIC) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) +set(test_wrap ${shell} ${CMAKE_SOURCE_DIR}/src/tests/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR}) + if (BUILD_TESTING_UNITTESTS) # Like this to work with cmake 2.4 on Unix @@ -50,7 +52,7 @@ target_link_libraries (legacystore_${theSourceFile} set_target_properties (legacystore_${theSourceFile} PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER) remember_location(legacystore_${theSourceFile}) -add_test (legacystore_${theSourceFile} ${test_wrap} ${legacystore_${theSourceFile}_LOCATION}) +add_test (legacystore_${theSourceFile} ${test_wrap} -- ${legacystore_${theSourceFile}_LOCATION}) ENDMACRO (define_legacystore_test) define_legacystore_test (SimpleTest) @@ -76,7 +78,7 @@ if ("${ARGV1}" STREQUAL "LONG") set_target_properties(${testname} PROPERTIES COMPILE_DEFINITIONS LONG_TEST) endif () remember_location(${testname}) -add_test (${testname} ${test_wrap} ${${testname}_LOCATION}) +add_test (${testname} ${test_wrap} -- ${${testname}_LOCATION}) unset (testname) ENDMACRO (define_journal_test) @@ -123,6 +125,8 @@ target_link_libraries (jtt__ut ${Boost_PROGRAM_OPTIONS_LIBRARY} ${clock_gettime_LIB} legacystore_shared) +add_test(journal_jtt_ut ${test_wrap} --working-dir=${CMAKE_CURRENT_SOURCE_DIR}/jrnl/jtt -- ${CMAKE_CURRENT_BINARY_DIR}/jtt__ut) + endif (BUILD_TESTING_UNITTESTS) # diff --git a/qpid/cpp/src/tests/legacystore/tests_env.sh b/qpid/cpp/src/tests/legacystore/tests_env.sh deleted file mode 100644 index 30d255b87c..0000000000 --- a/qpid/cpp/src/tests/legacystore/tests_env.sh +++ /dev/null @@ -1,260 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# --- Function definitions --- - - -func_check_required_env () -#------------------------- -# Check that EITHER: -# QPID_DIR is set (for running against svn QPID) -# OR -# QPID_PREFIX is set (for running against installed QPID -# Will exit with error code 1 if neither of these is defined. -# Params: None -# Returns: 0 if env vars ok, 1 otherwise -{ - if test -z "${QPID_DIR}" -a -z "${QPID_PREFIX}"; then - # Try to find qpidd in the normal installed location - if test -x /usr/sbin/qpidd; then - QPID_PREFIX=/usr - else - echo "ERROR: Could not find installed Qpid" - echo "Either of the following must be set in the environment for this script to run:" - echo " QPID_DIR for running against a Qpid svn build" - echo " QPID_PREFIX for running against an installed Qpid" - return 1 - fi - fi - return 0 -} - - -func_check_qpid_python () -#------------------------ -# Check that Qpid python environment is ok -# Params: None -# Returns: 0 if Python environment is ok; 1 otherwise -{ - if ! python -c "import qpid" ; then - cat <&1 || ERROR=1 + (cd $working_dir; $VALGRIND $VALGRIND_OPTS --log-file=$VG_LOG -- $program "$@" 2>&1) || ERROR=1 vg_check $VG_LOG* || ERROR=1 else - "$@" 2>&1 || ERROR=1 + (cd $working_dir; $program "$@") || ERROR=1 fi +# Check log +if [ -r $QPID_LOG_TO_FILE ]; then +egrep 'warning\|error\|critical' $QPID_LOG_TO_FILE && { + echo "WARNING: Suspicious broker log entries in $QPID_LOG_TO_FILE, above." +} +fi + +if [ -n "$start_broker" ] ; then + $QPIDD_EXEC --no-module-dir --quit || ERROR=1 + + # Check qpidd.log. + egrep 'warning\|error\|critical' $logfilebase-qpidd.log && { + echo "WARNING: Suspicious broker log entries in qpidd.log, above." + } + + # Check valgrind log. + if test -n "$VALGRIND"; then + vg_check $logfilebase-qpidd.vglog || ERROR=1 + fi +fi exit $ERROR diff --git a/qpid/cpp/src/tests/start_broker b/qpid/cpp/src/tests/start_broker deleted file mode 100755 index 6eea38e0f8..0000000000 --- a/qpid/cpp/src/tests/start_broker +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Start a test broker. -srcdir=`dirname $0` -exec $srcdir/run_test ../qpidd --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file qpidd.log "$@" > qpidd.port diff --git a/qpid/cpp/src/tests/start_broker.ps1 b/qpid/cpp/src/tests/start_broker.ps1 deleted file mode 100644 index 6f4a140efd..0000000000 --- a/qpid/cpp/src/tests/start_broker.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Get the directory where this script resides. -function Get-ScriptPath - { Split-Path $myInvocation.ScriptName } - -# Start a test broker and capture it's port (from stdout) to qpidd.port -# This script will exit immediately after spawning the broker process. To avoid -# running more tests before the broker is initialized, wait for the qpidd.port -# file to appear before exiting. -if (Test-Path qpidd.port) { - Remove-Item qpidd.port -} - -# Test runs from the tests directory but the broker executable is one level -# up, and most likely in a subdirectory from there based on what build type. -# Look around for it before trying to start it. -$subs = "Debug","Release","MinSizeRel","RelWithDebInfo" -foreach ($sub in $subs) { - $prog = "..\$sub\qpidd.exe" - if (Test-Path $prog) { - break - } -} -if (!(Test-Path $prog)) { - "Cannot locate qpidd.exe" - exit 1 -} -$cmdline = "$prog --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $args | foreach { set-content qpidd.port `$_ }" -$cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline) -$srcdir = Get-ScriptPath -. $srcdir\background.ps1 $cmdblock - -$wait_time = 0 -while (!(Test-Path qpidd.port) -and ($wait_time -lt 30)) { - Start-Sleep 2 - $wait_time += 2 -} -if (Test-Path qpidd.port) { - exit 0 -} -"Time out waiting for broker to start" -exit 1 diff --git a/qpid/cpp/src/tests/stop_broker b/qpid/cpp/src/tests/stop_broker deleted file mode 100755 index b774e70225..0000000000 --- a/qpid/cpp/src/tests/stop_broker +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Stop the broker, check for errors. -# -QPID_PORT=`cat qpidd.port` -export QPID_PORT -rm -f qpidd.port - -../qpidd --no-module-dir --quit || ERROR=1 - -# Check qpidd.log. -egrep 'warning\|error\|critical' qpidd.log && { - echo "WARNING: Suspicious broker log entries in qpidd.log, above." -} - -# Check valgrind log. -if test -n "$VALGRIND"; then - . `dirname $0`/vg_check $VG_LOG* - vg_check qpidd.vglog* || ERROR=1 -fi - -exit $ERROR diff --git a/qpid/cpp/src/tests/stop_broker.ps1 b/qpid/cpp/src/tests/stop_broker.ps1 deleted file mode 100644 index 4fdeb26e2b..0000000000 --- a/qpid/cpp/src/tests/stop_broker.ps1 +++ /dev/null @@ -1,56 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Stop the broker, check for errors. -Get-Content -path qpidd.port -totalCount 1 | Set-Variable -name qpid_port -Remove-Item qpidd.port - -# Test runs from the tests directory but the broker executable is one level -# up, and most likely in a subdirectory from there based on what build type. -# Look around for it before trying to start it. -$subs = "Debug","Release","MinSizeRel","RelWithDebInfo" -foreach ($sub in $subs) { - $prog = "..\$sub\qpidd.exe" - if (Test-Path $prog) { - break - } -} -if (!(Test-Path $prog)) { - "Cannot locate qpidd.exe" - exit 1 -} - -# Piping the output makes the script wait for qpidd to finish. -Invoke-Expression "$prog --quit --port $qpid_port" | Write-Output -$stopped = $? - -# Check qpidd.log. -filter bad_stuff { - $_ -match "( warning | error | critical )" -} - -$qpidd_errors = $false -Get-Content -path qpidd.log | where { bad_stuff } | Out-Default | Set-Variable -name qpidd_errors -value $true -if ($qpidd_errors -eq $true) { - "WARNING: Suspicious broker log entries in qpidd.log, above." -} -if ($stopped -eq $true) { - exit 0 -} -exit 1 diff --git a/qpid/cpp/src/tests/test_env.sh.in b/qpid/cpp/src/tests/test_env.sh.in index 2247469cc3..a16812ca6c 100644 --- a/qpid/cpp/src/tests/test_env.sh.in +++ b/qpid/cpp/src/tests/test_env.sh.in @@ -36,6 +36,7 @@ if [ "$enable_valgrind" = "ON" ] ; then export VALGRIND=@VALGRIND_EXECUTABLE@ fi export SASL_PW=@SASLPASSWD2_EXECUTABLE@ +export PYTHON=@PYTHON_EXECUTABLE@ # Python paths and directories export PYTHON_DIR=$builddir/python diff --git a/qpid/cpp/src/tests/test_wrap b/qpid/cpp/src/tests/test_wrap deleted file mode 100755 index dd43c5a2e2..0000000000 --- a/qpid/cpp/src/tests/test_wrap +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Read the started broker port, set appropriate env vars -# then run the program under test - -QPID_PORT=`cat qpidd.port` -export QPID_PORT - -program=$1 -shift - -QPID_LOG_TO_FILE=`basename $program`.log -export QPID_LOG_TO_FILE - -ERROR=0 -$program $* || ERROR=1 - -# Check qpidd.log. -egrep 'warning\|error\|critical' $QPID_LOG_TO_FILE && { - echo "WARNING: Suspicious broker log entries in $QPID_LOG_TO_FILE, above." -} - -# Check valgrind log. -#if test -n "$VALGRIND"; then -# . `dirname $0`/vg_check $VG_LOG* -# vg_check qpidd.vglog* || ERROR=1 -#fi - -exit $ERROR -- cgit v1.2.1