~ubuntu-branches/ubuntu/utopic/pacemaker/utopic-proposed

« back to all changes in this revision

Viewing changes to tools/regression.sh

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-07-16 16:40:24 UTC
  • mfrom: (1.1.11) (2.2.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130716164024-lvwrf4xivk1wdr3c
Tags: 1.1.9+git20130321-1ubuntu1
* Resync from debian expiremental.
* debian/control:
  - Use lower version for Build-Depends on libcorosync-dev
    and libqb-dev.
  - Build-Depends on libcfg-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    target=$1; shift
12
12
    app=$1; shift
13
13
    msg=$1; shift
14
 
    exit_code=$1; shift
 
14
    cib=$1; shift
15
15
 
16
 
    cibadmin -Q
 
16
    if [ x$cib = x0 ]; then
 
17
        : nothing
 
18
    else
 
19
        cibadmin -Q
 
20
    fi
17
21
 
18
22
    if [ $rc -ne $target ]; then
19
23
        num_errors=`expr $num_errors + 1`
20
24
        printf "* Failed (rc=%.3d): %-14s - %s\n" $rc $app "$msg"
21
 
        if [ ! -z $exit_code ]; then
22
 
            echo "Aborting tests"
23
 
            exit $exit_code
24
 
        fi
 
25
        printf "* Failed (rc=%.3d): %-14s - %s\n" $rc $app "$msg" 1>&2
 
26
        return
25
27
        exit 1
26
28
    else
27
29
        printf "* Passed: %-14s - %s\n" $app "$msg"
 
30
        printf "* Passed: %-14s - %s\n" $app "$msg" 1>&2
 
31
 
28
32
        num_passed=`expr $num_passed + 1`
29
33
    fi
30
34
}
60
64
 
61
65
function test_tools() {
62
66
    export CIB_shadow_dir=$test_home
63
 
    $VALGRIND_CMD crm_shadow --batch --force --create-empty $shadow
 
67
    $VALGRIND_CMD crm_shadow --batch --force --create-empty $shadow  2>&1
64
68
    export CIB_shadow=$shadow
65
 
    $VALGRIND_CMD cibadmin -Q
 
69
    $VALGRIND_CMD cibadmin -Q 2>&1
66
70
    
67
 
    $VALGRIND_CMD cibadmin -E 
68
 
    assert $? 1 cibadmin "Require --force for CIB erasure"
 
71
    $VALGRIND_CMD cibadmin -E 2>&1
 
72
    assert $? 22 cibadmin "Require --force for CIB erasure"
69
73
    
70
74
    $VALGRIND_CMD cibadmin -E --force
71
75
    assert $? 0 cibadmin "Allow CIB erasure with --force"
85
89
    $VALGRIND_CMD cibadmin -D -o crm_config --xml-text '<nvpair id="cib-bootstrap-options-cluster-delay"/>'
86
90
    assert $? 0 cibadmin "Delete nvpair"
87
91
    
88
 
    $VALGRIND_CMD cibadmin -C -o crm_config --xml-file /tmp/$$.opt.xml 
89
 
    assert $? 21 cibadmin "Create operaton should fail with: -21, The object already exists"
 
92
    $VALGRIND_CMD cibadmin -C -o crm_config --xml-file /tmp/$$.opt.xml 2>&1
 
93
    assert $? 76 cibadmin "Create operaton should fail with: -76, The object already exists"
90
94
    
91
95
    $VALGRIND_CMD cibadmin -M -o crm_config --xml-file /tmp/$$.opt.xml
92
96
    assert $? 0 cibadmin "Modify cluster options section"
98
102
    assert $? 0 crm_attribute "Set duplicate cluster option"
99
103
    
100
104
    $VALGRIND_CMD crm_attribute -n cluster-delay -v 30s 
101
 
    assert $? 216 crm_attribute "Setting multiply defined cluster option should fail with -216, Could not set cluster option"
 
105
    assert $? 234 crm_attribute "Setting multiply defined cluster option should fail with -216, Could not set cluster option"
102
106
    
103
107
    $VALGRIND_CMD crm_attribute -n cluster-delay -v 30s -s duplicate
104
108
    assert $? 0 crm_attribute "Set cluster option with -s"
122
126
    assert $? 0 cibadmin "Digest calculation"
123
127
    
124
128
    # This update will fail because it has version numbers
125
 
    $VALGRIND_CMD cibadmin -R --xml-file /tmp/$$.existing.xml
126
 
    assert $? 45 cibadmin "Replace operation should fail with: -45, Update was older than existing configuration"
 
129
    $VALGRIND_CMD cibadmin -R --xml-file /tmp/$$.existing.xml 2>&1
 
130
    assert $? 237 cibadmin "Replace operation should fail with: -45, Update was older than existing configuration"
127
131
 
128
132
    crm_standby -N clusterNode-UNAME -G
129
133
    assert $? 0 crm_standby "Default standby value"
131
135
    crm_standby -N clusterNode-UNAME -v true
132
136
    assert $? 0 crm_standby "Set standby status"
133
137
 
134
 
    crm_standby -N clusterNode-UNAME -G
 
138
    crm_standby -N clusterNode-UNAME -G 
135
139
    assert $? 0 crm_standby "Query standby value"
136
140
    
137
 
    crm_standby -N clusterNode-UNAME -D
 
141
    crm_standby -N clusterNode-UNAME -D 2>&1
138
142
    assert $? 0 crm_standby "Delete standby value"
139
143
    
140
144
    $VALGRIND_CMD cibadmin -C -o resources --xml-text '<primitive id="dummy" class="ocf" provider="pacemaker" type="Dummy"/>'
155
159
    $VALGRIND_CMD crm_resource -L
156
160
    assert $? 0 crm_resource "List the configured resources"
157
161
 
158
 
    crm_failcount -r dummy -v 10 -N clusterNode-UNAME
 
162
    crm_failcount -r dummy -v 10 -N clusterNode-UNAME 2>&1
159
163
    assert $? 0 crm_resource "Set a resource's fail-count"
160
164
 
161
 
    $VALGRIND_CMD crm_resource -r dummy -M
162
 
    assert $? 244 crm_resource "Require a destination when migrating a resource that is stopped"
 
165
    $VALGRIND_CMD crm_resource -r dummy -M 2>&1
 
166
    assert $? 234 crm_resource "Require a destination when migrating a resource that is stopped"
163
167
 
164
 
    $VALGRIND_CMD crm_resource -r dummy -M -N i.dont.exist
165
 
    assert $? 234 crm_resource "Don't support migration to non-existant locations"
 
168
    $VALGRIND_CMD crm_resource -r dummy -M -N i.dont.exist 2>&1
 
169
    assert $? 250 crm_resource "Don't support migration to non-existant locations"
166
170
 
167
171
    $VALGRIND_CMD crm_resource -r dummy -M -N clusterNode-UNAME
168
172
    assert $? 0 crm_resource "Migrate a resource"
195
199
    assert $? 0 crm_ticket "Delete ticket standby state"
196
200
 }
