update volume=vol58 pool=Test volstatus=Recycle
purge volume=vol57
update volume=vol56 pool=Test
-update volume=vol55 pool=Test volstatus=Full volretention=15
+update volume=vol55 pool=Test volstatus=Full
update volume=vol46 volstatus=Full volretention=15
purge volume=vol46
update volume=vol46 pool=Test
update Media SET LastWritten='2006-01-01 01:00:00';
update Media SET LastWritten='2006-01-01 01:00:01' WHERE VolumeName='vol57';
update Media SET LastWritten='2006-01-01 01:00:02' WHERE VolumeName='vol53';
+
list volume
EOF
dstat=$?
+
+# so some tests with File media
+cat <<EOF > ${cwd}/tmp/bconcmds
+@$out ${cwd}/tmp/log3.out
+label volume=file1 storage=File pool=Test
+label volume=file2 storage=File pool=Test
+label volume=file3 storage=File pool=Test
+label volume=file4 storage=File pool=Scratch
+label volume=file5 storage=File pool=Test
+label volume=file6 storage=File pool=Test
+label volume=file7 storage=File pool=Scratch
+label volume=file8 storage=File pool=Test
+label volume=file9 storage=File pool=Scratch
+label volume=file10 storage=File pool=Scratch
+label volume=file11 storage=File pool=Test
+update volume=file2 enabled=no
+update volume=file3 volstatus=Recycle
+@# volstatus=Purged
+purge volume=file4
+update volume=file5 recycle=no volretention=1
+update volume=file6 volstatus=Full volretention=15
+update volume=file7 volstatus=Full volretention=15
+purge volume=file7
+update volume=file8 pool=Test VolRetention=1
+update volume=file9 volstatus=Recycle
+purge volume=file11
+sql
+update Media SET VolJobs=1 WHERE VolumeName='file9';
+update Media SET LastWritten='2006-01-01 01:00:00';
+update Media SET LastWritten='2006-01-01 01:00:01' WHERE VolumeName='file4';
+update Media SET LastWritten='2006-01-01 01:00:02' WHERE VolumeName='file7';
+
+messages
+@$out ${cwd}/tmp/log4.out
+list volume
+messages
+@# Must choose file1
+@# Pool + Append + Lowest MediaId
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file5
+@# Pool + Append + Lowest MediaId (only once)
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file8
+@# Pool + Append + Lowest MediaId
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file3
+@# Pool + Recycle
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file11
+@# Pool + Purged
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file6
+@# Pool + Full (prunable)
+setdebug level=50 director
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+setdebug level=0 director
+list volume
+@sleep 5
+@# Must choose file8
+@# Pool + Full (prunable)
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+update volume=file8 enabled=no
+list volume
+@# Must choose file10
+@# (no more Pool) Scratch + Append
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file9
+@# (no more Pool) Scratch + Recycle
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@sleep 10
+@# Must choose file6
+@# Used (prunable) + Pool
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file4
+@# Used (prunable) + oldest + Scratch
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+@# Must choose file7
+@# Used (prunable) + oldest + Scratch
+run level=full pool=Test storage=File NightlySave yes
+wait
+message
+list volume
+quit
+EOF
+
+run_bconsole
+
+awk '/Must choose/ { print $4 } ' tmp/log4.out > tmp/normal4
+awk '/Volume name.+:/ { print $3 } ' tmp/log4.out > tmp/real4
+if [ "$debug" -eq 1 ]; then
+ diff -ur tmp/normal4 tmp/real4
+else
+ diff tmp/normal4 tmp/real4 > /dev/null
+fi
+
+dstat=`expr $? + $dstat`
+
# try to break the old code
# in this situation, we have 1 available volume (vol50) and bacula will try to use
# vol47, vol48 and vol49 and will stop without using vol50.