]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/client/TestClient.h
e1c0199b3105b70603eb502285e000db60ece143
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2021 Red Hat
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "gtest/gtest.h"
17 #include "common/async/context_pool.h"
18 #include "global/global_context.h"
20 #include "msg/Messenger.h"
21 #include "mon/MonClient.h"
22 #include "osdc/ObjectCacher.h"
24 #include "client/Client.h"
26 class TestClient
: public ::testing::Test
{
28 static void SetUpTestSuite() {
29 icp
.start(g_ceph_context
->_conf
.get_val
<std::uint64_t>("client_asio_thread_count"));
31 static void TearDownTestSuite() {
34 void SetUp() override
{
35 messenger
= Messenger::create_client_messenger(g_ceph_context
, "client");
36 if (messenger
->start() != 0) {
37 throw std::runtime_error("failed to start messenger");
40 mc
= new MonClient(g_ceph_context
, icp
);
41 if (mc
->build_initial_monmap() < 0) {
42 throw std::runtime_error("build monmap");
44 mc
->set_messenger(messenger
);
45 mc
->set_want_keys(CEPH_ENTITY_TYPE_MDS
| CEPH_ENTITY_TYPE_OSD
);
47 throw std::runtime_error("init monclient");
50 objecter
= new Objecter(g_ceph_context
, messenger
, mc
, icp
);
51 objecter
->set_client_incarnation(0);
53 messenger
->add_dispatcher_tail(objecter
);
56 client
= new Client(messenger
, mc
, objecter
);
58 client
->mount("/", myperm
, true);
60 void TearDown() override
{
61 if (client
->is_mounted())
66 messenger
->shutdown();
79 static inline ceph::async::io_context_pool icp
;
80 static inline UserPerm myperm
{0,0};
81 MonClient
* mc
= nullptr;
82 Messenger
* messenger
= nullptr;
83 Objecter
* objecter
= nullptr;
84 Client
* client
= nullptr;