From a1233f68863540ae0a29b29d36719befb189576c Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Mon, 9 Oct 2017 16:12:13 -0700 Subject: [PATCH] t/kvs: Add multi-blobref read tests --- t/t1002-kvs-extra.t | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/t/t1002-kvs-extra.t b/t/t1002-kvs-extra.t index 6159a3884662..d53edbb7a1c9 100755 --- a/t/t1002-kvs-extra.t +++ b/t/t1002-kvs-extra.t @@ -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' '