]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/speed-test
regress: test restore object in plugin-test
[bacula/bacula] / regress / tests / speed-test
index a454b28fae78385aa53cf9af849fedc0d6a1e3aa..aad96bc28fa7efe12be09be9c5495aed2e3f905a 100755 (executable)
@@ -3,56 +3,49 @@
 # Run a big test with backup of millions of files then run 100 incremental
 # modifying 10% each time
 #
+# Can use following env variables
+# ACCURATE=yes
+# BASEJOB=yes
+# NB_CONCURENT=4
+# NB_FULL=25
+# NB_INCR=25
+# NB_FILES=750000
+
 TestName="speed-test"
 JobName=speed 
 . scripts/functions
 
 ${rscripts}/cleanup
 ${rscripts}/copy-test-confs
+sed 's/Max Run Time/#Max Run Time/' $conf/bacula-dir.conf > $tmp/1
+sed 's/SpoolData/#SpoolData/' $tmp/1 > $conf/bacula-dir.conf
+
 echo "${cwd}/files" >${tmp}/file-list
 rm -rf ${tmp}/bacula-restores
 mkdir -p $cwd/files
 
 change_jobname CompressedTest $JobName
-if echo $* | grep accurate >/dev/null; then
+if [ a$ACCURATE != a ]; then
   sed 's/Name = "speed"/Name = "speed"; accurate=yes/' $conf/bacula-dir.conf > $tmp/1
   mv $tmp/1 $conf/bacula-dir.conf
 fi
 
-if echo $* | grep basejob >/dev/null; then
+if [ a$BASEJOB != a ]; then
   sed 's/Name = "speed"/Name = "speed"; accurate=yes;basejob=speed/' $conf/bacula-dir.conf > $tmp/1
   mv $tmp/1 $conf/bacula-dir.conf
   basejob="level=base"
 fi
 
+NB_CONCURENT=${NB_CONCURENT:-1}
+NB_FULL=${NB_FULL:-20}
+NB_INCR=${NB_INCR:-25}
+NB_FILES=${NB_FILES:-750000}
+
 start_test
 
 # Create X million of files 
-echo "Creating 1.5M files"
-perl -e '
-my $dest="'$cwd/files'";
-my $base;
-mkdir $dest;
-$base = chr(1450000 % 26 + 65);
-if (-f "$dest/$base/aaa1450000aaa$base") {
-  exit 0;
-}
-$| = 1;
-for(my $i=0; $i < 26; $i++) {
- $base = chr($i + 65);
-  mkdir("$dest/$base") or die "$dest/$base $!";
-}
-for(my $i=0; $i<=1500000; $i++) {
- $base = chr($i % 26 + 65);
- open(FP, ">$dest/$base/aaa${i}aaa$base") or die "$dest/$base $!";
- print FP "$i\n";
- close(FP);
-
- mkdir "$dest/$base/$base$i$base" if (!($i % 100));
- print "." if (!($i % 10000));
-}
-print "\n";
-'
+echo "Creating $NB_FILES files"
+perl -Mscripts::functions -e "create_many_files('$cwd/files', $NB_FILES);"
 
 cat <<END_OF_DATA >${tmp}/bconcmds
 @$out /dev/null
@@ -72,47 +65,36 @@ cat <<END_OF_DATA >${tmp}/bconcmds
 @$out /dev/null
 messages
 @$out ${tmp}/log1.out
-run job=$JobName level=Full yes
-wait
-messages
-quit
 END_OF_DATA
 
-# insert 15 million files into File table
-for i in $(seq 0 10)
+for j in $(seq 1 $NB_CONCURENT)
 do
- run_bconsole
+    cat <<EOF >>${tmp}/bconcmds
+@sleep 5
+run job=$JobName level=Full yes
+EOF
 done
 
-cat <<END_OF_DATA >${tmp}/bconcmds
-@$out /dev/null
-messages
-@$out ${tmp}/log1.out
-run job=$JobName level=Incremental yes
+cat <<EOF >>${tmp}/bconcmds
 wait
 messages
 quit
-END_OF_DATA
-
+EOF
 
-for i in $(seq 0 25)
+# insert X million files into File table
+for i in $(seq 0 $NB_FULL)
 do
+    run_bconsole
+done
 
-perl -e '
-my $dest="'$cwd/files'";
-my $start="'$i'";
-my $base = chr($start + 65);
-
-opendir(DIR, "$dest/$base") || die "$!";
-map {
- open(FP, ">$dest/$base/$_") or die "$_ $!";
- print FP "update $_\n";
- close(FP);
-} grep { ! /^\./ && -f $_ } readdir(DIR);
-closedir DIR;
-'
-run_bconsole
+# Now, run many incremental
+sed 's/Full/Incremental/' ${tmp}/bconcmds > $tmp/1
+mv $tmp/1 ${tmp}/bconcmds
 
+for i in $(seq 0 $NB_INCR)
+do
+    perl -Mscripts::functions -e "update_some_files('$cwd/files/'.chr($i+65));"
+    run_bconsole
 done
 
 cat <<END_OF_DATA >${tmp}/bconcmds
@@ -140,6 +122,16 @@ check_two_logs
 #rm -rf ${tmp}/files
 
 find ${tmp}/bacula-restores | wc -l | tee $tmp/bacula-restore-list
-
 rm -rf ${tmp}/bacula-restores
+
+# check the time needed to compute restore list
+if [ x$db_password != x ]; then
+   p="-P $db_password"
+fi
+(time $src/src/tools/bbatch -r 1 -n $db_name -u $db_user $p -w $tmp) >> $working/log 2>&1
+
+cp $working/log files/log${WHICHDB}-$(date +%F_%H-%M).log
+cp $tmp/log2.out files/log2${WHICHDB}-$(date +%F_%H-%M).log
+
+
 end_test