MCPcopy Create free account
hub / github.com/apache/arrow / SetUp

Method SetUp

cpp/src/arrow/io/hdfs_test.cc:84–122  ·  view source on GitHub ↗

Set up shared state between unit tests

Source from the content-addressed store, hash-verified

82
83 // Set up shared state between unit tests
84 void SetUp() {
85 internal::LibHdfsShim* driver_shim;
86
87 client_ = nullptr;
88 scratch_dir_ =
89 (std::filesystem::temp_directory_path() / "arrow-hdfs/scratch-").string();
90 int random_size = 4;
91 scratch_dir_.resize(scratch_dir_.size() + random_size, '%');
92 random_alnum(
93 random_size, 0,
94 reinterpret_cast<uint8_t*>(&scratch_dir_[scratch_dir_.size() - random_size]));
95
96 loaded_driver_ = false;
97
98 Status msg = ConnectLibHdfs(&driver_shim);
99 if (!msg.ok()) {
100 if (std::getenv("ARROW_HDFS_TEST_LIBHDFS_REQUIRE")) {
101 FAIL() << "Loading libhdfs failed: " << msg.ToString();
102 } else {
103 std::cout << "Loading libhdfs failed, skipping tests gracefully: "
104 << msg.ToString() << std::endl;
105 }
106 return;
107 }
108
109 loaded_driver_ = true;
110
111 const char* host = std::getenv("ARROW_HDFS_TEST_HOST");
112 const char* port = std::getenv("ARROW_HDFS_TEST_PORT");
113 const char* user = std::getenv("ARROW_HDFS_TEST_USER");
114
115 ASSERT_TRUE(user != nullptr) << "Set ARROW_HDFS_TEST_USER";
116
117 conf_.host = host == nullptr ? "localhost" : host;
118 conf_.user = user;
119 conf_.port = port == nullptr ? 20500 : atoi(port);
120
121 ASSERT_OK(HadoopFileSystem::Connect(&conf_, &client_));
122 }
123
124 void TearDown() {
125 if (client_) {

Callers

nothing calls this directly

Calls 7

random_alnumFunction · 0.85
ConnectLibHdfsFunction · 0.85
resizeMethod · 0.80
stringMethod · 0.45
sizeMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected