From d2e95ee17cf7b3f689c7a52dc53b64f55f43797d Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 23 Oct 2020 16:33:23 -0700 Subject: [PATCH] test/mon: add tests for mon_host build by hostname Signed-off-by: Patrick Donnelly (cherry picked from commit 4022c1f1fb4c37e63bf884e36a2b533735c56f94) Conflicts: src/test/mon/MonMap.cc - do not attempt to introduce boost::intrusive_ptr into Nautilus - monmap.build_initial takes bare cct in nautilus (master: cct.get()) --- src/test/mon/MonMap.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/mon/MonMap.cc b/src/test/mon/MonMap.cc index a9206e9cb8a..54720b559af 100644 --- a/src/test/mon/MonMap.cc +++ b/src/test/mon/MonMap.cc @@ -218,3 +218,22 @@ TEST_F(MonMapTest, DISABLED_build_initial_config_from_dns_with_domain) { ASSERT_EQ(os.str(), "192.168.1.13:6789/0"); } +TEST(MonMapBuildInitial, build_initial_mon_host_from_dns) { + CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_MON))->get(); + cct->_conf.set_val("mon_host", "ceph.io"); + MonMap monmap; + int r = monmap.build_initial(cct, false, std::cerr); + ASSERT_EQ(r, 0); + ASSERT_GE(monmap.mon_info.size(), 1u); + for (const auto& [name, info] : monmap.mon_info) { + std::cerr << info << std::endl; + } +} + +TEST(MonMapBuildInitial, build_initial_mon_host_from_dns_fail) { + CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_MON))->get(); + cct->_conf.set_val("mon_host", "ceph.noname"); + MonMap monmap; + int r = monmap.build_initial(cct, false, std::cerr); + ASSERT_EQ(r, -EINVAL); +} -- 2.47.3