This is an automated email from the ASF dual-hosted git repository. abukor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit cb69bb12eb07104c7d7c5333484534d997d65195 Author: Abhishek Chennaka <[email protected]> AuthorDate: Wed Oct 27 12:55:49 2021 -0400 KUDU-1959 - Add test for /startup page for the Master This patch contains a test for the Kudu Master Startup Webpage. We start up a mini master and validate the status of each startup step. We also fix the startup timers for the mini master. Change-Id: I823a59df215cfeb579f1593a63ef6133de37271c Reviewed-on: http://gerrit.cloudera.org:8080/17989 Reviewed-by: Attila Bukor <[email protected]> Tested-by: Attila Bukor <[email protected]> --- src/kudu/master/master-test.cc | 45 ++++++++++++++++++++++++++++++++++++++++++ src/kudu/master/master.cc | 6 ++---- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/kudu/master/master-test.cc b/src/kudu/master/master-test.cc index 37493fa..289c12f 100644 --- a/src/kudu/master/master-test.cc +++ b/src/kudu/master/master-test.cc @@ -18,6 +18,7 @@ #include "kudu/master/master.h" #include <algorithm> +#include <atomic> #include <cstdint> #include <ctime> #include <functional> @@ -372,6 +373,50 @@ TEST_F(MasterTest, TestResetBlockCacheMetricsInSameProcess) { }); } +TEST_F(MasterTest, TestStartupWebPage) { + EasyCurl c; + faststring buf; + string addr = mini_master_->bound_http_addr().ToString(); + mini_master_->Shutdown(); + std::atomic<bool> run_status_reader = false; + thread read_startup_page([&] { + EasyCurl thread_c; + faststring thread_buf; + while (!run_status_reader) { + SleepFor(MonoDelta::FromMilliseconds(10)); + if (!(thread_c.FetchURL(strings::Substitute("http://$0/startup", addr), &thread_buf)).ok()) { + continue; + } + ASSERT_STR_MATCHES(thread_buf.ToString(), "\"init_status\":(100|0)( |,)"); + ASSERT_STR_MATCHES(thread_buf.ToString(), "\"read_filesystem_status\":(100|0)( |,)"); + ASSERT_STR_MATCHES(thread_buf.ToString(), "\"read_instance_metadatafiles_status\"" + ":(100|0)( |,)"); + ASSERT_STR_MATCHES(thread_buf.ToString(), "\"read_data_directories_status\":" + "([0-9]|[1-9][0-9]|100)( |,)"); + ASSERT_STR_MATCHES(thread_buf.ToString(), "\"initialize_master_catalog_status\":" + "([0-9]|[1-9][0-9]|100)( |,)"); + ASSERT_STR_MATCHES(thread_buf.ToString(), "\"start_rpc_server_status\":(100|0)( |,)"); + } + }); + SCOPED_CLEANUP({ + run_status_reader = true; + read_startup_page.join(); + }); + + ASSERT_OK(mini_master_->Restart()); + ASSERT_OK(mini_master_->WaitForCatalogManagerInit()); + run_status_reader = true; + + // After all the steps have been completed, ensure every startup step has 100 percent status + ASSERT_OK(c.FetchURL(strings::Substitute("http://$0/startup", addr), &buf)); + ASSERT_STR_CONTAINS(buf.ToString(), "\"init_status\":100"); + ASSERT_STR_CONTAINS(buf.ToString(), "\"read_filesystem_status\":100"); + ASSERT_STR_CONTAINS(buf.ToString(), "\"read_instance_metadatafiles_status\":100"); + ASSERT_STR_CONTAINS(buf.ToString(), "\"read_data_directories_status\":100"); + ASSERT_STR_CONTAINS(buf.ToString(), "\"initialize_master_catalog_status\":100"); + ASSERT_STR_CONTAINS(buf.ToString(), "\"start_rpc_server_status\":100"); +} + TEST_F(MasterTest, TestRegisterAndHeartbeat) { const char* const kTsUUID = "my-ts-uuid"; diff --git a/src/kudu/master/master.cc b/src/kudu/master/master.cc index ea401b8..6262a84 100644 --- a/src/kudu/master/master.cc +++ b/src/kudu/master/master.cc @@ -225,13 +225,9 @@ Status Master::Init() { } Status Master::Start() { - Timer* init_master_catalog = - startup_path_handler_->initialize_master_catalog_progress(); - init_master_catalog->Start(); RETURN_NOT_OK(StartAsync()); RETURN_NOT_OK(WaitForCatalogManagerInit()); google::FlushLogFiles(google::INFO); // Flush the startup messages. - init_master_catalog->Stop(); return Status::OK(); } @@ -281,11 +277,13 @@ Status Master::StartAsync() { } void Master::InitCatalogManagerTask() { + startup_path_handler_->initialize_master_catalog_progress()->Start(); Status s = InitCatalogManager(); if (!s.ok()) { LOG(ERROR) << "Unable to init master catalog manager: " << s.ToString(); } catalog_manager_init_status_.Set(s); + startup_path_handler_->initialize_master_catalog_progress()->Stop(); } Status Master::InitCatalogManager() {
