From edfcac27a6d166dab14b40d7d80f47861b44932f 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 | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/t/t1002-kvs-extra.t b/t/t1002-kvs-extra.t index 6159a3884662..1872881f8beb 100755 --- a/t/t1002-kvs-extra.t +++ b/t/t1002-kvs-extra.t @@ -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