Skip to content

Commit

Permalink
modules/kvs: Add multiple operation unit tests
Browse files Browse the repository at this point in the history
Add unit tests covering multiple transactions which all use the
same namespace prefix.
  • Loading branch information
chu11 committed Apr 13, 2018
1 parent 0ebaf83 commit 29a902a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/modules/kvs/test/kvstxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2536,11 +2536,11 @@ void kvstxn_namespace_prefix (void)

kvstxn_mgr_remove_transaction (ktm, kt, false);

/* Third, test if invalid prefix across multiple prefixes fails */
/* Third, test if valid & indentical prefix across multiple operations works */

ops = json_array ();
ops_append (ops, "ns:primary/key3", "3", 0);
ops_append (ops, "ns:foobar/key4", "4", 0);
ops_append (ops, "ns:primary/key4", "4", 0);

ok (kvstxn_mgr_add_transaction (ktm,
"transaction3",
Expand All @@ -2550,6 +2550,44 @@ void kvstxn_namespace_prefix (void)

json_decref (ops);

ok ((kt = kvstxn_mgr_get_ready_transaction (ktm)) != NULL,
"kvstxn_mgr_get_ready_transaction returns ready kvstxn");

ok (kvstxn_process (kt, 1, rootref) == KVSTXN_PROCESS_DIRTY_CACHE_ENTRIES,
"kvstxn_process returns KVSTXN_PROCESS_DIRTY_CACHE_ENTRIES");

count = 0;
ok (kvstxn_iter_dirty_cache_entries (kt, cache_count_dirty_cb, &count) == 0,
"kvstxn_iter_dirty_cache_entries works for dirty cache entries");

ok (count == 1,
"correct number of cache entries were dirty");

ok (kvstxn_process (kt, 1, rootref) == KVSTXN_PROCESS_FINISHED,
"kvstxn_process returns KVSTXN_PROCESS_FINISHED");

ok ((newroot = kvstxn_get_newroot_ref (kt)) != NULL,
"kvstxn_get_newroot_ref returns != NULL when processing complete");

verify_value (cache, krm, KVS_PRIMARY_NAMESPACE, newroot, "key3", "3");
verify_value (cache, krm, KVS_PRIMARY_NAMESPACE, newroot, "key4", "4");

kvstxn_mgr_remove_transaction (ktm, kt, false);

/* Fourth, test if invalid prefix across multiple prefixes fails */

ops = json_array ();
ops_append (ops, "ns:primary/key5", "5", 0);
ops_append (ops, "ns:foobar/key6", "6", 0);

ok (kvstxn_mgr_add_transaction (ktm,
"transaction4",
ops,
0) == 0,
"kvstxn_mgr_add_transaction works");

json_decref (ops);

ok ((kt = kvstxn_mgr_get_ready_transaction (ktm)) != NULL,
"kvstxn_mgr_get_ready_transaction returns ready kvstxn");

Expand Down
4 changes: 4 additions & 0 deletions t/t1004-kvs-namespace.t
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ test_expect_success 'kvs: put - fails across multiple namespaces' '
! flux kvs put ns:${NAMESPACEPREFIX}-1/$DIR.puttest.a=1 ns:${NAMESPACEPREFIX}-2/$DIR.puttest.b=2
'

test_expect_success 'kvs: put - success multiple namespace prefixes identical' '
flux kvs put ns:${NAMESPACEPREFIX}-2/$DIR.puttest.a=1 ns:${NAMESPACEPREFIX}-2/$DIR.puttest.b=2
'

test_expect_success 'kvs: namespace prefix works with dir' '
flux kvs dir ns:${NAMESPACEPREFIX}-1/. | sort >output &&
cat >expected <<EOF &&
Expand Down

0 comments on commit 29a902a

Please sign in to comment.