Motr  M0
ios_buffer_pool.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-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 #include "ioservice/io_service.c"
24 #include "ut/misc.h" /* M0_UT_PATH */
25 #include "ut/ut.h"
26 
27 #define TRANSPORTNAME M0_NET_XPRT_PREFIX_DEFAULT":"
28 
29 extern const struct m0_tl_descr bufferpools_tl;
30 
31 /* Motr setup arguments. */
32 static char *ios_ut_bp_singledom_cmd[] = {
33  "m0d", "-T", "AD",
34  "-D", "cs_sdb", "-S", "cs_stob",
35  "-A", "linuxstob:cs_addb_stob",
36  "-e", M0_NET_XPRT_PREFIX_DEFAULT":0@lo:12345:34:1",
37  "-H", "0@lo:12345:34:1",
38  "-w", "10",
39  "-f", M0_UT_CONF_PROCESS,
40  "-c", M0_UT_PATH("conf.xc")
41 };
42 
43 static char *ios_ut_bp_multidom_cmd[] = {
44  "m0d", "-T", "AD",
45  "-D", "cs_sdb", "-S", "cs_stob",
46  "-A", "linuxstob:cs_addb_stob",
47  "-w", "10",
48  "-e", M0_NET_XPRT_PREFIX_DEFAULT":0@lo:12345:34:1",
49  "-e", "bulk-mem:127.0.0.1:35678",
50  "-H", "0@lo:12345:34:1",
51  "-f", M0_UT_CONF_PROCESS,
52  "-c", M0_UT_PATH("conf.xc")
53 };
54 
55 static char *ios_ut_bp_repeatdom_cmd[] = {
56  "m0d", "-T", "AD",
57  "-D", "cs_sdb", "-S", "cs_stob",
58  "-A", "linuxstob:cs_addb_stob",
59  "-w", "10",
60  "-e", M0_NET_XPRT_PREFIX_DEFAULT":0@lo:12345:34:1",
61  "-e", "bulk-mem:127.0.0.1:35678",
62  "-e", "bulk-mem:127.0.0.1:35679",
63  "-H", "0@lo:12345:34:1",
64  "-f", M0_UT_CONF_PROCESS,
65  "-c", M0_UT_PATH("conf.xc")
66 };
67 
68 static char *ios_ut_bp_onerepeatdom_cmd[] = {
69  "m0d", "-T", "AD",
70  "-D", "cs_sdb", "-S", "cs_stob",
71  "-A", "linuxstob:cs_addb_stob",
72  "-w", "10",
73  "-e", M0_NET_XPRT_PREFIX_DEFAULT":0@lo:12345:34:1",
74  "-e", "bulk-mem:127.0.0.1:35678",
75  "-e", "bulk-mem:127.0.0.1:35679",
76  "-H", "0@lo:12345:34:1",
77  "-f", M0_UT_CONF_PROCESS,
78  "-c", M0_UT_PATH("conf.xc")
79 };
80 
81 #define SERVER_LOG_FILE_NAME "cs_ut.errlog"
82 
84 {
85  struct m0_reqh_io_service *serv_obj;
86  struct m0_reqh_service *reqh_ios;
87  struct m0_reqh *reqh;
88 
91  serv_obj = container_of(reqh_ios, struct m0_reqh_io_service, rios_gen);
92  M0_UT_ASSERT(serv_obj != NULL);
93 
94  return bufferpools_tlist_length(&serv_obj->rios_buffer_pools);
95 }
96 
97 static int check_buffer_pool_per_domain(char *cs_argv[], int cs_argc, int nbp)
98 {
99  int rc;
100  int bp_count;
101  struct m0_rpc_server_ctx sctx = {
102  .rsx_argv = cs_argv,
103  .rsx_argc = cs_argc,
104  .rsx_log_file_name = SERVER_LOG_FILE_NAME
105  };
106 
110  M0_UT_ASSERT(rc == 0);
111 
113  M0_UT_ASSERT(bp_count == nbp);
114 
116  return rc;
117 }
118 
120 {
121  /* It will create single buffer pool (per domain)*/
124 }
125 
127 {
128  /* It will create two buffer pool (per domain) */
131 }
132 
134 {
135  /* It will create single buffer pool (per domain) */
138 }
140 {
141  /* It will create two buffer pool (per domain) */
144 }
145 
147  .ts_name = "ios-bufferpool-ut",
148  .ts_init = NULL,
149  .ts_fini = NULL,
150  .ts_tests = {
151  { "ios-bufferpool-single-domain", test_ios_bp_single_dom},
152  { "ios-bufferpool-multiple-domains", test_ios_bp_multi_dom},
153  { "ios-bufferpool-repeat-domains", test_ios_bp_repeat_dom},
154  { "ios-bufferpool-onerepeat-domain", test_ios_bp_onerepeat_dom},
155  { NULL, NULL }
156  }
157 };
158 
159 /*
160  * Local variables:
161  * c-indentation-style: "K&R"
162  * c-basic-offset: 8
163  * tab-width: 8
164  * fill-column: 80
165  * scroll-step: 1
166  * End:
167  */
struct m0_reqh * m0_cs_reqh_get(struct m0_motr *cctx)
Definition: setup.c:1762
#define NULL
Definition: misc.h:38
struct m0_tl rios_buffer_pools
Definition: io_service.h:98
static char * ios_ut_bp_onerepeatdom_cmd[]
char ** rsx_argv
Definition: rpclib.h:77
int m0_rpc_server_start(struct m0_rpc_server_ctx *sctx)
Definition: rpclib.c:50
static char * ios_ut_bp_multidom_cmd[]
static int check_buffer_pool_per_domain(char *cs_argv[], int cs_argc, int nbp)
#define container_of(ptr, type, member)
Definition: misc.h:33
static char * ios_ut_bp_singledom_cmd[]
Definition: ut.h:77
void test_ios_bp_single_dom()
static struct m0_net_buffer_pool nbp
Definition: cp.c:37
#define M0_NET_XPRT_PREFIX_DEFAULT
Definition: net.h:98
static char * ios_ut_bp_repeatdom_cmd[]
struct m0_reqh_service_type m0_ios_type
Definition: io_service.c:112
int m0_net_xprt_nr(void)
Definition: net.c:168
struct m0_net_xprt ** rsx_xprts
Definition: rpclib.h:69
static struct m0_rpc_server_ctx sctx
Definition: console.c:88
Definition: reqh.h:94
struct m0_ut_suite ios_bufferpool_ut
void test_ios_bp_repeat_dom()
void test_ios_bp_onerepeat_dom()
const char * ts_name
Definition: ut.h:99
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_find(const struct m0_reqh_service_type *st, const struct m0_reqh *reqh)
Definition: reqh_service.c:538
struct m0_reqh reqh
Definition: rm_foms.c:48
static int get_ioservice_buffer_pool_count(struct m0_rpc_server_ctx *sctx)
int rsx_xprts_nr
Definition: rpclib.h:71
#define M0_UT_CONF_PROCESS
Definition: misc.h:45
struct m0_net_xprt ** m0_net_all_xprt_get(void)
Definition: net.c:161
#define SERVER_LOG_FILE_NAME
void m0_rpc_server_stop(struct m0_rpc_server_ctx *sctx)
Definition: rpclib.c:85
#define M0_UT_PATH(name)
Definition: misc.h:41
const struct m0_tl_descr bufferpools_tl
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
#define M0_UT_ASSERT(a)
Definition: ut.h:46
struct m0_motr rsx_motr_ctx
Definition: rpclib.h:84
void test_ios_bp_multi_dom()