Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhli1142015 committed Dec 30, 2024
1 parent 6e475e2 commit c691bc3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 4 additions & 3 deletions velox/connectors/hive/storage_adapters/abfs/AbfsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

namespace facebook::velox::filesystems {

std::unique_ptr<AzureDataLakeFileClient> AbfsConfig::fakeWriteClient_;
std::function<std::unique_ptr<AzureDataLakeFileClient>()>
AbfsConfig::testWriteClientFn_;

class DataLakeFileClientWrapper final : public AzureDataLakeFileClient {
public:
Expand Down Expand Up @@ -161,8 +162,8 @@ std::unique_ptr<BlobClient> AbfsConfig::getReadFileClient() {
}

std::unique_ptr<AzureDataLakeFileClient> AbfsConfig::getWriteFileClient() {
if (fakeWriteClient_) {
return std::move(fakeWriteClient_);
if (testWriteClientFn_) {
return testWriteClientFn_();
}
std::unique_ptr<DataLakeFileClient> client;
if (authType_ == kAzureSASAuthType) {
Expand Down
14 changes: 10 additions & 4 deletions velox/connectors/hive/storage_adapters/abfs/AbfsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ class AbfsConfig {
}

/// Test only.
static void registerFakeWriteFileClient(
std::unique_ptr<AzureDataLakeFileClient> fakeClient) {
fakeWriteClient_ = std::move(fakeClient);
static void setUpTestWriteClient(
std::function<std::unique_ptr<AzureDataLakeFileClient>()> testClientFn) {
testWriteClientFn_ = testClientFn;
}

/// Test only.
static void tearDownTestWriteClient() {
testWriteClientFn_ = nullptr;
}

private:
Expand All @@ -118,7 +123,8 @@ class AbfsConfig {
std::string authorityHost_;
std::shared_ptr<Azure::Core::Credentials::TokenCredential> tokenCredential_;

static std::unique_ptr<AzureDataLakeFileClient> fakeWriteClient_;
static std::function<std::unique_ptr<AzureDataLakeFileClient>()>
testWriteClientFn_;
};

} // namespace facebook::velox::filesystems
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class AbfsFileSystemTest : public testing::Test {
}

void SetUp() override {
AbfsConfig::setUpTestWriteClient(
[]() { return std::make_unique<MockDataLakeFileClient>(); });
auto port = facebook::velox::exec::test::getFreePort();
azuriteServer_ = std::make_shared<AzuriteServer>(port);
azuriteServer_->start();
Expand All @@ -59,6 +61,7 @@ class AbfsFileSystemTest : public testing::Test {
}

void TearDown() override {
AbfsConfig::tearDownTestWriteClient();
azuriteServer_->stop();
}

Expand Down Expand Up @@ -277,8 +280,6 @@ TEST_F(AbfsFileSystemTest, registerAbfsFileSink) {
auto hiveConfig =
std::make_shared<const config::ConfigBase>(std::move(config));
for (const auto& path : paths) {
AbfsConfig::registerFakeWriteFileClient(
std::make_unique<MockDataLakeFileClient>());
auto sink = dwio::common::FileSink::create(
path, {.connectorProperties = hiveConfig});
auto writeFileSink = dynamic_cast<dwio::common::WriteFileSink*>(sink.get());
Expand Down

0 comments on commit c691bc3

Please sign in to comment.