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 b7fc44d commit a1233f6
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions t/t1002-kvs-extra.t
Expand Up @@ -312,6 +312,54 @@ test_expect_success 'kvs: valref that doesnt point to raw data fails' '
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

test_expect_success 'kvs: store 16x3 directory tree' '
Expand Down

0 comments on commit a1233f6

Please sign in to comment.