From: Patrick Donnelly Date: Fri, 23 Oct 2020 23:33:23 +0000 (-0700) Subject: test/mon: add tests for mon_host build by hostname X-Git-Tag: v14.2.13~4^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d2e95ee17cf7b3f689c7a52dc53b64f55f43797d;p=ceph.git 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()) --- diff --git a/src/test/mon/MonMap.cc b/src/test/mon/MonMap.cc index a9206e9cb8ad1..54720b559af7a 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); +}