diff options
Diffstat (limited to 'qpid/cpp/src/tests/run_federation_tests.ps1')
-rw-r--r-- | qpid/cpp/src/tests/run_federation_tests.ps1 | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/qpid/cpp/src/tests/run_federation_tests.ps1 b/qpid/cpp/src/tests/run_federation_tests.ps1 index db3dbf5a11..dd0ea2fe5b 100644 --- a/qpid/cpp/src/tests/run_federation_tests.ps1 +++ b/qpid/cpp/src/tests/run_federation_tests.ps1 @@ -18,42 +18,63 @@ # # Run the federation tests. -$srcdir = Split-Path $myInvocation.ScriptName -$PYTHON_DIR = $srcdir\..\..\..\python -trap stop_brokers INT TERM QUIT +$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 +} -start_brokers() { +# Test runs from the tests directory but the broker executable is one level +# up, and most likely in a subdirectory from there based on what build type. +# Look around for it before trying to start it. +$subs = "Debug","Release","MinSizeRel","RelWithDebInfo" +foreach ($sub in $subs) { + $prog = "..\$sub\qpidd.exe" + if (Test-Path $prog) { + break + } +} +if (!(Test-Path $prog)) { + "Cannot locate qpidd.exe" + exit 1 +} +$cmdline = "$prog --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $args | foreach { set-content qpidd.port `$_ }" +$cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline) + +function start_brokers { # Start 2 brokers, saving the port numbers in LOCAL_PORT, REMOTE_PORT. - . $srcdir\background.ps1 { - ..\Debug\qpidd --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $args | foreach { set-content qpidd.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 { - ..\Debug\qpidd --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $args | foreach { set-content 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) } -stop_brokers() { - ..\Debug\qpidd -q --port $LOCAL_PORT | Out-Default - ..\Debug\qpidd -q --port $REMOTE_PORT | Out-Default +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 } -if (Test-Path $PYTHON_DIR -pathType Container) { - start_brokers - "Running federation tests using brokers on ports $LOCAL_PORT $REMOTE_PORT" - $env:PYTHONPATH=$PYTHON_DIR - $srcdir/federation.py -v -s $srcdir\..\..\..\specs\amqp.0-10-qpid-errata.xml -b localhost:$LOCAL_PORT --remote-port $REMOTE_PORT $args - $RETCODE=$LASTEXITCODE - stop_brokers - if ($RETCODE != 0) { - "FAIL federation tests" - exit 1 - } +&start_brokers +"Running federation tests using brokers on ports $env:LOCAL_PORT $env:REMOTE_PORT" +$env:PYTHONPATH=$PYTHON_DIR +python $srcdir/federation.py -v -s $srcdir\..\..\..\specs\amqp.0-10-qpid-errata.xml -b localhost:$env:LOCAL_PORT --remote-port $env:REMOTE_PORT $args +$RETCODE=$LASTEXITCODE +&stop_brokers +if ($RETCODE -ne 0) { + "FAIL federation tests" + exit 1 } |