Skip to content

Commit

Permalink
testsuite: add checkpoint tests on rank > 0
Browse files Browse the repository at this point in the history
Problem: There were no content checkpoint tests on rank > 0
to ensure RPCs are forwarded to rank 0 appropriately.

Solution: Add some non-rank 0 checkpoint tests to t0012-content-sqlite.t,
t0018-content-files.t, and t0024-content-s3.t.
  • Loading branch information
chu11 committed Aug 24, 2022
1 parent 9f3ecfd commit aac39d2
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
22 changes: 19 additions & 3 deletions t/content/content-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,28 @@

# content module test helper functions

# Get RPC message contents for checkpoint put
# Usage: checkpoint_put_msg key rootref
checkpoint_put_msg() {
o="{key:\"$1\",value:{version:1,rootref:\"$2\",timestamp:2.2}}"
echo ${o}
}

# Usage: checkpoint_put key rootref
checkpoint_put() {
o="{key:\"$1\",value:{version:1,rootref:\"$2\",timestamp:2.2}}"
jq -j -c -n ${o} | $RPC content.checkpoint-put
o=$(checkpoint_put_msg $1 $2)
jq -j -c -n ${o} | $RPC content.checkpoint-put
}

# Get RPC message contents for checkpoint get
# Usage: checkpoint_get_msg key
checkpoint_get_msg() {
o="{key:\"$1\"}"
echo ${o}
}

# Usage: checkpoint_get key >value
checkpoint_get() {
jq -j -c -n "{key:\"$1\"}" | $RPC content.checkpoint-get
o=$(checkpoint_get_msg $1)
jq -j -c -n ${o} | $RPC content.checkpoint-get
}
14 changes: 14 additions & 0 deletions t/t0012-content-sqlite.t
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ test_expect_success HAVE_JQ 'checkpoint-get foo returned rootref bar' '
test_cmp rootref.exp rootref.out
'

test_expect_success HAVE_JQ 'checkpoint-put on rank 1 forwards to rank 0' '
o=$(checkpoint_put_msg rankone rankref) &&
jq -j -c -n ${o} | flux exec -r 1 ${RPC} content.checkpoint-put
'

test_expect_success HAVE_JQ 'checkpoint-get on rank 1 forwards to rank 0' '
echo rankref >rankref.exp &&
o=$(checkpoint_get_msg rankone) &&
jq -j -c -n ${o} \
| flux exec -r 1 ${RPC} content.checkpoint-get \
| jq -r .value | jq -r .rootref > rankref.out &&
test_cmp rankref.exp rankref.out
'

# use grep instead of compare, incase of floating point rounding
test_expect_success HAVE_JQ 'checkpoint-get foo returned correct timestamp' '
checkpoint_get foo | jq -r .value | jq -r .timestamp >timestamp.out &&
Expand Down
16 changes: 15 additions & 1 deletion t/t0018-content-files.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_description='Test content-files backing store service'

. `dirname $0`/sharness.sh

test_under_flux 1 minimal -o,-Sstatedir=$(pwd)
test_under_flux 2 minimal -o,-Sstatedir=$(pwd)

BLOBREF=${FLUX_BUILD_DIR}/t/kvs/blobref
RPC=${FLUX_BUILD_DIR}/t/request/rpc
Expand Down Expand Up @@ -168,6 +168,20 @@ test_expect_success HAVE_JQ 'checkpoint-get foo returned rootref bar' '
test_cmp rootref.exp rootref.out
'

test_expect_success HAVE_JQ 'checkpoint-put on rank 1 forwards to rank 0' '
o=$(checkpoint_put_msg rankone rankref) &&
jq -j -c -n ${o} | flux exec -r 1 ${RPC} content.checkpoint-put
'

test_expect_success HAVE_JQ 'checkpoint-get on rank 1 forwards to rank 0' '
echo rankref >rankref.exp &&
o=$(checkpoint_get_msg rankone) &&
jq -j -c -n ${o} \
| flux exec -r 1 ${RPC} content.checkpoint-get \
| jq -r .value | jq -r .rootref > rankref.out &&
test_cmp rankref.exp rankref.out
'

# use grep instead of compare, incase of floating point rounding
test_expect_success HAVE_JQ 'checkpoint-get foo returned correct timestamp' '
checkpoint_get foo | jq -r .value | jq -r .timestamp >timestamp.out &&
Expand Down
16 changes: 15 additions & 1 deletion t/t0024-content-s3.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

export FLUX_CONF_DIR=$(pwd)

test_under_flux 1 minimal
test_under_flux 2 minimal

BLOBREF=${FLUX_BUILD_DIR}/t/kvs/blobref
RPC=${FLUX_BUILD_DIR}/t/request/rpc
Expand Down Expand Up @@ -127,6 +127,20 @@ test_expect_success HAVE_JQ 'checkpoint-get foo returned rootref bar' '
test_cmp rootref.exp rootref.out
'

test_expect_success HAVE_JQ 'checkpoint-put on rank 1 forwards to rank 0' '
o=$(checkpoint_put_msg rankone rankref) &&
jq -j -c -n ${o} | flux exec -r 1 ${RPC} content.checkpoint-put
'

test_expect_success HAVE_JQ 'checkpoint-get on rank 1 forwards to rank 0' '
echo rankref >rankref.exp &&
o=$(checkpoint_get_msg rankone) &&
jq -j -c -n ${o} \
| flux exec -r 1 ${RPC} content.checkpoint-get \
| jq -r .value | jq -r .rootref > rankref.out &&
test_cmp rankref.exp rankref.out
'

# use grep instead of compare, incase of floating point rounding
test_expect_success HAVE_JQ 'checkpoint-get foo returned correct timestamp' '
checkpoint_get foo | jq -r .value | jq -r .timestamp >timestamp.out &&
Expand Down

0 comments on commit aac39d2

Please sign in to comment.