Skip to content

Commit 3b9b4a4

Browse files
committed
Stabilize Azure filesystem cache test
Signed-off-by: luohaha <18810541851@163.com>
1 parent b05d260 commit 3b9b4a4

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

fe/fe-core/src/test/java/com/starrocks/fs/hdfs/HdfsFsManagerTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.junit.jupiter.api.Assertions;
3030
import org.junit.jupiter.api.BeforeEach;
3131
import org.junit.jupiter.api.Test;
32+
import org.mockito.MockedStatic;
3233
import org.mockito.Mockito;
3334

3435
import java.io.File;
@@ -227,6 +228,19 @@ public void testS3FileSystemCache() throws StarRocksException, IOException {
227228

228229
@Test
229230
public void testAzureFileSystemCache() throws StarRocksException, IOException {
231+
// The cache-key behavior does not require a live Azure client. Constructing the real
232+
// ABFS/WASB implementations with fake endpoints can block on external network activity,
233+
// making this unit test hit the suite's five-minute timeout. Return a fresh mock for every
234+
// actual FileSystem.get() call: cache hits still return the same HdfsFs, while distinct
235+
// authorities still cause separate calls and therefore receive distinct FileSystem mocks.
236+
try (MockedStatic<FileSystem> fileSystemMock = Mockito.mockStatic(FileSystem.class)) {
237+
fileSystemMock.when(() -> FileSystem.get(Mockito.any(), Mockito.any()))
238+
.thenAnswer(invocation -> Mockito.mock(FileSystem.class));
239+
verifyAzureFileSystemCacheKeys();
240+
}
241+
}
242+
243+
private void verifyAzureFileSystemCacheKeys() throws StarRocksException, IOException {
230244
// Test ADLS Gen2 schemes (abfs/abfss) with ADLS2 credentials
231245
Map<String, String> adlsProperties = new HashMap<>();
232246
adlsProperties.put(CloudConfigurationConstants.AZURE_ADLS2_SHARED_KEY, "c2hhcmVkS2V5"); // base64 encoded

0 commit comments

Comments
 (0)