23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT 33 #define ST_VAL_STRING ("Client Index Test.") 51 type = idx_door_no % 3;
123 char *tmp_str =
NULL;
124 char *key_str =
NULL;
145 if (nr_kvp > max_nr_kvp)
148 for (
i = 0;
i < nr_kvp;
i++) {
156 klen = strlen(tmp_str);
161 memcpy(key_str, tmp_str, klen);
162 key_str[klen] =
'\0';
169 key_no_arr[
i] = key_no;
199 char *tmp_str =
NULL;
200 char *key_str =
NULL;
201 char *val_str =
NULL;
218 for (
i = 0;
i < nr_kvp;
i++) {
223 klen = strlen(tmp_str);
232 memcpy(key_str, tmp_str, klen);
265 memset(&idx, 0,
sizeof idx);
276 if (
rc < 0)
return rc;
300 nr_per_round = nr_kvp / nr_rounds;
301 for (
i = 0;
i < nr_rounds;
i++) {
303 if (
start + nr_per_round > nr_kvp)
304 nr_to_insert = nr_kvp -
start;
306 nr_to_insert = nr_per_round;
346 memset(&idx, 0,
sizeof idx);
360 if (
rc < 0)
return rc;
362 rc =
ops[0]->op_sm.sm_rc;
363 if (
rc < 0)
return rc;
378 memset(&idx, 0,
sizeof idx);
393 if (
rc < 0)
return rc;
395 rc =
ops[0]->op_sm.sm_rc;
425 id.u_lo = idx_fid.
f_key;
444 #define idx_query_exec(idx_id, opcode, keys, vals, rcs, flag, exp) \ 448 struct m0_op *ops[1] = {NULL}; \ 451 memset(&idx, 0, sizeof idx); \ 455 &st_idx_container.co_realm, &idx_id); \ 456 st_idx_op(&idx, opcode, keys, vals, rcs, flag, &ops[0]); \ 458 st_op_launch(ops, 1); \ 459 rc = st_op_wait(ops[0], \ 460 M0_BITS(M0_OS_FAILED, \ 463 ST_ASSERT_FATAL(rc == 0); \ 465 ops[0]->op_sm.sm_state == M0_OS_STABLE);\ 466 ST_ASSERT_FATAL(ops[0]->op_rc exp 0); \ 469 st_op_fini(ops[0]); \ 470 st_op_free(ops[0]); \ 471 st_entity_fini(&idx.in_entity); \ 474 #define idx_query_exp_success(idx_id, opcode, keys, vals, rcs, flag) \ 475 idx_query_exec(idx_id, opcode, keys, vals, rcs, flag, ==) 477 #define idx_query_exp_fail(idx_id, opcode, keys, vals, rcs, flag) \ 478 idx_query_exec(idx_id, opcode, keys, vals, rcs, flag, !=) 499 for (
i = 0;
i < nr_tests;
i++) {
515 memset(&idx, 0,
sizeof idx);
531 for(j = 0; j < nr_kvp; j++) {
568 for (
i = 0;
i < nr_tests;
i++) {
584 memset(&idx, 0,
sizeof idx);
597 if (
rc == -ETIMEDOUT) {
609 for(j = 0; j < nr_kvp; j++) {
626 static void idx_query_get_null(
void)
643 for (
i = 0;
i < nr_tests;
i++) {
657 memset(&idx, 0,
sizeof idx);
714 memcpy((
char *)(keys->
ov_buf[
i]),
"nonexistkv", 10);
718 memset(&idx, 0,
sizeof idx);
733 for(
i = 0;
i < nr_kvp;
i++) {
767 id.u_lo = idx_fid.
f_key;
784 memcpy((
char *)(keys->
ov_buf[
i]),
"nonexistkv", 10);
788 memset(&idx, 0,
sizeof idx);
834 key_no_arr =
m0_alloc(nr_kvp *
sizeof(*key_no_arr));
835 if (key_no_arr ==
NULL)
839 for (
i = 0;
i < nr_tests;
i++) {
854 for (j = 0; j < nr_kvp; j++) {
871 int last_key_len = 0;
872 void *last_key =
NULL;
880 for (
i = 0;
i < nr_rounds;
i++) {
893 keys->
ov_buf[0] = last_key;
898 if (
i == nr_rounds - 1)
904 if (last_key !=
NULL)
908 memcpy(last_key, keys->
ov_buf[nr_kvp - 1], last_key_len);
921 int last_key_len = 0;
922 int stored_key_len = 0;
923 void *last_key =
NULL;
924 void *stored_key =
NULL;
944 keys->
ov_buf[0] = last_key;
956 stored_key_len = last_key_len;
957 stored_key =
m0_alloc(last_key_len);
958 memcpy(last_key, keys->
ov_buf[nr_kvp - 1], last_key_len);
959 memcpy(stored_key, keys->
ov_buf[nr_kvp - 1], last_key_len);
977 keys->
ov_buf[0] = last_key;
987 keys->
ov_buf[0], stored_key_len) != 0);
1001 val = (
int *)
op->op_datum;
1009 val = (
int *)
op->op_datum;
1030 id.u_lo = idx_fid.
f_key;
1042 memset(&idx, 0,
sizeof idx);
1049 ops[0]->op_datum = (
void *)&
val;
1086 id.u_lo = idx_fid.
f_key;
1129 id.u_lo = idx_fid.
f_key;
1167 id.u_lo = idx_fid.
f_key;
1206 static void idx_query_put_duplicate(
void)
1219 id.u_hi = idx_fid.f_container;
1220 id.u_lo = idx_fid.f_key;
1265 id.u_lo = idx_fid.
f_key;
1329 {
"idx_query_get_cancel",
1332 {
"idx_query_get_null",
1333 &idx_query_get_null },
1334 {
"idx_query_put_duplicate",
1335 &idx_query_put_duplicate },
1337 {
"idx_query_put_not_existent_index",
1340 {
"idx_query_get_nonexist",
1342 {
"idx_query_get_non_existing_index",
1349 {
"idx_query_next_exclude_start",
1351 {
"idx_query_empty_next",
1353 {
"idx_query_next_not_exist_index",
1355 {
"idx_query_drop_index",
1357 {
"idx_query_callbacks",
1363 #undef M0_TRACE_SUBSYSTEM
void st_idx_init(struct m0_idx *idx, struct m0_realm *parent, const struct m0_uint128 *id)
int st_entity_create(struct m0_fid *pool, struct m0_entity *entity, struct m0_op **op)
void st_idx_open(struct m0_entity *entity)
#define M0_ALLOC_ARR(arr, nr)
void st_op_free(struct m0_op *op)
static int idx_do_insert_kv_pairs(struct m0_uint128 id, struct m0_bufvec *keys, struct m0_bufvec *vals, int *rcs)
static int idx_delete_one(struct m0_uint128 id)
static int st_idx_suite_fini(void)
const m0_time_t M0_TIME_NEVER
static void idx_query_del(void)
void(* oop_executed)(struct m0_op *op)
struct st_suite st_suite_idx
static struct m0_uint128 prefix
static int get_max_nr_kv_pairs(int idx_door_no)
int st_idx_op(struct m0_idx *idx, enum m0_idx_opcode opcode, struct m0_bufvec *keys, struct m0_bufvec *vals, int *rcs, int flag, struct m0_op **op)
static struct m0_container st_idx_container
const struct m0_uint128 M0_UBER_REALM
#define ST_ASSERT_FATAL(a)
static void idx_query_next_not_exist_index(void)
static void mock_op_cb_stable(struct m0_op *op)
static int idx_create_one(struct m0_uint128 id)
M0_INTERNAL void m0_bufvec_free(struct m0_bufvec *bufvec)
struct m0_entity in_entity
static void idx_query_callbacks(void)
static int idx_pick_keys(int idx_door_no, struct m0_bufvec *keys, int *key_no_arr)
static int st_idx_suite_init(void)
static struct m0_uint128 test_index_ids[ST_MAX_INDEX_NUM]
static bool is_kv_pair_deleted(int idx_door_no, int key_no)
static struct m0_bufvec * idx_bufvec_alloc(int nr)
#define M0_FID_TINIT(type, container, key)
static int idx_insert_kv_pairs(struct m0_uint128 id, int nr_kvp)
void(* oop_stable)(struct m0_op *op)
static void idx_query_get_cancel(void)
void st_container_init(struct m0_container *con, struct m0_realm *parent, const struct m0_uint128 *id, struct m0_client *instance)
struct m0_entity re_entity
int oid_get(struct m0_uint128 *oid)
static void idx_query_empty_next(void)
void * m0_alloc(size_t size)
static void idx_query_drop_index(void)
static void idx_query_next(void)
void console_printf(const char *fmt,...)
void(* oop_failed)(struct m0_op *op)
static void mem_free(const struct m0_be_btree *btree, struct m0_be_tx *tx, void *ptr)
void m0_op_cancel(struct m0_op **op, uint32_t nr)
static void idx_query_put_not_existent_index(void)
static int idx_test_prepare(void)
static void idx_query_get(void)
static void mock_op_cb_failed(struct m0_op *op)
static void idx_query_get_non_existing_index(void)
static void idx_query_get_nonexist(void)
m0_time_t m0_time_from_now(uint64_t secs, long ns)
struct m0_client * st_get_instance()
#define M0_CLIENT_THREAD_ENTER
static int start(struct m0_fom *fom)
void st_op_launch(struct m0_op **op, uint32_t nr)
void st_entity_fini(struct m0_entity *entity)
uint32_t generate_random(uint32_t max)
static void idx_bufvec_free(struct m0_bufvec *bv)
int st_entity_delete(struct m0_entity *entity, struct m0_op **op)
static bool * deleted_kv_pairs
static int idx_fill_kv_pairs(struct m0_uint128 id, int start, struct m0_bufvec *keys, struct m0_bufvec *vals)
#define idx_query_exp_success(idx_id, opcode, keys, vals, rcs, flag)
int32_t st_op_wait(struct m0_op *op, uint64_t bits, m0_time_t to)
void st_op_fini(struct m0_op *op)
static void idx_query_next_exclude_start(void)
#define idx_query_exp_fail(idx_id, opcode, keys, vals, rcs, flag)
void m0_op_setup(struct m0_op *op, const struct m0_op_ops *cbs, m0_time_t linger)