197
201
 
198
 
test_tools 2>&1 | sed s/cib-last-written.*\>/\>/ > $test_home/regression.out
199
 
rc=$?
 
202
function test_date() {
 
203
#    $VALGRIND_CMD cibadmin -Q
 
204
    for y in 06 07 08 09 10 11 12 13 14 15 16 17 18; do
 
205
        $VALGRIND_CMD iso8601 -d "20$y-W01-7 00Z"
 
206
        $VALGRIND_CMD iso8601 -d "20$y-W01-7 00Z" -W -E "20$y-W01-7 00:00:00Z"
 
207
        assert $? 0 iso8601 "20$y-W01-7" 0
 
208
        $VALGRIND_CMD iso8601 -d "20$y-W01-1 00Z"
 
209
        $VALGRIND_CMD iso8601 -d "20$y-W01-1 00Z" -W -E "20$y-W01-1 00:00:00Z"
 
210
        assert $? 0 iso8601 "20$y-W01-1" 0
 
211
    done
 
212
 
 
213
    $VALGRIND_CMD iso8601 -d "2009-W53-7 00:00:00Z" -W -E "2009-W53-7 00:00:00Z"
 
214
    assert $? 0 iso8601 "2009-W53-07" 0
 
215
 
 
216
    $VALGRIND_CMD iso8601 -d "2009-01-31 00:00:00Z" -D "P1M" -E "2009-02-28 00:00:00Z"
 
217
    assert $? 0 iso8601 "2009-01-31 + 1 Month" 0
 
218
 
 
219
    $VALGRIND_CMD iso8601 -d "2009-01-31 00:00:00Z" -D "P2M" -E "2009-03-31 00:00:00Z"
 
220
    assert $? 0 iso8601 "2009-01-31 + 2 Months" 0
 
221
 
 
222
    $VALGRIND_CMD iso8601 -d "2009-01-31 00:00:00Z" -D "P3M" -E "2009-04-30 00:00:00Z"
 
223
    assert $? 0 iso8601 "2009-01-31 + 3 Months" 0
 
224
 
 
225
    $VALGRIND_CMD iso8601 -d "2009-03-31 00:00:00Z" -D "P-1M" -E "2009-02-28 00:00:00Z"
 
226
    assert $? 0 iso8601 "2009-03-31 - 1 Month" 0
 
227
 }
 
228
 
 
229
echo "Testing dates"
 
230
test_date > $test_home/regression.out
 
231
echo "Testing tools"
 
232
test_tools >> $test_home/regression.out
 
233
sed -i.sed 's/cib-last-written.*>/>/' $test_home/regression.out
200
234
 
201
235
if [ $do_save = 1 ]; then
202
236
    cp $test_home/regression.out $test_home/regression.exp
203
237
fi
204
238
 
205
239
grep -e "^*" $test_home/regression.out
 
240
 
 
241
if [ $num_errors != 0 ]; then
 
242
    echo $num_errors tests failed
 
243
    diff -u $test_home/regression.exp $test_home/regression.out 
 
244
    exit 1
 
245
fi
 
246
 
206
247
diff -u $test_home/regression.exp $test_home/regression.out 
207
 
diff_rc=$?
208
 
 
209
 
if [ $rc != 0 ]; then
210
 
    echo Tests failed
211
 
    exit 1
212
 
 
213
 
elif [ $diff_rc != 0 ]; then
214
 
    echo Tests passed but diff failed
 
248
if [ $? != 0 ]; then
 
249
    echo $num_passed tests passed but diff failed
215
250
    exit 2
216
251
 
217
252
else
218
 
    echo Tests passed
 
253
    echo $num_passed tests passed
219
254
    exit 0
220
255
fi