Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuhamedagic committed Oct 22, 2023
1 parent 680e8f1 commit 3d7826e
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/live_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,44 @@ applicable_attr_prereq_fail() {
[ -n "`get_attr`" ]
}

## TEST: crmv1_group_start ##

add_crmv1_group() {
crmv1 group testgrp rsc1 Dummy rsc2 Dummy fake=test
}

rm_crmv1_group() {
crmv1 group delete testgrp
}

check_resources() {
export OCF_ROOT=/usr/lib/ocf
export OCF_RESOURCE_INSTANCE=rsc1
. /usr/lib/ocf/lib/heartbeat/ocf-shellfuncs
/usr/lib/ocf/resource.d/heartbeat/Dummy monitor || return 1
OCF_RESOURCE_INSTANCE=rsc2
export OCF_RESKEY_fake=test
/usr/lib/ocf/resource.d/heartbeat/Dummy monitor || return 1
return 0
}

# crmv1 start a group
setup_crmv1_group_start_ok() {
add_crmv1_group
}
test_crmv1_group_start_ok() {
wait_exp
wait_timeout
}
check_crmv1_group_start_ok() {
check_resources
}
recover_crmv1_group_start_ok() {
stop_site `get_site 1`
stop_site `get_site 2`
rm_crmv1_group
}

#
# environment modifications
#
Expand Down
47 changes: 47 additions & 0 deletions unit-tests/030_crmv1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# vim: ft=sh et :
#
# Testing crmv1 groups


ticket:
name "tick1"
state ST_LEADER
current_term 40
leader local
# may keep ticket all the time
term_duration 3000
# but shall start renewal now
term_expires time(0) + 1000
req_sent_at time(0) - 10


gdb0:
call parse_extprog("test `set|grep ^BOOTH|wc -l` -ge 5", booth_conf->ticket+0)

outgoing0:
header.cmd OP_HEARTBEAT


testgrp:
ext_verifier 'test "$BOOTH_TICKET" == "tick1"'
# cause re-query of the verifier
req_sent_at time(0) - 10

#
#gdb1:
# break ticket_broadcast_proposed_state § commands § bt § c § end


outgoing1:
header.cmd OP_HEARTBEAT


# now say that we may not have it anymore.
ticket2:
ext_verifier 'test "$BOOTH_TICKET" == "tick2FOO"'
# cause re-query of the verifier
req_sent_at time(0) - 10

finally:
state ST_LEADER
leader local

0 comments on commit 3d7826e

Please sign in to comment.