This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new aa233fd5e IMPALA-12778: Fix time strings in catalog operations page
aa233fd5e is described below
commit aa233fd5e6f53edcf927c384b6d64b285eac85a8
Author: stiga-huang <[email protected]>
AuthorDate: Fri Feb 2 10:42:33 2024 +0800
IMPALA-12778: Fix time strings in catalog operations page
In the /queries page of impalad, we are showing time strings using the
server timezone. However, in the /operations page of catalogd, UTC
timezone is used, which is confusing. This fixes the /operations page to
use the server timezone as well.
Tests
- Add e2e test
Change-Id: Ibebfc85267aabe9cef3a53f487d0ba53e050aa4c
Reviewed-on: http://gerrit.cloudera.org:8080/20983
Reviewed-by: Zihao Ye <[email protected]>
Reviewed-by: Wenzhe Zhou <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
be/src/catalog/catalog-server.cc | 4 ++--
tests/webserver/test_web_pages.py | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/be/src/catalog/catalog-server.cc b/be/src/catalog/catalog-server.cc
index be0ed3769..01617555e 100644
--- a/be/src/catalog/catalog-server.cc
+++ b/be/src/catalog/catalog-server.cc
@@ -1056,14 +1056,14 @@ static void CatalogOpListToJson(const
vector<TCatalogOpRecord>& catalog_ops,
Value target_name(catalog_op.target_name.c_str(),
document->GetAllocator());
obj.AddMember("target_name", target_name, document->GetAllocator());
- Value start_time(ToUtcStringFromUnixMillis(catalog_op.start_time_ms,
+ Value start_time(ToStringFromUnixMillis(catalog_op.start_time_ms,
TimePrecision::Millisecond).c_str(), document->GetAllocator());
obj.AddMember("start_time", start_time, document->GetAllocator());
int64_t end_time_ms;
if (catalog_op.finish_time_ms > 0) {
end_time_ms = catalog_op.finish_time_ms;
- Value finish_time(ToUtcStringFromUnixMillis(catalog_op.finish_time_ms,
+ Value finish_time(ToStringFromUnixMillis(catalog_op.finish_time_ms,
TimePrecision::Millisecond).c_str(), document->GetAllocator());
obj.AddMember("finish_time", finish_time, document->GetAllocator());
} else {
diff --git a/tests/webserver/test_web_pages.py
b/tests/webserver/test_web_pages.py
index b46490bfd..2a713cf86 100644
--- a/tests/webserver/test_web_pages.py
+++ b/tests/webserver/test_web_pages.py
@@ -21,6 +21,7 @@ from tests.common.file_utils import grep_dir
from tests.common.skip import SkipIfBuildType, SkipIfDockerizedCluster
from tests.common.impala_cluster import ImpalaCluster
from tests.common.impala_test_suite import ImpalaTestSuite
+from tests.util.parse_util import parse_duration_string_ms
from datetime import datetime
from multiprocessing import Process, Queue
from time import sleep, time
@@ -902,6 +903,44 @@ class TestWebPage(ImpalaTestSuite):
page = requests.head("http://localhost:25020/operations")
assert page.status_code == requests.codes.ok
+ def test_catalog_operation_fields(self, unique_database):
+ """Verify the CREATE_DATABASE operation is consistent with the statement
shown in the
+ /queries page of impalad."""
+ catalog_operations = json.loads(
+ requests.get("http://localhost:25020/operations?json").text)
+ assert "finished_catalog_operations" in catalog_operations
+
+ queries = json.loads(
+ requests.get("http://localhost:25000/queries?json").text)
+ assert "completed_queries" in queries
+
+ # Find the CREATE_DATABASE operation in catalogd
+ ts_format = "%Y-%m-%d %H:%M:%S.%f"
+ found = False
+ for op in catalog_operations["finished_catalog_operations"]:
+ if op["target_name"] == unique_database \
+ and op["catalog_op_name"] == "CREATE_DATABASE":
+ catalog_op_query_id = op["query_id"]
+ catalog_op_user = op["user"]
+ catalog_op_start_time = datetime.strptime(op["start_time"], ts_format)
+ catalog_op_end_time = datetime.strptime(op["finish_time"], ts_format)
+ catalog_op_duration = parse_duration_string_ms(op["duration"])
+ found = True
+ break
+ assert found
+ # Find the query in impalad
+ matched = False
+ for query in queries["completed_queries"]:
+ if query["query_id"] == catalog_op_query_id:
+ assert "CREATE DATABASE" in query["stmt"]
+ assert unique_database in query["stmt"]
+ assert catalog_op_user == query["effective_user"]
+ assert datetime.strptime(query["start_time"], ts_format) <=
catalog_op_start_time
+ assert datetime.strptime(query["end_time"], ts_format) >=
catalog_op_end_time
+ assert parse_duration_string_ms(query["duration"]) >=
catalog_op_duration
+ matched = True
+ assert matched
+
def test_catalog_metrics(self):
"""Test /metrics of catalogd"""
url = self.METRICS_URL.format(*self.CATALOG_TEST_PORT) + "?json"