From a1fd558c47e9d9958ad07a01a5ec1dadc019e892 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Wed, 9 Jan 2019 14:45:18 -0800 Subject: [PATCH] t/kvs: Add symlink w/ namespace basic tests --- t/t1000-kvs.t | 117 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 3 deletions(-) diff --git a/t/t1000-kvs.t b/t/t1000-kvs.t index 81da247c6b2c..ef08480eca1a 100755 --- a/t/t1000-kvs.t +++ b/t/t1000-kvs.t @@ -466,10 +466,12 @@ test_expect_success 'kvs: treeobj of all types handled by get --treeobj' ' flux kvs put $DIR.valref=$(seq -s 1 100) && flux kvs mkdir $DIR.dirref && flux kvs link foo $DIR.symlink && + flux kvs link --target-namespace=A bar $DIR.symlinkNS && flux kvs get --treeobj $DIR.val | grep -q val && flux kvs get --treeobj $DIR.valref | grep -q valref && flux kvs get --treeobj $DIR.dirref | grep -q dirref && - flux kvs get --treeobj $DIR.symlink | grep -q symlink + flux kvs get --treeobj $DIR.symlink | grep -q symlink && + flux kvs get --treeobj $DIR.symlinkNS | grep -q symlink ' test_expect_success 'kvs: get --treeobj: returns value ref for large value' ' flux kvs unlink -Rf $DIR && @@ -599,7 +601,10 @@ EOF # # ls tests # + test_expect_success 'kvs: ls -1F works' ' + flux kvs unlink -Rf $DIR && + flux kvs mkdir $DIR && flux kvs ls -1F >output && cat >expected <<-EOF && test. @@ -607,6 +612,8 @@ test_expect_success 'kvs: ls -1F works' ' test_cmp expected output ' test_expect_success 'kvs: ls -1F . works' ' + flux kvs unlink -Rf $DIR && + flux kvs mkdir $DIR && flux kvs ls -1F . >output && cat >expected <<-EOF && test. @@ -618,11 +625,13 @@ test_expect_success 'kvs: ls -1F DIR works' ' flux kvs put --json $DIR.a=69 && flux kvs mkdir $DIR.b && flux kvs link b $DIR.c && + flux kvs link --target-namespace=foo c $DIR.d && flux kvs ls -1F $DIR >output && cat >expected <<-EOF && a b. c@ + d@ EOF test_cmp expected output ' @@ -632,19 +641,23 @@ test_expect_success 'kvs: ls -1F DIR. works' ' a b. c@ + d@ EOF test_cmp expected output ' -test_expect_success 'kvs: ls -1Fd DIR.a DIR.b DIR.c works' ' +test_expect_success 'kvs: ls -1Fd DIR.a DIR.b DIR.c DIR.d works' ' flux kvs unlink -Rf $DIR && flux kvs put --json $DIR.a=69 && flux kvs mkdir $DIR.b && flux kvs link b $DIR.c && - flux kvs ls -1Fd $DIR.a $DIR.b $DIR.c >output && + flux kvs link --target-namespace=foo c $DIR.d && + flux kvs ls -1Fd $DIR.a $DIR.b $DIR.c $DIR.d >output-1 && + flux kvs ls -1Fd $DIR.a $DIR.b $DIR.c $DIR.d >output && cat >expected <<-EOF && $DIR.a $DIR.b. $DIR.c@ + $DIR.d@ EOF test_cmp expected output ' @@ -653,6 +666,7 @@ test_expect_success 'kvs: ls -1RF shows directory titles' ' flux kvs put --json $DIR.a=69 && flux kvs put --json $DIR.b.d=42 && flux kvs link b $DIR.c && + flux kvs ls -1RF $DIR | grep : >output-2 && flux kvs ls -1RF $DIR | grep : | wc -l >output && cat >expected <<-EOF && 2 @@ -868,9 +882,98 @@ test_expect_success 'kvs: link: path resolution with intermediate link and nonex test_must_fail flux kvs get --json $DIR.Z.Y ' +# +# link/readlink tests - across namespace +# + +test_expect_success 'kvs: namespace create setup' ' + flux kvs namespace-create TESTSYMLINKNS +' +test_expect_success 'kvs: symlink w/ Namespace works' ' + TARGET=$DIR.target && + flux kvs --namespace=TESTSYMLINKNS put --json $TARGET=\"foo\" && + flux kvs link --target-namespace=TESTSYMLINKNS $TARGET $DIR.symlinkNS && + OUTPUT=$(flux kvs get --json $DIR.symlinkNS) && + test "$OUTPUT" = "foo" +' +test_expect_success 'kvs: symlink w/ Namespace fails on bad namespace' ' + TARGET=$DIR.target && + flux kvs put --json $TARGET=\"foo\" && + flux kvs link --target-namespace=TESTSYMLINKNS-FAKE $TARGET $DIR.symlinkNS && + ! flux kvs get --json $DIR.symlinkNS +' +test_expect_success 'kvs: readlink on symlink w/ Namespace works' ' + TARGET=$DIR.target && + flux kvs put --json $TARGET=\"foo\" && + flux kvs link --target-namespace=TESTSYMLINKNS $TARGET $DIR.symlinkNS && + OUTPUT=$(flux kvs readlink $DIR.symlinkNS) && + test "$OUTPUT" = "TESTSYMLINKNS::$TARGET" +' +test_expect_success 'kvs: readlink works with nslnks (multiple inputs)' ' + TARGET1=$DIR.target1 && + TARGET2=$DIR.target2 && + flux kvs --namespace=TESTSYMLINKNS put --json $TARGET1=\"foo1\" && + flux kvs --namespace=TESTSYMLINKNS put --json $TARGET2=\"foo2\" && + flux kvs link --target-namespace=TESTSYMLINKNS $TARGET1 $DIR.symlinkNS1 && + flux kvs link --target-namespace=TESTSYMLINKNS $TARGET2 $DIR.symlinkNS2 && + flux kvs readlink $DIR.symlinkNS1 $DIR.symlinkNS2 >output && + cat >expected <