Skip to content

Commit

Permalink
test/kvs: Add KVS_NO_MERGE test in commitmerge
Browse files Browse the repository at this point in the history
Add additional KVS_NO_MERGE test in kvs/commitmerge.  If KVS
commit-merge flag is true, and all commits set the KVS_NO_MERGE
flag, the behavior should be similar to when commit-merge=0.
  • Loading branch information
chu11 committed Feb 17, 2017
1 parent 52fe716 commit fa3d15d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
31 changes: 27 additions & 4 deletions t/kvs/commitmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,21 @@ static int threadcount = -1;
static int changecount = 0;
static char *prefix = NULL;
static char *key = NULL;
static bool nopt = false;

static int watch_init = 0;
static pthread_cond_t watch_init_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t watch_init_lock = PTHREAD_MUTEX_INITIALIZER;

#define OPTIONS "n"
static const struct option longopts[] = {
{"nomerge", no_argument, 0, 'n'},
{0, 0, 0, 0},
};

static void usage (void)
{
fprintf (stderr, "Usage: commitmerge threadcount prefix\n");
fprintf (stderr, "Usage: commitmerge [--nomerge] threadcount prefix\n");
exit (1);
}

Expand Down Expand Up @@ -193,8 +200,14 @@ void *committhread (void *arg)
if (kvs_put_int (t->h, key, t->n) < 0)
log_err_exit ("%s", key);

if (kvs_commit (t->h) < 0)
log_err_exit ("kvs_commit");
if (nopt) {
if (kvs_commit_flags (t->h, KVS_NO_MERGE) < 0)
log_err_exit ("kvs_commit");
}
else {
if (kvs_commit (t->h) < 0)
log_err_exit ("kvs_commit");
}

flux_close (t->h);
return NULL;
Expand All @@ -203,10 +216,20 @@ void *committhread (void *arg)
int main (int argc, char *argv[])
{
thd_t *thd;
int i, rc;
int i, rc, ch;

log_init (basename (argv[0]));

while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) {
switch (ch) {
case 'n':
nopt = true;
break;
default:
usage ();
}
}

if (argc - optind != 2)
usage ();

Expand Down
12 changes: 12 additions & 0 deletions t/t1000-kvs-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,18 @@ test_expect_success 'kvs: copy-tokvs and copy-fromkvs work' '
test_cmp random.data reread.data
'

# kvs merging tests

# If commit-merge=1 and we set KVS_NO_MERGE on all commits, this test
# should behave similarly to commit-merge=0 and OUTPUT should equal
# THREADS.
test_expect_success 'kvs: test that KVS_NO_MERGE works with kvs_commit()' '
THREADS=64 &&
OUTPUT=`${FLUX_BUILD_DIR}/t/kvs/commitmerge --nomerge ${THREADS} \
$(basename ${SHARNESS_TEST_FILE})`
test "$OUTPUT" = "${THREADS}"
'

# All tests below assume commit-merge=0

# commit-merge option test
Expand Down

0 comments on commit fa3d15d

Please sign in to comment.