Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 2c7402b

Browse files
committed
Update unit test to check dix min_success
Signed-off-by: Tim Shaffer <[email protected]>
1 parent 70faca9 commit 2c7402b

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

dix/ut/client_ut.c

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ static int dix_common_rec_op(const struct m0_dix *index,
12851285
const struct m0_bufvec *keys,
12861286
struct m0_bufvec *vals,
12871287
const uint32_t *recs_nr,
1288+
uint32_t min_success,
12881289
uint32_t flags,
12891290
struct dix_rep_arr *rep,
12901291
enum ut_dix_req_type type)
@@ -1294,7 +1295,7 @@ static int dix_common_rec_op(const struct m0_dix *index,
12941295
int i;
12951296
int k = 0;
12961297

1297-
m0_dix_req_init(&req, &dix_ut_cctx.cl_cli, dix_ut_cctx.cl_grp, 1);
1298+
m0_dix_req_init(&req, &dix_ut_cctx.cl_cli, dix_ut_cctx.cl_grp, min_success);
12981299
m0_dix_req_lock(&req);
12991300
switch (type) {
13001301
case REQ_PUT:
@@ -1397,21 +1398,31 @@ static int dix_ut_put(const struct m0_dix *index,
13971398
uint32_t flags,
13981399
struct dix_rep_arr *rep)
13991400
{
1400-
return dix_common_rec_op(index, keys, vals, NULL, flags, rep, REQ_PUT);
1401+
return dix_common_rec_op(index, keys, vals, NULL, 1, flags, rep, REQ_PUT);
1402+
}
1403+
1404+
static int dix_ut_put_min_success(const struct m0_dix *index,
1405+
const struct m0_bufvec *keys,
1406+
struct m0_bufvec *vals,
1407+
uint32_t min_success,
1408+
uint32_t flags,
1409+
struct dix_rep_arr *rep)
1410+
{
1411+
return dix_common_rec_op(index, keys, vals, NULL, min_success, flags, rep, REQ_PUT);
14011412
}
14021413

14031414
static int dix_ut_get(const struct m0_dix *index,
14041415
const struct m0_bufvec *keys,
14051416
struct dix_rep_arr *rep)
14061417
{
1407-
return dix_common_rec_op(index, keys, NULL, NULL, 0, rep, REQ_GET);
1418+
return dix_common_rec_op(index, keys, NULL, NULL, 1, 0, rep, REQ_GET);
14081419
}
14091420

14101421
static int dix_ut_del(const struct m0_dix *index,
14111422
const struct m0_bufvec *keys,
14121423
struct dix_rep_arr *rep)
14131424
{
1414-
return dix_common_rec_op(index, keys, NULL, NULL, 0, rep, REQ_DEL);
1425+
return dix_common_rec_op(index, keys, NULL, NULL, 1, 0, rep, REQ_DEL);
14151426
}
14161427

14171428
static int dix_ut_next(const struct m0_dix *index,
@@ -1420,7 +1431,7 @@ static int dix_ut_next(const struct m0_dix *index,
14201431
uint32_t flags,
14211432
struct dix_rep_arr *rep)
14221433
{
1423-
return dix_common_rec_op(index, start_keys, NULL, recs_nr, flags,
1434+
return dix_common_rec_op(index, start_keys, NULL, recs_nr, 1, flags,
14241435
rep, REQ_NEXT);
14251436
}
14261437

@@ -2655,17 +2666,35 @@ static void local_failures(void)
26552666
dix_kv_alloc_and_fill(&keys, &vals, COUNT);
26562667
rc = dix_common_idx_op(&index, 1, REQ_CREATE);
26572668
M0_UT_ASSERT(rc == 0);
2669+
26582670
/*
2659-
* Consider DIX request to be successful if there is at least
2660-
* one successful CAS request. Here two cas requests can be
2661-
* sent successfully.
2671+
* Consider DIX request to be successful only if there are
2672+
* enough successful CAS requests to satisfy min_success.
2673+
* Here two cas requests can be sent successfully. First, try with
2674+
* min_success = 3, which should result in all CAS requests failing.
26622675
*/
26632676
m0_fi_enable_off_n_on_m("cas_req_replied_cb", "send-failure", 2, 3);
2664-
rc = dix_ut_put(&index, &keys, &vals, 0, &rep);
2677+
rc = dix_ut_put_min_success(&index, &keys, &vals, 3, 0, &rep);
2678+
m0_fi_disable("cas_req_replied_cb", "send-failure");
2679+
M0_UT_ASSERT(rc == 0);
2680+
M0_UT_ASSERT(rep.dra_nr == COUNT);
2681+
M0_UT_ASSERT(m0_forall(i, COUNT, rep.dra_rep[i].dre_rc == -ENOTCONN));
2682+
2683+
dix_rep_free(&rep);
2684+
rc = dix_ut_del(&index, &keys, &rep);
2685+
M0_UT_ASSERT(rc == 0);
2686+
dix_rep_free(&rep);
2687+
2688+
/*
2689+
* Now try again with min_success = 2, which should succeed.
2690+
*/
2691+
m0_fi_enable_off_n_on_m("cas_req_replied_cb", "send-failure", 2, 3);
2692+
rc = dix_ut_put_min_success(&index, &keys, &vals, 2, 0, &rep);
26652693
m0_fi_disable("cas_req_replied_cb", "send-failure");
26662694
M0_UT_ASSERT(rc == 0);
26672695
M0_UT_ASSERT(rep.dra_nr == COUNT);
26682696
M0_UT_ASSERT(m0_forall(i, COUNT, rep.dra_rep[i].dre_rc == 0));
2697+
26692698
dix_rep_free(&rep);
26702699
dix_kv_destroy(&keys, &vals);
26712700
dix_index_fini(&index);

0 commit comments

Comments
 (0)