Split and mock etcd_state_client_t for testing
This commit is contained in:
+2
-1
@@ -15,7 +15,7 @@
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
|
||||
osd_t::osd_t(const json11::Json & config, ring_loop_i *ringloop, timerfd_manager_t *tfd)
|
||||
osd_t::osd_t(const json11::Json & config, ring_loop_i *ringloop, timerfd_manager_t *tfd, std::unique_ptr<etcd_state_client_t> st_cli_ptr)
|
||||
{
|
||||
zero_buffer_size = 1<<20;
|
||||
zero_buffer = malloc_or_die(zero_buffer_size);
|
||||
@@ -23,6 +23,7 @@ osd_t::osd_t(const json11::Json & config, ring_loop_i *ringloop, timerfd_manager
|
||||
|
||||
this->ringloop = ringloop;
|
||||
this->tfd = tfd;
|
||||
this->st_cli = std::move(st_cli_ptr);
|
||||
|
||||
this->cli_config = config.object_items();
|
||||
this->file_config = msgr.read_config(this->cli_config);
|
||||
|
||||
+1
-1
@@ -390,7 +390,7 @@ class osd_t
|
||||
}
|
||||
|
||||
public:
|
||||
osd_t(const json11::Json & config, ring_loop_i *ringloop, timerfd_manager_t *tfd);
|
||||
osd_t(const json11::Json & config, ring_loop_i *ringloop, timerfd_manager_t *tfd, std::unique_ptr<etcd_state_client_t> st_cli_ptr);
|
||||
~osd_t();
|
||||
void force_stop(int exitcode);
|
||||
bool shutdown();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "osd.h"
|
||||
#include "str_util.h"
|
||||
#include "etcd_state_client.h"
|
||||
#include "etcd_state_client_http.h"
|
||||
#include "http_client.h"
|
||||
#include "osd_rmw.h"
|
||||
#include "addr_util.h"
|
||||
@@ -16,7 +16,6 @@
|
||||
// Peer connection is lost -> Reload connection data -> Try to reconnect
|
||||
void osd_t::init_cluster()
|
||||
{
|
||||
st_cli = std::make_unique<etcd_state_client_t>();
|
||||
if (!st_cli->address_count())
|
||||
{
|
||||
init_blockstore(NULL);
|
||||
@@ -65,7 +64,6 @@ void osd_t::init_cluster()
|
||||
}
|
||||
else
|
||||
{
|
||||
st_cli->tfd = tfd;
|
||||
st_cli->log_level = log_level;
|
||||
st_cli->on_change_osd_state_hook = [this](osd_num_t peer_osd) { on_change_osd_state_hook(peer_osd); };
|
||||
st_cli->on_change_pool_config_hook = [this]() { on_change_pool_config_hook(); };
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// License: VNPL-1.1 (see README.md for details)
|
||||
|
||||
#include "epoll_manager.h"
|
||||
#include "etcd_state_client_http.h"
|
||||
#include "osd.h"
|
||||
|
||||
#include <sys/prctl.h>
|
||||
@@ -65,7 +66,8 @@ int main(int narg, char *args[])
|
||||
signal(SIGTERM, handle_sigint);
|
||||
ring_loop_t *ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
|
||||
epoll_manager_t *epmgr = new epoll_manager_t(ringloop);
|
||||
osd = new osd_t(config, ringloop, epmgr->tfd);
|
||||
auto st_cli = new etcd_state_client_http_t(epmgr->tfd);
|
||||
osd = new osd_t(config, ringloop, epmgr->tfd, std::unique_ptr<etcd_state_client_t>(st_cli));
|
||||
while (1)
|
||||
{
|
||||
ringloop->loop();
|
||||
|
||||
Reference in New Issue
Block a user