Motr  M0
rconfc.c File Reference
#include "lib/trace.h"
#include <unistd.h>
#include "conf/rconfc.h"
#include "conf/rconfc_internal.h"
#include "conf/confd.h"
#include "conf/helpers.h"
#include "conf/ut/common.h"
#include "conf/ut/confc.h"
#include "conf/ut/rpc_helpers.h"
#include "rpc/rpclib.h"
#include "lib/finject.h"
#include "lib/fs.h"
#include "module/instance.h"
#include "ut/misc.h"
#include "ut/ut.h"
Include dependency graph for rconfc.c:

Go to the source code of this file.

Data Structures

struct  root_object
 
struct  _ha_notify_ctx
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT
 
#define M0_UT_TRACE   0
 
#define NAME(ext)   "rconfc-ut" ext
 

Enumerations

enum  { CLIENT_COB_DOM_ID = 16, SESSION_SLOTS = 1, MAX_RPCS_IN_FLIGHT = 1 }
 
enum  ut_confc_control { UT_CC_KEEP_AS_IS, UT_CC_DISCONNECT, UT_CC_DEINITIALISE }
 

Functions

static int rconfc_ut_motr_start (struct m0_rpc_machine *mach, struct m0_rpc_server_ctx *rctx)
 
static void rconfc_ut_motr_stop (struct m0_rpc_machine *mach, struct m0_rpc_server_ctx *rctx)
 
static void test_null_exp_cb (struct m0_rconfc *rconfc)
 
static void conflict_exp_cb (struct m0_rconfc *rconfc)
 
static void conflict_ready_cb (struct m0_rconfc *rconfc)
 
static void test_init_fini (void)
 
static void test_start_stop (void)
 
static void test_start_stop_local (void)
 
static void test_local_load_fail (void)
 
static void test_start_failures (void)
 
static void rconfc_ut_fatal_cb (struct m0_rconfc *rconfc)
 
static bool ha_clink_cb_suppress (struct m0_clink *clink)
 
static void test_fail_abort (void)
 
static char * suffix_subst (const char *src, char delim, const char *suffix)
 
static bool ha_clink_cb_bad_rm (struct m0_clink *clink)
 
static void test_fail_retry_rm (void)
 
static bool ha_clink_cb_bad_confd (struct m0_clink *clink)
 
static void test_fail_retry_confd (void)
 
static void _stop_rms (struct m0_rpc_machine *rmach)
 
static void test_no_rms (void)
 
static void rconfc_ut_ha_state_set (const struct m0_fid *fid, uint32_t state)
 
 M0_TL_DESCR_DECLARE (rpc_conn, M0_EXTERN)
 
 M0_TL_DECLARE (rpc_conn, M0_INTERNAL, struct m0_rpc_conn)
 
static void _on_death_cb (struct rconfc_link *lnk)
 
 M0_TL_DESCR_DECLARE (rcnf_herd, M0_EXTERN)
 
 M0_TL_DECLARE (rcnf_herd, M0_INTERNAL, struct rconfc_link)
 
static void on_death_cb_install (struct m0_rconfc *rconfc, enum ut_confc_control ctrl)
 
static void test_dead_down (void)
 
static void test_dead_stop (void)
 
static void test_reading (void)
 
static bool quorum_impossible_clink_cb (struct m0_clink *cl)
 
static void test_quorum_impossible (void)
 
static void test_quorum_retry (void)
 
static void test_gops (void)
 
static void update_confd_version (struct m0_rpc_server_ctx *rctx, uint64_t new_ver)
 
static void test_version_change (void)
 
static void test_cache_drop (void)
 
static void test_confc_ctx_block (void)
 
static int _skip (struct m0_confc *confc)
 
static void test_reconnect_success (void)
 
static void _subscribe_to_service (struct m0_rconfc *rconfc, struct m0_fid *fid, struct m0_clink *clink)
 
