diff options
| author | Stephen D. Huston <shuston@apache.org> | 2010-04-19 19:18:32 +0000 |
|---|---|---|
| committer | Stephen D. Huston <shuston@apache.org> | 2010-04-19 19:18:32 +0000 |
| commit | f79c211abba8839cb363279c3b0152a64e79a9a7 (patch) | |
| tree | 404f0da0aa08d55d9c74215ac6ddb3845ce11cbe /cpp | |
| parent | 28988707799e2f5a0efe08ea9094e91d61f95ec7 (diff) | |
| download | qpid-python-f79c211abba8839cb363279c3b0152a64e79a9a7.tar.gz | |
Add store test executions if building the store module. Add trigger on messageMap table deletes to remove orphaned messages from message table; part of QPID-2420.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@935710 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
| -rw-r--r-- | cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp | 16 | ||||
| -rw-r--r-- | cpp/src/tests/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | cpp/src/tests/run_store_tests.ps1 | 101 |
3 files changed, 120 insertions, 0 deletions
diff --git a/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp b/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp index 323bc94c5c..bc3584dd57 100644 --- a/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp +++ b/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp @@ -1203,6 +1203,20 @@ MSSqlProvider::createDb(DatabaseConnection *db, const std::string &name) " xid varbinary(512) REFERENCES tblTPL(xid)" " CONSTRAINT CK_NoDups UNIQUE NONCLUSTERED (messageId, queueId) )"; const std::string tplSpecs = " (xid varbinary(512) PRIMARY KEY NOT NULL)"; + // SET NOCOUNT ON added to prevent extra result sets from + // interfering with SELECT statements. (Added by SQL Management) + const std::string removeUnrefMsgsTrigger = + "CREATE TRIGGER dbo.RemoveUnreferencedMessages " + "ON tblMessageMap AFTER DELETE AS BEGIN " + "SET NOCOUNT ON; " + "DELETE FROM tblMessage " + "WHERE tblMessage.persistenceId IN " + " (SELECT messageId FROM deleted) AND" + " NOT EXISTS(SELECT * FROM tblMessageMap" + " WHERE tblMessageMap.messageId IN" + " (SELECT messageId FROM deleted)) " + "END"; + _variant_t unused; _bstr_t dbStr = dbCmd.c_str(); _ConnectionPtr conn(*db); @@ -1231,6 +1245,8 @@ MSSqlProvider::createDb(DatabaseConnection *db, const std::string &name) makeTable = tableCmd + TblMessageMap + messageMapSpecs; makeTableStr = makeTable.c_str(); conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + _bstr_t addTriggerStr = removeUnrefMsgsTrigger.c_str(); + conn->Execute(addTriggerStr, &unused, adExecuteNoRecords); } catch(_com_error &e) { throw ADOException("MSSQL can't create " + name, e, db->getErrors()); diff --git a/cpp/src/tests/CMakeLists.txt b/cpp/src/tests/CMakeLists.txt index 93897c0ca1..60339123fb 100644 --- a/cpp/src/tests/CMakeLists.txt +++ b/cpp/src/tests/CMakeLists.txt @@ -300,6 +300,9 @@ if (PYTHON_EXECUTABLE) if (BUILD_ACL) add_test (acl_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_acl_tests${test_script_suffix}) endif (BUILD_ACL) +if (BUILD_MSSQL) + add_test (store_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix}) +endif (BUILD_MSSQL) endif (PYTHON_EXECUTABLE) add_library(test_store MODULE test_store.cpp) diff --git a/cpp/src/tests/run_store_tests.ps1 b/cpp/src/tests/run_store_tests.ps1 new file mode 100644 index 0000000000..f4d43a57f7 --- /dev/null +++ b/cpp/src/tests/run_store_tests.ps1 @@ -0,0 +1,101 @@ +# +# 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 store tests. +# There are two sets of tests: +# 1. A subset of the normal broker python tests, dtx and persistence, but +# run again with the SQL store loaded. +# 2. store.py, which tests recovering things across broker restarts. + +$srcdir = Split-Path $myInvocation.InvocationName +$PYTHON_DIR = "$srcdir\..\..\..\python" +if (!(Test-Path $PYTHON_DIR -pathType Container)) { + "Skipping store tests as python libs not found" + exit 1 +} + +# 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 +} + +# The store to test is the same build type as the broker. +$store_dir = "..\qpid\store\$sub" +if (!([string]::Compare($sub, "Debug", $True))) { + $suffix = "d" +} + +$FAILCODE = 0 + +# Test 1... re-run some of the regular python broker tests against a broker +# with the store module loaded. +$stamp = Get-Date -format %dMMMyyyy_HHmmss +$catalog = "broker_test_$stamp" +$cmdline = "$prog --auth=no --port=0 --log-to-file qpidd-store.log --module-dir $store_dir --catalog $catalog | foreach { set-content qpidd-store.port `$_ }" +$cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline) +. $srcdir\background.ps1 $cmdblock + +$wait_time = 0 +while (!(Test-Path qpidd-store.port) -and ($wait_time -lt 10)) { + Start-Sleep 2 + $wait_time += 2 +} +if (!(Test-Path qpidd-store.port)) { + "Time out waiting for broker to start" + exit 1 +} +set-item -path env:QPID_PORT -value (get-content -path qpidd-store.port -totalcount 1) +Remove-Item qpidd-store.port +$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py\qpid_tests\broker_0_10" +$env:PYTHONPATH="$PYTHON_DIR;$PYTHON_TEST_DIR;$env:PYTHONPATH" +python $PYTHON_DIR/qpid-python-test -m dtx -m persistence -b localhost:$env:QPID_PORT $fails $tests +$RETCODE=$LASTEXITCODE +if ($RETCODE -ne 0) { + $FAILCODE = 1 +} +# Piping the output makes the script wait for qpidd to finish. +Invoke-Expression "$prog --quit --port $env:QPID_PORT" | Write-Output + + +# Test 2... store.py starts/stops/restarts its own brokers + +# This only works with the brokertest.py changes made by Steve - see QPID-2492. +#$tests = "*" +#$env:PYTHONPATH="$PYTHON_DIR;$srcdir" +#$env:QPIDD_EXEC="$prog" +#$env:STORE_LIB="$store_dir\store$suffix.dll" +#$env:STORE_SQL_LIB="$store_dir\mssql_store$suffix.dll" +#$env:STORE_CATALOG="store_recovery_test_$stamp" +#Invoke-Expression "python $PYTHON_DIR/qpid-python-test -m store $tests" | Out-Default +#$RETCODE=$LASTEXITCODE +#if ($RETCODE -ne 0) { +# "FAIL store tests" +# $FAILCODE = 1 +#} +exit $FAILCODE |
