From 5c5a616c76064885d2f2673d11f90292aa62d188 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 8 Dec 2010 09:55:42 +0100 Subject: [PATCH] regress: Add test that mixes mssql and systemstate --- regress/scripts/reboot_win32 | 23 +++ regress/tests/win32-mssql-systemstate-test | 186 +++++++++++++++++++++ 2 files changed, 209 insertions(+) create mode 100755 regress/scripts/reboot_win32 create mode 100755 regress/tests/win32-mssql-systemstate-test diff --git a/regress/scripts/reboot_win32 b/regress/scripts/reboot_win32 new file mode 100755 index 0000000000..4dacee8b02 --- /dev/null +++ b/regress/scripts/reboot_win32 @@ -0,0 +1,23 @@ +#!/bin/sh + +. scripts/functions + +URL=http://$WIN32_ADDR:8091 +wget -qO $tmp/start.log "$URL/reboot" + +# we need a way to start the regress-win32.pl at the start +while ! ping -c 1 $WIN32_ADDR > /dev/null; do + sleep 5 +done +echo "Machine $URL supposedly rebooted" + +echo "If the autologon doesn't work, you can double click on c:\\autologon.reg" +i=0 +while ! wget -qO /dev/null $URL/nop; do + sleep 5 + i=`expr $i + 1` + if [ $i -ge 12 ]; then # print message every minute + i=0 + echo "== `date +%T` Waiting for reboot and autologin to $URL, you can also login and start regress-win32.pl by hand" + fi +done diff --git a/regress/tests/win32-mssql-systemstate-test b/regress/tests/win32-mssql-systemstate-test new file mode 100755 index 0000000000..6c57619ba5 --- /dev/null +++ b/regress/tests/win32-mssql-systemstate-test @@ -0,0 +1,186 @@ +#!/bin/sh +# +# How to use this test +# -------------------- +# +# * Get a working Windows OS on your network +# * Install strawberry perl version with msi to c:/strawberry +# http://www.bacula.org/downloads/depkgs-mingw32/strawberry-perl-5.10.1.0.msi +# * Install the latest version of Bacula FD +# * Make accessible (Network share, VirtualBox share) +# regress/scripts/regress-win32.pl +# * Execute the script on the Windows box +# perl regress-win32.pl +# * Run this script with the proper config settings about WIN32 +# see win32-fd-test +# +# * Install MSSQL with default options, put database username in config +# WIN32_MSSQL_USER=sa +# WIN32_MSSQL_PASS=password +# +# Note, once everything is setup, and you have run the above once +# you can simply run the first part of this script prior to the URL= +# to get the proper conf files loaded in bin, then manually +# start bacula, and run the "SS_SQLJob" backup job, then +# restore it. +# +TestName="win32-mssql-systemstate-test" +. scripts/functions + +scripts/cleanup +scripts/copy-test-confs +cp scripts/win32-bacula-dir-systemstate.conf bin/bacula-dir.conf + +scripts/setup_win32 + +URL=http://$WIN32_ADDR:8091 + +wget -qO - "$URL/check_mssql?user=$WIN32_MSSQL_USER;pass=$WIN32_MSSQL_PASS" | grep OK > /dev/null +if [ $? != 0 ]; then + echo "check_msql user=$WIN32_MSSQL_USER pass=$WIN32_MSSQL_PASS failed" +fi +wget -qO - "$URL/setup_mssql_db?db=db$$" | grep OK > /dev/null +if [ $? != 0 ]; then + echo "setup_db failed" +fi + +wget -qO - "$URL/add_registry_key?key=Test$$;val=Val$$" | grep OK > /dev/null +if [ $? != 0 ]; then + print_debug "ERROR: Can't add registry key Test$$" +fi +wget -qO - "$URL/add_registry_key?key=RemovedAtRestore$$;val=Val$$" | grep OK > /dev/null +if [ $? != 0 ]; then + print_debug "ERROR: Can't add registry key RemovedAtRestore$$" +fi + +echo "Start test" +start_test + +cat <${cwd}/tmp/bconcmds +@output +messages +@$out ${cwd}/tmp/log1.out +status client=$WIN32_CLIENT +label storage=File volume=TestVolume001 +run job=SS_SQLJob storage=File yes +wait +messages +quit +END_OF_DATA + +run_bacula + +wget -qO - "$URL/del_registry_key?key=RemovedAtRestore$$" | grep OK > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: can't remove key RemovedAtRestore$$ from registry" + estat=1 +fi + +cat <${cwd}/tmp/bconcmds +@output +@$out ${cwd}/tmp/log1.out +run job=SS_SQLJob storage=File yes +wait +messages +quit +END_OF_DATA + +run_bconsole + +wget -qO - "$URL/del_registry_key?key=Test$$" | grep OK > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: can't remove key Test$$ from registry" + estat=1 +fi + +wget -qO - "$URL/cleanup_mssql_db?db=db$$" | grep OK > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: can't remove mssql db$$" + estat=1 +fi + +# the restore contains the name of the SQLServer instance +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log3.out +restore where=/ storage=File +5 +cd @MSSQL/ +cd SqlServerWriter/ +cd MSDEWriter/ +@$out ${cwd}/tmp/host.out +ls +@$out ${cwd}/tmp/log3.out +quit +quit +END_OF_DATA + +run_bconsole + +host=`head -2 ${cwd}/tmp/host.out | tail -1` + +cat <${cwd}/tmp/bconcmds +@# +@# now do a restore +@# +@$out ${cwd}/tmp/log2.out +restore where=/ storage=File +5 +cd @SYSTEMSTATE/ +mark Reg* +cd .. +cd @MSSQL/ +cd SqlServerWriter/ +cd MSDEWriter/ +cd $host +m db$$ +done +yes +wait +messages +quit +END_OF_DATA + +run_bconsole + +check_for_zombie_jobs storage=File +stop_bacula + +check_two_logs + +# with SQL 2005, the db is mounted automatically +wget -qO - "$URL/test_mssql_content?db=db$$" | grep OK > /dev/null +if [ $? -ne 0 ]; then + + wget -qO - "$URL/online_mssql_db?mdf=db$$;db=restoredb$$" | grep OK > /dev/null + if [ $? -ne 0 ]; then + print_debug "ERROR: can't put db$$ online" + estat=1 + fi + + wget -qO - "$URL/test_mssql_content?db=restoredb$$" | grep OK > /dev/null + if [ $? -ne 0 ]; then + print_debug "ERROR: can't get content of restoredb$$" + estat=1 + fi + + wget -qO $tmp/cleanup.log "$URL/cleanup_mssql_db?db=restoredb$$" + +else + wget -qO $tmp/cleanup.log "$URL/cleanup_mssql_db?db=db$$" +fi + +scripts/reboot_win32 + +wget -qO - "$URL/get_registry_key?key=RemovedAtRestore$$;val=Val$$" | grep ERR > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Should not find registry key RemovedAtRestore$$" + estat=1 +fi + +wget -qO - "$URL/get_registry_key?key=Test$$;val=Val$$" | grep OK > /dev/null +if [ $? -ne 0 ]; then + print_debug "ERROR: Can't find registry key Test$$" + estat=1 +fi + +end_test -- 2.39.5