From 84624a86858b6b5f9ce3be6734a4decc6c1c96a0 Mon Sep 17 00:00:00 2001 From: Jia Ke Date: Wed, 11 Dec 2024 22:25:46 +0800 Subject: [PATCH] Add unit tests --- .../hdfs/tests/HdfsFileSystemTest.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/velox/connectors/hive/storage_adapters/hdfs/tests/HdfsFileSystemTest.cpp b/velox/connectors/hive/storage_adapters/hdfs/tests/HdfsFileSystemTest.cpp index 33dcac02393d..a9c85854b12b 100644 --- a/velox/connectors/hive/storage_adapters/hdfs/tests/HdfsFileSystemTest.cpp +++ b/velox/connectors/hive/storage_adapters/hdfs/tests/HdfsFileSystemTest.cpp @@ -41,6 +41,7 @@ static const std::string localhost = "localhost"; static const std::string fullDestinationPath = "hdfs://" + localhost + ":" + hdfsPort + destinationPath; static const std::string simpleDestinationPath = "hdfs://" + destinationPath; +static const std::string viewfsDestinationPath = "viewfs://" + destinationPath; static const std::unordered_map configurationValues( {{"hive.hdfs.host", localhost}, {"hive.hdfs.port", hdfsPort}}); @@ -239,9 +240,8 @@ TEST_F(HdfsFileSystemTest, initializeFsWithEndpointInfoInFilePath) { TEST_F(HdfsFileSystemTest, fallbackToUseConfig) { auto config = std::make_shared( std::unordered_map(configurationValues)); - auto hdfsFileSystem = - filesystems::getFileSystem(simpleDestinationPath, config); - auto readFile = hdfsFileSystem->openFileForRead(simpleDestinationPath); + auto hdfsFileSystem = filesystems::getFileSystem(fullDestinationPath, config); + auto readFile = hdfsFileSystem->openFileForRead(fullDestinationPath); readData(readFile.get()); } @@ -262,7 +262,7 @@ TEST_F(HdfsFileSystemTest, missingFileViaFileSystem) { hdfsFileSystem->openFileForRead( "hdfs://localhost:7777/path/that/does/not/exist"), error_code::kFileNotFound, - "Unable to get file path info for file: /path/that/does/not/exist. got error: FileNotFoundException: Path /path/that/does/not/exist does not exist."); + "Unable to get file path info for file: hdfs://localhost:7777/path/that/does/not/exist. got error: FileNotFoundException: Path hdfs://localhost:7777/path/that/does/not/exist does not exist."); } TEST_F(HdfsFileSystemTest, missingHost) { @@ -331,6 +331,10 @@ TEST_F(HdfsFileSystemTest, schemeMatching) { auto fs = std::dynamic_pointer_cast( filesystems::getFileSystem(fullDestinationPath, nullptr)); ASSERT_TRUE(fs->isHdfsFile(fullDestinationPath)); + + fs = std::dynamic_pointer_cast( + filesystems::getFileSystem(viewfsDestinationPath, nullptr)); + ASSERT_TRUE(fs->isHdfsFile(viewfsDestinationPath)); } TEST_F(HdfsFileSystemTest, writeNotSupported) {