This is an automated email from the ASF dual-hosted git repository.
gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 348de6e920c [test](fe) Isolate cloud frontend service test (#65577)
348de6e920c is described below
commit 348de6e920cd959d7464ff3e05f668f851f95330
Author: shuke <[email protected]>
AuthorDate: Wed Jul 15 19:10:57 2026 +0800
[test](fe) Isolate cloud frontend service test (#65577)
Related PR: #62805
---
.../service/FrontendServiceImplCloudTest.java | 78 ++++++++++++++++++++++
.../doris/service/FrontendServiceImplTest.java | 48 -------------
2 files changed, 78 insertions(+), 48 deletions(-)
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplCloudTest.java
b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplCloudTest.java
new file mode 100644
index 00000000000..a5a28080315
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplCloudTest.java
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.service;
+
+import org.apache.doris.catalog.Env;
+import org.apache.doris.cloud.CacheHotspotManager;
+import org.apache.doris.cloud.catalog.CloudEnv;
+import org.apache.doris.common.Config;
+import org.apache.doris.thrift.TGetTabletReplicaInfosRequest;
+import org.apache.doris.thrift.TGetTabletReplicaInfosResult;
+import org.apache.doris.thrift.TStatusCode;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+
+import java.util.Collections;
+
+public class FrontendServiceImplCloudTest {
+
+ // Regression test for FrontendServiceImpl.getTabletReplicaInfos NPE:
+ // When a warm-up job has been removed from
+ // CacheHotspotManager.cloudWarmUpJobs (past
+ // history_cloud_warm_up_job_keep_max_second), getCloudWarmUpJob
+ // returns null. The previous code called job.getJobId() inside the
+ // log message, throwing NPE which bubbled up to BE as
+ // "Internal error processing getTabletReplicaInfos".
+ @Test
+ public void testGetTabletReplicaInfosNullJobReturnsCancelledWithoutNpe() {
+ String originalCloudUniqueId = Config.cloud_unique_id;
+ Config.cloud_unique_id = "gettabletreplicainfostest";
+
+ CloudEnv cloudEnv = Mockito.mock(CloudEnv.class);
+ CacheHotspotManager cacheHotspotManager =
Mockito.mock(CacheHotspotManager.class);
+
Mockito.when(cloudEnv.getCacheHotspotMgr()).thenReturn(cacheHotspotManager);
+ // Simulate job already removed from cloudWarmUpJobs.
+
Mockito.when(cacheHotspotManager.getCloudWarmUpJob(123456L)).thenReturn(null);
+
+ try (MockedStatic<Env> envMock = Mockito.mockStatic(Env.class)) {
+ envMock.when(Env::getCurrentEnv).thenReturn(cloudEnv);
+
+ FrontendServiceImpl frontendService = new
FrontendServiceImpl(Mockito.mock(ExecuteEnv.class));
+ TGetTabletReplicaInfosRequest request = new
TGetTabletReplicaInfosRequest();
+ request.setTabletIds(Collections.singletonList(789L));
+ request.setWarmUpJobId(123456L);
+
+ TGetTabletReplicaInfosResult result;
+ try {
+ result = frontendService.getTabletReplicaInfos(request);
+ } catch (NullPointerException e) {
+ throw new AssertionError("getTabletReplicaInfos must not NPE
when the "
+ + "warm-up job has been removed from
CacheHotspotManager", e);
+ }
+
+ Assert.assertNotNull("result.status must be set",
result.getStatus());
+ Assert.assertEquals("BE must be told to cancel its stale warm-up
job entry",
+ TStatusCode.CANCELLED, result.getStatus().getStatusCode());
+ } finally {
+ Config.cloud_unique_id = originalCloudUniqueId;
+ }
+ }
+}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
index 008c10d91df..c017cd71bc2 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
@@ -23,8 +23,6 @@ import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Partition;
import org.apache.doris.catalog.TableIf;
-import org.apache.doris.cloud.CacheHotspotManager;
-import org.apache.doris.cloud.catalog.CloudEnv;
import org.apache.doris.common.AuthenticationException;
import org.apache.doris.common.Config;
import org.apache.doris.common.ErrorCode;
@@ -51,8 +49,6 @@ import org.apache.doris.thrift.TGetDbsParams;
import org.apache.doris.thrift.TGetDbsResult;
import org.apache.doris.thrift.TGetTablesParams;
import org.apache.doris.thrift.TGetTablesResult;
-import org.apache.doris.thrift.TGetTabletReplicaInfosRequest;
-import org.apache.doris.thrift.TGetTabletReplicaInfosResult;
import org.apache.doris.thrift.TListTableStatusResult;
import org.apache.doris.thrift.TLoadTxnCommitRequest;
import org.apache.doris.thrift.TLoadTxnRollbackRequest;
@@ -732,50 +728,6 @@ public class FrontendServiceImplTest {
}
}
- // Regression test for FrontendServiceImpl.getTabletReplicaInfos NPE:
- // When a warm-up job has been removed from
- // CacheHotspotManager.cloudWarmUpJobs (past
- // history_cloud_warm_up_job_keep_max_second), getCloudWarmUpJob
- // returns null. The previous code called job.getJobId() inside the
- // log message, throwing NPE which bubbled up to BE as
- // "Internal error processing getTabletReplicaInfos".
- @Test
- public void testGetTabletReplicaInfosNullJobReturnsCancelledWithoutNpe() {
- String originalCloudUniqueId = Config.cloud_unique_id;
- Config.cloud_unique_id = "gettabletreplicainfostest";
-
- CloudEnv cloudEnv = Mockito.mock(CloudEnv.class);
- CacheHotspotManager cacheHotspotManager =
Mockito.mock(CacheHotspotManager.class);
-
Mockito.when(cloudEnv.getCacheHotspotMgr()).thenReturn(cacheHotspotManager);
- // Simulate job already removed from cloudWarmUpJobs.
-
Mockito.when(cacheHotspotManager.getCloudWarmUpJob(123456L)).thenReturn(null);
-
- MockedStatic<Env> envMock = Mockito.mockStatic(Env.class);
- try {
- envMock.when(Env::getCurrentEnv).thenReturn(cloudEnv);
-
- FrontendServiceImpl frontendService = new
FrontendServiceImpl(exeEnv);
- TGetTabletReplicaInfosRequest request = new
TGetTabletReplicaInfosRequest();
- request.setTabletIds(Collections.singletonList(789L));
- request.setWarmUpJobId(123456L);
-
- TGetTabletReplicaInfosResult result;
- try {
- result = frontendService.getTabletReplicaInfos(request);
- } catch (NullPointerException e) {
- throw new AssertionError("getTabletReplicaInfos must not NPE
when the "
- + "warm-up job has been removed from
CacheHotspotManager", e);
- }
-
- Assert.assertNotNull("result.status must be set",
result.getStatus());
- Assert.assertEquals("BE must be told to cancel its stale warm-up
job entry",
- TStatusCode.CANCELLED, result.getStatus().getStatusCode());
- } finally {
- envMock.close();
- Config.cloud_unique_id = originalCloudUniqueId;
- }
- }
-
private MockedStatic<Env> transactionValidationEnvMock;
private void mockTransactionForTokenValidation(long txnId) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]