Motr  M0
helper.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-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 
28 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_DTM0
29 #include "lib/trace.h"
30 
31 #include "dtm0/ut/helper.h"
32 
33 #include "ut/ut.h" /* M0_UT_ASSERT */
34 
35 #include "lib/misc.h" /* M0_IS0 */
36 #include "net/net.h" /* m0_net_all_xprt_get */
37 #include "dtm0/service.h" /* m0_dtm0_service */
38 
39 
40 struct m0_reqh_service;
41 
42 enum {
44 };
45 
46 #define SERVER_ENDPOINT_ADDR "0@lo:12345:34:1"
47 #define SERVER_ENDPOINT M0_NET_XPRT_PREFIX_DEFAULT":"SERVER_ENDPOINT_ADDR
48 #define DTM0_UT_CONF_PROCESS "<0x7200000000000001:5>"
49 
51  "m0d", "-T", "linux",
52  "-D", "dtm0_sdb", "-S", "dtm0_stob",
53  "-A", "linuxstob:dtm0_addb_stob",
54  "-e", SERVER_ENDPOINT,
56  "-w", "10",
58  "-c", M0_SRC_PATH("dtm0/conf.xc")
59 };
60 static const char *ut_dtm0_client_endpoint = "0@lo:12345:34:2";
61 const char *ut_dtm0_helper_log = "dtm0_ut_server.log";
62 
63 
64 M0_INTERNAL void m0_ut_dtm0_helper_init(struct m0_ut_dtm0_helper *udh)
65 {
66  struct m0_reqh_service *svc;
67  int rc;
68 
69  M0_PRE(M0_IS0(udh));
70 
71  *udh = (struct m0_ut_dtm0_helper){
72  .udh_sctx = {
74  .rsx_xprts_nr = m0_net_xprt_nr(),
75  .rsx_argv = ut_dtm0_helper_argv,
76  .rsx_argc = ARRAY_SIZE(ut_dtm0_helper_argv),
77  .rsx_log_file_name = ut_dtm0_helper_log,
78  },
79  .udh_cctx = {
80  .rcx_net_dom = &udh->udh_client_net_domain,
81  .rcx_local_addr = ut_dtm0_client_endpoint,
82  .rcx_remote_addr = SERVER_ENDPOINT_ADDR,
83  .rcx_max_rpcs_in_flight = MAX_RPCS_IN_FLIGHT,
84  .rcx_fid = &g_process_fid,
85  },
86  .udh_server_reqh =
88  .udh_client_reqh = &udh->udh_cctx.rcx_reqh,
89  .udh_server_dtm0_fid = M0_FID_INIT(0x7300000000000001, 0x1c),
90  .udh_client_dtm0_fid = M0_FID_INIT(0x7300000000000001, 0x1a),
91  };
93  M0_UT_ASSERT(rc == 0);
96  M0_UT_ASSERT(rc == 0);
98  M0_UT_ASSERT(rc == 0);
100  &udh->udh_client_dtm0_fid,
101  &svc);
102  M0_UT_ASSERT(rc == 0);
103 
105  dos_generic);
106 
108  &udh->udh_server_dtm0_fid);
109  /* TODO export the function which does bob_of() */
111  dos_generic);
112 }
113 
114 M0_INTERNAL void m0_ut_dtm0_helper_fini(struct m0_ut_dtm0_helper *udh)
115 {
116  int rc;
117 
119  rc = m0_rpc_client_stop(&udh->udh_cctx);
120  M0_UT_ASSERT(rc == 0);
123 }
124 
125 #undef M0_TRACE_SUBSYSTEM
126 
129 /*
130  * Local variables:
131  * c-indentation-style: "K&R"
132  * c-basic-offset: 8
133  * tab-width: 8
134  * fill-column: 80
135  * scroll-step: 1
136  * End:
137  */
138 /*
139  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
140  */
M0_INTERNAL void m0_ut_dtm0_helper_fini(struct m0_ut_dtm0_helper *udh)
Definition: helper.c:114
struct m0_reqh * udh_client_reqh
Definition: helper.h:52
#define M0_PRE(cond)
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_lookup(const struct m0_reqh *reqh, const struct m0_fid *fid)
Definition: reqh_service.c:551
void m0_net_domain_fini(struct m0_net_domain *dom)
Definition: domain.c:71
M0_INTERNAL void m0_dtm_client_service_stop(struct m0_reqh_service *svc)
Definition: service.c:139
char * ut_dtm0_helper_argv[]
Definition: helper.c:50
int m0_rpc_server_start(struct m0_rpc_server_ctx *sctx)
Definition: rpclib.c:50
#define M0_FID_INIT(container, key)
Definition: fid.h:84
struct m0_rpc_server_ctx udh_sctx
Definition: helper.h:43
#define container_of(ptr, type, member)
Definition: misc.h:33
#define M0_SRC_PATH(name)
Definition: misc.h:48
struct m0_fid udh_server_dtm0_fid
Definition: helper.h:53
const char * ut_dtm0_helper_log
Definition: helper.c:61
static const char * ut_dtm0_client_endpoint
Definition: helper.c:60
M0_INTERNAL int m0_dtm_client_service_start(struct m0_reqh *reqh, struct m0_fid *cli_srv_fid, struct m0_reqh_service **out)
Definition: service.c:113
struct m0_reqh rc_reqh
Definition: setup.h:312
int m0_net_xprt_nr(void)
Definition: net.c:168
int m0_rpc_client_stop(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:217
struct m0_rpc_client_ctx udh_cctx
Definition: helper.h:44
struct m0_net_xprt * m0_net_xprt_default_get(void)
Definition: net.c:151
int m0_rpc_client_start(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:160
struct m0_net_xprt ** rsx_xprts
Definition: rpclib.h:69
int m0_net_domain_init(struct m0_net_domain *dom, const struct m0_net_xprt *xprt)
Definition: domain.c:36
struct m0_reqh_context cc_reqh_ctx
Definition: setup.h:361
#define M0_IS0(obj)
Definition: misc.h:70
#define SERVER_ENDPOINT
Definition: helper.c:47
struct m0_net_domain udh_client_net_domain
Definition: helper.h:46
struct m0_net_xprt ** m0_net_all_xprt_get(void)
Definition: net.c:161
M0_INTERNAL void m0_ut_dtm0_helper_init(struct m0_ut_dtm0_helper *udh)
Definition: helper.c:64
static struct m0_net_test_service svc
Definition: service.c:34
#define DTM0_UT_CONF_PROCESS
Definition: helper.c:48
#define SERVER_ENDPOINT_ADDR
Definition: helper.c:46
void m0_rpc_server_stop(struct m0_rpc_server_ctx *sctx)
Definition: rpclib.c:85
struct m0_fid udh_client_dtm0_fid
Definition: helper.h:54
struct m0_reqh rcx_reqh
Definition: rpclib.h:144
struct m0_reqh * udh_server_reqh
Definition: helper.h:51
struct m0_reqh_service dos_generic
Definition: service.h:45
int32_t rc
Definition: trigger_fop.h:47
struct m0_dtm0_service * udh_client_dtm0_service
Definition: helper.h:56
#define ARRAY_SIZE(a)
Definition: misc.h:45
struct m0_fid g_process_fid
Definition: ut.c:689
#define M0_UT_ASSERT(a)
Definition: ut.h:46
struct m0_motr rsx_motr_ctx
Definition: rpclib.h:84
struct m0_dtm0_service * udh_server_dtm0_service
Definition: helper.h:55