From 71149592670f7592886751a9a866459bef0f12cc Mon Sep 17 00:00:00 2001 From: Justin Ross Date: Thu, 21 Apr 2016 12:31:34 +0000 Subject: QPID-7207: Create independent cpp and python subtrees, with content from tools and extras git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1740289 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/CMakeLists.txt | 41 +- qpid/cpp/src/tests/CMakeLists.txt | 351 ++++++------- qpid/cpp/src/tests/README.txt | 19 +- qpid/cpp/src/tests/ais_test.cpp | 23 - qpid/cpp/src/tests/allhosts | 79 --- qpid/cpp/src/tests/brokertest.py | 26 +- qpid/cpp/src/tests/check_dependencies.py.in | 53 ++ qpid/cpp/src/tests/cli_tests.py | 11 +- qpid/cpp/src/tests/common.py | 297 +++++++++++ qpid/cpp/src/tests/config.null | 21 - qpid/cpp/src/tests/dynamic_log_hires_timestamp | 22 +- qpid/cpp/src/tests/dynamic_log_level_test | 30 +- qpid/cpp/src/tests/env.ps1.in | 77 +++ qpid/cpp/src/tests/env.py.in | 100 ++++ qpid/cpp/src/tests/env.sh.in | 74 +++ qpid/cpp/src/tests/fanout_perftest | 22 - qpid/cpp/src/tests/federated_topic_test | 45 +- qpid/cpp/src/tests/ha_test.py | 10 +- qpid/cpp/src/tests/ha_tests.py | 16 +- qpid/cpp/src/tests/install_env.sh.in | 26 - qpid/cpp/src/tests/interlink_tests.py | 7 +- qpid/cpp/src/tests/interop_tests.py | 5 +- qpid/cpp/src/tests/ipv6_test | 120 ----- qpid/cpp/src/tests/legacystore/CMakeLists.txt | 8 +- .../legacystore/federation/federation_tests_env.sh | 2 +- qpid/cpp/src/tests/legacystore/run_python_tests | 32 +- qpid/cpp/src/tests/linearstore/CMakeLists.txt | 7 +- qpid/cpp/src/tests/linearstore/run_python_tests | 31 +- qpid/cpp/src/tests/multiq_perftest | 22 - qpid/cpp/src/tests/plano.py | 543 +++++++++++++++++++++ qpid/cpp/src/tests/python_tests | 34 -- qpid/cpp/src/tests/python_tests.ps1 | 42 -- qpid/cpp/src/tests/qpid-build-rinstall | 28 -- qpid/cpp/src/tests/quick_perftest | 22 - qpid/cpp/src/tests/quick_topictest | 30 -- qpid/cpp/src/tests/quick_topictest.ps1 | 30 -- qpid/cpp/src/tests/quick_txtest | 22 - qpid/cpp/src/tests/rsynchosts | 57 --- qpid/cpp/src/tests/run.py | 6 + qpid/cpp/src/tests/run_acl_tests | 170 ++----- qpid/cpp/src/tests/run_acl_tests.ps1 | 99 ---- qpid/cpp/src/tests/run_cli_tests | 88 ++-- qpid/cpp/src/tests/run_client_tests | 30 ++ qpid/cpp/src/tests/run_federation_sys_tests | 71 --- qpid/cpp/src/tests/run_federation_tests | 81 ++- qpid/cpp/src/tests/run_federation_tests.ps1 | 83 ---- qpid/cpp/src/tests/run_flow_control_tests | 28 ++ qpid/cpp/src/tests/run_ha_tests | 24 +- qpid/cpp/src/tests/run_header_test | 31 -- qpid/cpp/src/tests/run_header_test.ps1 | 48 -- qpid/cpp/src/tests/run_headers_federation_tests | 49 -- qpid/cpp/src/tests/run_idle_timeout_tests | 26 + qpid/cpp/src/tests/run_interlink_tests | 8 +- qpid/cpp/src/tests/run_interop_tests | 30 ++ qpid/cpp/src/tests/run_ipv6_tests | 116 +++++ qpid/cpp/src/tests/run_logging_tests | 38 ++ qpid/cpp/src/tests/run_long_federation_sys_tests | 2 +- qpid/cpp/src/tests/run_msg_group_tests | 59 +-- qpid/cpp/src/tests/run_msg_group_tests.ps1 | 71 --- qpid/cpp/src/tests/run_msg_group_tests_soak | 8 +- qpid/cpp/src/tests/run_paged_queue_tests | 55 +-- qpid/cpp/src/tests/run_performance_tests | 28 ++ qpid/cpp/src/tests/run_perftest | 28 -- qpid/cpp/src/tests/run_python_tests | 62 +++ qpid/cpp/src/tests/run_qmf_tests | 26 + qpid/cpp/src/tests/run_queue_flow_limit_tests | 27 - qpid/cpp/src/tests/run_queue_redirect | 56 --- qpid/cpp/src/tests/run_queue_redirect_tests | 30 ++ qpid/cpp/src/tests/run_ring_queue_test | 36 -- qpid/cpp/src/tests/run_ring_queue_tests | 30 ++ qpid/cpp/src/tests/run_sasl_tests | 64 +++ qpid/cpp/src/tests/run_ssl_tests | 329 +++++++++++++ qpid/cpp/src/tests/run_store_tests.ps1 | 2 +- qpid/cpp/src/tests/run_test | 191 -------- qpid/cpp/src/tests/run_test.ps1 | 162 ------ qpid/cpp/src/tests/run_topic_tests | 30 ++ qpid/cpp/src/tests/run_transaction_tests | 30 ++ qpid/cpp/src/tests/run_unit_tests | 39 ++ qpid/cpp/src/tests/sasl_fed | 153 ++---- qpid/cpp/src/tests/sasl_fed_ex | 208 +++----- qpid/cpp/src/tests/sasl_no_dir | 94 +--- qpid/cpp/src/tests/sasl_test_setup.sh | 11 +- qpid/cpp/src/tests/shared_perftest | 22 - qpid/cpp/src/tests/ssl_test | 140 +++--- qpid/cpp/src/tests/swig_python_tests | 68 --- qpid/cpp/src/tests/test.xquery | 6 - qpid/cpp/src/tests/test_env.ps1.in | 77 --- qpid/cpp/src/tests/test_env.sh.in | 100 ---- qpid/cpp/src/tests/test_env_common.sh | 28 -- qpid/cpp/src/tests/topic_perftest | 22 - qpid/cpp/src/tests/topictest | 4 +- qpid/cpp/src/tests/vg_check | 43 -- 92 files changed, 2790 insertions(+), 2962 deletions(-) delete mode 100644 qpid/cpp/src/tests/ais_test.cpp delete mode 100755 qpid/cpp/src/tests/allhosts create mode 100644 qpid/cpp/src/tests/check_dependencies.py.in create mode 100644 qpid/cpp/src/tests/common.py delete mode 100644 qpid/cpp/src/tests/config.null create mode 100644 qpid/cpp/src/tests/env.ps1.in create mode 100644 qpid/cpp/src/tests/env.py.in create mode 100644 qpid/cpp/src/tests/env.sh.in delete mode 100755 qpid/cpp/src/tests/fanout_perftest delete mode 100644 qpid/cpp/src/tests/install_env.sh.in delete mode 100755 qpid/cpp/src/tests/ipv6_test delete mode 100755 qpid/cpp/src/tests/multiq_perftest create mode 100644 qpid/cpp/src/tests/plano.py delete mode 100755 qpid/cpp/src/tests/python_tests delete mode 100644 qpid/cpp/src/tests/python_tests.ps1 delete mode 100755 qpid/cpp/src/tests/qpid-build-rinstall delete mode 100755 qpid/cpp/src/tests/quick_perftest delete mode 100755 qpid/cpp/src/tests/quick_topictest delete mode 100644 qpid/cpp/src/tests/quick_topictest.ps1 delete mode 100755 qpid/cpp/src/tests/quick_txtest delete mode 100755 qpid/cpp/src/tests/rsynchosts create mode 100755 qpid/cpp/src/tests/run.py delete mode 100644 qpid/cpp/src/tests/run_acl_tests.ps1 create mode 100755 qpid/cpp/src/tests/run_client_tests delete mode 100755 qpid/cpp/src/tests/run_federation_sys_tests delete mode 100644 qpid/cpp/src/tests/run_federation_tests.ps1 create mode 100755 qpid/cpp/src/tests/run_flow_control_tests delete mode 100755 qpid/cpp/src/tests/run_header_test delete mode 100644 qpid/cpp/src/tests/run_header_test.ps1 delete mode 100644 qpid/cpp/src/tests/run_headers_federation_tests create mode 100755 qpid/cpp/src/tests/run_idle_timeout_tests create mode 100755 qpid/cpp/src/tests/run_interop_tests create mode 100755 qpid/cpp/src/tests/run_ipv6_tests create mode 100755 qpid/cpp/src/tests/run_logging_tests delete mode 100644 qpid/cpp/src/tests/run_msg_group_tests.ps1 create mode 100755 qpid/cpp/src/tests/run_performance_tests delete mode 100755 qpid/cpp/src/tests/run_perftest create mode 100755 qpid/cpp/src/tests/run_python_tests create mode 100755 qpid/cpp/src/tests/run_qmf_tests delete mode 100755 qpid/cpp/src/tests/run_queue_flow_limit_tests delete mode 100755 qpid/cpp/src/tests/run_queue_redirect create mode 100644 qpid/cpp/src/tests/run_queue_redirect_tests delete mode 100755 qpid/cpp/src/tests/run_ring_queue_test create mode 100755 qpid/cpp/src/tests/run_ring_queue_tests create mode 100755 qpid/cpp/src/tests/run_sasl_tests create mode 100755 qpid/cpp/src/tests/run_ssl_tests delete mode 100755 qpid/cpp/src/tests/run_test delete mode 100644 qpid/cpp/src/tests/run_test.ps1 create mode 100755 qpid/cpp/src/tests/run_topic_tests create mode 100755 qpid/cpp/src/tests/run_transaction_tests create mode 100755 qpid/cpp/src/tests/run_unit_tests delete mode 100755 qpid/cpp/src/tests/shared_perftest delete mode 100755 qpid/cpp/src/tests/swig_python_tests delete mode 100644 qpid/cpp/src/tests/test.xquery delete mode 100644 qpid/cpp/src/tests/test_env.ps1.in delete mode 100644 qpid/cpp/src/tests/test_env.sh.in delete mode 100644 qpid/cpp/src/tests/test_env_common.sh delete mode 100755 qpid/cpp/src/tests/topic_perftest delete mode 100644 qpid/cpp/src/tests/vg_check (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt index 45f5987a6c..be10be9b85 100644 --- a/qpid/cpp/src/CMakeLists.txt +++ b/qpid/cpp/src/CMakeLists.txt @@ -502,30 +502,23 @@ if (BUILD_XML) endif (BUILD_XML) -# Build the ACL plugin -set (acl_default ON) - -option(BUILD_ACL "Build ACL enforcement broker plugin" ${acl_default}) - -if (BUILD_ACL) - set (acl_SOURCES - qpid/acl/Acl.cpp - qpid/acl/Acl.h - qpid/acl/AclConnectionCounter.cpp - qpid/acl/AclConnectionCounter.h - qpid/acl/AclData.cpp - qpid/acl/AclData.h - qpid/acl/AclLexer.cpp - qpid/acl/AclLexer.h - qpid/acl/AclPlugin.cpp - qpid/acl/AclReader.cpp - qpid/acl/AclReader.h - qpid/acl/AclResourceCounter.cpp - qpid/acl/AclResourceCounter.h - qpid/acl/AclValidator.cpp - qpid/acl/AclValidator.h - ) -endif (BUILD_ACL) +set (acl_SOURCES + qpid/acl/Acl.cpp + qpid/acl/Acl.h + qpid/acl/AclConnectionCounter.cpp + qpid/acl/AclConnectionCounter.h + qpid/acl/AclData.cpp + qpid/acl/AclData.h + qpid/acl/AclLexer.cpp + qpid/acl/AclLexer.h + qpid/acl/AclPlugin.cpp + qpid/acl/AclReader.cpp + qpid/acl/AclReader.h + qpid/acl/AclResourceCounter.cpp + qpid/acl/AclResourceCounter.h + qpid/acl/AclValidator.cpp + qpid/acl/AclValidator.h + ) set (ha_default ON) diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt index d2e6c7dd13..efc3176174 100644 --- a/qpid/cpp/src/tests/CMakeLists.txt +++ b/qpid/cpp/src/tests/CMakeLists.txt @@ -25,21 +25,22 @@ if (QPID_LINK_BOOST_DYNAMIC) add_definitions(-DBOOST_TEST_DYN_LINK) endif (QPID_LINK_BOOST_DYNAMIC) -include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) - -# Using the Boost DLLs triggers warning 4275 on Visual Studio -# (non dll-interface class used as base for dll-interface class). -# This is ok, so suppress the warning. -# Also, boost lengthy names trigger warning 4503, decorated name length exceeded -# and using getenv() triggers insecure CRT warnings which we can silence in the -# test environment. +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +# Using the Boost DLLs triggers warning 4275 on Visual Studio (non +# dll-interface class used as base for dll-interface class). This is +# ok, so suppress the warning. +# +# Also, boost lengthy names trigger warning 4503, decorated name +# length exceeded and using getenv() triggers insecure CRT warnings +# which we can silence in the test environment. if (MSVC) - add_definitions( /wd4275 /wd4503 /D_CRT_SECURE_NO_WARNINGS) + add_definitions(/wd4275 /wd4503 /D_CRT_SECURE_NO_WARNINGS) endif (MSVC) # If we're using GCC allow variadic macros (even though they're c99 not c++01) if (CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-Wno-variadic-macros) + add_definitions(-Wno-variadic-macros) endif (CMAKE_COMPILER_IS_GNUCXX) # Windows uses some process-startup calls to ensure that errors, etc. don't @@ -48,95 +49,91 @@ endif (CMAKE_COMPILER_IS_GNUCXX) # instead of windows. If you want to remove this code, build without the # QPID_WINDOWS_DEFAULT_TEST_OUTPUTS ON. if (CMAKE_SYSTEM_NAME STREQUAL Windows) - option(QPID_WINDOWS_DEFAULT_TEST_OUTPUTS "Use default error-handling on Windows tests" OFF) - if (NOT QPID_WINDOWS_DEFAULT_TEST_OUTPUTS) - set(platform_test_additions windows/DisableWin32ErrorWindows.cpp) - endif (NOT QPID_WINDOWS_DEFAULT_TEST_OUTPUTS) + option(QPID_WINDOWS_DEFAULT_TEST_OUTPUTS "Use default error-handling on Windows tests" OFF) + if (NOT QPID_WINDOWS_DEFAULT_TEST_OUTPUTS) + set(platform_test_additions windows/DisableWin32ErrorWindows.cpp) + endif (NOT QPID_WINDOWS_DEFAULT_TEST_OUTPUTS) endif (CMAKE_SYSTEM_NAME STREQUAL Windows) # Some generally useful utilities that just happen to be built in the test area -add_executable (qpid-receive qpid-receive.cpp Statistics.cpp ${platform_test_additions}) -target_link_libraries (qpid-receive qpidmessaging qpidtypes qpidcommon) +add_executable(qpid-receive qpid-receive.cpp Statistics.cpp ${platform_test_additions}) +target_link_libraries(qpid-receive qpidmessaging qpidtypes qpidcommon) -add_executable (qpid-send qpid-send.cpp Statistics.cpp ${platform_test_additions}) -target_link_libraries (qpid-send qpidmessaging qpidtypes qpidcommon) +add_executable(qpid-send qpid-send.cpp Statistics.cpp ${platform_test_additions}) +target_link_libraries(qpid-send qpidmessaging qpidtypes qpidcommon) -install (TARGETS - qpid-receive qpid-send - RUNTIME DESTINATION ${QPID_INSTALL_BINDIR}) +install(TARGETS qpid-receive qpid-send RUNTIME DESTINATION ${QPID_INSTALL_BINDIR}) -add_executable (qpid-perftest qpid-perftest.cpp ${platform_test_additions}) -target_link_libraries (qpid-perftest qpidclient qpidcommon ${Boost_PROGRAM_OPTIONS_LIBRARY}) +add_executable(qpid-perftest qpid-perftest.cpp ${platform_test_additions}) +target_link_libraries(qpid-perftest qpidclient qpidcommon ${Boost_PROGRAM_OPTIONS_LIBRARY}) -add_executable (qpid-latency-test qpid-latency-test.cpp ${platform_test_additions}) -target_link_libraries (qpid-latency-test qpidclient qpidcommon) +add_executable(qpid-latency-test qpid-latency-test.cpp ${platform_test_additions}) +target_link_libraries(qpid-latency-test qpidclient qpidcommon) -add_executable (qpid-client-test qpid-client-test.cpp ${platform_test_additions}) -target_link_libraries (qpid-client-test qpidclient qpidcommon) +add_executable(qpid-client-test qpid-client-test.cpp ${platform_test_additions}) +target_link_libraries(qpid-client-test qpidclient qpidcommon) -add_executable (qpid-ping qpid-ping.cpp ${platform_test_additions}) -target_link_libraries (qpid-ping qpidmessaging qpidtypes qpidcommon) +add_executable(qpid-ping qpid-ping.cpp ${platform_test_additions}) +target_link_libraries(qpid-ping qpidmessaging qpidtypes qpidcommon) -add_executable (qpid-topic-listener qpid-topic-listener.cpp ${platform_test_additions}) -target_link_libraries (qpid-topic-listener qpidclient qpidcommon) +add_executable(qpid-topic-listener qpid-topic-listener.cpp ${platform_test_additions}) +target_link_libraries(qpid-topic-listener qpidclient qpidcommon) -add_executable (qpid-topic-publisher qpid-topic-publisher.cpp ${platform_test_additions}) -target_link_libraries (qpid-topic-publisher qpidclient qpidcommon) +add_executable(qpid-topic-publisher qpid-topic-publisher.cpp ${platform_test_additions}) +target_link_libraries(qpid-topic-publisher qpidclient qpidcommon) -add_executable (receiver receiver.cpp ${platform_test_additions}) -target_link_libraries (receiver qpidclient qpidcommon) +add_executable(receiver receiver.cpp ${platform_test_additions}) +target_link_libraries(receiver qpidclient qpidcommon) # This is bizarre - using both messaging and client libraries -add_executable (sender sender.cpp Statistics.cpp ${platform_test_additions}) -target_link_libraries (sender qpidmessaging qpidtypes qpidclient qpidcommon) +add_executable(sender sender.cpp Statistics.cpp ${platform_test_additions}) +target_link_libraries(sender qpidmessaging qpidtypes qpidclient qpidcommon) -add_executable (qpid-txtest qpid-txtest.cpp ${platform_test_additions}) -target_link_libraries (qpid-txtest qpidclient qpidcommon qpidtypes) -#qpid_txtest_SOURCES=qpid-txtest.cpp TestOptions.h ConnectionOptions.h +add_executable(qpid-txtest qpid-txtest.cpp ${platform_test_additions}) +target_link_libraries(qpid-txtest qpidclient qpidcommon qpidtypes) -add_executable (qpid-txtest2 qpid-txtest2.cpp ${platform_test_additions}) -target_link_libraries (qpid-txtest2 qpidmessaging qpidtypes qpidcommon) +add_executable(qpid-txtest2 qpid-txtest2.cpp ${platform_test_additions}) +target_link_libraries(qpid-txtest2 qpidmessaging qpidtypes qpidcommon) -install (TARGETS - qpid-perftest qpid-latency-test qpid-client-test - qpid-ping - qpid-topic-listener qpid-topic-publisher receiver sender - qpid-txtest qpid-txtest2 - RUNTIME DESTINATION ${QPID_INSTALL_TESTDIR}) +install(TARGETS + qpid-perftest qpid-latency-test qpid-client-test + qpid-ping + qpid-topic-listener qpid-topic-publisher receiver sender + qpid-txtest qpid-txtest2 + RUNTIME DESTINATION ${QPID_INSTALL_TESTDIR}) # Only build test code if testing is turned on if (BUILD_TESTING) -# Create the environment scripts for tests -set (abs_srcdir ${CMAKE_CURRENT_SOURCE_DIR}) -set (abs_builddir ${CMAKE_CURRENT_BINARY_DIR}) -set (abs_top_srcdir ${CMAKE_SOURCE_DIR}) -set (abs_top_builddir ${CMAKE_BINARY_DIR}) -set (builddir_lib_suffix "") - if (CMAKE_SYSTEM_NAME STREQUAL Windows) - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.ps1.in - ${CMAKE_CURRENT_BINARY_DIR}/test_env.ps1 @ONLY) -else (CMAKE_SYSTEM_NAME STREQUAL Windows) - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.sh.in - ${CMAKE_CURRENT_BINARY_DIR}/test_env.sh @ONLY) -endif (CMAKE_SYSTEM_NAME STREQUAL Windows) - -# Copy qpidd-p0 script to build directory so tests can find it. -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/qpidd-p0 ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) + # Windows + + set(ENV{OUTDIR} ${EXECUTABLE_OUTPUT_PATH}) -if (CMAKE_SYSTEM_NAME STREQUAL Windows) - set (ENV{OUTDIR} ${EXECUTABLE_OUTPUT_PATH}) - set (test_script_suffix ".ps1") - set (shell "powershell") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/env.ps1.in + ${CMAKE_CURRENT_BINARY_DIR}/env.ps1 @ONLY) +else (CMAKE_SYSTEM_NAME STREQUAL Windows) + # Posix + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/env.sh.in + ${CMAKE_CURRENT_BINARY_DIR}/env.sh @ONLY) endif (CMAKE_SYSTEM_NAME STREQUAL Windows) -set(test_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} -buildDir ${CMAKE_BINARY_DIR}) -set(python_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} -buildDir ${CMAKE_BINARY_DIR} -python) - +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_dependencies.py.in + ${CMAKE_CURRENT_BINARY_DIR}/check_dependencies.py @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/env.py.in + ${CMAKE_CURRENT_BINARY_DIR}/env.py @ONLY) + +file(COPY . + DESTINATION . + PATTERN "*.cmake" EXCLUDE + PATTERN "*.in" EXCLUDE + PATTERN "*.c" EXCLUDE + PATTERN "*.h" EXCLUDE + PATTERN "*.cpp" EXCLUDE) + if (BUILD_TESTING_UNITTESTS) -# # Unit test program # # Unit tests are built as a single program to reduce valgrind overhead @@ -144,8 +141,8 @@ if (BUILD_TESTING_UNITTESTS) # ccmake and set unit_tests_to_build to the set you want to build. # Like this to work with cmake 2.4 on Unix -set (qpid_test_boost_libs - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY}) +set(qpid_test_boost_libs + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY}) set(all_unit_tests AccumulatedAckTest @@ -200,21 +197,16 @@ set(all_unit_tests Url Uuid Variant - ${xml_tests} - ) - -set(unit_tests_to_build - "" - CACHE STRING "Which unit tests to build" - ) + ${xml_tests}) +set(unit_tests_to_build "" CACHE STRING "Which unit tests to build") mark_as_advanced(unit_tests_to_build) # If no unit_test specifically set then use all unit tests if (unit_tests_to_build) -set(actual_unit_tests ${unit_tests_to_build}) + set(actual_unit_tests ${unit_tests_to_build}) else() -set(actual_unit_tests ${all_unit_tests}) + set(actual_unit_tests ${all_unit_tests}) endif() add_executable (unit_test unit_test @@ -224,148 +216,115 @@ target_link_libraries (unit_test qpidmessaging qpidtypes qpidbroker qpidclient qpidcommon) set_target_properties (unit_test PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER) -add_test (NAME unit_test COMMAND ${test_wrap} -boostTest -- $) - endif (BUILD_TESTING_UNITTESTS) -add_library (shlibtest MODULE shlibtest.cpp) +add_library(shlibtest MODULE shlibtest.cpp) if (BUILD_SASL) - add_custom_command( - OUTPUT sasl_config/qpidd.conf sasl_config/qpidd.sasldb - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sasl_test_setup.sh) + add_custom_command(OUTPUT sasl_config/qpidd.conf sasl_config/qpidd.sasldb + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sasl_test_setup.sh) - add_custom_target( - sasl_config ALL - DEPENDS sasl_config/qpidd.conf sasl_config/qpidd.sasldb) + add_custom_target(sasl_config ALL + DEPENDS sasl_config/qpidd.conf sasl_config/qpidd.sasldb) endif (BUILD_SASL) -# # Other test programs -# -add_executable (echotest echotest.cpp ${platform_test_additions}) -target_link_libraries (echotest qpidclient qpidcommon) -add_executable (publish publish.cpp ${platform_test_additions}) -target_link_libraries (publish qpidclient qpidcommon) +add_executable(echotest echotest.cpp ${platform_test_additions}) +target_link_libraries(echotest qpidclient qpidcommon) -add_executable (consume consume.cpp ${platform_test_additions}) -target_link_libraries (consume qpidclient qpidcommon) +add_executable(publish publish.cpp ${platform_test_additions}) +target_link_libraries(publish qpidclient qpidcommon) -add_executable (header_test header_test.cpp ${platform_test_additions}) -target_link_libraries (header_test qpidclient qpidcommon) +add_executable(consume consume.cpp ${platform_test_additions}) +target_link_libraries(consume qpidclient qpidcommon) -add_executable (declare_queues declare_queues.cpp ${platform_test_additions}) -target_link_libraries (declare_queues qpidclient qpidcommon) +add_executable(header_test header_test.cpp ${platform_test_additions}) +target_link_libraries(header_test qpidclient qpidcommon) -add_executable (replaying_sender replaying_sender.cpp ${platform_test_additions}) -target_link_libraries (replaying_sender qpidclient qpidcommon) +add_executable(declare_queues declare_queues.cpp ${platform_test_additions}) +target_link_libraries(declare_queues qpidclient qpidcommon) -add_executable (resuming_receiver resuming_receiver.cpp ${platform_test_additions}) -target_link_libraries (resuming_receiver qpidclient qpidcommon) +add_executable(replaying_sender replaying_sender.cpp ${platform_test_additions}) +target_link_libraries(replaying_sender qpidclient qpidcommon) -add_executable (txshift txshift.cpp ${platform_test_additions}) -target_link_libraries (txshift qpidclient qpidcommon) +add_executable(resuming_receiver resuming_receiver.cpp ${platform_test_additions}) +target_link_libraries(resuming_receiver qpidclient qpidcommon) -add_executable (txjob txjob.cpp ${platform_test_additions}) -target_link_libraries (txjob qpidclient qpidcommon) +add_executable(txshift txshift.cpp ${platform_test_additions}) +target_link_libraries(txshift qpidclient qpidcommon) -add_executable (datagen datagen.cpp ${platform_test_additions}) -target_link_libraries (datagen qpidclient qpidcommon) +add_executable(txjob txjob.cpp ${platform_test_additions}) +target_link_libraries(txjob qpidclient qpidcommon) -add_executable (msg_group_test msg_group_test.cpp ${platform_test_additions}) -target_link_libraries (msg_group_test qpidmessaging qpidtypes qpidcommon) +add_executable(datagen datagen.cpp ${platform_test_additions}) +target_link_libraries(datagen qpidclient qpidcommon) -add_executable (ha_test_max_queues ha_test_max_queues.cpp ${platform_test_additions}) -target_link_libraries (ha_test_max_queues qpidclient qpidcommon) +add_executable(msg_group_test msg_group_test.cpp ${platform_test_additions}) +target_link_libraries(msg_group_test qpidmessaging qpidtypes qpidcommon) -if (BUILD_SASL) - add_executable (sasl_version sasl_version.cpp ${platform_test_additions}) -endif (BUILD_SASL) +add_executable(ha_test_max_queues ha_test_max_queues.cpp ${platform_test_additions}) +target_link_libraries(ha_test_max_queues qpidclient qpidcommon) + +add_library(test_store MODULE test_store.cpp) +target_link_libraries(test_store qpidbroker qpidcommon) +set_target_properties(test_store PROPERTIES PREFIX "" COMPILE_DEFINITIONS _IN_QPID_BROKER) -set (python_src ${CMAKE_SOURCE_DIR}/../python) -if (EXISTS ${python_src}) - set (python_bld ${CMAKE_CURRENT_BINARY_DIR}/python) - # This will not pick up added or deleted python files - # In that case you need to rerun CMake - file(GLOB_RECURSE python_files ${python_src}/*.py) - - add_custom_command( - OUTPUT ${python_bld} - DEPENDS ${python_files} - COMMAND ${PYTHON_EXECUTABLE} - setup.py - build --build-base=${python_bld}/build - install --prefix=${python_bld} --install-lib=${python_bld} --install-scripts=${python_bld}/commands - WORKING_DIRECTORY ${python_src} - ) - - add_custom_target( - python_bld ALL - DEPENDS ${python_bld} - ) -endif (EXISTS ${python_src}) +add_library(dlclose_noop MODULE dlclose_noop.c) if (BUILD_SASL) - add_test (NAME sasl_fed COMMAND ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/sasl_fed${test_script_suffix}) - add_test (NAME sasl_fed_ex_dynamic COMMAND ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/sasl_fed_ex${test_script_suffix} dynamic) - add_test (NAME sasl_fed_ex_link COMMAND ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/sasl_fed_ex${test_script_suffix} link) - add_test (NAME sasl_fed_ex_queue COMMAND ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/sasl_fed_ex${test_script_suffix} queue) - add_test (NAME sasl_fed_ex_route COMMAND ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/sasl_fed_ex${test_script_suffix} route) - add_test (NAME sasl_no_dir COMMAND ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/sasl_no_dir${test_script_suffix}) - if (BUILD_SSL) - add_test(NAME ssl_test COMMAND ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/ssl_test${test_script_suffix}) - endif (BUILD_SSL) + add_executable(sasl_version sasl_version.cpp ${platform_test_additions}) endif (BUILD_SASL) -add_test (NAME qpid-client-test COMMAND ${test_wrap} -startBroker -- $) -add_test (NAME quick_perftest COMMAND ${test_wrap} -startBroker -- $ --summary --count 100) -add_test (NAME quick_topictest COMMAND ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix}) -add_test (NAME quick_txtest COMMAND ${test_wrap} -startBroker -- $ --queues 4 --tx-count 10 --quiet) -add_test (NAME quick_txtest2 COMMAND ${test_wrap} -startBroker -- $ --queues 4 --tx-count 10 --quiet) -add_test (NAME msg_group_tests COMMAND ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_msg_group_tests${test_script_suffix}) -add_test (NAME run_header_test COMMAND ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix}) -add_test (NAME python_tests COMMAND ${test_wrap} -startBroker -- ${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix}) -if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) - # paged queue not yet implemented for windows - add_test (NAME paged_queue_tests COMMAND ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_paged_queue_tests${test_script_suffix}) -endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) -if (BUILD_AMQP) - add_test (interop_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/interop_tests.py) -endif (BUILD_AMQP) +# Cross-platform tests + +add_test(NAME unit_tests COMMAND ${PYTHON_EXECUTABLE} run_unit_tests) + +add_test(NAME acl_tests COMMAND ${PYTHON_EXECUTABLE} run_acl_tests) +add_test(NAME cli_tests COMMAND ${PYTHON_EXECUTABLE} run_cli_tests) +add_test(NAME client_tests COMMAND ${PYTHON_EXECUTABLE} run_client_tests) +add_test(NAME federation_tests COMMAND ${PYTHON_EXECUTABLE} run_federation_tests) +add_test(NAME flow_control_tests COMMAND ${PYTHON_EXECUTABLE} run_flow_control_tests) +add_test(NAME ha_tests COMMAND ${PYTHON_EXECUTABLE} run_ha_tests) +add_test(NAME msg_group_tests COMMAND ${PYTHON_EXECUTABLE} run_msg_group_tests) +add_test(NAME performance_tests COMMAND ${PYTHON_EXECUTABLE} run_performance_tests) +add_test(NAME python_tests COMMAND ${PYTHON_EXECUTABLE} run_python_tests) +add_test(NAME queue_redirect_tests COMMAND ${PYTHON_EXECUTABLE} run_queue_redirect_tests) +add_test(NAME qmf_tests COMMAND ${PYTHON_EXECUTABLE} run_qmf_tests) +add_test(NAME transaction_tests COMMAND ${PYTHON_EXECUTABLE} run_transaction_tests) -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 ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py) - add_test (idle_timeout_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/idle_timeout_tests.py) + add_test(NAME idle_timeout_tests COMMAND ${PYTHON_EXECUTABLE} run_idle_timeout_tests) + add_test(NAME interlink_tests COMMAND ${PYTHON_EXECUTABLE} run_interlink_tests) + add_test(NAME interop_tests COMMAND ${PYTHON_EXECUTABLE} run_interop_tests) endif (BUILD_AMQP) -add_test (swig_python_tests ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/swig_python_tests${test_script_suffix}) -add_test (ipv6_test ${test_wrap} -- ${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 - ${test_wrap} - -startBroker -brokerOptions "--default-flow-stop-threshold=80 --default-flow-resume-threshold=70" - -- ${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) -add_test (cli_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_cli_tests${test_script_suffix}) -add_test (dynamic_log_level_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_log_level_test${test_script_suffix}) -add_test (dynamic_log_hires_timestamp ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_log_hires_timestamp${test_script_suffix}) -if (BUILD_MSSQL) - add_test (store_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL) -endif (BUILD_MSSQL) -if (BUILD_MSCLFS) - add_test (store_tests_clfs ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL-CLFS) -endif (BUILD_MSCLFS) -add_test (queue_redirect ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_redirect${test_script_suffix}) -add_library(test_store MODULE test_store.cpp) -target_link_libraries (test_store qpidbroker qpidcommon) -set_target_properties (test_store PROPERTIES PREFIX "" COMPILE_DEFINITIONS _IN_QPID_BROKER) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) + # Windows-only tests + + if (BUILD_MSSQL) + add_test(NAME store_tests COMMAND powershell run_store_tests.ps1 MSSQL) + endif (BUILD_MSSQL) + + if (BUILD_MSCLFS) + add_test(NAME store_tests_clfs COMMAND powershell run_store_tests.ps1 MSSQL-CLFS) + endif (BUILD_MSCLFS) +else (CMAKE_SYSTEM_NAME STREQUAL Windows) + # Posix-only tests -add_library (dlclose_noop MODULE dlclose_noop.c) + add_test(NAME logging_tests COMMAND run_logging_tests) # Pretty simple to convert + add_test(NAME ipv6_tests COMMAND run_ipv6_tests) # Also pretty simple to convert + add_test(NAME paged_queue_tests COMMAND run_paged_queue_tests) + add_test(NAME ring_queue_tests COMMAND run_ring_queue_tests) + add_test(NAME topic_tests COMMAND run_topic_tests) + + if (BUILD_SASL) + add_test(NAME sasl_tests COMMAND run_sasl_tests) + + if (BUILD_SSL) + add_test(NAME ssl_tests COMMAND run_ssl_tests) + endif (BUILD_SSL) + endif (BUILD_SASL) +endif (CMAKE_SYSTEM_NAME STREQUAL Windows) endif (BUILD_TESTING) diff --git a/qpid/cpp/src/tests/README.txt b/qpid/cpp/src/tests/README.txt index 8eaa5bbd25..50bd181ab0 100644 --- a/qpid/cpp/src/tests/README.txt +++ b/qpid/cpp/src/tests/README.txt @@ -8,21 +8,15 @@ developers can run tests selectively as explained below. Unit tests use the boost test framework, and are compiled to the programd unit_test -There are several options to control how test results are displayed, see - http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/parameters/index.html +There are several options to control how test results are displayed. See +http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/parameters/index.html. == System Tests == -System tests are executables or scripts. You can run executable tests directly -as well as via "make test" or "ctest". Some tests require environment settings -which are set by src/tests/test_env.sh on Unix or by src/tests/test_env.ps1 on -Windows. - -./python_tests: runs ../python/run_tests. This is the main set of -system tests for the broker. - -Other C++ client test executables and scripts under client/test are -system tests for the client. +System tests are executables or scripts. You can run executable tests +directly as well as via "make test" or "ctest". Some tests require +environment settings which are set by src/tests/env.sh on Unix or by +src/tests/env.ps1 on Windows. == Running selected tests == @@ -34,4 +28,3 @@ directly gives you additional options, e.g. This runs tests with names matching the regular expression and will print the full output of the tests rather than just listing which tests pass or fail. - diff --git a/qpid/cpp/src/tests/ais_test.cpp b/qpid/cpp/src/tests/ais_test.cpp deleted file mode 100644 index 00c61242e4..0000000000 --- a/qpid/cpp/src/tests/ais_test.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed 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. - * - */ - -// Defines test_main function to link with actual unit test code. -#define BOOST_AUTO_TEST_MAIN // Boost 1.33 -#define BOOST_TEST_MAIN -#include "unit_test.h" - diff --git a/qpid/cpp/src/tests/allhosts b/qpid/cpp/src/tests/allhosts deleted file mode 100755 index 07bc04fff5..0000000000 --- a/qpid/cpp/src/tests/allhosts +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env 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. -# - -usage() { - echo "Usage: $0 [options] command. -Run a command on each host in \$HOSTS. -Options: - -l USER passed to ssh - run as USER. - -t passed to ssh - create a terminal. - -b run in background, wait for commands to complete. - -d run in background, don't wait for commands to complete. - -s SECONDS sleep between starting commands. - -q don't print banner lines for each host. - -o SUFFIX log output of each command to .SUFFIX - -X passed to ssh - forward X connection. -" - exit 1 -} - -while getopts "tl:bs:dqo:X" opt; do - case $opt in - l) SSHOPTS="-l$OPTARG $SSHOPTS" ;; - t) SSHOPTS="-t $SSHOPTS" ;; - b) BACKGROUND=1 ;; - d) BACKGROUND=1; DISOWN=1 ;; - s) SLEEP="sleep $OPTARG" ;; - q) NOBANNER=1 ;; - o) SUFFIX=$OPTARG ;; - X) SSHOPTS="-X $SSHOPTS" ;; - *) usage;; - esac -done -shift `expr $OPTIND - 1` -test "$*" || usage; - -OK_FILE=`mktemp` # Will be deleted if anything goes wrong. -trap "rm -f $OK_FILE" EXIT - -do_ssh() { - h=$1; shift - if test $SUFFIX ; then ssh $SSHOPTS $h "$@" &> $h.$SUFFIX - else ssh $SSHOPTS $h "$@"; fi || rm -rf $OK_FILE; -} - -for h in $HOSTS ; do - test "$NOBANNER" || echo "== ssh $SSHOPTS $h $@ ==" - if [ "$BACKGROUND" = 1 ]; then - do_ssh $h "$@" & - CHILDREN="$! $CHILDREN" - else - do_ssh $h "$@" - fi - $SLEEP -done - -if [ "$DISOWN" = 1 ]; then - for c in $CHILDREN; do disown $c; done -else - wait -fi - -test -f $OK_FILE diff --git a/qpid/cpp/src/tests/brokertest.py b/qpid/cpp/src/tests/brokertest.py index 6fae88092b..8c32faad0c 100644 --- a/qpid/cpp/src/tests/brokertest.py +++ b/qpid/cpp/src/tests/brokertest.py @@ -354,7 +354,7 @@ class Broker(Popen): if (self.test.protocol and qm == qpid_messaging): kwargs.setdefault("protocol", self.test.protocol) return connection_class.establish(self.host_port(), timeout=timeout, **kwargs) - + @property def agent(self, **kwargs): """Return a BrokerAgent for this broker""" @@ -477,14 +477,14 @@ class BrokerTest(TestCase): TestCase.__init__(self, *args, **kwargs) # Environment settings. - qpidd_exec = os.path.abspath(checkenv("QPIDD_EXEC")) + qpidd_exec = "qpidd" ha_lib = os.getenv("HA_LIB") xml_lib = os.getenv("XML_LIB") amqp_lib = os.getenv("AMQP_LIB") - qpid_config_exec = os.getenv("QPID_CONFIG_EXEC") - qpid_route_exec = os.getenv("QPID_ROUTE_EXEC") - receiver_exec = os.getenv("RECEIVER_EXEC") - sender_exec = os.getenv("SENDER_EXEC") + qpid_config_exec = "qpid-config" + qpid_route_exec = "qpid-route" + receiver_exec = "receiver" + sender_exec = "sender" sql_store_lib = os.getenv("STORE_SQL_LIB") sql_clfs_store_lib = os.getenv("STORE_SQL_CLFS_LIB") sql_catalog = os.getenv("STORE_CATALOG") @@ -505,19 +505,7 @@ class BrokerTest(TestCase): PN_TX_VERSION = (0, 9) amqp_tx_supported = PN_VERSION >= PN_TX_VERSION - - @classmethod - def amqp_tx_warning(cls): - if not cls.amqp_tx_supported: - if cls.PN_VERSION == (0, 0): - print "WARNING: Cannot test transactions over AMQP 1.0, proton not on path so version could not be determined" - elif cls.PN_VERSION == (0, 7): - print "WARNING: Cannot test transactions over AMQP 1.0, proton version is 0.7 or less, %s.%s required" % cls.PN_TX_VERSION - else: - print "WARNING: Cannot test transactions over AMQP 1.0, proton version %s.%s < %s.%s" % (cls.PN_VERSION + cls.PN_TX_VERSION) - return False - return True - + def configure(self, config): self.config=config def setUp(self): diff --git a/qpid/cpp/src/tests/check_dependencies.py.in b/qpid/cpp/src/tests/check_dependencies.py.in new file mode 100644 index 0000000000..4a8a544026 --- /dev/null +++ b/qpid/cpp/src/tests/check_dependencies.py.in @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# +# 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. +# + +import os +import sys + +def _message(error): + return """ +=============================================================================== +Error! {} + +The tests require Qpid Python, version 1.33 or greater. Make sure +Qpid Python is installed and available on the Python path: + + - Linux distributions: Install 'python-qpid' + - Other: Install qpid-python from source and update PYTHONPATH + +See the Qpid website for more information: + + - Qpid downloads: http://qpid.apache.org/download.html + - Qpid packages: http://qpid.apache.org/packages.html +=============================================================================== +""".format(error) + +sys.path.insert(0, os.path.join("@CMAKE_SOURCE_DIR@", "management", "python", "lib")) + +try: + import qpid +except ImportError: + exit(_message("Can't find Python 'qpid' module")) + +try: + import qpid_tests +except ImportError: + exit(_message("Can't find Python 'qpid_tests' module")) diff --git a/qpid/cpp/src/tests/cli_tests.py b/qpid/cpp/src/tests/cli_tests.py index eee9bc648c..ae0f32d4d1 100755 --- a/qpid/cpp/src/tests/cli_tests.py +++ b/qpid/cpp/src/tests/cli_tests.py @@ -295,7 +295,8 @@ class CliTests(TestBase010): self.helper_create_queue(qname) # now bind the queue to the xchg - foo = self.qpid_config_command("-f test.xquery bind " + xchgname + " " + qname) + xquery_file = self.defines["xquery-file"] + foo = self.qpid_config_command("-f " + xquery_file + " bind " + xchgname + " " + qname) # print foo ret = os.system(foo) self.assertEqual(ret, 0) @@ -468,10 +469,14 @@ class CliTests(TestBase010): return self.cli_dir() + "/qpid-config -b localhost:%d" % self.broker.port + " " + arg def qpid_config_api(self, arg = ""): - script = import_script(checkenv("QPID_CONFIG_EXEC")) + path = os.path.join(os.getenv("SOURCE_DIR"), "management", "python", + "bin", "qpid-config") + script = import_script(path) broker = ["-b", "localhost:"+str(self.broker.port)] return script.main(broker + arg.split()) def qpid_route_api(self, arg = ""): - script = import_script(checkenv("QPID_ROUTE_EXEC")) + path = os.path.join(os.getenv("SOURCE_DIR"), "management", "python", + "bin", "qpid-route") + script = import_script(path) return script.main(arg.split()) diff --git a/qpid/cpp/src/tests/common.py b/qpid/cpp/src/tests/common.py new file mode 100644 index 0000000000..992bc60fb8 --- /dev/null +++ b/qpid/cpp/src/tests/common.py @@ -0,0 +1,297 @@ +# +# 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. +# + +from __future__ import print_function + +from env import * + +import atexit as _atexit +import os as _os +import platform as _platform +import re as _re +import signal as _signal +import subprocess as _subprocess +import shutil as _shutil +import time as _time +import uuid as _uuid + +WINDOWS = _platform.system() == "Windows" + +def _unique_id(): + return str(_uuid.uuid4())[:4] + +def make_work_dir(): + prog = file_name(ARGS[0]) + name = "{}_{}".format(prog, _unique_id()) + + return make_dir(join(BUILD_DIR, name)) + +WORK_DIR = make_work_dir() + +notice("Created work dir '{}'", WORK_DIR) + +def _init_valgrind_command(command): + if VALGRIND is None: + return command, None + + log_file = join(WORK_DIR, "valgrind_{}.log".format(_unique_id())) + suppressions_file = join(BUILD_DIR, "src", "tests", ".valgrind.supp") + + valgrind_command = [ + VALGRIND, + "--leak-check=full --num-callers=25 --error-exitcode=100", + "--log-file={}".format(log_file), + "--suppressions={}".format(suppressions_file), + "--", + command, + ] + + return " ".join(valgrind_command), log_file + +def call_with_valgrind(command, *args, **kwargs): + command, valgrind_log_file = _init_valgrind_command(command) + + try: + call(command, *args, **kwargs) + except _subprocess.CalledProcessError as e: + if e.returncode == 100: + error("Valgrind reported errors") + print(read(valgrind_log_file)) + + raise + +def call_for_output_with_valgrind(command, *args, **kwargs): + command, valgrind_log_file = _init_valgrind_command(command) + + try: + return call_for_output(command, *args, **kwargs) + except _subprocess.CalledProcessError as e: + if e.returncode == 100: + error("Valgrind reported errors") + print(read(valgrind_log_file)) + + raise + +_brokers = list() +_brokers_by_port = dict() +_broker_port_expr = _re.compile(r"Listening on TCP/TCP6 port ([0-9]+)") +_broker_config_file = join(BUILD_DIR, "src", "tests", "qpidd-empty.conf") + +class _Broker(object): + def __init__(self, dir): + self.dir = dir + + self.command_file = join(self.dir, "command") + self.log_file = join(self.dir, "log") + self.data_dir = join(self.dir, "data") + + self.port = None + self.proc = None + self.command = None + self.valgrind_log_file = None + + def __repr__(self): + args = self.port, self.proc.pid, self.proc.returncode + return "Broker(port={}, pid={}, exit={})".format(*args) + + def start(self, args): + make_dir(self.dir) + + command = [ + "qpidd", + "--port 0", + "--interface localhost", + "--no-module-dir", + "--log-enable info+", + "--log-source yes", + "--log-to-stderr no", + "--log-to-file {}".format(self.log_file), + "--config {}".format(_broker_config_file), + "--data-dir {}".format(self.data_dir), + ] + + if WINDOWS: + command += [ + "--ssl-cert-store-location LocalMachine", + "--ssl-cert-name localhost", + "--ssl-port 0", + ] + + command += [x for x in args if x is not None] + command = " ".join(command) + command, valgrind_log_file = _init_valgrind_command(command) + + self.command = command + self.valgrind_log_file = valgrind_log_file + + notice("Calling '{}'", self.command) + write(self.command_file, self.command) + + self.proc = _subprocess.Popen(self.command, shell=True, + stdout=_subprocess.PIPE) + self.port = self._wait_for_port() + + assert self.command is not None + assert self.proc is not None + assert self.port is not None + assert self.port not in _brokers_by_port, self.port + + _brokers.append(self) + _brokers_by_port[self.port] = self + + notice("Started {}", self) + + def _wait_for_port(self): + port = None + + while port is None: + _time.sleep(0.4) + port = self._scan_port() + + return port + + def _scan_port(self): + if not exists(self.log_file): + return + + match = _re.search(_broker_port_expr, read(self.log_file)) + + if match: + return match.group(1) + + def stop(self): + if self.proc.poll() is not None: + return + + notice("Stopping {}", self) + + if WINDOWS: + call("taskkill /f /t /pid {}", self.proc.pid) + else: + self.proc.terminate() + + self.proc.wait() + + def check(self): + if WINDOWS: + # Taskkilled windows processes always return 1, so exit + # codes don't mean anything there + return 0 + + notice("Checking {}", self) + + if self.proc.returncode == 0: + return 0 + + error("{} exited with code {}", self, self.proc.returncode) + + if self.proc.returncode == 100: + print("Valgrind reported errors:") + print(read(self.valgrind_log_file)) + else: + print("Last 100 lines of broker log:") + print(tail(self.log_file, 100)) + + flush() + + error("{} exited with code {}", self, self.proc.returncode) + + return self.proc.returncode + +def start_broker(dir, *args, **kwargs): + if not is_absolute(dir): + dir = join(WORK_DIR, dir) + + auth_disabled = kwargs.get("auth_disabled", True) + + if auth_disabled: + args = list(args) + args.append("--auth no") + + broker = _Broker(dir) + broker.start(args) + + return broker.port + +def stop_broker(port): + broker = _brokers_by_port[port] + broker.stop() + +def check_broker(port): + broker = _brokers_by_port[port] + + if broker.check() != 0: + exit("Broker failure") + +def check_results(): + for broker in _brokers: + broker.stop() + + errors = False + + for broker in _brokers: + code = broker.check() + + if code == 0: + continue + + errors = True + + if errors: + exit("Broker failure") + + remove(WORK_DIR) + + notice("Tests completed without error") + +def _exit_handler(): + if exists(WORK_DIR): + notice("Output saved in work dir '{}'", WORK_DIR) + + for broker in _brokers: + broker.stop() + +_atexit.register(_exit_handler) + +def configure_broker(broker_port, *args): + command = [ + "qpid-config", + "--broker localhost:{}".format(broker_port), + ] + + command += [x for x in args if x is not None] + + call(" ".join(command)) + +def run_broker_tests(broker_port, *args): + command = [ + "qpid-python-test", + "--broker localhost:{}".format(broker_port), + "--time", + ] + + command += [x for x in args if x is not None] + + call(" ".join(command)) + +def connect_brokers(*args): + command = ["qpid-route"] + command += [x for x in args if x is not None] + + call(" ".join(command)) diff --git a/qpid/cpp/src/tests/config.null b/qpid/cpp/src/tests/config.null deleted file mode 100644 index e2f355768b..0000000000 --- a/qpid/cpp/src/tests/config.null +++ /dev/null @@ -1,21 +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. -# - -# Deliberately empty configuration file for tests. - diff --git a/qpid/cpp/src/tests/dynamic_log_hires_timestamp b/qpid/cpp/src/tests/dynamic_log_hires_timestamp index 75034f9902..606286d9c3 100755 --- a/qpid/cpp/src/tests/dynamic_log_hires_timestamp +++ b/qpid/cpp/src/tests/dynamic_log_hires_timestamp @@ -20,14 +20,14 @@ # # Run a simple test to verify dynamic log highres timestamp changes -source ./test_env.sh -test -d $PYTHON_DIR || { echo "Skipping python tests, no python dir."; exit 0; } + +source ./env.sh LOG_FILE=hires_test.log trap cleanup EXIT cleanup() { - test -n "$PORT" && $QPIDD_EXEC --no-module-dir --quit --port $PORT + test -n "$PORT" && qpidd --no-module-dir --quit --port $PORT } error() { @@ -36,16 +36,16 @@ error() { } rm -rf $LOG_FILE -PORT=$($QPIDD_EXEC --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $LOG_FILE) || error "Could not start broker" +PORT=$(qpidd --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $LOG_FILE) || error "Could not start broker" -echo Broker for log highres timestamp test started on $PORT, pid is $($QPIDD_EXEC --no-module-dir --check --port $PORT) +echo Broker for log highres timestamp test started on $PORT, pid is $(qpidd --no-module-dir --check --port $PORT) -$srcdir/qpid-ctrl -b localhost:$PORT setLogLevel level='debug+:Broker' > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT echo sequence=1 body=LOWRES > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT setLogHiresTimestamp logHires='true' > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT echo sequence=2 body=HI_RES > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT setLogHiresTimestamp logHires='false' > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT echo sequence=3 body=LOWRES > /dev/null +qpid-ctrl -b localhost:$PORT setLogLevel level='debug+:Broker' > /dev/null +qpid-ctrl -b localhost:$PORT echo sequence=1 body=LOWRES > /dev/null +qpid-ctrl -b localhost:$PORT setLogHiresTimestamp logHires='true' > /dev/null +qpid-ctrl -b localhost:$PORT echo sequence=2 body=HI_RES > /dev/null +qpid-ctrl -b localhost:$PORT setLogHiresTimestamp logHires='false' > /dev/null +qpid-ctrl -b localhost:$PORT echo sequence=3 body=LOWRES > /dev/null # Expect 3 log entries with 'echo' in them if [[ $(grep echo $LOG_FILE | wc -l) -ne 3 ]]; then diff --git a/qpid/cpp/src/tests/dynamic_log_level_test b/qpid/cpp/src/tests/dynamic_log_level_test index f8fd7a8dd8..0ea40d11b6 100755 --- a/qpid/cpp/src/tests/dynamic_log_level_test +++ b/qpid/cpp/src/tests/dynamic_log_level_test @@ -20,14 +20,14 @@ # # Run a simple test to verify dynamic log level changes -source ./test_env.sh -test -d $PYTHON_DIR || { echo "Skipping python tests, no python dir."; exit 0; } + +source ./env.sh LOG_FILE=log_test.log trap cleanup EXIT cleanup() { - test -n "$PORT" && $QPIDD_EXEC --no-module-dir --quit --port $PORT + test -n "$PORT" && qpidd --no-module-dir --quit --port $PORT } error() { @@ -43,30 +43,30 @@ checklog() { } rm -rf $LOG_FILE -PORT=$($QPIDD_EXEC --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $LOG_FILE) || error "Could not start broker" +PORT=$(qpidd --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $LOG_FILE) || error "Could not start broker" -echo Broker for log level test started on $PORT, pid is $($QPIDD_EXEC --no-module-dir --check --port $PORT) +echo Broker for log level test started on $PORT, pid is $(qpidd --no-module-dir --check --port $PORT) # Set level to notice+ and send an echo request # The 'echo' in the log is hidden since it is at debug level. -$srcdir/qpid-ctrl -b localhost:$PORT setLogLevel level='notice+' > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT echo sequence=1 body=HIDDEN > /dev/null +qpid-ctrl -b localhost:$PORT setLogLevel level='notice+' > /dev/null +qpid-ctrl -b localhost:$PORT echo sequence=1 body=HIDDEN > /dev/null checklog 0 "Step 1 Expected no echo log entries" # Next, enable all Broker logs at debug and higher levels and send another echo # This 'echo' should be in the log. -$srcdir/qpid-ctrl -b localhost:$PORT setLogLevel level='debug+:Broker' > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT echo sequence=2 body=VISIBLE > /dev/null +qpid-ctrl -b localhost:$PORT setLogLevel level='debug+:Broker' > /dev/null +qpid-ctrl -b localhost:$PORT echo sequence=2 body=VISIBLE > /dev/null checklog 1 "Step 2 Expected one echo log entry" # Now turn on Broker debug messages but specifically disable ManagementMethod logs # The 'echo' should be hidden. -$srcdir/qpid-ctrl -b localhost:$PORT setLogLevel level='debug+:Broker !debug+:broker::Broker::ManagementMethod' > /dev/null -$srcdir/qpid-ctrl -b localhost:$PORT echo sequence=3 body=HIDDEN > /dev/null +qpid-ctrl -b localhost:$PORT setLogLevel level='debug+:Broker !debug+:broker::Broker::ManagementMethod' > /dev/null +qpid-ctrl -b localhost:$PORT echo sequence=3 body=HIDDEN > /dev/null checklog 1 "Step 3 Expected one echo log entry" # Verify that the management get returns what was just set -$srcdir/qpid-ctrl -b localhost:$PORT getLogLevel > dynamic_log_level.tmp +qpid-ctrl -b localhost:$PORT getLogLevel > dynamic_log_level.tmp if [[ $(grep 'level=debug+:Broker,!debug+:broker::Broker::ManagementMethod' dynamic_log_level.tmp | wc -l) -ne 1 ]]; then error "Step 4 getLogLevel returned unexpected value: " `cat dynamic_log_level.tmp` fi @@ -76,10 +76,10 @@ cleanup # Start another broker with --log-disable settings and make sure the management string receives them rm -rf $LOG_FILE -PORT=$($QPIDD_EXEC --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $LOG_FILE --log-enable debug:foo --log-disable debug:bar) || error "Could not start broker" -echo Broker for log level test started on $PORT, pid is $($QPIDD_EXEC --no-module-dir --check --port $PORT) +PORT=$(qpidd --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $LOG_FILE --log-enable debug:foo --log-disable debug:bar) || error "Could not start broker" +echo Broker for log level test started on $PORT, pid is $(qpidd --no-module-dir --check --port $PORT) -$srcdir/qpid-ctrl -b localhost:$PORT getLogLevel > dynamic_log_level.tmp +qpid-ctrl -b localhost:$PORT getLogLevel > dynamic_log_level.tmp if [[ $(grep 'level=debug:foo,!debug:bar' dynamic_log_level.tmp | wc -l) -ne 1 ]]; then error "Step 5 getLogLevel returned unexpected value: " `cat dynamic_log_level.tmp` fi diff --git a/qpid/cpp/src/tests/env.ps1.in b/qpid/cpp/src/tests/env.ps1.in new file mode 100644 index 0000000000..94834a4b5e --- /dev/null +++ b/qpid/cpp/src/tests/env.ps1.in @@ -0,0 +1,77 @@ +# +# 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. +# + +# Environment variables substituted by configure/cmake. +$abs_srcdir="@abs_srcdir@" +$abs_builddir="@abs_builddir@" +$top_srcdir="@abs_top_srcdir@" +$top_builddir="@abs_top_builddir@" +$moduledir="$top_builddir\src@builddir_lib_suffix@" +$testmoduledir="$builddir@builddir_lib_suffix@" +$BOOST_LIBRARYDIR="@BOOST_LIBRARYDIR@" + +# Python paths and directories +$PYTHON_EXE="@PYTHON_EXECUTABLE@" +$PYTHON_DIR="$builddir\python" +$QPID_PYTHON_TEST="$PYTHON_DIR\commands\qpid-python-test" +if ( !(Test-Path "$PYTHON_DIR") -and (Test-Path "$top_srcdir\..\python")) { + $PYTHON_DIR="$top_srcdir\..\python" + $QPID_PYTHON_TEST="$PYTHON_DIR\qpid-python-test" +} +$QPID_TESTS="$top_srcdir\..\tests" +$QPID_TESTS_PY="$QPID_TESTS\src\py" +$QPID_TOOLS="$top_srcdir\..\tools" +$QPID_TOOLS_LIBS="$QPID_TOOLS\src\py" +$QMF_LIB="$top_srcdir\..\extras\qmf\src\py" +$PYTHON_COMMANDS="$QPID_TOOLS\src\py" +$env:PYTHONPATH="$srcdir;$PYTHON_DIR;$PYTHON_COMMANDS;$QPID_TESTS_PY;$QPID_TOOLS_LIBS;$QMF_LIB;$env:PYTHONPATH" +$QPID_CONFIG_EXEC="$PYTHON_COMMANDS\qpid-config" +$QPID_ROUTE_EXEC="$PYTHON_COMMANDS\qpid-route" +$QPID_HA_TOOL_EXEC="$PYTHON_COMMANDS\qpid-ha-tool" + +# Executables +$env:QPIDD_EXEC="$top_builddir\src\@CMAKE_BUILD_TYPE@\qpidd.exe" +$env:QPID_WATCHDOG_EXEC="$top_builddir\src\qpidd_watchdog" + +# Test executables +$QPID_TEST_EXEC_DIR="$builddir\@CMAKE_BUILD_TYPE@" +$RECEIVER_EXEC="$QPID_TEST_EXEC_DIR\receiver" +$SENDER_EXEC="$QPID_TEST_EXEC_DIR\sender" + +# Path +$env:PATH="$top_builddir\src\@CMAKE_BUILD_TYPE@;$builddir\@CMAKE_BUILD_TYPE@;$srcdir;$PYTHON_COMMANDS;$QPID_TEST_EXEC_DIR;@BOOST_LIBRARYDIR@;$env:PATH" + +# Modules +$env:TEST_STORE_LIB="$testmoduledir\test_store.so" + +#exportmodule() { test -f $moduledir/$2 && eval "export $1=$moduledir/$2"; } +#exportmodule ACL_LIB acl.so +#exportmodule CLUSTER_LIB cluster.so +#exportmodule SSLCONNECTOR_LIB sslconnector.so +#exportmodule SSL_LIB ssl.so +#exportmodule WATCHDOG_LIB watchdog.so +#exportmodule XML_LIB xml.so + +# Qpid options +$env:QPID_NO_MODULE_DIR="1" # Don't accidentally load installed modules +$env:QPID_DATA_DIR= # Default to no data dir, not ~/.qpidd + +# Options for boost test framework +$env:BOOST_TEST_SHOW_PROGRESS="yes" +$env:BOOST_TEST_CATCH_SYSTEM_ERRORS="no" diff --git a/qpid/cpp/src/tests/env.py.in b/qpid/cpp/src/tests/env.py.in new file mode 100644 index 0000000000..d76e17f573 --- /dev/null +++ b/qpid/cpp/src/tests/env.py.in @@ -0,0 +1,100 @@ +# +# 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. +# + +from __future__ import print_function + +from plano import * + +def _export(name, value): + globals()[name] = value + + if value is not None: + ENV[name] = value + +def _export_module(name, path): + _export(name, None) + + if exists(path): + _export(name, path) + +# Variables substituted by cmake + +_export("BUILD_DIR", normalize_path("@CMAKE_BINARY_DIR@")) +_export("SOURCE_DIR", normalize_path("@CMAKE_SOURCE_DIR@")) +_export("SASLPASSWD2", normalize_path("@SASLPASSWD2_EXECUTABLE@")) +_export("PYTHON", normalize_path("@PYTHON_EXECUTABLE@")) +_export("VALGRIND", None) + +if "@ENABLE_VALGRIND@" == "ON": + _export("VALGRIND", normalize_path("@VALGRIND_EXECUTABLE@")) + +# Python path + +_python_path = [ + join(BUILD_DIR, "src", "tests"), + join(BUILD_DIR, "bindings", "qpid", "python"), + join(BUILD_DIR, "management", "python", "lib"), +] + +if "PYTHONPATH" in ENV: + _python_path.extend(ENV["PYTHONPATH"].split(PATH_VAR_SEP)) + +ENV["PYTHONPATH"] = PATH_VAR_SEP.join(_python_path) + +# Path + +_path = [ + join(BUILD_DIR, "src"), + join(BUILD_DIR, "src", "RelWithDebInfo"), + join(BUILD_DIR, "src", "tests"), + join(BUILD_DIR, "src", "tests", "RelWithDebInfo"), + join(BUILD_DIR, "management", "python", "bin"), +] + +if "PATH" in ENV: + _path.extend(ENV["PATH"].split(PATH_VAR_SEP)) + +ENV["PATH"] = PATH_VAR_SEP.join(_path) + +# Modules + +_export_module("HA_LIB", join(BUILD_DIR, "src", "ha.so")) +_export_module("XML_LIB", join(BUILD_DIR, "src", "xml.so")) +_export_module("AMQP_LIB", join(BUILD_DIR, "src", "amqp.so")) +_export_module("TEST_STORE_LIB", join(BUILD_DIR, "src", "tests", "test_store.so")) +_export_module("STORE_LIB", join(BUILD_DIR, "src", "linearstore.so")) + +if STORE_LIB is None: + _export_module("STORE_LIB", join(BUILD_DIR, "src", "legacystore.so")) + +# Summarize + +print("PWD: {}".format(current_dir())) +print("SOURCE_DIR: {}".format(SOURCE_DIR)) +print("BUILD_DIR: {}".format(BUILD_DIR)) + +print("PATH:") + +for item in _path: + print(" {}".format(item)) + +print("PYTHONPATH:") + +for item in _python_path: + print(" {}".format(item)) diff --git a/qpid/cpp/src/tests/env.sh.in b/qpid/cpp/src/tests/env.sh.in new file mode 100644 index 0000000000..ee5b858b94 --- /dev/null +++ b/qpid/cpp/src/tests/env.sh.in @@ -0,0 +1,74 @@ +# +# 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. +# + +# Environment variables substituted by cmake + +export BUILD_DIR=@CMAKE_BINARY_DIR@ +export SOURCE_DIR=@CMAKE_SOURCE_DIR@ + +export SASLPASSWD2=@SASLPASSWD2_EXECUTABLE@ +export PYTHON=@PYTHON_EXECUTABLE@ + +if [[ "@ENABLE_VALGRIND@" == "ON" ]]; then + export VALGRIND=@VALGRIND_EXECUTABLE@ +fi + +# Python path + +export PYTHONPATH=$BUILD_DIR/src/tests:$BUILD_DIR/bindings/qpid/python:$BUILD_DIR/management/python/lib:${PYTHONPATH-} + +# Path + +export PATH=$BUILD_DIR/src:$BUILD_DIR/src/tests:$BUILD_DIR/management/python/bin:${PATH-} + +# Modules + +function export_module { + [[ -f $BUILD_DIR/src/$2 ]] && export $1=$BUILD_DIR/src/$2 +} + +export_module HA_LIB ha.so +export_module XML_LIB xml.so +export_module AMQP_LIB amqp.so + +[[ ${STORE_LIB-} ]] || export_module STORE_LIB linearstore.so +[[ ${STORE_LIB-} ]] || export_module STORE_LIB legacystore.so + +export TEST_STORE_LIB=$BUILD_DIR/src/tests/test_store.so + +# Qpidd options - Eliminate + +export QPID_NO_MODULE_DIR=1 # Don't accidentally load installed modules +export QPID_DATA_DIR= # Disable persistence +export QPID_CONFIG=$SOURCE_DIR/src/tests/qpidd-empty.conf + +# Options for boost test framework + +[[ ${BOOST_TEST_SHOW_PROGRESS-} ]] || export BOOST_TEST_SHOW_PROGRESS=yes +[[ ${BOOST_TEST_CATCH_SYSTEM_ERRORS-} ]] || export BOOST_TEST_CATCH_SYSTEM_ERRORS=no + +echo "PWD: $PWD" +echo "SOURCE_DIR: ${SOURCE_DIR}" +echo "BUILD_DIR: ${BUILD_DIR}" + +echo "PATH:" +echo -n " "; echo $PATH | sed 's/:/\n /g' + +echo "PYTHONPATH:" +echo -n " "; echo $PYTHONPATH | sed 's/:/\n /g' diff --git a/qpid/cpp/src/tests/fanout_perftest b/qpid/cpp/src/tests/fanout_perftest deleted file mode 100755 index 168994d372..0000000000 --- a/qpid/cpp/src/tests/fanout_perftest +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env 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. -# - -exec `dirname $0`/run_perftest 10000 --mode fanout --npubs 16 --nsubs 16 --size 64 diff --git a/qpid/cpp/src/tests/federated_topic_test b/qpid/cpp/src/tests/federated_topic_test index 2d31f9af5a..b8356b4b9d 100755 --- a/qpid/cpp/src/tests/federated_topic_test +++ b/qpid/cpp/src/tests/federated_topic_test @@ -42,12 +42,12 @@ while getopts "s:m:b:" opt ; do esac done -source ./test_env.sh +source ./env.sh trap stop_brokers EXIT start_broker() { - $QPIDD_EXEC --daemon --port 0 --interface 127.0.0.1 --no-module-dir --no-data-dir --auth no > qpidd.port + qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --no-data-dir --auth no > qpidd.port } start_brokers() { @@ -61,7 +61,7 @@ start_brokers() { stop_brokers() { for p in $PORT_A $PORT_B $PORT_C; do - $QPIDD_EXEC --no-module-dir -q --port $p + qpidd --no-module-dir -q --port $p done } @@ -75,11 +75,11 @@ subscribe() { echo Subscriber $1 connecting on $MY_PORT LOG="subscriber_$1.log" - ./qpid-topic-listener -p $MY_PORT > $LOG 2>&1 && rm -f $LOG + qpid-topic-listener -p $MY_PORT > $LOG 2>&1 && rm -f $LOG } publish() { - ./qpid-topic-publisher --messages $MESSAGES --batches $BATCHES --subscribers $SUBSCRIBERS -p $PORT_A + qpid-topic-publisher --messages $MESSAGES --batches $BATCHES --subscribers $SUBSCRIBERS -p $PORT_A } setup_routes() { @@ -89,40 +89,39 @@ setup_routes() { if (($VERBOSE)); then echo "Establishing routes for topic..." fi - $QPID_ROUTE_EXEC route add $BROKER_B $BROKER_A amq.topic topic_control B B - $QPID_ROUTE_EXEC route add $BROKER_C $BROKER_B amq.topic topic_control C C + qpid-route route add $BROKER_B $BROKER_A amq.topic topic_control B B + qpid-route route add $BROKER_C $BROKER_B amq.topic topic_control C C if (($VERBOSE)); then echo "linked A->B->C" fi - $QPID_ROUTE_EXEC route add $BROKER_B $BROKER_C amq.topic topic_control B B - $QPID_ROUTE_EXEC route add $BROKER_A $BROKER_B amq.topic topic_control A A + qpid-route route add $BROKER_B $BROKER_C amq.topic topic_control B B + qpid-route route add $BROKER_A $BROKER_B amq.topic topic_control A A if (($VERBOSE)); then echo "linked C->B->A" echo "Establishing routes for response queue..." fi - $QPID_ROUTE_EXEC route add $BROKER_B $BROKER_C amq.direct response B B - $QPID_ROUTE_EXEC route add $BROKER_A $BROKER_B amq.direct response A A + qpid-route route add $BROKER_B $BROKER_C amq.direct response B B + qpid-route route add $BROKER_A $BROKER_B amq.direct response A A if (($VERBOSE)); then echo "linked C->B->A" for b in $BROKER_A $BROKER_B $BROKER_C; do echo "Routes for $b" - $QPID_ROUTE_EXEC route list $b + qpid-route route list $b done fi } -if test -d ${PYTHON_DIR} ; then - start_brokers - if (($VERBOSE)); then - echo "Running federated topic test against brokers on ports $PORT_A $PORT_B $PORT_C" - fi +start_brokers - for ((i=$SUBSCRIBERS ; i--; )); do - subscribe $i & - done +if (($VERBOSE)); then + echo "Running federated topic test against brokers on ports $PORT_A $PORT_B $PORT_C" +fi - setup_routes +for ((i=$SUBSCRIBERS ; i--; )); do + subscribe $i & +done - publish || exit 1 -fi +setup_routes + +publish || exit 1 diff --git a/qpid/cpp/src/tests/ha_test.py b/qpid/cpp/src/tests/ha_test.py index ace225a509..3659185140 100755 --- a/qpid/cpp/src/tests/ha_test.py +++ b/qpid/cpp/src/tests/ha_test.py @@ -160,9 +160,8 @@ acl allow all all @property def qpid_ha_script(self): if not hasattr(self, "_qpid_ha_script"): - qpid_ha_exec = os.getenv("QPID_HA_EXEC") - if not qpid_ha_exec or not os.path.isfile(qpid_ha_exec): - raise Skipped("qpid-ha not available") + qpid_ha_exec = os.path.join(os.getenv("SOURCE_DIR"), "management", + "python", "bin", "qpid-ha") self._qpid_ha_script = import_script(qpid_ha_exec) return self._qpid_ha_script @@ -225,11 +224,8 @@ acl allow all all assert retry(lambda: agent.getQueue(queue) is None, timeout=timeout), "%s: queue %s still present"%(msg,queue) def qpid_config(self, args): - qpid_config_exec = os.getenv("QPID_CONFIG_EXEC") - if not qpid_config_exec or not os.path.isfile(qpid_config_exec): - raise Skipped("qpid-config not available") assert subprocess.call( - [qpid_config_exec, "--broker", self.host_port()]+args, stdout=1, stderr=subprocess.STDOUT + ["qpid-config", "--broker", self.host_port()]+args, stdout=1, stderr=subprocess.STDOUT ) == 0, "qpid-config failed" def config_replicate(self, from_broker, queue): diff --git a/qpid/cpp/src/tests/ha_tests.py b/qpid/cpp/src/tests/ha_tests.py index 0efb8182ec..fdcb314751 100755 --- a/qpid/cpp/src/tests/ha_tests.py +++ b/qpid/cpp/src/tests/ha_tests.py @@ -1450,15 +1450,9 @@ class TransactionTests(HaBrokerTest): "*.tx.*"], stdout=None, stderr=None).assert_exit_ok() if __name__ == "__main__": - qpid_ha_exec = os.getenv("QPID_HA_EXEC") - if qpid_ha_exec and os.path.isfile(qpid_ha_exec): - BrokerTest.amqp_tx_warning() - outdir = "ha_tests.tmp" - shutil.rmtree(outdir, True) - os.execvp("qpid-python-test", - ["qpid-python-test", "-m", "ha_tests", "-DOUTDIR=%s"%outdir] - + sys.argv[1:]) - else: - print "Skipping ha_tests, qpid-ha not available" - + outdir = "ha_tests.tmp" + shutil.rmtree(outdir, True) + os.execvp("qpid-python-test", + ["qpid-python-test", "-m", "ha_tests", "-DOUTDIR=%s"%outdir] + + sys.argv[1:]) diff --git a/qpid/cpp/src/tests/install_env.sh.in b/qpid/cpp/src/tests/install_env.sh.in deleted file mode 100644 index d29a23930d..0000000000 --- a/qpid/cpp/src/tests/install_env.sh.in +++ /dev/null @@ -1,26 +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. -# - -absdir() { echo `cd $1 && pwd`; } - -prefix=`absdir @prefix@` -export QPID_INSTALL_PREFIX=$prefix -export PATH=$prefix/bin:$prefix/sbin:$prefix/libexec/qpid/tests:$PATH -export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH -export PYTHONPATH=$prefix/lib/python2.6/site-packages:$PYTHONPATH diff --git a/qpid/cpp/src/tests/interlink_tests.py b/qpid/cpp/src/tests/interlink_tests.py index 3eec2422f1..8833f06af5 100755 --- a/qpid/cpp/src/tests/interlink_tests.py +++ b/qpid/cpp/src/tests/interlink_tests.py @@ -72,12 +72,7 @@ class AmqpBrokerTest(BrokerTest): return self.popen(cmd, stdout=PIPE) def ready_receiver(self, config): - # NOTE: some tests core dump when run with SWIG binding over proton - # version<=0.6. This is fixed on proton 0.7. - def use_native(): - pv=os.environ.get("QPID_PROTON_VERSION") - return pv and [int(n) for n in pv.split(".")] <= [0,6] - s = self.broker.connect(native=use_native()).session() + s = self.broker.connect().session() r = s.receiver("readyq; {create:always}") cmd = ["qpid-receive", "--broker", config.url, diff --git a/qpid/cpp/src/tests/interop_tests.py b/qpid/cpp/src/tests/interop_tests.py index f76b9f634b..31182f324a 100755 --- a/qpid/cpp/src/tests/interop_tests.py +++ b/qpid/cpp/src/tests/interop_tests.py @@ -192,10 +192,7 @@ class CppTxTest(InteropTest): if __name__ == "__main__": - if not BrokerTest.amqp_tx_supported: - BrokerTest.amqp_tx_warning() - print "Skipping interop_tests" - sys.exit(0) + from env import * outdir = "interop_tests.tmp" shutil.rmtree(outdir, True) cmd = ["qpid-python-test", "-m", "interop_tests", "-DOUTDIR=%s"%outdir] + sys.argv[1:] diff --git a/qpid/cpp/src/tests/ipv6_test b/qpid/cpp/src/tests/ipv6_test deleted file mode 100755 index 4ac5f95fba..0000000000 --- a/qpid/cpp/src/tests/ipv6_test +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env 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. -# - -# Check whether we have any globally configured IPv6 addresses -# - if not then we can't run the tests because ipv6 lookups won't -# work within the qpid code. This is a deliberate feature to avoid -# getting addresses that can't be routed by the machine. - -if ip -f inet6 -o addr | cut -f 9 -s -d' ' | grep global > /dev/null ; then - echo "IPv6 addresses configured continuing" -else - echo "No global IPv6 addresses configured - skipping test" - exit 0 -fi - - -# Run a simple test over IPv6 -source $QPID_TEST_COMMON - -CONFIG=$(dirname $0)/config.null -TEST_HOSTNAME=::1 -COUNT=10 - -trap cleanup EXIT - -error() { echo $*; exit 1; } - -# Don't need --no-module-dir or --no-data-dir as they are set as env vars in test_env.sh -COMMON_OPTS="--interface [::1] --daemon --auth no --config $CONFIG" - -# Record all broker ports started -unset PORTS -declare -a PORTS - -# Start new brokers: -# $1 must be integer -# $2 = extra opts -# Append used ports to PORTS variable -start_brokers() { - local -a ports - for (( i=0; $i<$1; i++)) do - ports[$i]=$($QPIDD_EXEC --port 0 $COMMON_OPTS $2) - done - PORTS=( ${PORTS[@]} ${ports[@]} ) -} - -stop_brokers() { - for port in "${PORTS[@]}"; - do - $QPIDD_EXEC -qp $port - done - PORTS=() -} - -cleanup() { - stop_brokers -} - -start_brokers 1 -PORT=${PORTS[0]} -echo "Started IPv6 smoke perftest on broker port $PORT" - -## Test connection via connection settings -./qpid-perftest --count ${COUNT} --port ${PORT} -b $TEST_HOSTNAME --summary - -## Test connection with a URL -URL="amqp:[$TEST_HOSTNAME]:$PORT" - -./qpid-send -b $URL --content-string=hello -a "foo;{create:always}" -MSG=`./qpid-receive -b $URL -a "foo;{create:always}" --messages 1` -test "$MSG" = "hello" || { echo "receive failed '$MSG' != 'hello'"; exit 1; } - -stop_brokers - -# Federation smoke test follows - -# Start 2 brokers - -# In a distribution, the python tools will be absent. -ensure_python_tests - -start_brokers 2 -echo "Started Federated brokers on ports ${PORTS[*]}" -# Make broker urls -BROKER0="[::1]:${PORTS[0]}" -BROKER1="[::1]:${PORTS[1]}" -TEST_QUEUE=ipv6-fed-test - -$QPID_CONFIG_EXEC -b $BROKER0 add queue $TEST_QUEUE -$QPID_CONFIG_EXEC -b $BROKER1 add queue $TEST_QUEUE -$QPID_ROUTE_EXEC dynamic add $BROKER1 $BROKER0 amq.direct -$QPID_CONFIG_EXEC -b $BROKER1 bind amq.direct $TEST_QUEUE $TEST_QUEUE -$QPID_ROUTE_EXEC route map $BROKER1 - -./datagen --count 100 | tee rdata-in | - ./qpid-send -b amqp:$BROKER0 -a amq.direct/$TEST_QUEUE --content-stdin -./qpid-receive -b amqp:$BROKER1 -a $TEST_QUEUE --print-content yes -m 0 > rdata-out - -cmp rdata-in rdata-out || { echo "Federated data over IPv6 does not compare"; exit 1; } - -stop_brokers -rm rdata-in rdata-out diff --git a/qpid/cpp/src/tests/legacystore/CMakeLists.txt b/qpid/cpp/src/tests/legacystore/CMakeLists.txt index 9f6f6b7171..20a242b415 100644 --- a/qpid/cpp/src/tests/legacystore/CMakeLists.txt +++ b/qpid/cpp/src/tests/legacystore/CMakeLists.txt @@ -28,8 +28,6 @@ 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} -buildDir=${CMAKE_BINARY_DIR}) - if (BUILD_TESTING_UNITTESTS) # Like this to work with cmake 2.4 on Unix @@ -53,7 +51,7 @@ target_link_libraries (${testname} if ("${ARGV1}" STREQUAL "LONG") set_target_properties(${testname} PROPERTIES COMPILE_DEFINITIONS LONG_TEST) endif () -add_test (NAME ${testname} COMMAND ${test_wrap} -boostTest -- $) +add_test (NAME ${testname} COMMAND ${CMAKE_BINARY_DIR}/src/tests/run.sh $) unset (testname) ENDMACRO (define_journal_test) @@ -100,7 +98,7 @@ target_link_libraries (jtt__ut ${Boost_PROGRAM_OPTIONS_LIBRARY} ${clock_gettime_LIB} legacystore_shared) -add_test(journal_jtt_ut ${test_wrap} -boostTest -workingDir=${CMAKE_CURRENT_SOURCE_DIR}/jrnl/jtt -- ${CMAKE_CURRENT_BINARY_DIR}/jtt__ut) +add_test(journal_jtt_ut ${CMAKE_BINARY_DIR}/src/tests/run.sh ${CMAKE_CURRENT_BINARY_DIR}/jtt__ut) endif (BUILD_TESTING_UNITTESTS) @@ -127,6 +125,6 @@ target_link_libraries (jtt add_test(journal_jtt ${CMAKE_CURRENT_BINARY_DIR}/jtt -c ${CMAKE_CURRENT_SOURCE_DIR}/jrnl/jtt/jtt.csv) -add_test (legacystore_python_tests ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/run_python_tests${test_script_suffix}) +add_test(legacystore_python_tests ${PYTHON_EXECUTABLE} run_python_tests) endif (BUILD_LEGACYSTORE AND BUILD_TESTING) diff --git a/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh b/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh index bf75056444..be4504f3bf 100755 --- a/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh +++ b/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh @@ -142,7 +142,7 @@ func_set_env () if test -z ${QPID_BLD}; then QPID_BLD="${QPID_DIR}/cpp" fi - source $QPID_BLD/src/tests/test_env.sh + source $QPID_BLD/src/tests/env.sh # CPP_CLUSTER_EXEC="${QPID_BLD}/src/tests/cluster_test" # PYTHON_CLUSTER_EXEC="${QPID_DIR}/cpp/src/tests/$PYTHON_TESTNAME" FEDERATION_SYS_TESTS_FAIL="${QPID_DIR}/cpp/src/tests/federation_sys_tests.fail" diff --git a/qpid/cpp/src/tests/legacystore/run_python_tests b/qpid/cpp/src/tests/legacystore/run_python_tests index c1d04a28a1..d87c72e966 100755 --- a/qpid/cpp/src/tests/legacystore/run_python_tests +++ b/qpid/cpp/src/tests/legacystore/run_python_tests @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env python + # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -18,26 +19,29 @@ # under the License. # -source $QPID_TEST_COMMON +import os +import sys -ensure_python_tests +# Put the python test library on the path so we can get our +# environment -#Add our directory to the python path -export PYTHONPATH=$srcdir/legacystore:$PYTHONPATH +file_path = os.path.abspath(__file__) +store_tests_dir = os.path.split(file_path)[0] +tests_dir = os.path.split(store_tests_dir)[0] -MODULENAME=python_tests +sys.path.insert(0, tests_dir) -echo "Running Python tests in module ${MODULENAME}..." +from common import * -QPID_PORT=${QPID_PORT:-5672} -FAILING=${FAILING:-/dev/null} -PYTHON_TESTS=${PYTHON_TESTS:-$*} +# Add our directory to the python path -OUTDIR=${MODULENAME}.tmp -rm -rf $OUTDIR +ENV["PYTHONPATH"] = "{}:{}".format(store_tests_dir, ENV["PYTHONPATH"]) # To debug a test, add the following options to the end of the following line: # -v DEBUG -c qpid.messaging.io.ops [*.testName] -${QPID_PYTHON_TEST} -m ${MODULENAME} -I $FAILING -DOUTDIR=$OUTDIR \ - $PYTHON_TEST || exit 1 +port = start_broker("broker", "--load-module {}".format(STORE_LIB)) + +run_broker_tests(port, "-m python_tests", "-DOUTDIR={}".format(WORK_DIR)) + +check_results() diff --git a/qpid/cpp/src/tests/linearstore/CMakeLists.txt b/qpid/cpp/src/tests/linearstore/CMakeLists.txt index bf6c164818..760c54f3b1 100644 --- a/qpid/cpp/src/tests/linearstore/CMakeLists.txt +++ b/qpid/cpp/src/tests/linearstore/CMakeLists.txt @@ -17,13 +17,10 @@ # under the License. # -if(BUILD_LINEARSTORE AND BUILD_TESTING) +if (BUILD_LINEARSTORE AND BUILD_TESTING) message(STATUS "Building linearstore tests") -set(test_wrap ${shell} ${CMAKE_SOURCE_DIR}/src/tests/run_test${test_script_suffix} -buildDir=${CMAKE_BINARY_DIR}) - -add_test (linearstore_python_tests ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/run_python_tests${test_script_suffix}) +add_test(linearstore_python_tests ${PYTHON_EXECUTABLE} run_python_tests) endif (BUILD_LINEARSTORE AND BUILD_TESTING) - diff --git a/qpid/cpp/src/tests/linearstore/run_python_tests b/qpid/cpp/src/tests/linearstore/run_python_tests index 4ff212a71c..d87c72e966 100755 --- a/qpid/cpp/src/tests/linearstore/run_python_tests +++ b/qpid/cpp/src/tests/linearstore/run_python_tests @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env python + # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -18,25 +19,29 @@ # under the License. # -source ${QPID_TEST_COMMON} +import os +import sys -ensure_python_tests +# Put the python test library on the path so we can get our +# environment -#Add our directory to the python path -export PYTHONPATH=$srcdir/linearstore:${PYTHONPATH} +file_path = os.path.abspath(__file__) +store_tests_dir = os.path.split(file_path)[0] +tests_dir = os.path.split(store_tests_dir)[0] -MODULENAME=python_tests +sys.path.insert(0, tests_dir) -echo "Running Python tests in module ${MODULENAME}..." +from common import * -QPID_PORT=${QPID_PORT:-5672} -FAILING=${FAILING:-/dev/null} -PYTHON_TESTS=${PYTHON_TESTS:-$*} +# Add our directory to the python path -OUTDIR=${MODULENAME}.tmp -rm -rf ${OUTDIR} +ENV["PYTHONPATH"] = "{}:{}".format(store_tests_dir, ENV["PYTHONPATH"]) # To debug a test, add the following options to the end of the following line: # -v DEBUG -c qpid.messaging.io.ops [*.testName] -${QPID_PYTHON_TEST} -m ${MODULENAME} -I ${FAILING} -DOUTDIR=${OUTDIR} ${PYTHON_TEST} || exit 1 +port = start_broker("broker", "--load-module {}".format(STORE_LIB)) + +run_broker_tests(port, "-m python_tests", "-DOUTDIR={}".format(WORK_DIR)) + +check_results() diff --git a/qpid/cpp/src/tests/multiq_perftest b/qpid/cpp/src/tests/multiq_perftest deleted file mode 100755 index 9673dd2e6d..0000000000 --- a/qpid/cpp/src/tests/multiq_perftest +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env 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. -# - -exec `dirname $0`/run_perftest 10000 --mode shared --qt 16 diff --git a/qpid/cpp/src/tests/plano.py b/qpid/cpp/src/tests/plano.py new file mode 100644 index 0000000000..74a0f6d0b3 --- /dev/null +++ b/qpid/cpp/src/tests/plano.py @@ -0,0 +1,543 @@ +# +# 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. +# + +from __future__ import print_function + +import atexit as _atexit +import codecs as _codecs +import fnmatch as _fnmatch +import getpass as _getpass +import os as _os +import random as _random +import re as _re +import shutil as _shutil +import subprocess as _subprocess +import sys as _sys +import tarfile as _tarfile +import tempfile as _tempfile +import traceback as _traceback + +# See documentation at http://www.ssorj.net/projects/plano.html + +def fail(message, *args): + error(message, *args) + + if isinstance(message, BaseException): + raise message + + raise Exception(message) + +def error(message, *args): + _print_message("Error", message, args, _sys.stderr) + +def warn(message, *args): + _print_message("Warn", message, args, _sys.stderr) + +def notice(message, *args): + _print_message(None, message, args, _sys.stdout) + +def debug(message, *args): + _print_message("Debug", message, args, _sys.stdout) + +def exit(message=None, *args): + if message is None: + _sys.exit() + + _print_message("Error", message, args, _sys.stderr) + + _sys.exit(1) + +def _print_message(category, message, args, file): + message = _format_message(category, message, args) + + print(message, file=file) + file.flush() + +def _format_message(category, message, args): + if isinstance(message, BaseException): + message = str(message) + + if message == "": + message = message.__class__.__name__ + + if category: + message = "{}: {}".format(category, message) + + if args: + message = message.format(*args) + + script = split(_sys.argv[0])[1] + message = "{}: {}".format(script, message) + + return message + +def flush(): + _sys.stdout.flush() + _sys.stderr.flush() + +absolute_path = _os.path.abspath +normalize_path = _os.path.normpath +exists = _os.path.exists +is_absolute = _os.path.isabs +is_dir = _os.path.isdir +is_file = _os.path.isfile +is_link = _os.path.islink + +join = _os.path.join +split = _os.path.split +split_extension = _os.path.splitext + +LINE_SEP = _os.linesep +PATH_SEP = _os.sep +PATH_VAR_SEP = _os.pathsep +ENV = _os.environ +ARGS = _sys.argv + +current_dir = _os.getcwd + +def home_dir(user=""): + return _os.path.expanduser("~{}".format(user)) + +def parent_dir(path): + path = normalize_path(path) + parent, child = split(path) + + return parent + +def file_name(file): + file = normalize_path(file) + dir, name = split(file) + + return name + +def name_stem(file): + name = file_name(file) + + if name.endswith(".tar.gz"): + name = name[:-3] + + stem, ext = split_extension(name) + + return stem + +def name_extension(file): + name = file_name(file) + stem, ext = split_extension(name) + + return ext + +def read(file): + with _codecs.open(file, encoding="utf-8", mode="r") as f: + return f.read() + +def write(file, string): + with _codecs.open(file, encoding="utf-8", mode="w") as f: + f.write(string) + + return file + +def append(file, string): + with _codecs.open(file, encoding="utf-8", mode="a") as f: + f.write(string) + + return file + +def prepend(file, string): + orig = read(file) + prepended = string + orig + + return write(file, prepended) + +def touch(file): + return append(file, "") + +def tail(file, n): + return "".join(tail_lines(file, n)) + +def read_lines(file): + with _codecs.open(file, encoding="utf-8", mode="r") as f: + return f.readlines() + +def write_lines(file, lines): + with _codecs.open(file, encoding="utf-8", mode="r") as f: + f.writelines(lines) + + return file + +def append_lines(file, lines): + with _codecs.open(file, encoding="utf-8", mode="a") as f: + f.writelines(string) + + return file + +def prepend_lines(file, lines): + orig_lines = read_lines(file) + + with _codecs.open(file, encoding="utf-8", mode="w") as f: + f.writelines(lines) + f.writelines(orig_lines) + + return file + +# Derived from http://stackoverflow.com/questions/136168/get-last-n-lines-of-a-file-with-python-similar-to-tail +def tail_lines(file, n): + assert n >= 0 + + with _codecs.open(file, encoding="utf-8", mode="r") as f: + pos = n + 1 + lines = list() + + while len(lines) <= n: + try: + f.seek(-pos, 2) + except IOError: + f.seek(0) + break + finally: + lines = f.readlines() + + pos *= 2 + + return lines[-n:] + +_temp_dir = _tempfile.mkdtemp(prefix="plano.") + +def _get_temp_file(key): + assert not key.startswith("_") + + return join(_temp_dir, "_file_{}".format(key)) + +def _remove_temp_dir(): + _shutil.rmtree(_temp_dir, ignore_errors=True) + +_atexit.register(_remove_temp_dir) + +def read_temp(key): + file = _get_temp_file(key) + return read(file) + +def write_temp(key, string): + file = _get_temp_file(key) + return write(file, string) + +def append_temp(key, string): + file = _get_temp_file(key) + return append(file, string) + +def prepend_temp(key, string): + file = _get_temp_file(key) + return prepend(file, string) + +def make_temp(key): + return append_temp(key, "") + +def open_temp(key, mode="r"): + file = _get_temp_file(key) + return _codecs.open(file, encoding="utf-8", mode=mode) + +# This one is deleted on process exit +def make_temp_dir(): + return _tempfile.mkdtemp(prefix="_dir_", dir=_temp_dir) + +# This one sticks around +def make_user_temp_dir(): + temp_dir = _tempfile.gettempdir() + user = _getpass.getuser() + user_temp_dir = join(temp_dir, user) + + return make_dir(user_temp_dir) + +def copy(from_path, to_path): + notice("Copying '{}' to '{}'", from_path, to_path) + + to_dir = parent_dir(to_path) + + if to_dir: + make_dir(to_dir) + + if is_dir(from_path): + _copytree(from_path, to_path, symlinks=True) + else: + _shutil.copy(from_path, to_path) + + return to_path + +def move(from_path, to_path): + notice("Moving '{}' to '{}'", from_path, to_path) + + _shutil.move(from_path, to_path) + + return to_path + +def rename(path, expr, replacement): + path = normalize_path(path) + parent_dir, name = split(path) + to_name = string_replace(name, expr, replacement) + to_path = join(parent_dir, to_name) + + notice("Renaming '{}' to '{}'", path, to_path) + + move(path, to_path) + + return to_path + +def remove(path): + notice("Removing '{}'", path) + + if not exists(path): + return + + if is_dir(path): + _shutil.rmtree(path, ignore_errors=True) + else: + _os.remove(path) + + return path + +def make_link(source_path, link_file): + if exists(link_file): + assert read_link(link_file) == source_path + return + + _os.symlink(source_path, link_file) + + return link_file + +def read_link(file): + return _os.readlink(file) + +def find(dir, *patterns): + matched_paths = set() + + if not patterns: + patterns = ("*",) + + for root, dirs, files in _os.walk(dir): + for pattern in patterns: + matched_dirs = _fnmatch.filter(dirs, pattern) + matched_files = _fnmatch.filter(files, pattern) + + matched_paths.update([join(root, x) for x in matched_dirs]) + matched_paths.update([join(root, x) for x in matched_files]) + + return sorted(matched_paths) + +def find_any_one(dir, *patterns): + paths = find(dir, *patterns) + + if len(paths) == 0: + return + + return paths[0] + +def find_only_one(dir, *patterns): + paths = find(dir, *patterns) + + if len(paths) == 0: + return + + assert len(paths) == 1 + + return paths[0] + +# find_via_expr? + +def string_replace(string, expr, replacement, count=0): + return _re.sub(expr, replacement, string, count) + +def make_dir(dir): + if not exists(dir): + _os.makedirs(dir) + + return dir + +# Returns the current working directory so you can change it back +def change_dir(dir): + notice("Changing directory to '{}'", dir) + + cwd = current_dir() + _os.chdir(dir) + return cwd + +def list_dir(dir, *patterns): + assert is_dir(dir) + + names = _os.listdir(dir) + + if not patterns: + return sorted(names) + + matched_names = set() + + for pattern in patterns: + matched_names.update(_fnmatch.filter(names, pattern)) + + return sorted(matched_names) + +class working_dir(object): + def __init__(self, dir): + self.dir = dir + self.prev_dir = None + + def __enter__(self): + self.prev_dir = change_dir(self.dir) + return self.dir + + def __exit__(self, type, value, traceback): + change_dir(self.prev_dir) + +def _init_call(command, args, kwargs): + if args: + command = command.format(*args) + + if "shell" not in kwargs: + kwargs["shell"] = True + + notice("Calling '{}'", command) + + return command, kwargs + +def call(command, *args, **kwargs): + command, args = _init_call(command, args, kwargs) + _subprocess.check_call(command, **kwargs) + +def call_for_output(command, *args, **kwargs): + command, args = _init_call(command, args, kwargs) + return _subprocess.check_output(command, **kwargs) + +def make_archive(input_dir, output_dir, archive_stem): + temp_dir = make_temp_dir() + temp_input_dir = join(temp_dir, archive_stem) + + copy(input_dir, temp_input_dir) + make_dir(output_dir) + + output_file = "{}.tar.gz".format(join(output_dir, archive_stem)) + output_file = absolute_path(output_file) + + with working_dir(temp_dir): + call("tar -czf {} {}", output_file, archive_stem) + + return output_file + +def extract_archive(archive_file, output_dir): + assert is_file(archive_file) + + if not exists(output_dir): + make_dir(output_dir) + + archive_file = absolute_path(archive_file) + + with working_dir(output_dir): + call("tar -xf {}", archive_file) + + return output_dir + +def rename_archive(archive_file, new_archive_stem): + assert is_file(archive_file) + + if name_stem(archive_file) == new_archive_stem: + return + + temp_dir = make_temp_dir() + + extract_archive(archive_file, temp_dir) + + input_name = list_dir(temp_dir)[0] + input_dir = join(temp_dir, input_name) + output_file = make_archive(input_dir, temp_dir, new_archive_stem) + output_name = file_name(output_file) + archive_dir = parent_dir(archive_file) + new_archive_file = join(archive_dir, output_name) + + move(output_file, new_archive_file) + remove(archive_file) + + return new_archive_file + +def random_port(min=49152, max=65535): + return _random.randint(min, max) + +# Modified copytree impl that allows for already existing destination +# dirs +def _copytree(src, dst, symlinks=False, ignore=None): + """Recursively copy a directory tree using copy2(). + + If exception(s) occur, an Error is raised with a list of reasons. + + If the optional symlinks flag is true, symbolic links in the + source tree result in symbolic links in the destination tree; if + it is false, the contents of the files pointed to by symbolic + links are copied. + + The optional ignore argument is a callable. If given, it + is called with the `src` parameter, which is the directory + being visited by copytree(), and `names` which is the list of + `src` contents, as returned by os.listdir(): + + callable(src, names) -> ignored_names + + Since copytree() is called recursively, the callable will be + called once for each directory that is copied. It returns a + list of names relative to the `src` directory that should + not be copied. + + XXX Consider this example code rather than the ultimate tool. + + """ + names = _os.listdir(src) + if ignore is not None: + ignored_names = ignore(src, names) + else: + ignored_names = set() + + if not exists(dst): + _os.makedirs(dst) + errors = [] + for name in names: + if name in ignored_names: + continue + srcname = _os.path.join(src, name) + dstname = _os.path.join(dst, name) + try: + if symlinks and _os.path.islink(srcname): + linkto = _os.readlink(srcname) + _os.symlink(linkto, dstname) + elif _os.path.isdir(srcname): + _copytree(srcname, dstname, symlinks, ignore) + else: + # Will raise a SpecialFileError for unsupported file types + _shutil.copy2(srcname, dstname) + # catch the Error from the recursive copytree so that we can + # continue with other files + except _shutil.Error as err: + errors.extend(err.args[0]) + except EnvironmentError as why: + errors.append((srcname, dstname, str(why))) + try: + _shutil.copystat(src, dst) + except OSError as why: + if _shutil.WindowsError is not None and isinstance \ + (why, _shutil.WindowsError): + # Copying file access times may fail on Windows + pass + else: + errors.append((src, dst, str(why))) + if errors: + raise _shutil.Error(errors) diff --git a/qpid/cpp/src/tests/python_tests b/qpid/cpp/src/tests/python_tests deleted file mode 100755 index a36839a43c..0000000000 --- a/qpid/cpp/src/tests/python_tests +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env 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. -# - -# Run the python tests. -source $QPID_TEST_COMMON -ensure_python_tests -QPID_PORT=${QPID_PORT:-5672} -PYTHON_TESTS=${PYTHON_TESTS:-$*} -FAILING=${FAILING:-/dev/null} - -if [ ! -d $QPID_TESTS ]; then - echo "SKIPPED python tests: test code not found" - exit 0 -fi - -python $QPID_PYTHON_TEST -m qpid_tests.broker_0_10 -m qpid.tests -b localhost:$QPID_PORT -I $FAILING $PYTHON_TESTS || exit 1 diff --git a/qpid/cpp/src/tests/python_tests.ps1 b/qpid/cpp/src/tests/python_tests.ps1 deleted file mode 100644 index f7caa8f75a..0000000000 --- a/qpid/cpp/src/tests/python_tests.ps1 +++ /dev/null @@ -1,42 +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. -# - -# Run the python tests; intended to be run by run_test.ps1 which sets up -# QPID_PORT -$srcdir = Split-Path $myInvocation.InvocationName -$PYTHON_DIR = "$srcdir\..\..\..\python" -if (!(Test-Path $PYTHON_DIR -pathType Container)) { - "Skipping python tests as python libs not found" - exit 1 -} - -. .\test_env.ps1 - -if (Test-Path env:FAILING) { - $fails = "-I $env:FAILING" -} -if (Test-Path env:PYTHON_TESTS) { - $tests = "$env:PYTHON_TESTS" -} -else { - $tests = "$args" -} - -python $PYTHON_DIR/qpid-python-test -m qpid_tests.broker_0_10 -m qpid.tests -b localhost:$env:QPID_PORT $fails $tests -exit $LASTEXITCODE diff --git a/qpid/cpp/src/tests/qpid-build-rinstall b/qpid/cpp/src/tests/qpid-build-rinstall deleted file mode 100755 index beff7dffba..0000000000 --- a/qpid/cpp/src/tests/qpid-build-rinstall +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under onemake -# 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. -# - -# Run "make install"" locally then copy the install tree to each of $HOSTS -# Must be run in a configured qpid build directory. -# -test -f config.status || { echo "Not in a configured build directory."; usage; } -. src/tests/install_env.sh -set -ex -make && make -j1 install -rsynchosts $QPID_INSTALL_PREFIX diff --git a/qpid/cpp/src/tests/quick_perftest b/qpid/cpp/src/tests/quick_perftest deleted file mode 100755 index 698af60324..0000000000 --- a/qpid/cpp/src/tests/quick_perftest +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env 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. -# - -exec `dirname $0`/run_test ./qpid-perftest --summary --count 100 diff --git a/qpid/cpp/src/tests/quick_topictest b/qpid/cpp/src/tests/quick_topictest deleted file mode 100755 index e44ec0f477..0000000000 --- a/qpid/cpp/src/tests/quick_topictest +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env 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. -# - - -# Quick and quiet topic test for make check. -test -z "$srcdir" && srcdir=`dirname $0` -$srcdir/topictest -s2 -m2 -b1 > topictest.log 2>&1 || { - echo $0 FAILED: - cat topictest.log - exit 1 -} -rm topictest.log diff --git a/qpid/cpp/src/tests/quick_topictest.ps1 b/qpid/cpp/src/tests/quick_topictest.ps1 deleted file mode 100644 index 8f5b2caff7..0000000000 --- a/qpid/cpp/src/tests/quick_topictest.ps1 +++ /dev/null @@ -1,30 +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. -# - -# Quick and quiet topic test for make check. -[string]$me = $myInvocation.InvocationName -$srcdir = Split-Path $me -Invoke-Expression "$srcdir\topictest.ps1 -subscribers 2 -messages 2 -batches 1" > topictest.log 2>&1 -if (!$?) { - "$me FAILED:" - cat topictest.log - exit 1 -} -Remove-Item topictest.log -exit 0 diff --git a/qpid/cpp/src/tests/quick_txtest b/qpid/cpp/src/tests/quick_txtest deleted file mode 100755 index 77e8556f1d..0000000000 --- a/qpid/cpp/src/tests/quick_txtest +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env 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. -# - -exec `dirname $0`/run_test ./qpid-txtest --queues 4 --tx-count 10 --quiet diff --git a/qpid/cpp/src/tests/rsynchosts b/qpid/cpp/src/tests/rsynchosts deleted file mode 100755 index 10e1081f76..0000000000 --- a/qpid/cpp/src/tests/rsynchosts +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under onemake -# 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. -# - -absdir() { echo `cd $1 && pwd`; } - -abspath() { - if test -d "$1"; then absdir "$1"; - else echo $(absdir $(dirname "$1"))/$(basename "$1") - fi -} - -usage() { - echo "Usage: $(basename $0) [-l user] file [file...] -Synchronize the contents of each file or directory to the same absolute path on -each host in \$HOSTS. -" - exit 1 -} - -while getopts "l:" opt; do - case $opt in - l) RSYNC_USER="$OPTARG@" ;; - *) usage ;; - esac -done -shift `expr $OPTIND - 1` - -test "$*" || usage - -for f in $*; do FILES="$FILES $(abspath $f)" || exit 1; done - -OK_FILE=`mktemp` # Will be deleted if anything goes wrong. -trap "rm -f $OK_FILE" EXIT - -for h in $HOSTS; do - rsync -vaRO --delete $FILES $RSYNC_USER$h:/ || { echo "rsync to $h failed"; rm -f $OK_FILE; } & -done -wait -test -f $OK_FILE - diff --git a/qpid/cpp/src/tests/run.py b/qpid/cpp/src/tests/run.py new file mode 100755 index 0000000000..9b74ba4d30 --- /dev/null +++ b/qpid/cpp/src/tests/run.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +from common import * + +call(" ".join(ARGS[1:])) + diff --git a/qpid/cpp/src/tests/run_acl_tests b/qpid/cpp/src/tests/run_acl_tests index 4bb9e7aa5d..831fc7fbc7 100755 --- a/qpid/cpp/src/tests/run_acl_tests +++ b/qpid/cpp/src/tests/run_acl_tests @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -19,148 +19,52 @@ # under the License. # -# Run the acl tests. $srcdir is set by the Makefile. -source ./test_env.sh -DATA_DIR=`pwd`/data_dir -DATA_DIRI=`pwd`/data_diri -DATA_DIRU=`pwd`/data_diru -DATA_DIRQ=`pwd`/data_dirq +from common import * -trap stop_brokers INT TERM QUIT +policy_file = join(BUILD_DIR, "src", "tests", "policy.acl") +broker_args = "--acl-file {}".format(policy_file) -start_brokers() { - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIR --acl-file policy.acl --auth no --log-enable trace+:acl --log-to-file local.log > qpidd.port - LOCAL_PORT=`cat qpidd.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIRI --acl-file policy.acl --auth no --connection-limit-per-ip 2 --log-to-file locali.log > qpiddi.port - LOCAL_PORTI=`cat qpiddi.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIRU --acl-file policy.acl --auth no --connection-limit-per-user 2 --log-to-file localu.log > qpiddu.port - LOCAL_PORTU=`cat qpiddu.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIRQ --acl-file policy.acl --auth no --max-queues-per-user 2 --log-to-file localq.log > qpiddq.port - LOCAL_PORTQ=`cat qpiddq.port` -} +broker_port = start_broker("broker", broker_args, "--log-enable debug+:acl") +broker_i_port = start_broker("broker_i", broker_args, "--connection-limit-per-ip 2") +broker_u_port = start_broker("broker_u", broker_args, "--connection-limit-per-user 2") +broker_q_port = start_broker("broker_q", broker_args, "--max-queues-per-user 2") -start_noacl_noauth_brokers() { - ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIR --auth no --log-to-file local.log > qpidd.port - LOCAL_PORT=`cat qpidd.port` - ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRI --auth no --log-to-file locali.log > qpiddi.port - LOCAL_PORTI=`cat qpiddi.port` - ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRU --auth no --log-to-file localu.log > qpiddu.port - LOCAL_PORTU=`cat qpiddu.port` - ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRQ --auth no --log-to-file localq.log > qpiddq.port - LOCAL_PORTQ=`cat qpiddq.port` -} +run_broker_tests(broker_port, "-m acl", + "-Dport-i={}".format(broker_i_port), + "-Dport-u={}".format(broker_u_port), + "-Dport-q={}".format(broker_q_port), + "-Dpolicy-file={}".format(policy_file)) -start_noacl_auth_brokers() { - sasl_config_file=$builddir/sasl_config - if [ ! -f $sasl_config_file ] ; then - echo Creating sasl database - . $srcdir/sasl_test_setup.sh - fi - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIR --auth yes --sasl-config=$sasl_config_file --log-to-file local.log > qpidd.port - LOCAL_PORT=`cat qpidd.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIRI --auth yes --sasl-config=$sasl_config_file --log-to-file locali.log > qpiddi.port - LOCAL_PORTI=`cat qpiddi.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIRU --auth yes --sasl-config=$sasl_config_file --log-to-file localu.log > qpiddu.port - LOCAL_PORTU=`cat qpiddu.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --data-dir $DATA_DIRQ --auth yes --sasl-config=$sasl_config_file --log-to-file localq.log > qpiddq.port - LOCAL_PORTQ=`cat qpiddq.port` -} +# Test interaction of authentication and link creation -stop_brokers() { - $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORT - $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTI - $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTU - $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTQ -} +broker_1_port = start_broker("broker_1") +broker_2_port = start_broker("broker_2") -delete_directories() { - rm -rf $DATA_DIR - rm -rf $DATA_DIRI - rm -rf $DATA_DIRU - rm -rf $DATA_DIRQ -} +configure_broker(broker_1_port, "add exchange topic fed.topic") +configure_broker(broker_2_port, "add exchange topic fed.topic") -delete_logfiles() { - rm -rf local.log - rm -rf locali.log - rm -rf localu.log - rm -rf localq.log -} +connect_brokers("dynamic add", + "localhost:{}".format(broker_1_port), + "localhost:{}".format(broker_2_port), + "fed.topic") -create_directories() { - mkdir -p $DATA_DIR - mkdir -p $DATA_DIRI - mkdir -p $DATA_DIRU - mkdir -p $DATA_DIRQ -} +sasl_config_dir = join(BUILD_DIR, "src", "tests", "sasl_config") +broker_args = "--auth yes --sasl-config {}".format(sasl_config_dir) -populate_directories() { - cp $srcdir/policy.acl $DATA_DIR - cp $srcdir/policy.acl $DATA_DIRI - cp $srcdir/policy.acl $DATA_DIRU - cp $srcdir/policy.acl $DATA_DIRQ -} +broker_3_port = start_broker("broker_3", broker_args, auth_disabled=False) +broker_4_port = start_broker("broker_4", broker_args, auth_disabled=False) -test_loading_acl_from_absolute_path(){ - POLICY_FILE=$srcdir/policy.acl - rm -f temp.log - PORT=`../qpidd --daemon --port 0 --interface 127.0.0.1 --no-module-dir --no-data-dir --auth no --acl-file $POLICY_FILE -t --log-to-file temp.log 2>/dev/null` - ACL_FILE=`grep "notice ACL: Read file" temp.log | sed 's/^.*Read file //'` - $QPIDD_EXEC --no-module-dir -q --port $PORT - if test "$ACL_FILE" != "\"$POLICY_FILE\""; then - echo "unable to load policy file from an absolute path"; - return 1; - fi - rm temp.log -} +configure_broker(broker_3_port, "add exchange topic fed.topic") +configure_broker(broker_4_port, "add exchange topic fed.topic") -test_noacl_deny_create_link() { - delete_logfiles - start_noacl_noauth_brokers - echo "Running no-acl, no-auth tests using brokers on ports $LOCAL_PORT, $LOCAL_PORTI, $LOCAL_PORTU, and $LOCAL_PORTQ" - $QPID_CONFIG_EXEC -a localhost:$LOCAL_PORT add exchange topic fed.topic - $QPID_CONFIG_EXEC -a localhost:$LOCAL_PORTI add exchange topic fed.topic - $QPID_ROUTE_EXEC dynamic add localhost:$LOCAL_PORT localhost:$LOCAL_PORTI fed.topic 2>/dev/null - sleep 2 - stop_brokers - grep -q "must specify ACL create link rules" local.log - if [ $? -eq 0 ] - then - echo "Test fail - Broker with auth=no should have allowed link creation"; - return 1; - fi +try: + connect_brokers("dynamic add", + "localhost:{}".format(broker_3_port), + "localhost:{}".format(broker_4_port), + "fed.topic") - delete_logfiles - start_noacl_auth_brokers - echo "Running no-acl, auth tests using brokers on ports $LOCAL_PORT, $LOCAL_PORTI, $LOCAL_PORTU, and $LOCAL_PORTQ" - $QPID_CONFIG_EXEC -a localhost:$LOCAL_PORT add exchange topic fed.topic - $QPID_CONFIG_EXEC -a localhost:$LOCAL_PORTI add exchange topic fed.topic - $QPID_ROUTE_EXEC dynamic add localhost:$LOCAL_PORT localhost:$LOCAL_PORTI fed.topic 2>/dev/null - sleep 2 - stop_brokers - grep -q "must specify ACL create link rules" local.log - if [ $? -ne 0 ] - then - echo "Test fail - Broker with no ACL and --auth=yes file did not deny link creation"; - return 1; - fi -} - -if test -d ${PYTHON_DIR} ; then - # run acl.py test file - delete_directories - create_directories - populate_directories - delete_logfiles - start_brokers - echo "Running acl tests using brokers on ports $LOCAL_PORT, $LOCAL_PORTI, $LOCAL_PORTU, and $LOCAL_PORTQ" - $QPID_PYTHON_TEST -b localhost:$LOCAL_PORT -m acl -Dport-i=$LOCAL_PORTI -Dport-u=$LOCAL_PORTU -Dport-q=$LOCAL_PORTQ || EXITCODE=1 - stop_brokers || EXITCODE=1 - # - test_loading_acl_from_absolute_path || EXITCODE=1 - # - test_noacl_deny_create_link || EXITCODE=1 - delete_directories - exit $EXITCODE -fi + fail("Broker with no ACLs but auth enabled did not deny link creation") +except: + pass +check_results() diff --git a/qpid/cpp/src/tests/run_acl_tests.ps1 b/qpid/cpp/src/tests/run_acl_tests.ps1 deleted file mode 100644 index 8279d87e54..0000000000 --- a/qpid/cpp/src/tests/run_acl_tests.ps1 +++ /dev/null @@ -1,99 +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. -# - -# Run the acl tests. - -$srcdir = Split-Path $myInvocation.InvocationName -. .\test_env.ps1 -if (!(Test-Path $PYTHON_DIR -pathType Container)) { - "Skipping acl tests as python libs not found" - exit 1 -} - -$Global:BROKER_EXE = "" - -Function start_broker($acl_options) -{ - # 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. - . $srcdir\find_prog.ps1 ..\qpidd.exe - if (!(Test-Path $prog)) { - "Cannot locate qpidd.exe" - exit 1 - } - $Global:BROKER_EXE = $prog - if (Test-Path qpidd.port) { - Remove-Item qpidd.port - } - $cmdline = "$prog --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $acl_options | foreach { set-content qpidd.port `$_ }" - $cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline) - . $srcdir\background.ps1 $cmdblock - # Wait for the broker to start - $wait_time = 0 - while (!(Test-Path qpidd.port) -and ($wait_time -lt 30)) { - Start-Sleep 2 - $wait_time += 2 - } - if (!(Test-Path qpidd.port)) { - "Timeout waiting for broker to start" - exit 1 - } - set-item -path env:BROKER_PORT -value (get-content -path qpidd.port -totalcount 1) -} - -Function stop_broker -{ - "Stopping $Global:BROKER_EXE" - Invoke-Expression "$Global:BROKER_EXE --no-module-dir -q --port $env:BROKER_PORT" | Write-Output - Remove-Item qpidd.port -} - -$DATA_DIR = [IO.Directory]::GetCurrentDirectory() + "\data_dir" -Remove-Item $DATA_DIR -recurse -New-Item $DATA_DIR -type directory -Copy-Item $srcdir\policy.acl $DATA_DIR -start_broker("--data-dir $DATA_DIR --acl-file policy.acl") -"Running acl tests using broker on port $env:BROKER_PORT" -Invoke-Expression "python $PYTHON_DIR/qpid-python-test -m acl -b localhost:$env:BROKER_PORT" | Out-Default -$RETCODE=$LASTEXITCODE -stop_broker - -# Now try reading the acl file from an absolute path. -Remove-Item qpidd.log -$policy_full_path = "$srcdir\policy.acl" -start_broker("--no-data-dir --acl-file $policy_full_path") -#test_loading_acl_from_absolute_path(){ -# POLICY_FILE=$srcdir/policy.acl -# rm -f temp.log -# PORT=`../qpidd --daemon --port 0 --no-module-dir --no-data-dir --auth no --load-module $ACL_LIB --acl-file $POLICY_FILE -t --log-to-file temp.log 2>/dev/null` -# ACL_FILE=`grep "notice Read ACL file" temp.log | sed 's/^.*Read ACL file //'` -# $QPIDD_EXEC --no-module-dir -q --port $PORT -# if test "$ACL_FILE" != "\"$POLICY_FILE\""; then -# echo "unable to load policy file from an absolute path"; -# return 1; -# fi -# rm temp.log -#} -# -# test_loading_acl_from_absolute_path || EXITCODE=1 -# rm -rf $DATA_DIR -# exit $EXITCODE -stop_broker -exit $RETCODE diff --git a/qpid/cpp/src/tests/run_cli_tests b/qpid/cpp/src/tests/run_cli_tests index 1db99001a4..54517e0ef0 100755 --- a/qpid/cpp/src/tests/run_cli_tests +++ b/qpid/cpp/src/tests/run_cli_tests @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -19,63 +19,45 @@ # under the License. # -# Run the cli-utility tests. +# Run the cli-utility tests -source ./test_env.sh -CLI_DIR=$PYTHON_COMMANDS +from common import * -trap stop_brokers INT TERM QUIT +cli_dir = join(SOURCE_DIR, "management", "python", "bin") -# helper function to create test.xquery in the current directory, so -# that the python test program can find it. yes, it leaves a turd. -create_test_xquery() { - cat < ./test.xquery - let \$w := ./weather - return \$w/station = 'Raleigh-Durham International Airport (KRDU)' - and \$w/temperature_f > 50 - and \$w/temperature_f - \$w/dewpoint > 5 - and \$w/wind_speed_mph > 7 - and \$w/wind_speed_mph < 20 -EOF -} +xquery = """ +let $w := ./weather +return $w/station = 'Raleigh-Durham International Airport (KRDU)' + and $w/temperature_f > 50 + and $w/temperature_f - $w/dewpoint > 5 + and $w/wind_speed_mph > 7 + and $w/wind_speed_mph < 20 +""" +xquery_file = write(join(WORK_DIR, "xquery_file"), xquery) -start_brokers() { - # if the xml lib is present, use it. if not, disable any tests which - # look like they're xml related. - # if we start supporting xml on windows, it will need something similar - # here - if [ -f ../xml.so ] ; then - xargs="--load-module ../xml.so" - if [ ! -f test.xquery ] ; then - create_test_xquery - fi - targs="" - else - echo "Ignoring XML tests" - xargs="" - targs="--ignore=*xml*" - fi +# If the xml lib is present, use it. if not, disable any tests which +# look like they're xml related. +# +# If we start supporting xml on windows, it will need something +# similar here. + +if XML_LIB is not None: + broker_args = "--load-module {}".format(XML_LIB) + test_args = "" +else: + notice("Ignoring XML tests") - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-data-dir --no-module-dir --mgmt-publish no --auth no $xargs > qpidd.port - LOCAL_PORT=`cat qpidd.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-data-dir --no-module-dir --mgmt-publish no --auth no $xargs > qpidd.port - REMOTE_PORT=`cat qpidd.port` -} + broker_args = "" + test_args = "--ignore=*xml*" -stop_brokers() { - $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORT - $QPIDD_EXEC --no-module-dir -q --port $REMOTE_PORT -} +local_port = start_broker("local", broker_args) +remote_port = start_broker("remote", broker_args) -if test -d ${PYTHON_DIR} ; then - start_brokers - echo "Running CLI tests using brokers on ports $LOCAL_PORT $REMOTE_PORT" - PYTHON_TESTS=${PYTHON_TESTS:-$*} - $QPID_PYTHON_TEST -m cli_tests -b localhost:$LOCAL_PORT -Dremote-port=$REMOTE_PORT -Dcli-dir=$CLI_DIR $targs $PYTHON_TESTS $@ - RETCODE=$? - stop_brokers - if test x$RETCODE != x0; then - echo "FAIL CLI tests"; exit 1; - fi -fi +run_broker_tests(local_port, + "-m cli_tests", + "-Dremote-port={}".format(remote_port), + "-Dcli-dir={}".format(cli_dir), + "-Dxquery-file={}".format(xquery_file), + test_args) +check_results() diff --git a/qpid/cpp/src/tests/run_client_tests b/qpid/cpp/src/tests/run_client_tests new file mode 100755 index 0000000000..76c46ef949 --- /dev/null +++ b/qpid/cpp/src/tests/run_client_tests @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +port = start_broker("broker") + +ENV["QPID_PORT"] = str(port) + +call_with_valgrind("qpid-client-test --verbose") + +check_results() diff --git a/qpid/cpp/src/tests/run_federation_sys_tests b/qpid/cpp/src/tests/run_federation_sys_tests deleted file mode 100755 index f5f1ae44d3..0000000000 --- a/qpid/cpp/src/tests/run_federation_sys_tests +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env 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. -# - -# Run the federation system tests. - -source ./test_env.sh - -MODULENAME=federation_sys - -# Test for long test -if [[ "$1" == "LONG_TEST" ]]; then - USE_LONG_TEST=1 - shift # get rid of this param so it is not treated as a test name -fi - -trap stop_brokers INT TERM QUIT - -SKIPTESTS="-i federation_sys.E_* -i federation_sys.F_* -i federation_sys.G_* -i federation_sys.H_*" -if [ -z ${USE_LONG_TEST} ]; then - SKIPTESTS="-i federation_sys.A_Long* -i federation_sys.B_Long* ${SKIPTESTS}" -fi -echo "WARNING: Tests using persistence will be ignored." -SKIPTESTS="${SKIPTESTS} -i federation_sys.C_* -i federation_sys.D_*" - -start_brokers() { - start_broker() { - ${QPIDD_EXEC} --daemon --port 0 --interface 127.0.0.1 --auth no --no-data-dir $1 > qpidd.port - PORT=`cat qpidd.port` - eval "$2=${PORT}" - } - start_broker "" LOCAL_PORT - start_broker "" REMOTE_PORT - rm qpidd.port -} - -stop_brokers() { - ${QPIDD_EXEC} -q --port ${LOCAL_PORT} - ${QPIDD_EXEC} -q --port ${REMOTE_PORT} -} - -if test -d ${PYTHON_DIR} ; then - start_brokers - echo "Running federation tests using brokers on local port ${LOCAL_PORT}, remote port ${REMOTE_PORT} (NOTE: clustering is DISABLED)" - if [ -z ${USE_LONG_TEST} ]; then - echo "NOTE: To run a full set of federation system tests, use \"make check-long\". To test with persistence, run the store version of this script." - fi - ${QPID_PYTHON_TEST} -m ${MODULENAME} ${SKIPTESTS} -b localhost:${REMOTE_PORT} -Dlocal-port=${LOCAL_PORT} -Dremote-port=${REMOTE_PORT} $@ - RETCODE=$? - stop_brokers - if test x${RETCODE} != x0; then - echo "FAIL federation tests"; exit 1; - fi -fi diff --git a/qpid/cpp/src/tests/run_federation_tests b/qpid/cpp/src/tests/run_federation_tests index 8cadd3702f..381195af4e 100755 --- a/qpid/cpp/src/tests/run_federation_tests +++ b/qpid/cpp/src/tests/run_federation_tests @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -19,43 +19,42 @@ # under the License. # -# Run the federation tests. - -source ./test_env.sh -#set -x -trap stop_brokers INT TERM QUIT - -if [ -f ../xml.so ] ; then - MODULES="--load-module xml" # Load the XML exchange and run XML exchange federation tests - SKIPTESTS= -else - MODULES="--no-module-dir" - SKIPTESTS='-i *_xml' # note: single quotes prevent expansion of * -fi - -QPIDD_CMD="../qpidd --daemon --port 0 --interface 127.0.0.1 --no-data-dir $MODULES --auth no --log-enable=info+ --log-enable=debug+:Bridge --log-to-file" -start_brokers() { - rm -f fed_local.log fed_remote.log fed_b1.log fed_b2.log - LOCAL_PORT=$($QPIDD_CMD fed_local.log --federation-tag LOCAL) - REMOTE_PORT=$($QPIDD_CMD fed_remote.log --federation-tag REMOTE) - REMOTE_B1=$($QPIDD_CMD fed_b1.log --federation-tag B1) - REMOTE_B2=$($QPIDD_CMD fed_b2.log --federation-tag B2) -} - -stop_brokers() { - $QPIDD_EXEC $MODULES -q --port $LOCAL_PORT - $QPIDD_EXEC $MODULES -q --port $REMOTE_PORT - $QPIDD_EXEC $MODULES -q --port $REMOTE_B1 - $QPIDD_EXEC $MODULES -q --port $REMOTE_B2 -} - -if test -d ${PYTHON_DIR} ; then - start_brokers - echo "Running federation tests using brokers on ports $LOCAL_PORT $REMOTE_PORT $REMOTE_B1 $REMOTE_B2" - $QPID_PYTHON_TEST -m federation ${SKIPTESTS} -b localhost:$LOCAL_PORT -Dremote-port=$REMOTE_PORT -Dextra-brokers="$REMOTE_B1 $REMOTE_B2" $@ - RETCODE=$? - stop_brokers - if test x$RETCODE != x0; then - echo "FAIL federation tests"; exit 1; - fi -fi +from common import * + +common_args = "--log-enable=debug+:Bridge" +module_args = None +test_args = "-i *_xml" + +sys_test_args = [ + "-i federation_sys.A_Long*", + "-i federation_sys.B_Long*", + "-i federation_sys.C_*", + "-i federation_sys.D_*", + "-i federation_sys.E_*", + "-i federation_sys.F_*", + "-i federation_sys.G_*", + "-i federation_sys.H_*", +] + +if XML_LIB is not None: + module_args = "--load-module {}".format(XML_LIB) + test_args = None + +local_port = start_broker("local", common_args, module_args, "--federation-tag LOCAL") +remote_port = start_broker("remote", common_args, module_args, "--federation-tag REMOTE") +remote_b1 = start_broker("remote_b1", common_args, module_args, "--federation-tag REMOTE_B1") +remote_b2 = start_broker("remote_b2", common_args, module_args, "--federation-tag REMOTE_B2") + +run_broker_tests(local_port, "-m federation", + "-Dremote-port={}".format(remote_port), + "-Dextra-brokers='{} {}'".format(remote_b1, remote_b2), + test_args) + +run_broker_tests(local_port, "-m headers_federation", "-Dremote-port={}".format(remote_port)) + +run_broker_tests(remote_port, "-m federation_sys", + "-Dlocal-port={}".format(local_port), + "-Dremote-port={}".format(remote_port), + *sys_test_args) + +check_results() diff --git a/qpid/cpp/src/tests/run_federation_tests.ps1 b/qpid/cpp/src/tests/run_federation_tests.ps1 deleted file mode 100644 index 803b3eef6f..0000000000 --- a/qpid/cpp/src/tests/run_federation_tests.ps1 +++ /dev/null @@ -1,83 +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. -# - -# Run the federation tests. - -$srcdir = Split-Path $myInvocation.InvocationName -$PYTHON_DIR = "$srcdir\..\..\..\python" -if (!(Test-Path $PYTHON_DIR -pathType Container)) { - "Skipping federation tests as python libs not found" - exit 1 -} - -. .\test_env.ps1 - -# 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 --no-data-dir --port=0 --ssl-port=0 --log-to-file qpidd.log $args | foreach { set-content qpidd.port `$_ }" -$cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline) - -function start_brokers { - # Start 2 brokers, saving the port numbers in LOCAL_PORT, REMOTE_PORT. - . $srcdir\background.ps1 $cmdblock - while (!(Test-Path qpidd.port)) { - Start-Sleep 2 - } - set-item -path env:LOCAL_PORT -value (get-content -path qpidd.port -totalcount 1) - Remove-Item qpidd.port - . $srcdir\background.ps1 $cmdblock - while (!(Test-Path qpidd.port)) { - Start-Sleep 2 - } - set-item -path env:REMOTE_PORT -value (get-content -path qpidd.port -totalcount 1) -} - -function stop_brokers { - Invoke-Expression "$prog -q --port $env:LOCAL_PORT" | Out-Default - Invoke-Expression "$prog -q --port $env:REMOTE_PORT" | Out-Default -} - -trap { - &stop_brokers - break -} - -&start_brokers -"Running federation tests using brokers on ports $env:LOCAL_PORT $env:REMOTE_PORT" -$env:PYTHONPATH="$srcdir;$PYTHON_DIR;$PYTHON_TEST_DIR;$env:PYTHONPATH;$QMF_LIB" -$tests = "*" -Invoke-Expression "python $PYTHON_DIR/qpid-python-test -m federation -b localhost:$env:LOCAL_PORT -Dremote-port=$env:REMOTE_PORT $tests" | Out-Default -$RETCODE=$LASTEXITCODE -&stop_brokers -if ($RETCODE -ne 0) { - "FAIL federation tests" - exit 1 -} diff --git a/qpid/cpp/src/tests/run_flow_control_tests b/qpid/cpp/src/tests/run_flow_control_tests new file mode 100755 index 0000000000..5158fb2c47 --- /dev/null +++ b/qpid/cpp/src/tests/run_flow_control_tests @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +port = start_broker("broker", "--default-flow-stop-threshold=80 --default-flow-resume-threshold=70") + +run_broker_tests(port, "-m queue_flow_limit_tests") + +check_results() diff --git a/qpid/cpp/src/tests/run_ha_tests b/qpid/cpp/src/tests/run_ha_tests index bb60bea076..159f258c34 100755 --- a/qpid/cpp/src/tests/run_ha_tests +++ b/qpid/cpp/src/tests/run_ha_tests @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -8,9 +8,9 @@ # 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 @@ -19,11 +19,19 @@ # under the License. # +from common import * + +# ENV["QPID_USE_SWIG_CLIENT"] = "1" # XXX is this necessary? + +# XXX These tests hang, and I can't figure out why +# -i *tx_block_threads -# Make sure the python tools are available. They will be if we are building in -# a checkoug, they may not be in a distribution. -test -d $PYTHON_COMMANDS -a -x $PYTHON_COMMANDS/qpid-ha -a -x $PYTHON_COMMANDS/qpid-config || { echo "Skipping HA tests, qpid-ha or qpid-config not available."; exit 0; } +# ENV["QPID_NO_MODULE_DIR"] = "1" # Don't accidentally load installed modules +# ENV["QPID_DATA_DIR"] = "" +# ENV["QPID_CONFIG"] = join(BUILD_DIR, "src", "tests", "qpidd-empty.conf") +# ENV["QPID_PORT"] = "" +# ENV["QPID_LOG_TO_FILE"] = join(BUILD_DIR, "src", "tests", "gah.log") -srcdir=`dirname $0` -$srcdir/ha_tests.py +call("qpid-python-test -m ha_tests -DOUTDIR={}", WORK_DIR) +check_results() diff --git a/qpid/cpp/src/tests/run_header_test b/qpid/cpp/src/tests/run_header_test deleted file mode 100755 index d1edcf6831..0000000000 --- a/qpid/cpp/src/tests/run_header_test +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env 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. -# - -# Simple test of encode/decode of a double in application headers -# TODO: this should be expanded to cover a wider set of types and go -# in both directions - -source $QPID_TEST_COMMON - -ensure_python_tests - -./header_test -p $QPID_PORT -$srcdir/header_test.py "localhost" $QPID_PORT diff --git a/qpid/cpp/src/tests/run_header_test.ps1 b/qpid/cpp/src/tests/run_header_test.ps1 deleted file mode 100644 index 344fac9cf9..0000000000 --- a/qpid/cpp/src/tests/run_header_test.ps1 +++ /dev/null @@ -1,48 +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. -# - -# Simple test of encode/decode of a double in application headers -# TODO: this should be expanded to cover a wider set of types and go -# in both directions - -$srcdir = Split-Path $myInvocation.InvocationName -$PYTHON_DIR = "$srcdir\..\..\..\python" -if (!(Test-Path $PYTHON_DIR -pathType Container)) { - "Skipping header test as python libs not found" - exit 0 -} - -. .\test_env.ps1 - -if (Test-Path qpidd.port) { - set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1) -} - -# Test runs from the tests directory but the test executables are in a -# subdirectory based on the build type. Look around for it before trying -# to start it. -. $srcdir\find_prog.ps1 .\header_test.exe -if (!(Test-Path $prog)) { - "Cannot locate header_test.exe" - exit 1 -} - -Invoke-Expression "$prog -p $env:QPID_PORT" | Write-Output -Invoke-Expression "python $srcdir/header_test.py localhost $env:QPID_PORT" | Write-Output -exit $LASTEXITCODE diff --git a/qpid/cpp/src/tests/run_headers_federation_tests b/qpid/cpp/src/tests/run_headers_federation_tests deleted file mode 100644 index afbbf144ee..0000000000 --- a/qpid/cpp/src/tests/run_headers_federation_tests +++ /dev/null @@ -1,49 +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. -# - -# Run the federation tests for the Headers Exchange. - -source ./test_env.sh - -trap stop_brokers INT TERM QUIT - -start_brokers() { - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-data-dir --no-module-dir --auth no > qpidd.port - LOCAL_PORT=`cat qpidd.port` - ../qpidd --daemon --port 0 --interface 127.0.0.1 --no-data-dir --no-module-dir --auth no > qpidd.port - REMOTE_PORT=`cat qpidd.port` -} - -stop_brokers() { - $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORT - $QPIDD_EXEC --no-module-dir -q --port $REMOTE_PORT -} - -if test -d ${PYTHON_DIR} ; then - start_brokers - echo "Running HeadersExchange federation tests using brokers on ports $LOCAL_PORT $REMOTE_PORT" - $QPID_PYTHON_TEST -m headers_federation -b localhost:$LOCAL_PORT -Dremote-port=$REMOTE_PORT $@ - RETCODE=$? - stop_brokers - if test x$RETCODE != x0; then - echo "FAIL federation tests"; exit 1; - fi -fi diff --git a/qpid/cpp/src/tests/run_idle_timeout_tests b/qpid/cpp/src/tests/run_idle_timeout_tests new file mode 100755 index 0000000000..79de1c9f22 --- /dev/null +++ b/qpid/cpp/src/tests/run_idle_timeout_tests @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +call("qpid-python-test -m idle_timeout_tests -DOUTDIR={}", WORK_DIR) + +check_results() diff --git a/qpid/cpp/src/tests/run_interlink_tests b/qpid/cpp/src/tests/run_interlink_tests index 71482fa7fd..2505d1e1f8 100755 --- a/qpid/cpp/src/tests/run_interlink_tests +++ b/qpid/cpp/src/tests/run_interlink_tests @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -19,8 +19,8 @@ # under the License. # -test -e "$AMQP_LIB" || { echo "Skipping AMQP 1.0 based tests; AMQP 1.0 support not available."; exit 0; } +from common import * -srcdir=`dirname $0` -$srcdir/interlink_tests.py +call("qpid-python-test -m interlink_tests -DOUTDIR={}", WORK_DIR) +check_results() diff --git a/qpid/cpp/src/tests/run_interop_tests b/qpid/cpp/src/tests/run_interop_tests new file mode 100755 index 0000000000..8cc918bba8 --- /dev/null +++ b/qpid/cpp/src/tests/run_interop_tests @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +port = start_broker("broker", "--load-module {}".format(AMQP_LIB)) + +ENV["QPID_INTEROP_URL"] = "localhost:{}".format(port) + +call("qpid-python-test -m interop_tests -DOUTDIR={}", WORK_DIR) + +check_results() diff --git a/qpid/cpp/src/tests/run_ipv6_tests b/qpid/cpp/src/tests/run_ipv6_tests new file mode 100755 index 0000000000..55212257a9 --- /dev/null +++ b/qpid/cpp/src/tests/run_ipv6_tests @@ -0,0 +1,116 @@ +#!/usr/bin/env 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. +# + +source env.sh + +# Check whether we have any globally configured IPv6 addresses +# - if not then we can't run the tests because ipv6 lookups won't +# work within the qpid code. This is a deliberate feature to avoid +# getting addresses that can't be routed by the machine. + +if ip -f inet6 -o addr | cut -f 9 -s -d' ' | grep global > /dev/null ; then + echo "IPv6 addresses configured - continuing" +else + echo "No global IPv6 addresses configured - skipping test" + exit 0 +fi + + +CONFIG=$(dirname $0)/qpidd-empty.conf +TEST_HOSTNAME=::1 +COUNT=10 + +trap cleanup EXIT + +error() { echo $*; exit 1; } + +# Don't need --no-module-dir or --no-data-dir as they are set as env vars in env.sh +COMMON_OPTS="--interface [::1] --daemon --auth no --config $CONFIG" + +# Record all broker ports started +unset PORTS +declare -a PORTS + +# Start new brokers: +# $1 must be integer +# $2 = extra opts +# Append used ports to PORTS variable +start_brokers() { + local -a ports + for (( i=0; $i<$1; i++)) do + ports[$i]=$(qpidd --port 0 $COMMON_OPTS $2) + done + PORTS=( ${PORTS[@]} ${ports[@]} ) +} + +stop_brokers() { + for port in "${PORTS[@]}"; + do + qpidd -qp $port + done + PORTS=() +} + +cleanup() { + stop_brokers +} + +start_brokers 1 +PORT=${PORTS[0]} +echo "Started IPv6 smoke perftest on broker port $PORT" + +## Test connection via connection settings +qpid-perftest --count ${COUNT} --port ${PORT} -b $TEST_HOSTNAME --summary + +## Test connection with a URL +URL="amqp:[$TEST_HOSTNAME]:$PORT" + +qpid-send -b $URL --content-string=hello -a "foo;{create:always}" +MSG=`qpid-receive -b $URL -a "foo;{create:always}" --messages 1` +test "$MSG" = "hello" || { echo "receive failed '$MSG' != 'hello'"; exit 1; } + +stop_brokers + +# Federation smoke test follows + +# Start 2 brokers + +start_brokers 2 +echo "Started Federated brokers on ports ${PORTS[*]}" +# Make broker urls +BROKER0="[::1]:${PORTS[0]}" +BROKER1="[::1]:${PORTS[1]}" +TEST_QUEUE=ipv6-fed-test + +qpid-config -b $BROKER0 add queue $TEST_QUEUE +qpid-config -b $BROKER1 add queue $TEST_QUEUE +qpid-route dynamic add $BROKER1 $BROKER0 amq.direct +qpid-config -b $BROKER1 bind amq.direct $TEST_QUEUE $TEST_QUEUE +qpid-route route map $BROKER1 + +datagen --count 100 | tee rdata-in | + ./qpid-send -b amqp:$BROKER0 -a amq.direct/$TEST_QUEUE --content-stdin +qpid-receive -b amqp:$BROKER1 -a $TEST_QUEUE --print-content yes -m 0 > rdata-out + +cmp rdata-in rdata-out || { echo "Federated data over IPv6 does not compare"; exit 1; } + +stop_brokers +rm rdata-in rdata-out diff --git a/qpid/cpp/src/tests/run_logging_tests b/qpid/cpp/src/tests/run_logging_tests new file mode 100755 index 0000000000..2ebcc5c902 --- /dev/null +++ b/qpid/cpp/src/tests/run_logging_tests @@ -0,0 +1,38 @@ +#!/usr/bin/env 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. +# + +set -eu + +source env.sh + +export WORK_DIR=$(mktemp -d $PWD/run_logging_tests_XXXX) + +exit_code=0 + +dynamic_log_hires_timestamp || exit_code=1 +dynamic_log_level_test || exit_code=1 + +if (( exit_code != 0 )); then + echo "Logging test failures" + exit $exit_code +fi + +rm -rf $WORK_DIR diff --git a/qpid/cpp/src/tests/run_long_federation_sys_tests b/qpid/cpp/src/tests/run_long_federation_sys_tests index c2b4e02d81..ab8b5646ec 100644 --- a/qpid/cpp/src/tests/run_long_federation_sys_tests +++ b/qpid/cpp/src/tests/run_long_federation_sys_tests @@ -21,4 +21,4 @@ # Run the federation system tests (long version). -./run_federation_sys_tests LONG_TEST $@ +USE_LONG_TEST=1 ./run_federation_sys_tests $@ diff --git a/qpid/cpp/src/tests/run_msg_group_tests b/qpid/cpp/src/tests/run_msg_group_tests index ee479c23c7..78bc802a09 100755 --- a/qpid/cpp/src/tests/run_msg_group_tests +++ b/qpid/cpp/src/tests/run_msg_group_tests @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -18,45 +18,30 @@ # specific language governing permissions and limitations # under the License. # -#script to run a sequence of message group queue tests via make -source $QPID_TEST_COMMON +from common import * -ensure_python_tests +port = start_broker("broker") -QUEUE_NAME="group-queue" -GROUP_KEY="My-Group-Id" +commands = [ + "qpid-config -b {} add queue group-queue --group-header=My-Group-Id --shared-groups", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 3", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 7 --randomize-group-size", + "qpid-config -b {} add queue group-queue-two --group-header=My-Group-Id --shared-groups", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 3 --randomize-group-size", + "msg_group_test -b {} -a group-queue-two --group-key My-Group-Id --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 5", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 59 --group-size 5 --receivers 2 --senders 3 --capacity 1 --ack-frequency 3 --randomize-group-size", + "qpid-config -b {} del queue group-queue-two --force", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 59 --group-size 3 --receivers 2 --senders 3 --capacity 1 --ack-frequency 1 --randomize-group-size", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 211 --group-size 13 --receivers 2 --senders 3 --capacity 47 --ack-frequency 79 --interleave 53", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 10000 --group-size 1 --receivers 0 --senders 1", + "msg_group_test -b {} -a group-queue --group-key My-Group-Id --messages 10000 --receivers 5 --senders 0", + "qpid-config -b {} del queue group-queue --force", +] -BROKER_URL="${QPID_BROKER:-localhost}:${QPID_PORT:-5672}" +address = "localhost:{}".format(port) -run_test() { - "$@" -} +for command in commands: + call(command, address) -##set -x - -declare -i i=0 -declare -a tests -tests=("qpid-config -b $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 3" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 7 --randomize-group-size" - "qpid-config -b $BROKER_URL add queue ${QUEUE_NAME}-two --group-header=${GROUP_KEY} --shared-groups" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 3 --randomize-group-size" - "msg_group_test -b $BROKER_URL -a ${QUEUE_NAME}-two --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 5" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 5 --receivers 2 --senders 3 --capacity 1 --ack-frequency 3 --randomize-group-size" - "qpid-config -b $BROKER_URL del queue ${QUEUE_NAME}-two --force" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 3 --receivers 2 --senders 3 --capacity 1 --ack-frequency 1 --randomize-group-size" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 211 --group-size 13 --receivers 2 --senders 3 --capacity 47 --ack-frequency 79 --interleave 53" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --group-size 1 --receivers 0 --senders 1" - "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --receivers 5 --senders 0" - "qpid-config -b $BROKER_URL del queue $QUEUE_NAME --force") - -while [ -n "${tests[i]}" ]; do - run_test ${tests[i]} - RETCODE=$? - if test x$RETCODE != x0; then - echo "FAILED message group test. Failed command: \"${tests[i]}\""; - exit 1; - fi - i+=1 -done +check_results() diff --git a/qpid/cpp/src/tests/run_msg_group_tests.ps1 b/qpid/cpp/src/tests/run_msg_group_tests.ps1 deleted file mode 100644 index e9cee0a5a0..0000000000 --- a/qpid/cpp/src/tests/run_msg_group_tests.ps1 +++ /dev/null @@ -1,71 +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. -# - -# Simple test of encode/decode of a double in application headers -# TODO: this should be expanded to cover a wider set of types and go -# in both directions - -$srcdir = Split-Path $myInvocation.InvocationName -$PYTHON_DIR = "$srcdir\..\..\..\python" -if (!(Test-Path $PYTHON_DIR -pathType Container)) { - "Skipping msg_group test as python libs not found" - exit 0 -} - -. .\test_env.ps1 - -if (Test-Path qpidd.port) { - set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1) -} - -# Test runs from the tests directory but the test executables are in a -# subdirectory based on the build type. Look around for it before trying -# to start it. -. $srcdir\find_prog.ps1 .\msg_group_test.exe -if (!(Test-Path $prog)) { - "Cannot locate msg_group_test.exe" - exit 1 -} - -$QUEUE_NAME="group-queue" -$GROUP_KEY="My-Group-Id" -$BROKER_URL="localhost:$env:QPID_PORT" - -$tests=@("python $QPID_CONFIG_EXEC -b $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 3", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 7 --randomize-group-size", - "python $QPID_CONFIG_EXEC -b $BROKER_URL add queue ${QUEUE_NAME}-two --group-header=${GROUP_KEY} --shared-groups", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 3 --randomize-group-size", - "$prog -b $BROKER_URL -a ${QUEUE_NAME}-two --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 5", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 5 --receivers 2 --senders 3 --capacity 1 --ack-frequency 3 --randomize-group-size", - "python $QPID_CONFIG_EXEC -b $BROKER_URL del queue ${QUEUE_NAME}-two --force", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 3 --receivers 2 --senders 3 --capacity 1 --ack-frequency 1 --randomize-group-size", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 211 --group-size 13 --receivers 2 --senders 3 --capacity 47 --ack-frequency 79 --interleave 53", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --group-size 1 --receivers 0 --senders 1", - "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --receivers 5 --senders 0", - "python $QPID_CONFIG_EXEC -b $BROKER_URL del queue $QUEUE_NAME --force") - -foreach ($cmd in $tests) -{ - Invoke-Expression "$cmd" | Write-Output - $ret = $LASTEXITCODE - if ($ret -ne 0) {Write-Host "FAILED message group test. Failed command: $cmd" - break} -} -exit $ret diff --git a/qpid/cpp/src/tests/run_msg_group_tests_soak b/qpid/cpp/src/tests/run_msg_group_tests_soak index d87ca16c88..68a16793f3 100755 --- a/qpid/cpp/src/tests/run_msg_group_tests_soak +++ b/qpid/cpp/src/tests/run_msg_group_tests_soak @@ -18,13 +18,11 @@ # specific language governing permissions and limitations # under the License. # -#script to run a sequence of long-running message group tests via make -#setup path to find qpid-config and msg_group_test test progs -source ./test_env.sh -test -d $PYTHON_DIR || { echo "Skipping message group tests, no python dir."; exit 0; } +# Script to run a sequence of long-running message group tests via +# make -export PATH=$PWD:$srcdir:$PYTHON_COMMANDS:$PATH +source env.sh #set port to connect to via env var test -s qpidd.port && QPID_PORT=`cat qpidd.port` diff --git a/qpid/cpp/src/tests/run_paged_queue_tests b/qpid/cpp/src/tests/run_paged_queue_tests index 2c1e3ae614..c5f6aec927 100755 --- a/qpid/cpp/src/tests/run_paged_queue_tests +++ b/qpid/cpp/src/tests/run_paged_queue_tests @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -19,32 +19,27 @@ # under the License. # -#setup path to find qpid-config and sender/receiver test progs -source ./test_env.sh -trap stop_broker INT TERM QUIT - -export PATH=$PWD:$srcdir:$PYTHON_COMMANDS:$PATH - -start_broker() { - QPID_PORT=$($QPIDD_EXEC --daemon --port 0 --interface 127.0.0.1 --no-data-dir --paging-dir=$PWD/pqtest_data $MODULES --auth no) || { echo "Could not start broker"; exit 1; } -} - -stop_broker() { - $QPIDD_EXEC -q --port $QPID_PORT -} - -test_single_page() { - msgcount=1000 - qpid-send --messages $msgcount --content-size 1024 --broker "localhost:$QPID_PORT" --address "onepage; {create: always, node:{x-declare:{arguments:{'qpid.paging':True,'qpid.max_pages_loaded':1}}}}" - received=$(qpid-receive --address onepage --broker "localhost:$QPID_PORT" --messages $msgcount | wc -l) - if [[ $received -ne $msgcount ]]; then - echo "single page test failed: received $received messages, expected $msgcount" - exit 1 - fi -} - -start_broker -test_single_page -qpid-cpp-benchmark --broker "localhost:$QPID_PORT" --create-option "node:{x-declare:{arguments:{'qpid.paging':True,'qpid.max_size':0,'qpid.max_count':0,'qpid.flow_stop_size':0,'qpid.flow_resume_size':0,'qpid.flow_stop_count':0,'qpid.flow_resume_count':0}}}" -qpid-cpp-benchmark --broker "localhost:$QPID_PORT" --create-option "node:{x-declare:{arguments:{'qpid.paging':True,'qpid.max_size':0,'qpid.max_count':0,'qpid.flow_stop_size':0,'qpid.flow_resume_size':0,'qpid.flow_stop_count':0,'qpid.flow_resume_count':0}}}" --fill-drain -stop_broker +from common import * + +port = start_broker("broker", "--paging-dir={}".format(join(WORK_DIR, "pqtest_data"))) + +messages = 1000 +address = "onepage; {create: always, node:{x-declare:{arguments:{'qpid.paging':True,'qpid.max_pages_loaded':1}}}}" + +call_with_valgrind("qpid-send --messages {} --content-size 1024 --broker localhost:{} --address \"{}\"", + messages, port, address) + +output = call_for_output_with_valgrind("qpid-receive --address onepage --messages {} --broker localhost:{}", + messages, port) + +received = len(output.splitlines()) + +if received != messages: + fail("Single page test failed: received {} messages, expected {}", received, messages) + +option = "node:{x-declare:{arguments:{'qpid.paging':True,'qpid.max_size':0,'qpid.max_count':0,'qpid.flow_stop_size':0,'qpid.flow_resume_size':0,'qpid.flow_stop_count':0,'qpid.flow_resume_count':0}}}" + +call("qpid-cpp-benchmark --broker localhost:{} --create-option \"{}\"", port, option) +call("qpid-cpp-benchmark --broker localhost:{} --create-option \"{}\" --fill-drain", port, option) + +check_results() diff --git a/qpid/cpp/src/tests/run_performance_tests b/qpid/cpp/src/tests/run_performance_tests new file mode 100755 index 0000000000..ea195ae80d --- /dev/null +++ b/qpid/cpp/src/tests/run_performance_tests @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +port = start_broker("broker") + +call_with_valgrind("qpid-perftest --summary --count 100 --port {}", port) + +check_results() diff --git a/qpid/cpp/src/tests/run_perftest b/qpid/cpp/src/tests/run_perftest deleted file mode 100755 index 2fadc6cc62..0000000000 --- a/qpid/cpp/src/tests/run_perftest +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env 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. -# - -# Args: count [qpid-perftest options...] -# Run a qpid-perftest with count multiplied. -# -MULTIPLIER=3 -COUNT=`expr $1 \* $MULTIPLIER` -shift -exec `dirname $0`/run_test ./qpid-perftest --summary --count $COUNT "$@" diff --git a/qpid/cpp/src/tests/run_python_tests b/qpid/cpp/src/tests/run_python_tests new file mode 100755 index 0000000000..2c6570335c --- /dev/null +++ b/qpid/cpp/src/tests/run_python_tests @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +load_module_arg = None + +if AMQP_LIB is not None: + load_module_arg = "--load-module {}".format(AMQP_LIB) + +acl_file = join(BUILD_DIR, "src", "tests", "policy.acl") +acl_file_arg = "--acl-file {}".format(acl_file) + +port = start_broker("broker", load_module_arg, acl_file_arg) + +# Native python tests + +run_broker_tests(port, "-m qpid_tests.broker_0_10 -m qpid.tests") + +# Swigged python tests + +failing_tests = join(BUILD_DIR, "src", "tests", "failing-amqp0-10-python-tests") + +ENV["QPID_USE_SWIG_CLIENT"] = "1" + +run_broker_tests(port, + "-m qpid.tests.messaging.message", + "-m qpid_tests.broker_0_10.priority", + "-m qpid_tests.broker_0_10.lvq", + "-m qpid_tests.broker_0_10.new_api", + "-I {}".format(failing_tests)) + +if AMQP_LIB is not None: + failing_tests = join(BUILD_DIR, "src", "tests", "failing-amqp1.0-python-tests") + + run_broker_tests(port, + "--define=\"protocol_version=amqp1.0\"", + "--define=\"policy_file={}\"".format(acl_file), + "-m qpid_tests.broker_1_0", + "-m qpid_tests.broker_0_10.new_api", + "-m assertions -m reject_release -m misc -m policies -m acl_1", + "-I {}".format(failing_tests)) + +check_results() diff --git a/qpid/cpp/src/tests/run_qmf_tests b/qpid/cpp/src/tests/run_qmf_tests new file mode 100755 index 0000000000..40c6118470 --- /dev/null +++ b/qpid/cpp/src/tests/run_qmf_tests @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +call("qpid-python-test -m qpidd_qmfv2_tests -DOUTDIR={}", WORK_DIR) + +check_results() diff --git a/qpid/cpp/src/tests/run_queue_flow_limit_tests b/qpid/cpp/src/tests/run_queue_flow_limit_tests deleted file mode 100755 index 55b3e5d4c5..0000000000 --- a/qpid/cpp/src/tests/run_queue_flow_limit_tests +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env 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. -# - -source $QPID_TEST_COMMON - -ensure_python_tests - -# Run tests against Queue producer flow control. -$QPID_PYTHON_TEST -m queue_flow_limit_tests $SKIPTESTS -b localhost:$QPID_PORT diff --git a/qpid/cpp/src/tests/run_queue_redirect b/qpid/cpp/src/tests/run_queue_redirect deleted file mode 100755 index 3a0ae5118a..0000000000 --- a/qpid/cpp/src/tests/run_queue_redirect +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env 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. -# - -# Run the queue redirect. $srcdir is set by the Makefile. -source ./test_env.sh -DATA_DIR=`pwd`/data_dir - -trap stop_brokers INT TERM QUIT - -start_brokers() { - $QPIDD_EXEC --daemon \ - --port 0 --interface 127.0.0.1 \ - --no-module-dir \ - --data-dir $DATA_DIR \ - --acl-file policy.acl \ - --auth no \ - --log-to-file queue_redirect.log \ - --log-enable info+ \ - --log-enable trace+:Model \ - --log-enable trace+ > qpidd.port - LOCAL_PORT=`cat qpidd.port` -} - -stop_brokers() { - $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORT -} - -if test -d ${PYTHON_DIR} ; then - rm -f queue_redirect.log - rm -rf $DATA_DIR - mkdir -p $DATA_DIR - cp $srcdir/policy.acl $DATA_DIR - start_brokers - echo "Running queue redirect tests using broker on port $LOCAL_PORT" - $QPID_PYTHON_TEST -b localhost:$LOCAL_PORT -m queue_redirect - stop_brokers || EXITCODE=1 - exit $EXITCODE -fi diff --git a/qpid/cpp/src/tests/run_queue_redirect_tests b/qpid/cpp/src/tests/run_queue_redirect_tests new file mode 100644 index 0000000000..27458c272e --- /dev/null +++ b/qpid/cpp/src/tests/run_queue_redirect_tests @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +policy_file = join(BUILD_DIR, "src", "tests", "policy.acl") + +port = start_broker("broker", "--acl-file {}".format(policy_file), "--log-enable debug+:Model") + +run_broker_tests(port, "-m queue_redirect", "-Dpolicy-file={}".format(policy_file)) + +check_results() diff --git a/qpid/cpp/src/tests/run_ring_queue_test b/qpid/cpp/src/tests/run_ring_queue_test deleted file mode 100755 index 69497f9872..0000000000 --- a/qpid/cpp/src/tests/run_ring_queue_test +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env 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. -# -#script to run a sequence of ring queue tests via make - -#setup path to find qpid-config and sender/receiver test progs -source ./test_env.sh - -export PATH=$PWD:$srcdir:$PYTHON_COMMANDS:$PATH - -#set port to connect to via env var -test -s qpidd.port && QPID_PORT=`cat qpidd.port` -export QPID_PORT - -ring_queue_test -c -s 4 -r 4 -ring_queue_test -s 4 -r 0 -ring_queue_test -s 1 -r 1 - - diff --git a/qpid/cpp/src/tests/run_ring_queue_tests b/qpid/cpp/src/tests/run_ring_queue_tests new file mode 100755 index 0000000000..fbd6b0dff8 --- /dev/null +++ b/qpid/cpp/src/tests/run_ring_queue_tests @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +ENV["QPID_PORT"] = start_broker("broker") + +call("ring_queue_test -c -s 4 -r 4") +call("ring_queue_test -s 4 -r 0") +call("ring_queue_test -s 1 -r 1") + +check_results() diff --git a/qpid/cpp/src/tests/run_sasl_tests b/qpid/cpp/src/tests/run_sasl_tests new file mode 100755 index 0000000000..7ce92a232b --- /dev/null +++ b/qpid/cpp/src/tests/run_sasl_tests @@ -0,0 +1,64 @@ +#!/usr/bin/env 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. +# + +set -eu + +source env.sh + +export WORK_DIR=$(mktemp -d $PWD/run_sasl_tests_XXXX) + +echo "Created work dir '${WORK_DIR}'" + +min_sasl_version=131350 # Sasl version 2.1.22 +sasl_version=$(sasl_version) + +if (( $sasl_version < min_sasl_version )); then + echo "Sasl version is too old; found $version; require $min_version or greater" + echo "SKIPPING" + exit 0 +fi + +exit_code=0 + +function fail { + echo "FAILED! ${1}" + exit_code=1 +} + +echo "# Running sasl_fed" +sasl_fed || fail "Test sasl_fed failed" +echo "# Running sasl_fed_ex dynamic" +sasl_fed_ex dynamic || fail "Test sasl_fed_ex dynamic failed" +echo "# Running sasl_fed_ex link" +sasl_fed_ex link || fail "Test sasl_fed_ex link failed" +echo "# Running sasl_fed_ex queue" +sasl_fed_ex queue || fail "Test sasl_fed_ex queue failed" +echo "# Running sasl_fed_ex route" +sasl_fed_ex route || fail "Test sasl_fed_ex route failed" +echo "# Running sasl_no_dir" +sasl_no_dir || fail "Test sasl_no_dir failed" + +if (( exit_code != 0 )); then + echo "SASL test failures" + exit $exit_code +fi + +rm -rf $WORK_DIR diff --git a/qpid/cpp/src/tests/run_ssl_tests b/qpid/cpp/src/tests/run_ssl_tests new file mode 100755 index 0000000000..896893eb3d --- /dev/null +++ b/qpid/cpp/src/tests/run_ssl_tests @@ -0,0 +1,329 @@ +#!/usr/bin/env 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. +# + +# Run a simple test over SSL + +source env.sh + +#set -x + +CONFIG=$(dirname $0)/qpidd-empty.conf +TEST_CERT_DIR=`pwd`/test_cert_dir +CERT_DB=${TEST_CERT_DIR}/test_cert_db +CERT_PW_FILE=`pwd`/cert.password +TEST_HOSTNAME=127.0.0.1 +TEST_CLIENT_CERT=rumplestiltskin +CA_PEM_FILE=${TEST_CERT_DIR}/ca_cert.pem +OTHER_CA_CERT_DB=${TEST_CERT_DIR}/x_ca_cert_db +OTHER_CA_PEM_FILE=${TEST_CERT_DIR}/other_ca_cert.pem +PY_PING_BROKER=$SOURCE_DIR/src/tests/ping_broker +COUNT=10 + +if [[ -a $AMQP_LIB ]] ; then + MODULES="--load-module $AMQP_LIB" +fi + +trap cleanup EXIT + +error() { echo $*; exit 1; } + +# create the test certificate database +# $1 = string used as Subject in server's certificate +# $2 = string used as SubjectAlternateName (SAN) in server's certificate +create_certs() { + + local CERT_SUBJECT=${1:-"CN=${TEST_HOSTNAME},O=MyCo,ST=Massachusetts,C=US"} + local CERT_SAN=${2:-"*.server.com"} + + mkdir -p ${TEST_CERT_DIR} + rm -rf ${TEST_CERT_DIR}/* + + # Set Up a CA with a self-signed Certificate + # + mkdir -p ${CERT_DB} + certutil -N -d ${CERT_DB} -f ${CERT_PW_FILE} + certutil -S -d ${CERT_DB} -n "Test-CA" -s "CN=Test-CA,O=MyCo,ST=Massachusetts,C=US" -t "CT,," -x -f ${CERT_PW_FILE} -z /bin/sh >/dev/null 2>&1 + certutil -L -d ${CERT_DB} -n "Test-CA" -a -o ${CERT_DB}/rootca.crt -f ${CERT_PW_FILE} + #certutil -L -d ${CERT_DB} -f ${CERT_PW_FILE} + + # create server certificate signed by Test-CA + # + certutil -R -d ${CERT_DB} -s "${CERT_SUBJECT}" -o ${TEST_CERT_DIR}/server.req -f ${CERT_PW_FILE} -z /bin/sh > /dev/null 2>&1 + certutil -C -d ${CERT_DB} -c "Test-CA" -8 "${CERT_SAN}" -i ${TEST_CERT_DIR}/server.req -o ${TEST_CERT_DIR}/server.crt -f ${CERT_PW_FILE} -m ${RANDOM} + certutil -A -d ${CERT_DB} -n ${TEST_HOSTNAME} -i ${TEST_CERT_DIR}/server.crt -t "Pu,," + + # create a certificate to identify the client + # + certutil -R -d ${CERT_DB} -s "CN=${TEST_CLIENT_CERT}" -o ${TEST_CERT_DIR}/client.req -f ${CERT_PW_FILE} -z /bin/sh > /dev/null 2>&1 + certutil -C -d ${CERT_DB} -c "Test-CA" -8 "*.client.com" -i ${TEST_CERT_DIR}/client.req -o ${TEST_CERT_DIR}/client.crt -f ${CERT_PW_FILE} -m ${RANDOM} + certutil -A -d ${CERT_DB} -n ${TEST_CLIENT_CERT} -i ${TEST_CERT_DIR}/client.crt -t "Pu,," + ### + #certutil -N -d ${SERVER_CERT_DIR} -f ${CERT_PW_FILE} + #certutil -S -d ${SERVER_CERT_DIR} -n ${TEST_HOSTNAME} -s "CN=${TEST_HOSTNAME}" -t "CT,," -x -f ${CERT_PW_FILE} -z /usr/bin/certutil + #certutil -S -d ${SERVER_CERT_DIR} -n ${TEST_CLIENT_CERT} -s "CN=${TEST_CLIENT_CERT}" -t "CT,," -x -f ${CERT_PW_FILE} -z /usr/bin/certutil + + # Set up a separate DB with its own CA for testing failure to validate scenario + # + mkdir -p ${OTHER_CA_CERT_DB} + certutil -N -d ${OTHER_CA_CERT_DB} -f ${CERT_PW_FILE} + certutil -S -d ${OTHER_CA_CERT_DB} -n "Other-Test-CA" -s "CN=Another Test CA,O=MyCo,ST=Massachusetts,C=US" -t "CT,," -x -f ${CERT_PW_FILE} -z /bin/sh >/dev/null 2>&1 + certutil -L -d ${OTHER_CA_CERT_DB} -n "Other-Test-CA" -a -o ${OTHER_CA_CERT_DB}/rootca.crt -f ${CERT_PW_FILE} + #certutil -L -d ${OTHER_CA_CERT_DB} -f ${CERT_PW_FILE} +} + +delete_certs() { + if [[ -e ${TEST_CERT_DIR} ]] ; then + rm -rf ${TEST_CERT_DIR} + fi +} + +# Don't need --no-module-dir or --no-data-dir as they are set as env vars in env.sh +COMMON_OPTS="--daemon --config $CONFIG --ssl-cert-db $CERT_DB --ssl-cert-password-file $CERT_PW_FILE --ssl-cert-name $TEST_HOSTNAME" + +# Start new brokers: +# $1 must be integer +# $2 = extra opts +# Append used ports to PORTS variable +start_brokers() { + local -a ports + for (( i=0; $i<$1; i++)) do + ports[$i]=$(qpidd --port 0 --interface 127.0.0.1 $COMMON_OPTS $2) || error "Could not start broker $i" + done + PORTS=( ${PORTS[@]} ${ports[@]} ) +} + +# Stop single broker: +# $1 is number of broker to stop (0 based) +stop_broker() { + qpidd -qp ${PORTS[$1]} + + # Remove from ports array + unset PORTS[$1] +} + +stop_brokers() { + for port in "${PORTS[@]}"; + do + qpidd -qp $port + done + PORTS=() +} + +pick_port() { + # We need a fixed port to set --cluster-url. Use qpidd to pick a free port. + PICK=`qpidd --no-module-dir --listen-disable ssl -dp0` + qpidd --no-module-dir -qp $PICK + echo $PICK +} + +cleanup() { + stop_brokers + delete_certs + rm -f ${CERT_PW_FILE} +} + +start_ssl_broker() { + start_brokers 1 "--transport ssl --ssl-port 0 --require-encryption --auth no $MODULES" +} + +start_ssl_mux_broker() { + qpidd $COMMON_OPTS --port $1 --ssl-port $1 --auth no + PORTS=( ${PORTS[@]} $1 ) +} + +sasl_config_dir=$BUILD_DIR/src/tests/sasl_config + +start_authenticating_broker() { + start_brokers 1 "--transport ssl --ssl-port 0 --require-encryption --ssl-sasl-no-dict --ssl-require-client-authentication --auth yes --sasl-config=${sasl_config_dir} $MODULES" +} + +ssl_cluster_broker() { # $1 = port + start_brokers 1 "--ssl-port $1 --auth no --load-module $CLUSTER_LIB --cluster-name ssl_test.$HOSTNAME.$$ --cluster-url amqp:ssl:$TEST_HOSTNAME:$1" + + # Wait for broker to be ready + qpid-ping -Pssl -b $TEST_HOSTNAME:$1 -q || { echo "Cannot connect to broker on $1"; exit 1; } +} + +CERTUTIL=$(type -p certutil) +if [[ !(-x $CERTUTIL) ]] ; then + echo "No certutil, skipping ssl test"; + exit 0; +fi + +if [[ !(-e ${CERT_PW_FILE}) ]] ; then + echo password > ${CERT_PW_FILE} +fi +delete_certs +create_certs || error "Could not create test certificate database" + +start_ssl_broker +PORT=${PORTS[0]} +echo "Running SSL test on port $PORT" +export QPID_NO_MODULE_DIR=1 +export QPID_SSL_CERT_DB=${CERT_DB} +export QPID_SSL_CERT_PASSWORD_FILE=${CERT_PW_FILE} + +## Test connection via connection settings +qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary + +## Test connection with a URL +URL=amqp:ssl:$TEST_HOSTNAME:$PORT +qpid-send -b $URL --content-string=hello -a "foo;{create:always}" +MSG=`qpid-receive -b $URL -a "foo;{create:always}" --messages 1` +test "$MSG" = "hello" || { echo "receive failed '$MSG' != 'hello'"; exit 1; } + +if [[ -a $AMQP_LIB ]] ; then + echo "Testing ssl over AMQP 1.0" + qpid-send --connection-options '{protocol:amqp1.0}' -b $URL --content-string=hello -a "foo;{create:always}" + MSG=`qpid-receive --connection-options '{protocol:amqp1.0}' -b $URL -a "foo;{create:always}" --messages 1` + test "$MSG" = "hello" || { echo "receive failed for AMQP 1.0 '$MSG' != 'hello'"; exit 1; } +fi + +## Test connection with a combination of URL and connection options (in messaging API) +URL=$TEST_HOSTNAME:$PORT +qpid-send -b $URL --connection-options '{transport:ssl,heartbeat:2}' --content-string='hello again' -a "foo;{create:always}" +MSG=`qpid-receive -b $URL --connection-options '{transport:ssl,heartbeat:2}' -a "foo;{create:always}" --messages 1` +test "$MSG" = "hello again" || { echo "receive failed '$MSG' != 'hello again'"; exit 1; } + +## Test using the Python client +if test -d $PYTHON_DIR; then + echo "Testing Non-Authenticating with Python Client..." + URL=amqps://$TEST_HOSTNAME:$PORT + if `$PY_PING_BROKER -b $URL`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi +else + echo "Skipping python part of ssl_test, no python dir." +fi + +#### Client Authentication tests + +start_authenticating_broker +PORT2=${PORTS[1]} +echo "Running SSL client authentication test on port $PORT2" +URL=amqp:ssl:$TEST_HOSTNAME:$PORT2 + +## See if you can set the SSL cert-name for the connection +qpid-send -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" --content-string=hello -a "bar;{create:always}" +MSG2=`qpid-receive -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" -a "bar;{create:always}" --messages 1` +test "$MSG2" = "hello" || { echo "receive failed '$MSG2' != 'hello'"; exit 1; } + +## Make sure that connect fails with an invalid SSL cert-name +qpid-send -b $URL --connection-options "{ssl-cert-name: pignose }" --content-string=hello -a "baz;{create:always}" 2>/dev/null 1>/dev/null +MSG3=`qpid-receive -b $URL --connection-options "{ssl-cert-name: pignose }" -a "baz;{create:always}" --messages 1 2>/dev/null` +test "$MSG3" = "" || { echo "receive succeeded without valid ssl cert '$MSG3' != ''"; exit 1; } + +stop_brokers + +# Test ssl muxed with plain TCP on the same connection + +# Test a specified port number - since tcp/ssl are the same port don't need to specify --transport ssl +PORT=`pick_port` +start_ssl_mux_broker $PORT || error "Could not start broker" +echo "Running SSL/TCP mux test on fixed port $PORT" + +## Test connection via connection settings +qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary || error "SSL connection failed!" +qpid-perftest --count ${COUNT} --port ${PORT} -P tcp -b $TEST_HOSTNAME --summary || error "TCP connection failed!" + +# Test a broker chosen port - since ssl chooses port need to use --transport ssl here +start_ssl_broker +PORT=${PORTS[0]} +echo "Running SSL/TCP mux test on random port $PORT" + +## Test connection via connection settings +qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary || error "SSL connection failed!" +qpid-perftest --count ${COUNT} --port ${PORT} -P tcp -b $TEST_HOSTNAME --summary || error "TCP connection failed!" + +stop_brokers + +### Additional tests that require 'openssl' and 'pk12util' to be installed (optional) + +PK12UTIL=$(type -p pk12util) +if [[ !(-x $PK12UTIL) ]] ; then + echo >&2 "'pk12util' command not available, skipping remaining tests" + exit 0 +fi + +OPENSSL=$(type -p openssl) +if [[ !(-x $OPENSSL) ]] ; then + echo >&2 "'openssl' command not available, skipping remaining tests" + exit 0 +fi + +## verify python version > 2.5 (only 2.6+ does certificate checking) +PY_VERSION=$(python -c "import sys; print hex(sys.hexversion)") +if (( PY_VERSION < 0x02060000 )); then + echo >&2 "Detected python version < 2.6 - skipping certificate verification tests" + exit 0 +fi + +echo "Testing Certificate validation and Authentication with the Python Client..." + +# extract the CA's certificate as a PEM file +get_ca_certs() { + $PK12UTIL -o ${TEST_CERT_DIR}/CA_pk12.out -d ${CERT_DB} -n "Test-CA" -w ${CERT_PW_FILE} -k ${CERT_PW_FILE} > /dev/null + $OPENSSL pkcs12 -in ${TEST_CERT_DIR}/CA_pk12.out -out ${CA_PEM_FILE} -nokeys -passin file:${CERT_PW_FILE} >/dev/null + $PK12UTIL -o ${TEST_CERT_DIR}/other_CA_pk12.out -d ${OTHER_CA_CERT_DB} -n "Other-Test-CA" -w ${CERT_PW_FILE} -k ${CERT_PW_FILE} > /dev/null + $OPENSSL pkcs12 -in ${TEST_CERT_DIR}/other_CA_pk12.out -out ${OTHER_CA_PEM_FILE} -nokeys -passin file:${CERT_PW_FILE} >/dev/null +} + +get_ca_certs || error "Could not extract CA certificates as PEM files" +start_ssl_broker +PORT=${PORTS[0]} +URL=amqps://$TEST_HOSTNAME:$PORT +# verify the python client can authenticate the broker using the CA +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi +# verify the python client fails to authenticate the broker when using the other CA +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${OTHER_CA_PEM_FILE} > /dev/null 2>&1`; then { echo " Failed"; exit 1; }; else echo " Passed"; fi +stop_brokers + +# create a certificate without matching TEST_HOSTNAME, should fail to verify + +create_certs "O=MyCo" "*.${TEST_HOSTNAME}.com" || error "Could not create server test certificate" +get_ca_certs || error "Could not extract CA certificates as PEM files" +start_ssl_broker +PORT=${PORTS[0]} +URL=amqps://$TEST_HOSTNAME:$PORT +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE} > /dev/null 2>&1`; then { echo " Failed"; exit 1; }; else echo " Passed"; fi +# but disabling the check for the hostname should pass +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE} --ssl-skip-hostname-check`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi +stop_brokers + +# test SubjectAltName parsing + +if (( PY_VERSION >= 0x02070300 )); then +# python 2.7.3+ supports SubjectAltName extraction +# create a certificate with TEST_HOSTNAME only in SAN, should verify OK + create_certs "O=MyCo" "*.foo.com,${TEST_HOSTNAME},*xyz.com" || error "Could not create server test certificate" + get_ca_certs || error "Could not extract CA certificates as PEM files" + start_ssl_broker + PORT=${PORTS[0]} + URL=amqps://$TEST_HOSTNAME:$PORT + if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi + stop_brokers + + create_certs "O=MyCo" "*${TEST_HOSTNAME}" || error "Could not create server test certificate" + get_ca_certs || error "Could not extract CA certificates as PEM files" + start_ssl_broker + PORT=${PORTS[0]} + URL=amqps://$TEST_HOSTNAME:$PORT + if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi + stop_brokers +fi diff --git a/qpid/cpp/src/tests/run_store_tests.ps1 b/qpid/cpp/src/tests/run_store_tests.ps1 index 0683892393..f85e158cc0 100644 --- a/qpid/cpp/src/tests/run_store_tests.ps1 +++ b/qpid/cpp/src/tests/run_store_tests.ps1 @@ -31,7 +31,7 @@ if ($test_store -ne "MSSQL" -and $test_store -ne "MSSQL-CLFS") { $srcdir = Split-Path $myInvocation.InvocationName -. .\test_env.ps1 +. .\env.ps1 if (!(Test-Path $PYTHON_DIR -pathType Container)) { "Skipping store tests as python libs not found" diff --git a/qpid/cpp/src/tests/run_test b/qpid/cpp/src/tests/run_test deleted file mode 100755 index 8e397b3458..0000000000 --- a/qpid/cpp/src/tests/run_test +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/env 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. -# - -# -# Set up environment and run a test executable or script. -# -# Output nothing if test passes, show the output if it fails and -# leave output in .log for examination. -# -# If qpidd.port exists and is not empty run test with QPID_PORT=`cat qpidd.port` -# -# If $VALGRIND if is set run under valgrind. If there are valgrind -# erros show valgrind output, also leave it in .valgrind for -# examination. -# - -wrapper="Qpid Test Wrapper" -function usage { - echo "Usage:" - echo " -workingDir DIR" - echo " -buildDir DIR" - echo " -sourceDir DIR" - echo " -python - run python script" - echo " -boostTest - run boost unit test" - echo " -xml - XML output from tests" - echo " -startBroker - start/stop broker before/after test" - echo " -brokerOptions - use these extra options when starting broker" - echo " -help - print this message" - echo " -- - This is required to separate the wrapped command" - echo " from the test parameters" -} - -function illegal_option { - echo "$wrapper: $1 is not an accepted option" - usage >&2 -} - -function no_command { - echo "$wrapper: No wrapped command specified" - usage >&2 -} - -function ignored_argument { - echo "Ignored argument: $1" >&2 -} - -working_dir='.' - -while true; do -case "$1" in - --) shift; break ;; - # Split up any parameters expressed as -blah=foo - # and process them next time round the loop - -*=*) option=${1%%=*}; param=${1#*=} - shift; - set -- "$option" "$param" "$@" ;; - -workingDir) working_dir=$2; shift 2 ;; - -buildDir) build_dir=$2; shift 2 ;; - -sourceDir) source_dir=$2; shift 2 ;; - -python) run_python=yes; shift ;; - -boostTest) boost_test=yes; shift ;; - -xml) xml_output=yes; shift ;; - -startBroker) start_broker=yes; shift ;; - -brokerOptions) qpidd_extra_options=$2; shift 2 ;; - -help) usage; exit 0; ;; - -*) illegal_option "$1"; exit 1; ;; - '') no_command; exit 1; ;; - *) ignored_argument "$1"; shift; ;; -esac -done - -program=$1 -shift - -logfilebase=$(pwd -P)/$(basename $program) -source $build_dir/src/tests/test_env.sh || (echo "Error: Couldn't read test_env.sh (build settings)" ; exit 1) -source $srcdir/vg_check - -# Allow environment to dictate if we output xml test results -if [ -n "$QPID_XML_TEST_OUTPUT" ] ; then - xml_output=yes -fi - -# Use VALGRIND_OPTS="--gen-suppressions=all" to generated suppressions -VALGRIND_OPTS="$VALGRIND_OPTS ---leak-check=full ---demangle=yes ---suppressions=$srcdir/.valgrind.supp ---num-callers=25 -" - -# Set up environment for running a Qpid test -if [ -n "$start_broker" ] ; then - qpidd_command="$QPIDD_EXEC --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $logfilebase-qpidd.log $qpidd_extra_options" - if [ -n "$VALGRIND" ] ; then - if [ -n "$xml_output" ] ; then - QPID_PORT=$($VALGRIND $VALGRIND_OPTS --xml=yes --xml-file=$logfilebase-qpidd-vg.xml -- $qpidd_command) - else - QPID_PORT=$($VALGRIND $VALGRIND_OPTS --log-file=$logfilebase-qpidd.vglog -- $qpidd_command) - fi - else - QPID_PORT=$($qpidd_command) - fi -elif [ -r qpidd.port ]; then - QPID_PORT=$(cat qpidd.port) -fi -export QPID_PORT -QPID_LOG_TO_FILE="$logfilebase.log" -export QPID_LOG_TO_FILE - -# Export variables from makefile. -export srcdir - -if [ -n "$VALGRIND" ] ; then - if [ -n "$xml_output" ] ; then - valgrind_command="$VALGRIND $VALGRIND_OPTS --xml=yes --xml-file=$logfilebase-vg.xml --" - else - VG_LOG="$logfilebase.vglog" - rm -f $VG_LOG* - valgrind_command="$VALGRIND $VALGRIND_OPTS --log-file=$VG_LOG --" - fi -fi - -ERROR=0 -if [ -n "$run_python" -a -n "$PYTHON" ] ; then - (cd $working_dir; $PYTHON $program "$@") || ERROR=1 -elif [ ! -x $program ] ; then - echo "Cannot execute $program" - ERROR=1 -elif file $program | grep -q ELF; then - if [ -n "$boost_test" ] ; then - # Set boost unit test environment - if [ -n "$xml_output" ] ; then - export BOOST_TEST_SHOW_PROGRESS=no - export BOOST_TEST_OUTPUT_FORMAT=XML - export BOOST_TEST_LOG_LEVEL=test_suite - export BOOST_TEST_REPORT_LEVEL=no - (cd $working_dir; $valgrind_command $program "$@") > $logfilebase-unittest.xml || ERROR=1 - else - (cd $working_dir; $valgrind_command $program "$@") || ERROR=1 - fi - else - # This is a real executable, valgrind it if required - # Hide output unless there's an error. - (cd $working_dir; $valgrind_command $program "$@" 2>&1) || ERROR=1 - fi - if [ -n "$VG_LOG" ] ; then - vg_check $VG_LOG* || ERROR=1 - fi -else - (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 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 [ -n "$VALGRIND" -a -z "$xml_output" ] ; then - vg_check $logfilebase-qpidd.vglog || ERROR=1 - fi -fi -exit $ERROR diff --git a/qpid/cpp/src/tests/run_test.ps1 b/qpid/cpp/src/tests/run_test.ps1 deleted file mode 100644 index ff103e4556..0000000000 --- a/qpid/cpp/src/tests/run_test.ps1 +++ /dev/null @@ -1,162 +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. -# - -param( - [string]$workingDir = $pwd, - [string]$buildDir = $(throw "-buildDir is required"), - [string]$sourceDir, - [switch]$python = $false, - [switch]$boostTest = $false, - [switch]$xml, - [switch]$startBroker = $false, - [string]$brokerOptions, - [switch]$help, - [Parameter(Mandatory=$true, ValueFromRemainingArguments=$true, Position=0)] - [String[]]$rest - ) - -if ([string]::IsNullOrEmpty($sourceDir)) { - $sourceDir = Split-Path $myInvocation.InvocationName -} - -if ([string]::IsNullOrEmpty($xml)) { - $xml = Test-Path variable:global:QPID_XML_TEST_OUTPUT -} - -# Set up environment and run a test executable or script. -. .\test_env.ps1 - -if ($rest[0] -eq $null) { - "No wrapped command specified" - exit 1 -} -# The test exe is probably not in the current binary dir - it's usually -# placed in a subdirectory based on the configuration built in Visual Studio. -# So check around to see where it is - when located, set the QPID_LIB_DIR -# and PATH to look in the corresponding configuration off the src directory, -# one level up. -$prog = $rest[0] -$logfilebase = [System.IO.Path]::GetFileNameWithoutExtension($prog) -$logfilebase = "$pwd\\$logfilebase" -# Qpid client lib sees QPID_LOG_TO_FILE; acts like using --log-to-file on -# command line. -$env:QPID_LOG_TO_FILE = "$logfilebase.log" -$is_script = $prog -match ".ps1$" -if (($is_script -or $python) -and !(Test-Path "$prog")) { - "$prog does not exist" - exit 1 -} -if (!$is_script -and !(Test-Path "$prog")) { - . $sourceDir\find_prog.ps1 $prog - $rest[0] = $prog - $env:QPID_LIB_DIR = "..\$sub" -} - -# Set up environment for running a Qpid test. If a broker should be started, -# do that, else check for a saved port number to use. -if ($startBroker) { - $broker = new-object System.Diagnostics.ProcessStartInfo - $broker.WorkingDirectory = $pwd - $broker.UseShellExecute = $false - $broker.CreateNoWindow = $true - $broker.RedirectStandardOutput = $true - $broker.FileName = $env:QPIDD_EXEC - $broker.Arguments = "--auth=no --no-module-dir --port=0 --interface 127.0.0.1 --log-to-file $logfilebase-qpidd.log $brokerOptions" - $broker_process = [System.Diagnostics.Process]::Start($broker) - $env:QPID_PORT = $broker_process.StandardOutput.ReadLine() -} -else { - # If qpidd.port exists and is not empty run test with QPID_PORT set. - if (Test-Path qpidd.port) { - set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1) - } -} - -# Now start the real test. -if ($python) { - $to_run = $PYTHON_EXE - $skip_args0 = $false - $outputfile = "" -} -elseif ($boostTest) { - if ($xml) { - $env:BOOST_TEST_SHOW_PROGRESS=no - $env:BOOST_TEST_OUTPUT_FORMAT=XML - $env:BOOST_TEST_LOG_LEVEL=test_suite - $env:BOOST_TEST_REPORT_LEVEL=no - $to_run = $rest[0] - $skip_args0 = $true - $outputfile = "$logfilebase-unittest.xml" - } - else { - $to_run = $rest[0] - $skip_args0 = $true - $outputfile = "" - } -} -else { - # Non-boost executable or powershell script - $outputfile = "" - if ($is_script) { - $to_run = (get-command powershell.exe).Definition - $skip_args0 = $false - } - else { - $to_run = $rest[0] - $skip_args0 = $true - } -} - -if ($skip_args0) { - $arglist = $rest[1..($rest.length-1)] -} -else { - $arglist = $rest -} - -if ($outputfile -eq "") { - $p = Start-Process -FilePath $to_run -ArgumentList $arglist -NoNewWindow -PassThru - $line = "" -} -else { - $p = Start-Process -FilePath $to_run -ArgumentList $arglist -NoNewWindow -RedirectStandardOutput $outputfile -PassThru -} -Wait-Process -InputObject $p -$status = $p.ExitCode - -if (Test-Path $env:QPID_LOG_TO_FILE) { - $problems = Select-String -Path $env:QPID_LOG_TO_FILE -pattern " error ", " warning ", " critical " - if ($problems -ne $null) { - "WARNING: suspicious log entries in $env:QPID_LOG_TO_FILE:\n$problems" - $status = 1 - } -} - -# If a broker was started, stop it. -if ($startBroker) { - & $env:QPIDD_EXEC --no-module-dir --quit - # Check qpid log for problems - $problems = Select-String -Path $logfilebase-qpidd.log -pattern " error ", " warning ", " critical " - if ($problems -ne $null) { - "WARNING: suspicious log entries in $logfilebase-qpidd.log:\n$problems" - $status = 1 - } -} - -exit $status diff --git a/qpid/cpp/src/tests/run_topic_tests b/qpid/cpp/src/tests/run_topic_tests new file mode 100755 index 0000000000..f34b8044ba --- /dev/null +++ b/qpid/cpp/src/tests/run_topic_tests @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# +# 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. +# + +# Quick and quiet topic test for make test + +from common import * + +ENV["QPID_PORT"] = start_broker("broker") + +call_with_valgrind("topictest -s2 -m2 -b1") + +check_results() diff --git a/qpid/cpp/src/tests/run_transaction_tests b/qpid/cpp/src/tests/run_transaction_tests new file mode 100755 index 0000000000..4319b22096 --- /dev/null +++ b/qpid/cpp/src/tests/run_transaction_tests @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +port1 = start_broker("broker1") +port2 = start_broker("broker2") + +call_with_valgrind("qpid-txtest --queues 4 --tx-count 10 --quiet --port {}", port1) +call_with_valgrind("qpid-txtest2 --queues 4 --tx-count 10 --quiet --port {}", port2) + +check_results() diff --git a/qpid/cpp/src/tests/run_unit_tests b/qpid/cpp/src/tests/run_unit_tests new file mode 100755 index 0000000000..8e81fe73a0 --- /dev/null +++ b/qpid/cpp/src/tests/run_unit_tests @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +# +# 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. +# + +from common import * + +# Options for boost test framework + +if "BOOST_TEST_SHOW_PROGRESS" not in ENV: + ENV["BOOST_TEST_SHOW_PROGRESS"] = "yes" + +if "BOOST_TEST_CATCH_SYSTEM_ERRORS" not in ENV: + ENV["BOOST_TEST_CATCH_SYSTEM_ERRORS"] = "no" + +if WINDOWS: + ENV["QPID_SSL_CERT_STORE_LOCATION"] = "LocalMachine" + ENV["QPID_SSL_CERT_NAME"] = "localhost" + ENV["QPID_SSL_PORT"] = "0" + +call_with_valgrind("unit_test") + +check_results() diff --git a/qpid/cpp/src/tests/sasl_fed b/qpid/cpp/src/tests/sasl_fed index 38ef43f56f..8491d428be 100755 --- a/qpid/cpp/src/tests/sasl_fed +++ b/qpid/cpp/src/tests/sasl_fed @@ -19,69 +19,54 @@ # under the License. # -# This minimum value corresponds to sasl version 2.1.22 -minimum_sasl_version=131350 +set -eu -sasl_version=`$QPID_TEST_EXEC_DIR/sasl_version` - -# This test is necessary becasue this sasl version is the first one that permits -# redirection of the sasl config file path. -if [ "$sasl_version" -lt "$minimum_sasl_version" ]; then - echo "sasl_fed: must have sasl version 2.1.22 or greater. ( Integer value: $minimum_sasl_version ) Version is: $sasl_version" - exit 0 -fi - -# In a distribution, the python tools will be absent. -if [ ! -f $QPID_CONFIG_EXEC ] || [ ! -f $QPID_ROUTE_EXEC ] ; then - echo "python tools absent - skipping sasl_fed." - exit 0 -fi +WORK_DIR=$WORK_DIR/sasl_fed +mkdir $WORK_DIR +sasl_config_dir=$BUILD_DIR/src/tests/sasl_config -sasl_config_file=$QPID_TEST_EXEC_DIR/sasl_config +# Create ACL file to allow links +echo acl allow all all > $WORK_DIR/sasl_fed.acl -my_random_number=$RANDOM -tmp_root=/tmp/sasl_fed_$my_random_number -mkdir -p $tmp_root +echo "Starting broker 1" -# create ACL file to allow links -echo acl allow all all > $tmp_root/sasl_fed.acl - - -#-------------------------------------------------- -#echo " Starting broker 1" -#-------------------------------------------------- -$QPIDD_EXEC \ +qpidd \ -p 0 --interface 127.0.0.1 \ - --data-dir $tmp_root/data_1 \ + --data-dir $WORK_DIR/data_1 \ --auth=yes \ --mgmt-enable=yes \ --log-enable info+ \ --log-source yes \ - --log-to-file $tmp_root/qpidd_1.log \ - --sasl-config=$sasl_config_file \ - --acl-file $tmp_root/sasl_fed.acl \ - -d > $tmp_root/broker_1_port + --log-to-file $WORK_DIR/qpidd_1.log \ + --sasl-config=$sasl_config_dir \ + --acl-file $WORK_DIR/sasl_fed.acl \ + -d > $WORK_DIR/broker_1_port -broker_1_port=`cat $tmp_root/broker_1_port` +broker_1_port=$(cat $WORK_DIR/broker_1_port) +echo "Starting broker 2" -#-------------------------------------------------- -#echo " Starting broker 2" -#-------------------------------------------------- -$QPIDD_EXEC \ +qpidd \ -p 0 --interface 127.0.0.1 \ - --data-dir $tmp_root/data_2 \ + --data-dir $WORK_DIR/data_2 \ --auth=yes \ --mgmt-enable=yes \ --log-enable info+ \ --log-source yes \ - --log-to-file $tmp_root/qpidd_2.log \ - --sasl-config=$sasl_config_file \ - --acl-file $tmp_root/sasl_fed.acl \ - -d > $tmp_root/broker_2_port + --log-to-file $WORK_DIR/qpidd_2.log \ + --sasl-config=$sasl_config_dir \ + --acl-file $WORK_DIR/sasl_fed.acl \ + -d > $WORK_DIR/broker_2_port + +broker_2_port=$(cat $WORK_DIR/broker_2_port) + +function stop_brokers { + qpidd --port $broker_1_port --quit + qpidd --port $broker_2_port --quit +} -broker_2_port=`cat $tmp_root/broker_2_port` +trap stop_brokers EXIT sleep 2 @@ -90,80 +75,48 @@ QUEUE_NAME=sasl_fed_queue ROUTING_KEY=sasl_fed_queue EXCHANGE_NAME=sasl_fedex -#-------------------------------------------------- -#echo " add exchanges" -#-------------------------------------------------- -$QPID_CONFIG_EXEC -b localhost:$broker_1_port add exchange direct $EXCHANGE_NAME -$QPID_CONFIG_EXEC -b localhost:$broker_2_port add exchange direct $EXCHANGE_NAME +echo "Adding exchanges" +qpid-config -b localhost:$broker_1_port add exchange direct $EXCHANGE_NAME +qpid-config -b localhost:$broker_2_port add exchange direct $EXCHANGE_NAME -#-------------------------------------------------- -#echo " add queues" -#-------------------------------------------------- -$QPID_CONFIG_EXEC -b localhost:$broker_1_port add queue $QUEUE_NAME -$QPID_CONFIG_EXEC -b localhost:$broker_2_port add queue $QUEUE_NAME +echo "Adding queues" + +qpid-config -b localhost:$broker_1_port add queue $QUEUE_NAME +qpid-config -b localhost:$broker_2_port add queue $QUEUE_NAME sleep 5 -#-------------------------------------------------- -#echo " create bindings" -#-------------------------------------------------- -$QPID_CONFIG_EXEC -b localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY -$QPID_CONFIG_EXEC -b localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +echo "Creating bindings" + +qpid-config -b localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +qpid-config -b localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY sleep 5 +echo "Adding routes" -#-------------------------------------------------- -#echo " qpid-route route add" -#-------------------------------------------------- -$QPID_ROUTE_EXEC route add zag/zag@localhost:$broker_2_port zag/zag@localhost:$broker_1_port $EXCHANGE_NAME $ROUTING_KEY "" "" DIGEST-MD5 +qpid-route route add zag/zag@localhost:$broker_2_port zag/zag@localhost:$broker_1_port $EXCHANGE_NAME $ROUTING_KEY "" "" DIGEST-MD5 sleep 5 - n_messages=100 -#-------------------------------------------------- -#echo " Sending 100 messages to $broker_1_port " -#-------------------------------------------------- -$QPID_TEST_EXEC_DIR/datagen --count $n_messages | $SENDER_EXEC --mechanism DIGEST-MD5 --username zag --password zag --exchange $EXCHANGE_NAME --routing-key $ROUTING_KEY --port $broker_1_port -sleep 5 +echo "Sending 100 messages to $broker_1_port " -#-------------------------------------------------- -#echo " Examine Broker $broker_1_port" -#-------------------------------------------------- -broker_1_message_count=`$PYTHON_COMMANDS/qpid-stat -q -b localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}'` -#echo " " - -#-------------------------------------------------- -#echo " Examine Broker $broker_2_port" -#-------------------------------------------------- -broker_2_message_count=`$PYTHON_COMMANDS/qpid-stat -q -b localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}'` -#echo " " - -#-------------------------------------------------- -#echo " Asking brokers to quit." -#-------------------------------------------------- -$QPIDD_EXEC --port $broker_1_port --quit -$QPIDD_EXEC --port $broker_2_port --quit - - -#-------------------------------------------------- -#echo "Removing temporary directory $tmp_root" -#-------------------------------------------------- -rm -rf $tmp_root - -if [ "$broker_2_message_count" -eq "$n_messages" ]; then - # echo "good: |$broker_2_message_count| == |$n_messages|" - exit 0 -else - # echo "not ideal: |$broker_1_message_count| != |$n_messages|" - exit 1 -fi +datagen --count $n_messages | sender --mechanism DIGEST-MD5 --username zag --password zag --exchange $EXCHANGE_NAME --routing-key $ROUTING_KEY --port $broker_1_port +sleep 5 +echo "Examining Broker $broker_1_port" +broker_1_message_count=$(qpid-stat -q -b localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}') +echo "Examining Broker $broker_2_port" +broker_2_message_count=$(qpid-stat -q -b localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}') +if (( $broker_2_message_count != $n_messages )); then + echo "Expected ${n_messages} and received ${broker_2_message_count}" + exit 1 +fi diff --git a/qpid/cpp/src/tests/sasl_fed_ex b/qpid/cpp/src/tests/sasl_fed_ex index e2ee37ba39..bf62be95df 100755 --- a/qpid/cpp/src/tests/sasl_fed_ex +++ b/qpid/cpp/src/tests/sasl_fed_ex @@ -25,86 +25,47 @@ # transport-layer security. #=============================================================================== -source $QPID_TEST_COMMON +set -eu -ensure_python_tests - -script_name=`basename $0` - -if [ $# -lt 1 ] || [ $# -gt 2 ] -then - echo - # These are the four different ways of creating links ( or routes+links ) - # that the qpid-route command provides. - echo "Usage: ${script_name} dynamic|link|queue|route" - echo - exit 1 +if (( $# != 1 )); then + # These are the four different ways of creating links ( or routes+links ) + # that the qpid-route command provides. + echo "Usage: $(basename $0) dynamic|link|queue|route" + exit 1 fi qpid_route_method=$1 -# Debugging print. -------------------------- -debug= -function print { - if [ "$debug" ]; then - echo "${script_name}: $1" - fi -} - -print "=========== start sasl_fed_ex $* ============" - +WORK_DIR="${WORK_DIR}/sasl_fed_ex_${qpid_route_method}" +mkdir $WORK_DIR - -# This minimum value corresponds to sasl version 2.1.22 -minimum_sasl_version=131350 - -sasl_version=`$QPID_TEST_EXEC_DIR/sasl_version` - -# This test is necessary because this sasl version is the first one that permits -# redirection of the sasl config file path. -if [ "$sasl_version" -lt "$minimum_sasl_version" ]; then - echo "sasl_fed: must have sasl version 2.1.22 or greater. ( Integer value: $minimum_sasl_version ) Version is: $sasl_version" - exit 0 -fi - -CERT_DIR=`pwd`/test_cert_db -CERT_PW_FILE=`pwd`/cert.password +CERT_DIR=$WORK_DIR/test_cert_db +CERT_PW_FILE=$WORK_DIR/cert.password TEST_HOSTNAME=127.0.0.1 create_certs() { - #create certificate and key databases with single, simple, self-signed certificate in it + # Create certificate and key databases with single, simple, + # self-signed certificate in it mkdir ${CERT_DIR} certutil -N -d ${CERT_DIR} -f ${CERT_PW_FILE} certutil -S -d ${CERT_DIR} -n ${TEST_HOSTNAME} -s "CN=${TEST_HOSTNAME}" -t "CT,," -x -f ${CERT_PW_FILE} -z /bin/sh 2> /dev/null } -delete_certs() { - if [[ -e ${CERT_DIR} ]] ; then - print "removing cert dir ${CERT_DIR}" - rm -rf ${CERT_DIR} - fi -} - - CERTUTIL=$(type -p certutil) -if [[ !(-x $CERTUTIL) ]] ; then - echo "No certutil, skipping ssl test"; - exit 0; + +if [[ ! -x $CERTUTIL ]]; then + echo "No certutil, skipping ssl test" + exit 0 fi -delete_certs create_certs 2> /dev/null -if [ ! $? ]; then - error "Could not create test certificate" - exit 1 -fi -sasl_config_dir=$QPID_TEST_EXEC_DIR/sasl_config +if (( $? != 0 )); then + echo "Could not create test certificate" + exit 1 +fi -tmp_root=$QPID_TEST_EXEC_DIR/sasl_fed_ex_temp -print "results dir is ${tmp_root}" -rm -rf ${tmp_root} -mkdir -p $tmp_root +sasl_config_dir=$BUILD_DIR/src/tests/sasl_config SRC_SSL_PORT=6667 DST_SSL_PORT=6666 @@ -125,8 +86,6 @@ export QPID_SSL_CERT_DB=${CERT_DIR} export QPID_SSL_CERT_PASSWORD_FILE=${CERT_PW_FILE} export QPID_SSL_CERT_NAME=${TEST_HOSTNAME} - - ####################################### # Understanding this Plumbing ####################################### @@ -146,7 +105,7 @@ export QPID_SSL_CERT_NAME=${TEST_HOSTNAME} COMMON_BROKER_OPTIONS=" \ --ssl-sasl-no-dict \ - --sasl-config=$sasl_config_dir \ + --sasl-config $sasl_config_dir \ --ssl-require-client-authentication \ --auth yes \ --ssl-cert-db $CERT_DIR \ @@ -154,130 +113,111 @@ COMMON_BROKER_OPTIONS=" \ --ssl-cert-name $TEST_HOSTNAME \ --no-data-dir \ --no-module-dir \ - --mgmt-enable=yes \ + --mgmt-enable yes \ --log-enable info+ \ --log-source yes \ - --daemon " + --daemon" - function start_brokers { # vanilla brokers -------------------------------- - print "Starting SRC broker" - $QPIDD_EXEC \ + echo "Starting SRC broker" + qpidd \ --port=${SRC_TCP_PORT} \ --ssl-port ${SRC_SSL_PORT} \ ${COMMON_BROKER_OPTIONS} \ - --log-to-file $tmp_root/qpidd_src.log 2> /dev/null + --log-to-file $WORK_DIR/qpidd_src.log 2> /dev/null broker_ports[0]=${SRC_TCP_PORT} - print "Starting DST broker" - $QPIDD_EXEC \ + echo "Starting DST broker" + qpidd \ --port=${DST_TCP_PORT} \ --ssl-port ${DST_SSL_PORT} \ ${COMMON_BROKER_OPTIONS} \ - --log-to-file $tmp_root/qpidd_dst.log 2> /dev/null + --log-to-file $WORK_DIR/qpidd_dst.log 2> /dev/null broker_ports[1]=${DST_TCP_PORT} } function halt_brokers { - n_brokers=${#broker_ports[@]} - print "Halting ${n_brokers} brokers." - for i in $(seq 0 $((${n_brokers} - 1))) - do - halt_port=${broker_ports[$i]} - print "Halting broker $i on port ${halt_port}" - $QPIDD_EXEC --port ${halt_port} --quit - done - + n_brokers=${#broker_ports[@]} + echo "Halting ${n_brokers} brokers" + for i in $(seq 0 $((${n_brokers} - 1))); do + halt_port=${broker_ports[$i]} + echo "Halting broker $i on port ${halt_port}" + qpidd --port ${halt_port} --quit + done } - start_brokers - +trap halt_brokers EXIT # I am not randomizing these names, because this test creates its own brokers. QUEUE_NAME=sasl_fed_queue ROUTING_KEY=sasl_fed_queue EXCHANGE_NAME=sasl_fedex +echo "Add exchanges" +qpid-config -b localhost:${SRC_TCP_PORT} add exchange direct $EXCHANGE_NAME +qpid-config -b localhost:${DST_TCP_PORT} add exchange direct $EXCHANGE_NAME -print "add exchanges" -$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} add exchange direct $EXCHANGE_NAME -$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} add exchange direct $EXCHANGE_NAME - - -print "add queues" -$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} add queue $QUEUE_NAME -$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} add queue $QUEUE_NAME - - -print "create bindings" -$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY -$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +echo "Add queues" +qpid-config -b localhost:${SRC_TCP_PORT} add queue $QUEUE_NAME +qpid-config -b localhost:${DST_TCP_PORT} add queue $QUEUE_NAME +echo "Create bindings" +qpid-config -b localhost:${SRC_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +qpid-config -b localhost:${DST_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY # # NOTE: The SRC broker *must* be referred to as $TEST_HOSTNAME, and not as "localhost". # It must be referred to by the exact string given as the Common Name (CN) in the cert, # which was created in the function create_certs, above. - - #---------------------------------------------------------------- # Use qpid-route to create the link, or the link+route, depending # on which of its several methods was requested. #---------------------------------------------------------------- -if [ ${qpid_route_method} == "dynamic" ]; then - print "dynamic add" - $QPID_ROUTE_EXEC -t ssl dynamic add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} $EXCHANGE_NAME "" "" EXTERNAL -elif [ ${qpid_route_method} == "link" ]; then - print "link add" - $QPID_ROUTE_EXEC -t ssl link add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} EXTERNAL -elif [ ${qpid_route_method} == "queue" ]; then - print "queue add" - $QPID_ROUTE_EXEC -t ssl queue add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} $EXCHANGE_NAME $ROUTING_KEY EXTERNAL -elif [ ${qpid_route_method} == "route" ]; then - print "route add" - $QPID_ROUTE_EXEC -t ssl route add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} $EXCHANGE_NAME $ROUTING_KEY "" "" EXTERNAL +if [[ $qpid_route_method == "dynamic" ]]; then + echo "Dynamic add" + qpid-route -t ssl dynamic add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} $EXCHANGE_NAME "" "" EXTERNAL || : +elif [[ $qpid_route_method == "link" ]]; then + echo "Link add" + qpid-route -t ssl link add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} EXTERNAL || : +elif [[ $qpid_route_method == "queue" ]]; then + echo "Queue add" + qpid-route -t ssl queue add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} $EXCHANGE_NAME $ROUTING_KEY EXTERNAL || : +elif [[ $qpid_route_method == "route" ]]; then + echo "Route add" + qpid-route -t ssl route add localhost:${DST_TCP_PORT} $TEST_HOSTNAME:${SRC_SSL_PORT} $EXCHANGE_NAME $ROUTING_KEY "" "" EXTERNAL || : else - echo "unknown method: |${qpid_route_method}|" - echo " choices are: dynamic|link|queue|route " - halt_brokers - exit 1 + echo "Unknown method: |${qpid_route_method}|" + echo "Choices are: dynamic|link|queue|route " + halt_brokers + exit 1 fi - # I don't know how to avoid this sleep yet. It has to come after route-creation # to avoid false negatives. sleep 5 # Look only at the transport field, which should be "ssl". -print "check the link" -link_status=$($QPID_ROUTE_EXEC link list localhost:${DST_TCP_PORT} | tail -1 | awk '{print $3}') - -halt_brokers +echo "Check the link" +link_status=$(qpid-route link list localhost:${DST_TCP_PORT} | tail -1 | awk '{print $3}') sleep 1 -if [ ! ${link_status} ]; then - print "link_status is empty" - print "result: fail" - exit 2 +if [[ ! $link_status ]]; then + echo "Link status is empty" + echo "Result: fail" + exit 2 fi -if [ ${link_status} == "ssl" ]; then - print "result: good" - # Only remove the tmp_root on success, to permit debugging. - print "Removing temporary directory $tmp_root" - rm -rf $tmp_root - exit 0 +if [[ $link_status == "ssl" ]]; then + echo "Result: good" + exit 0 fi -print "link_status has a bad value: ${link_status}" -print "result: fail" +echo "Link status has a bad value: ${link_status}" +echo "Result: fail" exit 3 - - - diff --git a/qpid/cpp/src/tests/sasl_no_dir b/qpid/cpp/src/tests/sasl_no_dir index b2f5d1668e..30d8434079 100755 --- a/qpid/cpp/src/tests/sasl_no_dir +++ b/qpid/cpp/src/tests/sasl_no_dir @@ -19,88 +19,40 @@ # under the License. # -script_name=`basename $0` +set -eu -# This minimum value corresponds to sasl version 2.1.22 -minimum_sasl_version=131350 +sasl_config_dir=$BUILD_DIR/not_there_at_all -sasl_version=$($QPID_TEST_EXEC_DIR/sasl_version) - -# This test is necessary because this sasl version is the first one that permits -# redirection of the sasl config file path. -if [ "$sasl_version" -lt "$minimum_sasl_version" ]; then - echo "sasl_fed: must have sasl version 2.1.22 or greater. ( Integer value: $minimum_sasl_version ) Version is: $sasl_version" - exit 0 -fi - - -sasl_config_dir=$QPID_TEST_EXEC_DIR/sasl_config - - -# Debugging print. -------------------------- -debug= -function print { - if [ "$debug" ]; then - echo "${script_name}: $1" - fi -} - - -my_random_number=$RANDOM -tmp_root=/tmp/sasl_fed_$my_random_number -mkdir -p $tmp_root - - -LOG_FILE=$tmp_root/qpidd.log - -# If you want to see this test fail, just comment out this 'mv' command. -print "Moving sasl configuration dir." -mv ${sasl_config_dir} ${sasl_config_dir}- - - -#-------------------------------------------------- -print " Starting broker" -#-------------------------------------------------- -$QPIDD_EXEC \ - -p 0 --interface 127.0.0.1 \ - --no-data-dir \ - --auth=yes \ - --mgmt-enable=yes \ - --log-enable info+ \ - --log-source yes \ - --log-to-file ${LOG_FILE} \ - --sasl-config=$sasl_config_dir \ - -d 2> /dev/null 1> $tmp_root/broker_port +WORK_DIR=$WORK_DIR/sasl_no_dir +mkdir $WORK_DIR +LOG_FILE=$WORK_DIR/qpidd.log +echo "Starting broker" +qpidd \ + -p 0 --interface 127.0.0.1 \ + --no-data-dir \ + --auth=yes \ + --mgmt-enable=yes \ + --log-enable info+ \ + --log-source yes \ + --log-to-file ${LOG_FILE} \ + --sasl-config=$sasl_config_dir \ + -d 2> /dev/null 1> $WORK_DIR/broker_port || : # If it works right, the output will look something like this: ( two lines long ) # Daemon startup failed: SASL: sasl_set_path failed: no such directory: /home/mick/trunk/qpid/cpp/src/tests/sasl_config (qpid/broker/SaslAuthenticator.cpp:112) # 2011-10-13 14:07:00 critical qpidd.cpp:83: Unexpected error: Daemon startup failed: SASL: sasl_set_path failed: no such directory: /home/mick/trunk/qpid/cpp/src/tests/sasl_config (qpid/broker/SaslAuthenticator.cpp:112) -result=`cat ${LOG_FILE} | grep "sasl_set_path failed: no such directory" | wc -l ` - -#-------------------------------------------------- -print "Restore the Sasl config dir to its original place." -#-------------------------------------------------- -mv ${sasl_config_dir}- ${sasl_config_dir} +result=$(cat ${LOG_FILE} | grep "sasl_set_path failed: no such directory" | wc -l) -if [ "2" -eq ${result} ]; then - print "result: success" - rm -rf $tmp_root - exit 0 +if (( $result == 2 )); then + echo "Result: success" + exit 0 fi +broker_port=$(cat $WORK_DIR/broker_port) +qpidd --port ${broker_port} --quit -# If this test fails, the broker is still alive. -# Kill it. -broker_port=`cat $tmp_root/broker_port` -#-------------------------------------------------- -print "Asking broker to quit." -#-------------------------------------------------- -$QPIDD_EXEC --port $broker_port --quit - -rm -rf $tmp_root - -print "result: fail" +echo "Result: fail" exit 1 diff --git a/qpid/cpp/src/tests/sasl_test_setup.sh b/qpid/cpp/src/tests/sasl_test_setup.sh index d41efbe6e5..1416759da7 100755 --- a/qpid/cpp/src/tests/sasl_test_setup.sh +++ b/qpid/cpp/src/tests/sasl_test_setup.sh @@ -18,9 +18,10 @@ # specific language governing permissions and limitations # under the License. # -source ./test_env.sh -test -x $SASL_PW || { echo Skipping SASL test, saslpasswd2 not found; exit 0; } +source env.sh + +test -x $SASLPASSWD2 || { echo Skipping SASL test, saslpasswd2 not found; exit 0; } mkdir -p sasl_config @@ -36,7 +37,7 @@ EOF # Populate temporary sasl db. SASLTEST_DB=./sasl_config/qpidd.sasldb rm -f $SASLTEST_DB -echo guest | $SASL_PW -c -p -f $SASLTEST_DB -u QPID guest -echo zig | $SASL_PW -c -p -f $SASLTEST_DB -u QPID zig -echo zag | $SASL_PW -c -p -f $SASLTEST_DB -u QPID zag +echo guest | $SASLPASSWD2 -c -p -f $SASLTEST_DB -u QPID guest +echo zig | $SASLPASSWD2 -c -p -f $SASLTEST_DB -u QPID zig +echo zag | $SASLPASSWD2 -c -p -f $SASLTEST_DB -u QPID zag diff --git a/qpid/cpp/src/tests/shared_perftest b/qpid/cpp/src/tests/shared_perftest deleted file mode 100755 index 709ffd56b5..0000000000 --- a/qpid/cpp/src/tests/shared_perftest +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env 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. -# - -exec `dirname $0`/run_perftest 100000 --mode shared --npubs 16 --nsubs 16 diff --git a/qpid/cpp/src/tests/ssl_test b/qpid/cpp/src/tests/ssl_test index 46068afefb..7c85087ad1 100755 --- a/qpid/cpp/src/tests/ssl_test +++ b/qpid/cpp/src/tests/ssl_test @@ -21,9 +21,11 @@ # Run a simple test over SSL +source env.sh + #set -x -CONFIG=$(dirname $0)/config.null +CONFIG=$(dirname $0)/qpidd-empty.conf TEST_CERT_DIR=`pwd`/test_cert_dir CERT_DB=${TEST_CERT_DIR}/test_cert_db CERT_PW_FILE=`pwd`/cert.password @@ -32,7 +34,7 @@ TEST_CLIENT_CERT=rumplestiltskin CA_PEM_FILE=${TEST_CERT_DIR}/ca_cert.pem OTHER_CA_CERT_DB=${TEST_CERT_DIR}/x_ca_cert_db OTHER_CA_PEM_FILE=${TEST_CERT_DIR}/other_ca_cert.pem -PY_PING_BROKER=${QPID_TEST_SRC_DIR}/ping_broker +PY_PING_BROKER=$SOURCE_DIR/src/tests/ping_broker COUNT=10 if [[ -a $AMQP_LIB ]] ; then @@ -93,7 +95,7 @@ delete_certs() { fi } -# Don't need --no-module-dir or --no-data-dir as they are set as env vars in test_env.sh +# Don't need --no-module-dir or --no-data-dir as they are set as env vars in env.sh COMMON_OPTS="--daemon --config $CONFIG --ssl-cert-db $CERT_DB --ssl-cert-password-file $CERT_PW_FILE --ssl-cert-name $TEST_HOSTNAME" # Start new brokers: @@ -103,7 +105,7 @@ COMMON_OPTS="--daemon --config $CONFIG --ssl-cert-db $CERT_DB --ssl-cert-passwor start_brokers() { local -a ports for (( i=0; $i<$1; i++)) do - ports[$i]=$($QPIDD_EXEC --port 0 --interface 127.0.0.1 $COMMON_OPTS $2) || error "Could not start broker $i" + ports[$i]=$(qpidd --port 0 --interface 127.0.0.1 $COMMON_OPTS $2) || error "Could not start broker $i" done PORTS=( ${PORTS[@]} ${ports[@]} ) } @@ -111,7 +113,7 @@ start_brokers() { # Stop single broker: # $1 is number of broker to stop (0 based) stop_broker() { - $QPIDD_EXEC -qp ${PORTS[$1]} + qpidd -qp ${PORTS[$1]} # Remove from ports array unset PORTS[$1] @@ -120,15 +122,15 @@ stop_broker() { stop_brokers() { for port in "${PORTS[@]}"; do - $QPIDD_EXEC -qp $port + qpidd -qp $port done PORTS=() } pick_port() { # We need a fixed port to set --cluster-url. Use qpidd to pick a free port. - PICK=`../qpidd --no-module-dir --listen-disable ssl -dp0` - ../qpidd --no-module-dir -qp $PICK + PICK=`qpidd --no-module-dir --listen-disable ssl -dp0` + qpidd --no-module-dir -qp $PICK echo $PICK } @@ -143,11 +145,11 @@ start_ssl_broker() { } start_ssl_mux_broker() { - ../qpidd $COMMON_OPTS --port $1 --ssl-port $1 --auth no + qpidd $COMMON_OPTS --port $1 --ssl-port $1 --auth no PORTS=( ${PORTS[@]} $1 ) } -sasl_config_dir=$QPID_TEST_EXEC_DIR/sasl_config +sasl_config_dir=$BUILD_DIR/src/tests/sasl_config start_authenticating_broker() { start_brokers 1 "--transport ssl --ssl-port 0 --require-encryption --ssl-sasl-no-dict --ssl-require-client-authentication --auth yes --sasl-config=${sasl_config_dir} $MODULES" @@ -180,25 +182,25 @@ export QPID_SSL_CERT_DB=${CERT_DB} export QPID_SSL_CERT_PASSWORD_FILE=${CERT_PW_FILE} ## Test connection via connection settings -./qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary +qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary ## Test connection with a URL URL=amqp:ssl:$TEST_HOSTNAME:$PORT -./qpid-send -b $URL --content-string=hello -a "foo;{create:always}" -MSG=`./qpid-receive -b $URL -a "foo;{create:always}" --messages 1` +qpid-send -b $URL --content-string=hello -a "foo;{create:always}" +MSG=`qpid-receive -b $URL -a "foo;{create:always}" --messages 1` test "$MSG" = "hello" || { echo "receive failed '$MSG' != 'hello'"; exit 1; } if [[ -a $AMQP_LIB ]] ; then echo "Testing ssl over AMQP 1.0" - ./qpid-send --connection-options '{protocol:amqp1.0}' -b $URL --content-string=hello -a "foo;{create:always}" - MSG=`./qpid-receive --connection-options '{protocol:amqp1.0}' -b $URL -a "foo;{create:always}" --messages 1` + qpid-send --connection-options '{protocol:amqp1.0}' -b $URL --content-string=hello -a "foo;{create:always}" + MSG=`qpid-receive --connection-options '{protocol:amqp1.0}' -b $URL -a "foo;{create:always}" --messages 1` test "$MSG" = "hello" || { echo "receive failed for AMQP 1.0 '$MSG' != 'hello'"; exit 1; } fi ## Test connection with a combination of URL and connection options (in messaging API) URL=$TEST_HOSTNAME:$PORT -./qpid-send -b $URL --connection-options '{transport:ssl,heartbeat:2}' --content-string='hello again' -a "foo;{create:always}" -MSG=`./qpid-receive -b $URL --connection-options '{transport:ssl,heartbeat:2}' -a "foo;{create:always}" --messages 1` +qpid-send -b $URL --connection-options '{transport:ssl,heartbeat:2}' --content-string='hello again' -a "foo;{create:always}" +MSG=`qpid-receive -b $URL --connection-options '{transport:ssl,heartbeat:2}' -a "foo;{create:always}" --messages 1` test "$MSG" = "hello again" || { echo "receive failed '$MSG' != 'hello again'"; exit 1; } ## Test using the Python client @@ -218,14 +220,14 @@ echo "Running SSL client authentication test on port $PORT2" URL=amqp:ssl:$TEST_HOSTNAME:$PORT2 ## See if you can set the SSL cert-name for the connection -./qpid-send -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" --content-string=hello -a "bar;{create:always}" -MSG2=`./qpid-receive -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" -a "bar;{create:always}" --messages 1` +qpid-send -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" --content-string=hello -a "bar;{create:always}" +MSG2=`qpid-receive -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" -a "bar;{create:always}" --messages 1` test "$MSG2" = "hello" || { echo "receive failed '$MSG2' != 'hello'"; exit 1; } ## Make sure that connect fails with an invalid SSL cert-name -./qpid-send -b $URL --connection-options "{ssl-cert-name: pignose }" --content-string=hello -a "baz;{create:always}" 2>/dev/null 1>/dev/null -MSG3=`./qpid-receive -b $URL --connection-options "{ssl-cert-name: pignose }" -a "baz;{create:always}" --messages 1 2>/dev/null` +qpid-send -b $URL --connection-options "{ssl-cert-name: pignose }" --content-string=hello -a "baz;{create:always}" 2>/dev/null 1>/dev/null +MSG3=`qpid-receive -b $URL --connection-options "{ssl-cert-name: pignose }" -a "baz;{create:always}" --messages 1 2>/dev/null` test "$MSG3" = "" || { echo "receive succeeded without valid ssl cert '$MSG3' != ''"; exit 1; } ## Set the userid in the message to the authenticated username @@ -243,8 +245,8 @@ start_ssl_mux_broker $PORT || error "Could not start broker" echo "Running SSL/TCP mux test on fixed port $PORT" ## Test connection via connection settings -./qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary || error "SSL connection failed!" -./qpid-perftest --count ${COUNT} --port ${PORT} -P tcp -b $TEST_HOSTNAME --summary || error "TCP connection failed!" +qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary || error "SSL connection failed!" +qpid-perftest --count ${COUNT} --port ${PORT} -P tcp -b $TEST_HOSTNAME --summary || error "TCP connection failed!" # Test a broker chosen port - since ssl chooses port need to use --transport ssl here start_ssl_broker @@ -252,8 +254,8 @@ PORT=${PORTS[0]} echo "Running SSL/TCP mux test on random port $PORT" ## Test connection via connection settings -./qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary || error "SSL connection failed!" -./qpid-perftest --count ${COUNT} --port ${PORT} -P tcp -b $TEST_HOSTNAME --summary || error "TCP connection failed!" +qpid-perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary || error "SSL connection failed!" +qpid-perftest --count ${COUNT} --port ${PORT} -P tcp -b $TEST_HOSTNAME --summary || error "TCP connection failed!" stop_brokers @@ -271,67 +273,63 @@ if [[ !(-x $OPENSSL) ]] ; then exit 0 fi -if test -d $PYTHON_DIR; then ## verify python version > 2.5 (only 2.6+ does certificate checking) - PY_VERSION=$(python -c "import sys; print hex(sys.hexversion)") - if (( PY_VERSION < 0x02060000 )); then - echo >&2 "Detected python version < 2.6 - skipping certificate verification tests" - exit 0 - fi +PY_VERSION=$(python -c "import sys; print hex(sys.hexversion)") +if (( PY_VERSION < 0x02060000 )); then + echo >&2 "Detected python version < 2.6 - skipping certificate verification tests" + exit 0 +fi - echo "Testing Certificate validation and Authentication with the Python Client..." +echo "Testing Certificate validation and Authentication with the Python Client..." # extract the CA's certificate as a PEM file - get_ca_certs() { - $PK12UTIL -o ${TEST_CERT_DIR}/CA_pk12.out -d ${CERT_DB} -n "Test-CA" -w ${CERT_PW_FILE} -k ${CERT_PW_FILE} > /dev/null - $OPENSSL pkcs12 -in ${TEST_CERT_DIR}/CA_pk12.out -out ${CA_PEM_FILE} -nokeys -passin file:${CERT_PW_FILE} >/dev/null - $PK12UTIL -o ${TEST_CERT_DIR}/other_CA_pk12.out -d ${OTHER_CA_CERT_DB} -n "Other-Test-CA" -w ${CERT_PW_FILE} -k ${CERT_PW_FILE} > /dev/null - $OPENSSL pkcs12 -in ${TEST_CERT_DIR}/other_CA_pk12.out -out ${OTHER_CA_PEM_FILE} -nokeys -passin file:${CERT_PW_FILE} >/dev/null - } +get_ca_certs() { + $PK12UTIL -o ${TEST_CERT_DIR}/CA_pk12.out -d ${CERT_DB} -n "Test-CA" -w ${CERT_PW_FILE} -k ${CERT_PW_FILE} > /dev/null + $OPENSSL pkcs12 -in ${TEST_CERT_DIR}/CA_pk12.out -out ${CA_PEM_FILE} -nokeys -passin file:${CERT_PW_FILE} >/dev/null + $PK12UTIL -o ${TEST_CERT_DIR}/other_CA_pk12.out -d ${OTHER_CA_CERT_DB} -n "Other-Test-CA" -w ${CERT_PW_FILE} -k ${CERT_PW_FILE} > /dev/null + $OPENSSL pkcs12 -in ${TEST_CERT_DIR}/other_CA_pk12.out -out ${OTHER_CA_PEM_FILE} -nokeys -passin file:${CERT_PW_FILE} >/dev/null +} +get_ca_certs || error "Could not extract CA certificates as PEM files" +start_ssl_broker +PORT=${PORTS[0]} +URL=amqps://$TEST_HOSTNAME:$PORT +# verify the python client can authenticate the broker using the CA +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi +# verify the python client fails to authenticate the broker when using the other CA +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${OTHER_CA_PEM_FILE} > /dev/null 2>&1`; then { echo " Failed"; exit 1; }; else echo " Passed"; fi +stop_brokers + +# create a certificate without matching TEST_HOSTNAME, should fail to verify + +create_certs "O=MyCo" "*.${TEST_HOSTNAME}.com" || error "Could not create server test certificate" +get_ca_certs || error "Could not extract CA certificates as PEM files" +start_ssl_broker +PORT=${PORTS[0]} +URL=amqps://$TEST_HOSTNAME:$PORT +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE} > /dev/null 2>&1`; then { echo " Failed"; exit 1; }; else echo " Passed"; fi +# but disabling the check for the hostname should pass +if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE} --ssl-skip-hostname-check`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi +stop_brokers + +# test SubjectAltName parsing + +if (( PY_VERSION >= 0x02070300 )); then +# python 2.7.3+ supports SubjectAltName extraction +# create a certificate with TEST_HOSTNAME only in SAN, should verify OK + create_certs "O=MyCo" "*.foo.com,${TEST_HOSTNAME},*xyz.com" || error "Could not create server test certificate" get_ca_certs || error "Could not extract CA certificates as PEM files" start_ssl_broker PORT=${PORTS[0]} URL=amqps://$TEST_HOSTNAME:$PORT -# verify the python client can authenticate the broker using the CA if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi -# verify the python client fails to authenticate the broker when using the other CA - if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${OTHER_CA_PEM_FILE} > /dev/null 2>&1`; then { echo " Failed"; exit 1; }; else echo " Passed"; fi stop_brokers -# create a certificate without matching TEST_HOSTNAME, should fail to verify - - create_certs "O=MyCo" "*.${TEST_HOSTNAME}.com" || error "Could not create server test certificate" + create_certs "O=MyCo" "*${TEST_HOSTNAME}" || error "Could not create server test certificate" get_ca_certs || error "Could not extract CA certificates as PEM files" start_ssl_broker PORT=${PORTS[0]} URL=amqps://$TEST_HOSTNAME:$PORT - if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE} > /dev/null 2>&1`; then { echo " Failed"; exit 1; }; else echo " Passed"; fi -# but disabling the check for the hostname should pass - if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE} --ssl-skip-hostname-check`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi + if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi stop_brokers - -# test SubjectAltName parsing - - if (( PY_VERSION >= 0x02070300 )); then - # python 2.7.3+ supports SubjectAltName extraction - # create a certificate with TEST_HOSTNAME only in SAN, should verify OK - create_certs "O=MyCo" "*.foo.com,${TEST_HOSTNAME},*xyz.com" || error "Could not create server test certificate" - get_ca_certs || error "Could not extract CA certificates as PEM files" - start_ssl_broker - PORT=${PORTS[0]} - URL=amqps://$TEST_HOSTNAME:$PORT - if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi - stop_brokers - - create_certs "O=MyCo" "*${TEST_HOSTNAME}" || error "Could not create server test certificate" - get_ca_certs || error "Could not extract CA certificates as PEM files" - start_ssl_broker - PORT=${PORTS[0]} - URL=amqps://$TEST_HOSTNAME:$PORT - if `${PY_PING_BROKER} -b $URL --ssl-trustfile=${CA_PEM_FILE}`; then echo " Passed"; else { echo " Failed"; exit 1; }; fi - stop_brokers - fi - fi - diff --git a/qpid/cpp/src/tests/swig_python_tests b/qpid/cpp/src/tests/swig_python_tests deleted file mode 100755 index c28c96e839..0000000000 --- a/qpid/cpp/src/tests/swig_python_tests +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env 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. -# - -# Run the python tests. -source $QPID_TEST_COMMON - -ensure_python_tests - -trap stop_broker INT TERM QUIT - -if [[ -a $AMQP_LIB ]] ; then - echo "Found AMQP support: $AMQP_LIB" - MODULES="--load-module $AMQP_LIB" -fi - -fail() { - echo "FAIL swigged python tests: $1"; exit 1; -} -skip() { - echo "SKIPPED swigged python tests: $1"; exit 0; -} - -start_broker() { - rm -f swig_python_tests.log - cp $srcdir/policy.acl $builddir/policy.acl - QPID_PORT=$($QPIDD_EXEC --daemon --port 0 --interface 127.0.0.1 --no-data-dir $MODULES --auth no --acl-file $builddir/policy.acl --log-to-file swig_python_tests.log) || fail "Could not start broker" -} - -stop_broker() { - $QPIDD_EXEC -q --port $QPID_PORT - rm $builddir/policy.acl -} - -test -f $PYTHONSWIGMODULE || skip "no swigged python client" -test -d $QPID_TESTS || skip "test code not found" - -start_broker -echo "Running swigged python tests using broker on port $QPID_PORT" - -export PYTHONPATH=$PYTHONPATH:$PYTHONPATH_SWIG -export QPID_USE_SWIG_CLIENT=1 -$QPID_PYTHON_TEST -m qpid.tests.messaging.message -m qpid_tests.broker_0_10.priority -m qpid_tests.broker_0_10.lvq -m qpid_tests.broker_0_10.new_api -b localhost:$QPID_PORT -I $srcdir/failing-amqp0-10-python-tests $* || FAILED=1 -if [[ -a $AMQP_LIB ]] ; then - $QPID_PYTHON_TEST --define="protocol_version=amqp1.0" --define="policy_file=$builddir/policy.acl" -m qpid_tests.broker_1_0 -m qpid_tests.broker_0_10.new_api -m assertions -m reject_release -m misc -m policies -m acl_1 -b localhost:$QPID_PORT -I $srcdir/failing-amqp1.0-python-tests $* || FAILED=1 -fi -stop_broker -if [[ $FAILED -eq 1 ]]; then - fail "" -fi - diff --git a/qpid/cpp/src/tests/test.xquery b/qpid/cpp/src/tests/test.xquery deleted file mode 100644 index 4cfe3af02d..0000000000 --- a/qpid/cpp/src/tests/test.xquery +++ /dev/null @@ -1,6 +0,0 @@ - let $w := ./weather - return $w/station = 'Raleigh-Durham International Airport (KRDU)' - and $w/temperature_f > 50 - and $w/temperature_f - $w/dewpoint > 5 - and $w/wind_speed_mph > 7 - and $w/wind_speed_mph < 20 diff --git a/qpid/cpp/src/tests/test_env.ps1.in b/qpid/cpp/src/tests/test_env.ps1.in deleted file mode 100644 index 94834a4b5e..0000000000 --- a/qpid/cpp/src/tests/test_env.ps1.in +++ /dev/null @@ -1,77 +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. -# - -# Environment variables substituted by configure/cmake. -$abs_srcdir="@abs_srcdir@" -$abs_builddir="@abs_builddir@" -$top_srcdir="@abs_top_srcdir@" -$top_builddir="@abs_top_builddir@" -$moduledir="$top_builddir\src@builddir_lib_suffix@" -$testmoduledir="$builddir@builddir_lib_suffix@" -$BOOST_LIBRARYDIR="@BOOST_LIBRARYDIR@" - -# Python paths and directories -$PYTHON_EXE="@PYTHON_EXECUTABLE@" -$PYTHON_DIR="$builddir\python" -$QPID_PYTHON_TEST="$PYTHON_DIR\commands\qpid-python-test" -if ( !(Test-Path "$PYTHON_DIR") -and (Test-Path "$top_srcdir\..\python")) { - $PYTHON_DIR="$top_srcdir\..\python" - $QPID_PYTHON_TEST="$PYTHON_DIR\qpid-python-test" -} -$QPID_TESTS="$top_srcdir\..\tests" -$QPID_TESTS_PY="$QPID_TESTS\src\py" -$QPID_TOOLS="$top_srcdir\..\tools" -$QPID_TOOLS_LIBS="$QPID_TOOLS\src\py" -$QMF_LIB="$top_srcdir\..\extras\qmf\src\py" -$PYTHON_COMMANDS="$QPID_TOOLS\src\py" -$env:PYTHONPATH="$srcdir;$PYTHON_DIR;$PYTHON_COMMANDS;$QPID_TESTS_PY;$QPID_TOOLS_LIBS;$QMF_LIB;$env:PYTHONPATH" -$QPID_CONFIG_EXEC="$PYTHON_COMMANDS\qpid-config" -$QPID_ROUTE_EXEC="$PYTHON_COMMANDS\qpid-route" -$QPID_HA_TOOL_EXEC="$PYTHON_COMMANDS\qpid-ha-tool" - -# Executables -$env:QPIDD_EXEC="$top_builddir\src\@CMAKE_BUILD_TYPE@\qpidd.exe" -$env:QPID_WATCHDOG_EXEC="$top_builddir\src\qpidd_watchdog" - -# Test executables -$QPID_TEST_EXEC_DIR="$builddir\@CMAKE_BUILD_TYPE@" -$RECEIVER_EXEC="$QPID_TEST_EXEC_DIR\receiver" -$SENDER_EXEC="$QPID_TEST_EXEC_DIR\sender" - -# Path -$env:PATH="$top_builddir\src\@CMAKE_BUILD_TYPE@;$builddir\@CMAKE_BUILD_TYPE@;$srcdir;$PYTHON_COMMANDS;$QPID_TEST_EXEC_DIR;@BOOST_LIBRARYDIR@;$env:PATH" - -# Modules -$env:TEST_STORE_LIB="$testmoduledir\test_store.so" - -#exportmodule() { test -f $moduledir/$2 && eval "export $1=$moduledir/$2"; } -#exportmodule ACL_LIB acl.so -#exportmodule CLUSTER_LIB cluster.so -#exportmodule SSLCONNECTOR_LIB sslconnector.so -#exportmodule SSL_LIB ssl.so -#exportmodule WATCHDOG_LIB watchdog.so -#exportmodule XML_LIB xml.so - -# Qpid options -$env:QPID_NO_MODULE_DIR="1" # Don't accidentally load installed modules -$env:QPID_DATA_DIR= # Default to no data dir, not ~/.qpidd - -# Options for boost test framework -$env:BOOST_TEST_SHOW_PROGRESS="yes" -$env:BOOST_TEST_CATCH_SYSTEM_ERRORS="no" diff --git a/qpid/cpp/src/tests/test_env.sh.in b/qpid/cpp/src/tests/test_env.sh.in deleted file mode 100644 index 1c4c117e4b..0000000000 --- a/qpid/cpp/src/tests/test_env.sh.in +++ /dev/null @@ -1,100 +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. -# - -absdir() { echo `cd $1 && pwd`; } - -# Environment variables substituted by cmake. -export srcdir=`absdir @abs_srcdir@` -export builddir=`absdir @abs_builddir@` -export top_srcdir=`absdir @abs_top_srcdir@` -export top_builddir=`absdir @abs_top_builddir@` -export moduledir=$top_builddir/src@builddir_lib_suffix@ -export pythonswigdir=$top_builddir/bindings/qpid/python/ -export pythonswiglibdir=$top_builddir/bindings/qpid/python@builddir_lib_suffix@ -export testmoduledir=$builddir@builddir_lib_suffix@ -export QPID_INSTALL_PREFIX=@prefix@ - -# Tools substituted by cmake -enable_valgrind=${enable_valgrind-@ENABLE_VALGRIND@} -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 -export QPID_PYTHON_TEST=$PYTHON_DIR/commands/qpid-python-test -if [ ! -d $PYTHON_DIR -a -d $top_srcdir/../python ]; then - export PYTHON_DIR=$top_srcdir/../python - export QPID_PYTHON_TEST=$PYTHON_DIR/qpid-python-test -fi -export QPID_TESTS=$top_srcdir/../tests -export QPID_TESTS_PY=$QPID_TESTS/src/py -export QPID_TOOLS=$top_srcdir/../tools -export QMF_LIB=$top_srcdir/../extras/qmf/src/py -export PYTHON_COMMANDS=$QPID_TOOLS/src/py -export PYTHONPATH_SWIG=$pythonswigdir:$pythonswiglibdir -export PYTHONPATH=$srcdir:$PYTHON_DIR:$PYTHON_COMMANDS:$QPID_TESTS_PY:$QMF_LIB:$PYTHONPATH_SWIG:$PYTHONPATH -export QPID_CONFIG_EXEC=$PYTHON_COMMANDS/qpid-config -export QPID_ROUTE_EXEC=$PYTHON_COMMANDS/qpid-route -export QPID_HA_EXEC=$PYTHON_COMMANDS/qpid-ha -export PYTHONSWIGMODULE=$pythonswigdir/qpid_messaging.py -# Executables -export QPIDD_EXEC=$top_builddir/src/qpidd - -# Test executables -export QPID_TEST_EXEC_DIR=$builddir -export QPID_TEST_SRC_DIR=$srcdir -export RECEIVER_EXEC=$QPID_TEST_EXEC_DIR/receiver -export SENDER_EXEC=$QPID_TEST_EXEC_DIR/sender - -# Path -export PATH=$top_builddir/src:$builddir:$srcdir:$PYTHON_COMMANDS:$QPID_TEST_EXEC_DIR:$PYTHON_DIR/commands:$PATH - -# Modules -export TEST_STORE_LIB=$testmoduledir/test_store.so - -exportmodule() { test -f $moduledir/$2 && eval "export $1=$moduledir/$2"; } -exportmodule HA_LIB ha.so -exportmodule XML_LIB xml.so -test "$STORE_LIB" || exportmodule STORE_LIB linearstore.so -test "$STORE_LIB" || exportmodule STORE_LIB legacystore.so -exportmodule AMQP_LIB amqp.so - -# Qpid options -export QPID_NO_MODULE_DIR=1 # Don't accidentally load installed modules -export QPID_DATA_DIR= -export QPID_CONFIG=$srcdir/qpidd-empty.conf - -# Use temporary directory if $HOME does not exist -if [ ! -e "$HOME" ]; then - export QPID_DATA_DIR=/tmp/qpid - export QPID_PID_DIR=/tmp/qpid -fi - -# Options for boost test framework -test -z "$BOOST_TEST_SHOW_PROGRESS" && export BOOST_TEST_SHOW_PROGRESS=yes -test -z "$BOOST_TEST_CATCH_SYSTEM_ERRORS" && export BOOST_TEST_CATCH_SYSTEM_ERRORS=no - -# Source this for useful common testing functions -export QPID_TEST_COMMON=$srcdir/test_env_common.sh - -# Proton configuration -export QPID_PROTON_VERSION=@Proton_VERSION@ diff --git a/qpid/cpp/src/tests/test_env_common.sh b/qpid/cpp/src/tests/test_env_common.sh deleted file mode 100644 index 348664ca76..0000000000 --- a/qpid/cpp/src/tests/test_env_common.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env 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. -# - -# Ensure that we have python testing tools available -function ensure_python_tests { - if [ ! -d ${PYTHON_DIR} ] ; then - echo "Python test code not found: skipping python based test" - exit 0; - fi -} - diff --git a/qpid/cpp/src/tests/topic_perftest b/qpid/cpp/src/tests/topic_perftest deleted file mode 100755 index 04e1cdcffb..0000000000 --- a/qpid/cpp/src/tests/topic_perftest +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env 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. -# - -exec `dirname $0`/run_perftest 10000 --mode topic --qt 16 diff --git a/qpid/cpp/src/tests/topictest b/qpid/cpp/src/tests/topictest index f4c6e7187d..13f38120b3 100755 --- a/qpid/cpp/src/tests/topictest +++ b/qpid/cpp/src/tests/topictest @@ -46,11 +46,11 @@ done subscribe() { echo Start subscriber $1 LOG="subscriber_$1.log" - ./qpid-topic-listener $TRANSACTIONAL > $LOG 2>&1 && rm -f $LOG + qpid-topic-listener $TRANSACTIONAL > $LOG 2>&1 && rm -f $LOG } publish() { - ./qpid-topic-publisher --messages $MESSAGES --batches $BATCHES --subscribers $SUBSCRIBERS $HOST $TRANSACTIONAL + qpid-topic-publisher --messages $MESSAGES --batches $BATCHES --subscribers $SUBSCRIBERS $HOST $TRANSACTIONAL } for ((i=$SUBSCRIBERS ; i--; )); do diff --git a/qpid/cpp/src/tests/vg_check b/qpid/cpp/src/tests/vg_check deleted file mode 100644 index 462f4cb5e4..0000000000 --- a/qpid/cpp/src/tests/vg_check +++ /dev/null @@ -1,43 +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. -# - -# Check for valgrind errors. Sourced by test scripts. - -vg_failed() { - echo "Valgrind error log in $VG_LOG." 1>&2 - cat $VG_LOG 1>&2 - echo $1 1>&2 - exit 1 -} - -vg_check() -{ - test -z "$1" || VG_LOG=$1 - test -f $VG_LOG || vg_failed Valgrind log file $VG_LOG missing. - # Ensure there is an ERROR SUMMARY line. - grep -E '^==[0-9]+== ERROR SUMMARY:' $VG_LOG > /dev/null || \ - vg_failed "No valgrind ERROR SUMMARY line in $VG_LOG." - # Ensure that the number of errors is 0. - grep -E '^==[0-9]+== ERROR SUMMARY: [^0]' $VG_LOG > /dev/null && \ - vg_failed "Valgrind reported errors in $VG_LOG; see above." - # Check for leaks. - grep -E '^==[0-9]+== +.* lost: [^0]' $VG_LOG && \ - vg_failed "Found memory leaks (see log file, $VG_LOG); see above." - true -} -- cgit v1.2.1