Skip to content

Commit dc619aa

Browse files
committed
t/kvs: support multiple ops in each fence request
Problem: In the fence_api testing tool, each fence request sends a single transaction operation. This limits some testing ability. Support a new --opcount option that allows us to configure greater than one operation per fence request.
1 parent 14641e5 commit dc619aa

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

t/kvs/fence_api.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,38 @@ static char *fence_name;
4545
static bool syncflag = false;
4646
static bool symlinkflag = false;
4747
static const char *namespace = NULL;
48+
static int opcount = 1;
4849

49-
#define OPTIONS "n:Ss"
50+
#define OPTIONS "n:Sso:"
5051
static const struct option longopts[] = {
5152
{"namespace", required_argument, 0, 'n'},
5253
{"sync", no_argument, 0, 'S'},
5354
{"symlink", no_argument, 0, 's'},
55+
{"opcount", required_argument, 0, 'o'},
5456
{0, 0, 0, 0},
5557
};
5658

5759
static void usage (void)
5860
{
5961
fprintf (stderr,
6062
"Usage: fence_api "
61-
"[--sync] [--symlink] [--namespace=ns] "
63+
"[--sync] [--symlink] [--namespace=ns] [--opcount=num] "
6264
"<fencecount> <prefix>\n");
6365
exit (1);
6466
}
6567

6668
void *thread (void *arg)
6769
{
6870
thd_t *t = arg;
69-
char *key;
71+
char *key = NULL;
7072
uint32_t rank;
7173
flux_future_t *f;
7274
flux_kvs_txn_t *txn;
7375
const char *treeobj;
7476
const char *rootref;
7577
int sequence;
7678
int flags = 0;
79+
int i;
7780

7881
if (!(t->h = flux_open (NULL, 0))) {
7982
log_err ("%d: flux_open", t->n);
@@ -90,15 +93,19 @@ void *thread (void *arg)
9093
if (!(txn = flux_kvs_txn_create ()))
9194
log_err_exit ("flux_kvs_txn_create");
9295

93-
key = xasprintf ("%s.%"PRIu32".%d", prefix, rank, t->n);
96+
for (i = 0; i < opcount; i++) {
97+
key = xasprintf ("%s.%"PRIu32".%d.%d", prefix, rank, t->n, i);
9498

95-
if (symlinkflag) {
96-
if (flux_kvs_txn_symlink (txn, 0, key, NULL, "a-target") < 0)
97-
log_err_exit ("%s", key);
98-
}
99-
else {
100-
if (flux_kvs_txn_pack (txn, 0, key, "i", 42) < 0)
101-
log_err_exit ("%s", key);
99+
if (symlinkflag) {
100+
if (flux_kvs_txn_symlink (txn, 0, key, NULL, "a-target") < 0)
101+
log_err_exit ("%s", key);
102+
}
103+
else {
104+
if (flux_kvs_txn_pack (txn, 0, key, "i", 42 + i) < 0)
105+
log_err_exit ("%s", key);
106+
}
107+
108+
free (key);
102109
}
103110

104111
if (syncflag)
@@ -131,7 +138,6 @@ void *thread (void *arg)
131138

132139
flux_future_destroy (f);
133140

134-
free (key);
135141
flux_kvs_txn_destroy (txn);
136142

137143
done:
@@ -158,6 +164,10 @@ int main (int argc, char *argv[])
158164
case 'n':
159165
namespace = optarg;
160166
break;
167+
case 'o':
168+
opcount = atoi (optarg);
169+
if (opcount <= 0)
170+
usage ();
161171
default:
162172
usage ();
163173
}

0 commit comments

Comments
 (0)