static void _notify_cb (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static bool _clink_cb (struct m0_clink *link)
 
static M0_UNUSED void test_ha_notify (void)
 
static void drain_expired_cb (struct m0_rconfc *rconfc)
 
static bool fs_expired (struct m0_clink *clink)
 
static void drain_ready_cb (struct m0_rconfc *rconfc)
 
static bool fs_ready (struct m0_clink *clink)
 
static void test_drain (void)
 
static int rconfc_ut_init (void)
 
static int rconfc_ut_fini (void)
 

Variables

static struct m0_semaphore g_expired_sem
 
static struct m0_semaphore g_ready_sem
 
static struct m0_semaphore g_fatal_sem
 
static struct m0_reqhut_reqh
 
static struct m0_net_domain client_net_dom
 
static struct m0_fid profile = M0_FID_TINIT('p', 1, 0)
 
static bool(* ha_clink_cb_orig )(struct m0_clink *clink)
 
M0_EXTERN struct m0_confc_gate_ops m0_rconfc_gate_ops
 
M0_EXTERN struct m0_rm_incoming_ops m0_rconfc_ri_ops
 
static struct m0_rpc_client_ctx cctx
 
static bool do_fake = true
 
static struct m0_semaphore sem_death
 
static bool expected_fom_queued_value
 
struct m0_semaphore gops_sem
 
struct m0_fid drain_fs_fid = M0_FID0
 
struct m0_ut_suite rconfc_ut
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT

Definition at line 23 of file rconfc.c.

◆ M0_UT_TRACE

#define M0_UT_TRACE   0

Definition at line 26 of file rconfc.c.

◆ NAME

#define NAME (   ext)    "rconfc-ut" ext

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CLIENT_COB_DOM_ID 
SESSION_SLOTS 
MAX_RPCS_IN_FLIGHT 

Definition at line 56 of file rconfc.c.

◆ ut_confc_control

Enumerator
UT_CC_KEEP_AS_IS 
UT_CC_DISCONNECT 
UT_CC_DEINITIALISE 

Definition at line 568 of file rconfc.c.

Function Documentation

◆ _clink_cb()

static bool _clink_cb ( struct m0_clink link)
static

Definition at line 1214 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _notify_cb()

static void _notify_cb ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

Definition at line 1205 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _on_death_cb()

static void _on_death_cb ( struct rconfc_link lnk)
static

Definition at line 548 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _skip()

static int _skip ( struct m0_confc confc)
static

Definition at line 1141 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _stop_rms()

static void _stop_rms ( struct m0_rpc_machine rmach)
static

Definition at line 475 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _subscribe_to_service()

static void _subscribe_to_service ( struct m0_rconfc rconfc,
struct m0_fid fid,
struct m0_clink clink 
)
static

Definition at line 1185 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ conflict_exp_cb()

static void conflict_exp_cb ( struct m0_rconfc rconfc)
static

Definition at line 127 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ conflict_ready_cb()

static void conflict_ready_cb ( struct m0_rconfc rconfc)
static

Definition at line 134 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drain_expired_cb()

static void drain_expired_cb ( struct m0_rconfc rconfc)
static

Definition at line 1283 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drain_ready_cb()

static void drain_ready_cb ( struct m0_rconfc rconfc)
static

Definition at line 1311 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fs_expired()

static bool fs_expired ( struct m0_clink clink)
static

Definition at line 1297 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fs_ready()

static bool fs_ready ( struct m0_clink clink)
static

Definition at line 1319 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ha_clink_cb_bad_confd()

static bool ha_clink_cb_bad_confd ( struct m0_clink clink)
static

Definition at line 407 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ha_clink_cb_bad_rm()

static bool ha_clink_cb_bad_rm ( struct m0_clink clink)
static

Definition at line 338 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ha_clink_cb_suppress()

static bool ha_clink_cb_suppress ( struct m0_clink clink)
static

Definition at line 268 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ M0_TL_DECLARE() [1/2]

M0_TL_DECLARE ( rpc_conn  ,
M0_INTERNAL  ,
struct m0_rpc_conn   
)

◆ M0_TL_DECLARE() [2/2]

M0_TL_DECLARE ( rcnf_herd  ,
M0_INTERNAL  ,
struct rconfc_link   
)

◆ M0_TL_DESCR_DECLARE() [1/2]

M0_TL_DESCR_DECLARE ( rpc_conn  ,
M0_EXTERN   
)

◆ M0_TL_DESCR_DECLARE() [2/2]

M0_TL_DESCR_DECLARE ( rcnf_herd  ,
M0_EXTERN   
)

◆ on_death_cb_install()

static void on_death_cb_install ( struct m0_rconfc rconfc,
enum ut_confc_control  ctrl 
)
static

Definition at line 574 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ quorum_impossible_clink_cb()

static bool quorum_impossible_clink_cb ( struct m0_clink cl)
static

Definition at line 831 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rconfc_ut_fatal_cb()

static void rconfc_ut_fatal_cb ( struct m0_rconfc rconfc)
static

Definition at line 262 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rconfc_ut_fini()

static int rconfc_ut_fini ( void  )
static

Definition at line 1421 of file rconfc.c.

Here is the call graph for this function:

◆ rconfc_ut_ha_state_set()

static void rconfc_ut_ha_state_set ( const struct m0_fid fid,
uint32_t  state 
)
static

Definition at line 534 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rconfc_ut_init()

static int rconfc_ut_init ( void  )
static

Definition at line 1408 of file rconfc.c.

Here is the call graph for this function:

◆ rconfc_ut_motr_start()

static int rconfc_ut_motr_start ( struct m0_rpc_machine mach,
struct m0_rpc_server_ctx rctx 
)
static

Definition at line 77 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rconfc_ut_motr_stop()

static void rconfc_ut_motr_stop ( struct m0_rpc_machine mach,
struct m0_rpc_server_ctx rctx 
)
static

Definition at line 110 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ suffix_subst()

static char* suffix_subst ( const char *  src,
char  delim,
const char *  suffix 
)
static

Definition at line 322 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_cache_drop()

static void test_cache_drop ( void  )
static

Definition at line 1070 of file rconfc.c.

Here is the call graph for this function:

◆ test_confc_ctx_block()

static void test_confc_ctx_block ( void  )
static

Definition at line 1113 of file rconfc.c.

Here is the call graph for this function:

◆ test_dead_down()

static void test_dead_down ( void  )
static

Definition at line 608 of file rconfc.c.

Here is the call graph for this function:

◆ test_dead_stop()

static void test_dead_stop ( void  )
static

Definition at line 764 of file rconfc.c.

Here is the call graph for this function:

◆ test_drain()

static void test_drain ( void  )
static

Definition at line 1333 of file rconfc.c.

Here is the call graph for this function:

◆ test_fail_abort()

static void test_fail_abort ( void  )
static

Definition at line 288 of file rconfc.c.

Here is the call graph for this function:

◆ test_fail_retry_confd()

static void test_fail_retry_confd ( void  )
static

Definition at line 443 of file rconfc.c.

Here is the call graph for this function:

◆ test_fail_retry_rm()

static void test_fail_retry_rm ( void  )
static

Definition at line 374 of file rconfc.c.

Here is the call graph for this function:

◆ test_gops()

static void test_gops ( void  )
static

Definition at line 957 of file rconfc.c.

Here is the call graph for this function:

◆ test_ha_notify()

static M0_UNUSED void test_ha_notify ( void  )
static

Definition at line 1229 of file rconfc.c.

Here is the call graph for this function:

◆ test_init_fini()

static void test_init_fini ( void  )
static

Definition at line 141 of file rconfc.c.

Here is the call graph for this function:

◆ test_local_load_fail()

static void test_local_load_fail ( void  )
static

Definition at line 205 of file rconfc.c.

Here is the call graph for this function:

◆ test_no_rms()

static void test_no_rms ( void  )
static

Definition at line 489 of file rconfc.c.

Here is the call graph for this function:

◆ test_null_exp_cb()

static void test_null_exp_cb ( struct m0_rconfc rconfc)
static

Definition at line 118 of file rconfc.c.

Here is the caller graph for this function:

◆ test_quorum_impossible()

static void test_quorum_impossible ( void  )
static

Definition at line 854 of file rconfc.c.

Here is the call graph for this function:

◆ test_quorum_retry()

static void test_quorum_retry ( void  )
static

Definition at line 887 of file rconfc.c.

Here is the call graph for this function:

◆ test_reading()

static void test_reading ( void  )
static

Definition at line 802 of file rconfc.c.

Here is the call graph for this function:

◆ test_reconnect_success()

static void test_reconnect_success ( void  )
static

Definition at line 1147 of file rconfc.c.

Here is the call graph for this function:

◆ test_start_failures()

static void test_start_failures ( void  )
static

Definition at line 226 of file rconfc.c.

Here is the call graph for this function:

◆ test_start_stop()

static void test_start_stop ( void  )
static
Todo:
Check addresses used by rconfc

Definition at line 157 of file rconfc.c.

Here is the call graph for this function:

◆ test_start_stop_local()

static void test_start_stop_local ( void  )
static

Definition at line 182 of file rconfc.c.

Here is the call graph for this function:

◆ test_version_change()

static void test_version_change ( void  )
static

Definition at line 1017 of file rconfc.c.

Here is the call graph for this function:

◆ update_confd_version()

static void update_confd_version ( struct m0_rpc_server_ctx rctx,
uint64_t  new_ver 
)
static

Definition at line 989 of file rconfc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cctx

struct m0_rpc_client_ctx cctx
static
Initial value:
= {
.rcx_net_dom = &client_net_dom,
.rcx_local_addr = CLIENT_ENDPOINT_ADDR,
.rcx_remote_addr = SERVER_ENDPOINT_ADDR,
.rcx_max_rpcs_in_flight = MAX_RPCS_IN_FLIGHT,
.rcx_fid = &g_process_fid,
}
#define CLIENT_ENDPOINT_ADDR
Definition: common.h:32
static struct m0_net_domain client_net_dom
Definition: rconfc.c:47
#define SERVER_ENDPOINT_ADDR
Definition: common.h:30
struct m0_fid g_process_fid
Definition: ut.c:689

Definition at line 69 of file rconfc.c.

◆ client_net_dom

struct m0_net_domain client_net_dom
static

Definition at line 47 of file rconfc.c.

◆ do_fake

bool do_fake = true
static

Definition at line 337 of file rconfc.c.

◆ drain_fs_fid

struct m0_fid drain_fs_fid = M0_FID0

Definition at line 1281 of file rconfc.c.

◆ expected_fom_queued_value

bool expected_fom_queued_value
static

Definition at line 543 of file rconfc.c.

◆ g_expired_sem

struct m0_semaphore g_expired_sem
static

Definition at line 43 of file rconfc.c.

◆ g_fatal_sem

struct m0_semaphore g_fatal_sem
static

Definition at line 45 of file rconfc.c.

◆ g_ready_sem

struct m0_semaphore g_ready_sem
static

Definition at line 44 of file rconfc.c.

◆ gops_sem

struct m0_semaphore gops_sem

Definition at line 955 of file rconfc.c.

◆ ha_clink_cb_orig

bool(* ha_clink_cb_orig) (struct m0_clink *clink)
static

Definition at line 50 of file rconfc.c.

◆ m0_rconfc_gate_ops

M0_EXTERN struct m0_confc_gate_ops m0_rconfc_gate_ops

Definition at line 53 of file rconfc.c.

◆ m0_rconfc_ri_ops

M0_EXTERN struct m0_rm_incoming_ops m0_rconfc_ri_ops

Definition at line 54 of file rconfc.c.

◆ profile

struct m0_fid profile = M0_FID_TINIT('p', 1, 0)
static

Definition at line 49 of file rconfc.c.

◆ rconfc_ut

struct m0_ut_suite rconfc_ut
Initial value:
= {
.ts_name = "rconfc-ut",
.ts_init = rconfc_ut_init,
.ts_fini = rconfc_ut_fini,
.ts_tests = {
{ "init-fini", test_init_fini },
{ "start-stop", test_start_stop },
{ "local-conf", test_start_stop_local },
{ "local-load-fail", test_local_load_fail },
{ "start-fail", test_start_failures },
{ "fail-abort", test_fail_abort },
{ "fail-retry-rm", test_fail_retry_rm },
{ "fail-retry-confd", test_fail_retry_confd },
{ "no-rms", test_no_rms },
{ "dead-down", test_dead_down },
{ "dead-stop", test_dead_stop },
{ "reading", test_reading },
{ "impossible", test_quorum_impossible },
{ "quorum-retry", test_quorum_retry },
{ "gate-ops", test_gops },
{ "change-ver", test_version_change },
{ "cache-drop", test_cache_drop },
{ "ctx-block", test_confc_ctx_block },
{ "reconnect", test_reconnect_success },
{ "test-drain", test_drain },
{ NULL, NULL }
}
}
static void test_quorum_retry(void)
Definition: rconfc.c:887
static void test_no_rms(void)
Definition: rconfc.c:489
#define NULL
Definition: misc.h:38
static void test_dead_down(void)
Definition: rconfc.c:608
static void test_drain(void)
Definition: rconfc.c:1333
static void test_quorum_impossible(void)
Definition: rconfc.c:854
static void test_gops(void)
Definition: rconfc.c:957
static int rconfc_ut_fini(void)
Definition: rconfc.c:1421
static void test_fail_abort(void)
Definition: rconfc.c:288
static void test_init_fini(void)
Definition: rconfc.c:141
static int rconfc_ut_init(void)
Definition: rconfc.c:1408
static void test_reading(void)
Definition: rconfc.c:802
static void test_start_stop_local(void)
Definition: rconfc.c:182
static void test_cache_drop(void)
Definition: rconfc.c:1070
static void test_local_load_fail(void)
Definition: rconfc.c:205
static void test_reconnect_success(void)
Definition: rconfc.c:1147
static void test_fail_retry_confd(void)
Definition: rconfc.c:443
static void test_dead_stop(void)
Definition: rconfc.c:764
static void test_confc_ctx_block(void)
Definition: rconfc.c:1113
static void test_version_change(void)
Definition: rconfc.c:1017
static void test_fail_retry_rm(void)
Definition: rconfc.c:374
static void test_start_failures(void)
Definition: rconfc.c:226
static void test_start_stop(void)
Definition: rconfc.c:157

Definition at line 1426 of file rconfc.c.

◆ sem_death

struct m0_semaphore sem_death
static

Definition at line 542 of file rconfc.c.

◆ ut_reqh

struct m0_reqh* ut_reqh
static

Definition at line 46 of file rconfc.c.