Motr  M0
st.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_ST_ST_H__
26 #define __MOTR_ST_ST_H__
27 
28 #include "motr/client.h"
29 #include "motr/client_internal.h"
30 #include "module/instance.h"
31 
32 #ifdef __KERNEL__
33 #include <asm-generic/errno-base.h>
34 #else
35 #include <errno.h>
36 #endif
37 
59 enum {
61 };
62 
63 enum {
68 };
69 
70 /*
71  * structure to define test in test suite.
72  */
73 struct st_test {
75  const char *st_name;
77  void (*st_proc)(void);
78 
79  /* a test is selected in a CLIENT SELECTED MODE */
81 };
82 
83 struct st_suite {
85  const char *ss_name;
86 
88  int (*ss_init)(void);
89  int (*ss_fini)(void);
90 
92  struct st_test ss_tests[];
93 };
94 
98 enum st_mode {
102 };
103 
104 struct st_cfg {
105  /*number of test threads*/
107 
108  /*if this flag is set, only specified tests are run*/
110  const char *sc_tests;
111 
117  uint64_t sc_deadline;
118 
119  /* test mode, see above*/
121 
128  int sc_pace;
129 };
130 
131 /*
132  * Client related details
133  */
134 struct m0_instance {
135  char *si_laddr;
136  char *si_ha_addr;
138  char *si_prof;
139 
141 };
142 
147  int64_t sws_nr_asserts;
149 };
150 
151 struct m0_st_ctx {
152  struct st_cfg sx_cfg;
153 
154  /* Client instance */
156 
157  /* Test suites */
160  struct st_suite **sx_all;
162 
163  /* Worker thread ID */
165 
166  /* Statistics data */
168 
169  /* Maximum length of test name (used for output)*/
171 };
172 
173 enum {
175 };
176 
180 struct m0* st_get_motr(void);
181 
185 void st_set_instance(struct m0_client *instance);
186 struct m0_client* st_get_instance(void);
187 
196 int st_run(const char *test_list_str);
197 
201 void st_add_suites(void);
202 
206 void st_list(bool);
207 
211 int st_init(void);
212 void st_fini(void);
213 
217 bool st_assertimpl(bool c, const char *str_c, const char *file,
218  int lno, const char *func);
219 
223 struct st_cfg st_get_cfg(void);
224 struct st_worker_stat* st_get_worker_stat(int idx);
225 
229 int st_get_nr_workers(void);
230 void st_set_nr_workers(int nr);
231 
235 void st_set_tests(const char *);
236 const char* st_get_tests(void);
237 
241 void st_set_test_mode(enum st_mode);
242 enum st_mode st_get_test_mode(void);
243 
244 
248 int st_set_worker_tid(int idx, pid_t tid);
249 int st_get_worker_idx(pid_t tid);
250 
254 int st_start_workers(void);
255 int st_stop_workers(void);
256 
260 int oid_get(struct m0_uint128 *oid);
261 void oid_put(struct m0_uint128 oid);
262 uint64_t oid_get_many(struct m0_uint128 *oids, uint64_t nr_oids);
263 void oid_put_many(struct m0_uint128 *oids, uint64_t nr_oids);
264 
265 int oid_allocator_init(void);
266 int oid_allocator_fini(void);
267 
268 /* Wrappers for Client APIs*/
269 void st_container_init(struct m0_container *con,
270  struct m0_realm *parent,
271  const struct m0_uint128 *id,
272  struct m0_client *instance);
273 void st_obj_init(struct m0_obj *obj,
274  struct m0_realm *parent,
275  const struct m0_uint128 *id, uint64_t layout_id);
276 void st_obj_fini(struct m0_obj *obj);
277 int st_entity_create(struct m0_fid *pool,
278  struct m0_entity *entity,
279  struct m0_op **op);
280 int st_entity_delete(struct m0_entity *entity,
281  struct m0_op **op);
282 void st_entity_fini(struct m0_entity *entity);
283 void st_op_launch(struct m0_op **op, uint32_t nr);
284 int32_t st_op_wait(struct m0_op *op, uint64_t bits, m0_time_t to);
285 void st_op_fini(struct m0_op *op);
286 void st_op_free(struct m0_op *op);
287 void st_entity_open(struct m0_entity *entity);
288 void st_idx_open(struct m0_entity *entity);
289 void st_obj_op(struct m0_obj *obj,
290  enum m0_obj_opcode opcode,
291  struct m0_indexvec *ext,
292  struct m0_bufvec *data,
293  struct m0_bufvec *attr,
294  uint64_t mask,
295  uint32_t flags,
296  struct m0_op **op);
297 
298 void st_idx_init(struct m0_idx *idx,
299  struct m0_realm *parent,
300  const struct m0_uint128 *id);
301 void st_idx_fini(struct m0_idx *idx);
302 int st_idx_op(struct m0_idx *idx,
303  enum m0_idx_opcode opcode,
304  struct m0_bufvec *keys,
305  struct m0_bufvec *vals,
306  int *rcs,
307  int flag,
308  struct m0_op **op);
309 
310 int st_layout_op(struct m0_obj *obj,
312  struct m0_client_layout *layout,
313  struct m0_op **op);
314 
315 /* Allocate aligned memory - user/kernel specific */
316 void st_alloc_aligned(void **ptr, size_t size, size_t alignment);
317 void st_free_aligned(void *ptr, size_t size, size_t alignment);
318 
323 #endif /* __MOTR_ST_ST_H__ */
char * si_prof
Definition: st.h:138
int sc_nr_threads
Definition: st.h:106
struct st_worker_stat * sx_worker_stats
Definition: st.h:167
void st_idx_init(struct m0_idx *idx, struct m0_realm *parent, const struct m0_uint128 *id)
Definition: api.c:56
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
void st_alloc_aligned(void **ptr, size_t size, size_t alignment)
Definition: st.h:104
static size_t nr
Definition: dump.c:1505
int st_entity_create(struct m0_fid *pool, struct m0_entity *entity, struct m0_op **op)
Definition: api.c:71
void st_idx_open(struct m0_entity *entity)
Definition: api.c:176
struct st_worker_stat * st_get_worker_stat(int idx)
Definition: st.c:67
Definition: client.h:835
void st_op_free(struct m0_op *op)
Definition: api.c:147
struct st_test ss_tests[]
Definition: st.h:92
Definition: client.h:788
int const char const void size_t int flags
Definition: dir.c:328
int sc_run_selected
Definition: st.h:109
m0_idx_opcode
Definition: client.h:550
m0_entity_opcode
Definition: client.h:523
struct st_cfg sx_cfg
Definition: st.h:152
int st_stop_workers(void)
Definition: st_worker.c:258
struct m0_file file
Definition: di.c:36
uint64_t m0_time_t
Definition: time.h:37
void st_obj_fini(struct m0_obj *obj)
Definition: api.c:50
void(* st_proc)(void)
Definition: st.h:77
void st_idx_fini(struct m0_idx *idx)
Definition: api.c:64
void st_free_aligned(void *ptr, size_t size, size_t alignment)
char * si_laddr
Definition: st.h:135
struct m0_bufvec data
Definition: di.c:40
int st_run(const char *test_list_str)
Definition: st.c:389
uint64_t oid_get_many(struct m0_uint128 *oids, uint64_t nr_oids)
Definition: oid.c:397
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)
Definition: api.c:113
Definition: st.h:73
void st_list(bool)
Definition: st.c:435
int st_set_worker_tid(int idx, pid_t tid)
Definition: st.c:108
void st_set_instance(struct m0_client *instance)
Definition: st.c:52
static struct foo * obj
Definition: tlist.c:302
int sx_nr_selected
Definition: st.h:159
struct st_suite ** sx_selected
Definition: st.h:161
int st_enabled
Definition: st.h:80
int oid_allocator_fini(void)
Definition: oid.c:454
op
Definition: libdemo.c:64
int st_get_nr_workers(void)
Definition: st.c:103
int opcode
Definition: crate.c:301
void st_fini(void)
Definition: st.c:490
Definition: client.h:641
char * si_confd_addr
Definition: st.h:137
void st_set_nr_workers(int nr)
Definition: st.c:95
uint64_t sc_deadline
Definition: st.h:117
void st_add_suites(void)
Definition: st.c:541
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:949
struct m0 * st_get_motr(void)
Definition: st.c:47
int64_t sws_nr_failed_asserts
Definition: st.h:148
int st_init(void)
Definition: st.c:448
void st_container_init(struct m0_container *con, struct m0_realm *parent, const struct m0_uint128 *id, struct m0_client *instance)
Definition: api.c:34
int oid_get(struct m0_uint128 *oid)
Definition: oid.c:373
Definition: st.h:151
Definition: st.h:83
static struct m0_addb2_callback c
Definition: consumer.c:41
const char * st_name
Definition: st.h:75
Definition: instance.h:80
int layout_id
Definition: dir.c:331
void st_set_tests(const char *)
Definition: st.c:75
int(* ss_fini)(void)
Definition: st.h:89
char * si_ha_addr
Definition: st.h:136
const char * sc_tests
Definition: st.h:110
int sx_nr_all
Definition: st.h:158
int sc_nr_rounds
Definition: st.h:116
void oid_put_many(struct m0_uint128 *oids, uint64_t nr_oids)
Definition: oid.c:408
static int lno
void st_obj_init(struct m0_obj *obj, struct m0_realm *parent, const struct m0_uint128 *id, uint64_t layout_id)
Definition: api.c:42
int(* ss_init)(void)
Definition: st.h:88
static struct m0_pool pool
Definition: iter_ut.c:58
struct m0_client * si_instance
Definition: st.h:140
enum st_mode st_get_test_mode(void)
Definition: st.c:90
void st_obj_op(struct m0_obj *obj, enum m0_obj_opcode opcode, struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr, uint64_t mask, uint32_t flags, struct m0_op **op)
Definition: api.c:100
Definition: fid.h:38
struct m0_instance sx_instance
Definition: st.h:155
struct m0_client * st_get_instance(void)
Definition: st.c:57
enum st_mode sc_mode
Definition: st.h:120
static bool flag
Definition: nucleus.c:266
Definition: st.h:99
int oid_allocator_init(void)
Definition: oid.c:426
m0_bcount_t size
Definition: di.c:39
m0_obj_opcode
Definition: client.h:537
void st_op_launch(struct m0_op **op, uint32_t nr)
Definition: api.c:129
void st_entity_fini(struct m0_entity *entity)
Definition: api.c:94
const char * st_get_tests(void)
Definition: st.c:80
struct st_suite ** sx_all
Definition: st.h:160
static struct m0 instance
Definition: main.c:78
const char * ss_name
Definition: st.h:85
int64_t sws_nr_asserts
Definition: st.h:147
int st_entity_delete(struct m0_entity *entity, struct m0_op **op)
Definition: api.c:83
void oid_put(struct m0_uint128 oid)
Definition: oid.c:384
int st_get_worker_idx(pid_t tid)
Definition: st.c:119
int sx_max_name_len
Definition: st.h:170
int sc_pace
Definition: st.h:128
struct st_cfg st_get_cfg(void)
Definition: st.c:62
void st_entity_open(struct m0_entity *entity)
Definition: api.c:153
pid_t * sx_worker_tids
Definition: st.h:164
int st_start_workers(void)
Definition: st_worker.c:226
int32_t st_op_wait(struct m0_op *op, uint64_t bits, m0_time_t to)
Definition: api.c:136
bool st_assertimpl(bool c, const char *str_c, const char *file, int lno, const char *func)
Definition: st_assert.c:93
void st_op_fini(struct m0_op *op)
Definition: api.c:142
st_mode
Definition: st.h:98
Definition: vec.h:145
void st_set_test_mode(enum st_mode)
Definition: st.c:85
int st_layout_op(struct m0_obj *obj, enum m0_entity_opcode opcode, struct m0_client_layout *layout, struct m0_op **op)
Definition: api.c:183