1#!/bin/sh
2#
3# Run a backup of generated data and check if the hard quota limits are respected
4#
5#
6TestName="quota-hardquota-test"
7JobName=BackupClient1
8. scripts/functions
9
10scripts/cleanup
11scripts/copy-test-confs
12
13rm -f bin/bareos-dir.conf
14/bin/cp -f ${rconfigs}/${TestName}/bareos-dir.conf.quota-hardquota-test bin/bareos-dir.conf
15
16# create test data
17dd if=/dev/zero of=${cwd}/tmp/testdata bs=40000k count=1 >/dev/null
18
19echo "${cwd}/tmp/testdata" >${cwd}/tmp/file-list
20start_test
21
22
23
24#@$out /dev/null
25cat >${cwd}/tmp/bconcmds <<END_OF_DATA
26messages
27label storage=File volume=TestVolume001
28@$out ${cwd}/tmp/log1.out
29run job=$JobName Level=Full yes
30wait
31messages
32@$out ${cwd}/tmp/log2.out
33run job=$JobName Level=Full yes
34wait
35messages
36
37delete job jobid=1 yes
38delete job jobid=2 yes
39
40@$out ${cwd}/tmp/log3.out
41run job=$JobName Level=Full yes
42wait
43messages
44@$out ${cwd}/tmp/log4.out
45run job=$JobName Level=Full yes
46wait
47messages
48
49END_OF_DATA
50
51
52run_bareos
53check_for_zombie_jobs storage=File
54stop_bareos
55
56
57
58# check if job1 is successful
59grep "^  Termination: *Backup OK" ${tmp}/log1.out 2>&1 >/dev/null
60if test $? -eq 0; then
61   print_debug "Check for Hardquota: First Backup is OK."
62else
63   estat=1
64fi
65#
66
67
68# check if job2 gets a over quota warning
69grep "Quota Exceeded" ${tmp}/log2.out 2>&1 >/dev/null
70if test $? -eq 0; then
71   print_debug "'Quota Exceeded.' warning found. OK"
72else
73   estat=2
74fi
75# check if job is no successful
76grep "^  Termination: .*Backup Error " ${tmp}/log2.out 2>&1 >/dev/null
77if test $? -eq 0; then
78   print_debug "Check for Hardquota: Backup Error is OK."
79else
80   estat=3
81fi
82
83
84
85# check if job is successful again
86grep  "Termination.*Backup OK" ${tmp}/log3.out 2>&1 >/dev/null
87if test $? -eq 0; then
88   print_debug "Check for Hardquota: First Backup is OK."
89else
90   estat=4
91fi
92#
93
94# check if job gets a over quota warning
95grep "Quota Exceeded" ${tmp}/log4.out 2>&1 >/dev/null
96if test $? -eq 0; then
97   print_debug "'Quota Exceeded.' warning found. OK."
98else
99   estat=5
100fi
101# check if job is successful
102grep "^  Termination: .*Backup Error " ${tmp}/log4.out 2>&1 >/dev/null
103if test $? -eq 0; then
104   print_debug "Check for Hardquota: Backup Error is OK."
105else
106   estat=6
107fi
108
109
110
111end_test
112