From b91b90d63931ee203c684f769b067fd5fae1607d Mon Sep 17 00:00:00 2001 From: alesapin Date: Tue, 9 Nov 2021 16:02:17 +0300 Subject: [PATCH] Fix test local address --- src/Common/tests/gtest_local_address.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Common/tests/gtest_local_address.cpp b/src/Common/tests/gtest_local_address.cpp index a7191ef30ea..4aadff400e9 100644 --- a/src/Common/tests/gtest_local_address.cpp +++ b/src/Common/tests/gtest_local_address.cpp @@ -10,11 +10,16 @@ TEST(LocalAddress, SmokeTest) DB::ShellCommand::Config config("/bin/hostname"); config.arguments = {"-i"}; auto cmd = DB::ShellCommand::executeDirect(config); + std::string address_str; DB::readString(address_str, cmd->out); cmd->wait(); std::cerr << "Got Address: " << address_str << std::endl; + /// hostname -i can return more than one address: "2001:db8:1::242:ac11:2 172.17.0.2" + if (auto space_pos = address_str.find(' '); space_pos != std::string::npos) + address_str = address_str.substr(0, space_pos); + Poco::Net::IPAddress address(address_str); EXPECT_TRUE(DB::isLocalAddress(address));