Skip to content

Commit

Permalink
t/kvs: Add multi-blobref read tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chu11 committed Oct 17, 2017
1 parent 42808fd commit edfcac2
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions t/t1002-kvs-extra.t
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,53 @@ test_expect_success 'kvs: valref that doesnt point to raw data fails' '
dirhash=`${KVSBASIC} get-treeobj $TEST.a.b.c | grep -P "sha1-[A-Za-z0-9]+" -o` &&
${KVSBASIC} put-treeobj $TEST.value="{\"data\":[\"${dirhash}\"],\"type\":\"valref\",\"ver\":1}" &&
test_must_fail ${KVSBASIC} copy-fromkvs $TEST.value -
# multi-blobref valrefs
test_expect_success 'kvs: multi blob-ref valref can be read' '
flux kvs unlink -Rf $TEST &&
hashval1=`echo -n "abcd" | flux content store` &&
hashval2=`echo -n "efgh" | flux content store` &&
${KVSBASIC} put-treeobj $TEST.multival="{\"data\":[\"${hashval1}\", \"${hashval2}\"],\"type\":\"valref\",\"ver\":1}" &&
${KVSBASIC} copy-fromkvs $TEST.multival - | grep "abcdefgh" &&
test $(${KVSBASIC} copy-fromkvs $TEST.multival -|wc -c) -eq 8
'
test_expect_success 'kvs: multi blob-ref valref with an empty blobref on left, can be read' '
flux kvs unlink -Rf $TEST &&
hashval1=`flux content store < /dev/null` &&
hashval2=`echo -n "abcd" | flux content store` &&
${KVSBASIC} put-treeobj $TEST.multival="{\"data\":[\"${hashval1}\", \"${hashval2}\"],\"type\":\"valref\",\"ver\":1}" &&
${KVSBASIC} copy-fromkvs $TEST.multival - | grep "abcd" &&
test $(${KVSBASIC} copy-fromkvs $TEST.multival -|wc -c) -eq 4
'
test_expect_success 'kvs: multi blob-ref valref with an empty blobref on right, can be read' '
flux kvs unlink -Rf $TEST &&
hashval1=`echo -n "abcd" | flux content store` &&
hashval2=`flux content store < /dev/null` &&
${KVSBASIC} put-treeobj $TEST.multival="{\"data\":[\"${hashval1}\", \"${hashval2}\"],\"type\":\"valref\",\"ver\":1}" &&
${KVSBASIC} copy-fromkvs $TEST.multival - | grep "abcd"
test $(${KVSBASIC} copy-fromkvs $TEST.multival -|wc -c) -eq 4
'
test_expect_success 'kvs: multi blob-ref valref with an empty blobref in middle, can be read' '
flux kvs unlink -Rf $TEST &&
hashval1=`echo -n "abcd" | flux content store` &&
hashval2=`flux content store < /dev/null` &&
hashval3=`echo -n "efgh" | flux content store` &&
${KVSBASIC} put-treeobj $TEST.multival="{\"data\":[\"${hashval1}\", \"${hashval2}\", \"${hashval3}\"],\"type\":\"valref\",\"ver\":1}" &&
${KVSBASIC} copy-fromkvs $TEST.multival - | grep "abcdefgh"
test $(${KVSBASIC} copy-fromkvs $TEST.multival -|wc -c) -eq 8
'
test_expect_success 'kvs: multi blob-ref valref with a blobref that doesnt point to raw data fails' '
flux kvs unlink -Rf $TEST &&
hashval1=`echo -n "abcd" | flux content store` &&
flux kvs mkdir $TEST.a.b.c &&
dirhash=`${KVSBASIC} get-treeobj $TEST.a.b.c | grep -P "sha1-[A-Za-z0-9]+" -o` &&
${KVSBASIC} put-treeobj $TEST.multival="{\"data\":[\"${hashval1}\", \"${dirhash}\"],\"type\":\"valref\",\"ver\":1}" &&
test_must_fail ${KVSBASIC} copy-fromkvs $TEST.multival -
'
# dtree tests
Expand Down

0 comments on commit edfcac2

Please sign in to comment.