Skip to content

Commit 988d6e9

Browse files
committed
Update TempDirectoryPath and TempFilePath path
1 parent a531e32 commit 988d6e9

File tree

9 files changed

+52
-46
lines changed

9 files changed

+52
-46
lines changed

presto-native-execution/presto_cpp/main/operators/tests/BroadcastTest.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
#include "velox/common/base/tests/GTestUtils.h"
2323
#include "velox/common/compression/Compression.h"
2424
#include "velox/common/file/FileSystems.h"
25+
#include "velox/common/testutil/TempDirectoryPath.h"
2526
#include "velox/core/QueryConfig.h"
2627
#include "velox/exec/Exchange.h"
2728
#include "velox/exec/ExchangeSource.h"
2829
#include "velox/exec/tests/utils/OperatorTestBase.h"
2930
#include "velox/exec/tests/utils/PlanBuilder.h"
3031
#include "velox/exec/tests/utils/QueryAssertions.h"
31-
#include "velox/exec/tests/utils/TempDirectoryPath.h"
3232
#include "velox/serializers/PrestoSerializer.h"
3333

3434
using namespace facebook::velox;
35+
using namespace facebook::velox::common::testutil;
3536
using namespace facebook::presto;
3637
using namespace facebook::presto::operators;
3738

@@ -189,7 +190,7 @@ class BroadcastTest : public exec::test::OperatorTestBase,
189190
exec::Operator::registerOperator(
190191
std::make_unique<BroadcastWriteTranslator>());
191192

192-
auto tempDirectoryPath = exec::test::TempDirectoryPath::create();
193+
auto tempDirectoryPath = TempDirectoryPath::create();
193194
auto [serdeRowType, broadcastFilePaths] =
194195
executeBroadcastWrite(data, tempDirectoryPath->getPath(), serdeLayout);
195196

@@ -264,7 +265,7 @@ TEST_P(BroadcastTest, endToEndSerdeLayout) {
264265
TEST_P(BroadcastTest, endToEndWithNoRows) {
265266
std::vector<RowVectorPtr> data = {makeRowVector(
266267
{makeFlatVector<double>({}), makeArrayVector<int32_t>({})})};
267-
auto tempDirectoryPath = exec::test::TempDirectoryPath::create();
268+
auto tempDirectoryPath = TempDirectoryPath::create();
268269
std::vector<std::string> broadcastFilePaths;
269270

270271
// Execute write.
@@ -291,7 +292,7 @@ TEST_P(BroadcastTest, endToEndWithMultipleWriteNodes) {
291292
makeFlatVector<int32_t>({11, 21, 31, 41, 51, 61}),
292293
makeFlatVector<int64_t>({102, 203, 304, 405, 506, 607}),
293294
})};
294-
auto tempDirectoryPath = exec::test::TempDirectoryPath::create();
295+
auto tempDirectoryPath = TempDirectoryPath::create();
295296
std::vector<std::string> broadcastFilePaths;
296297

297298
// Execute write.
@@ -380,7 +381,7 @@ TEST_P(BroadcastTest, malformedBroadcastInfoJson) {
380381
}
381382

382383
TEST_P(BroadcastTest, broadcastFileWriter) {
383-
auto tempDirectoryPath = exec::test::TempDirectoryPath::create();
384+
auto tempDirectoryPath = TempDirectoryPath::create();
384385
auto fileSystem =
385386
velox::filesystems::getFileSystem(tempDirectoryPath->getPath(), nullptr);
386387
fileSystem->mkdir(tempDirectoryPath->getPath());
@@ -585,7 +586,7 @@ TEST_P(BroadcastTest, endToEndWithDifferentWriterPageSizes) {
585586
};
586587

587588
for (size_t i = 0; i < kPageSizes.size(); ++i) {
588-
auto tempDirectoryPath = exec::test::TempDirectoryPath::create();
589+
auto tempDirectoryPath = TempDirectoryPath::create();
589590

590591
// Create a modified factory that uses custom buffer size
591592
auto fileSystem = velox::filesystems::getFileSystem(
@@ -652,7 +653,7 @@ TEST_P(BroadcastTest, endToEndWithDifferentWriterPageSizes) {
652653
}
653654

654655
TEST_P(BroadcastTest, exceedBroadcastFileWriterLimit) {
655-
auto tempDirectoryPath = exec::test::TempDirectoryPath::create();
656+
auto tempDirectoryPath = TempDirectoryPath::create();
656657
auto fileSystem =
657658
velox::filesystems::getFileSystem(tempDirectoryPath->getPath(), nullptr);
658659
fileSystem->mkdir(tempDirectoryPath->getPath());
@@ -693,7 +694,7 @@ TEST_P(BroadcastTest, exceedBroadcastFileWriterLimit) {
693694
}
694695

695696
TEST_P(BroadcastTest, broadcastJoinExceedLimit) {
696-
auto tempDirectoryPath = exec::test::TempDirectoryPath::create();
697+
auto tempDirectoryPath = TempDirectoryPath::create();
697698

698699
// Create build side data (data to broadcast)
699700
auto buildData = makeRowVector({

presto-native-execution/presto_cpp/main/operators/tests/ShuffleTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
#include "presto_cpp/main/operators/tests/PlanBuilder.h"
2828

2929
#include "velox/common/base/tests/GTestUtils.h"
30+
#include "velox/common/testutil/TempDirectoryPath.h"
3031
#include "velox/common/testutil/TestValue.h"
3132
#include "velox/exec/Exchange.h"
3233
#include "velox/exec/ExchangeClient.h"
3334
#include "velox/exec/tests/utils/AssertQueryBuilder.h"
3435
#include "velox/exec/tests/utils/OperatorTestBase.h"
3536
#include "velox/exec/tests/utils/PlanBuilder.h"
36-
#include "velox/exec/tests/utils/TempDirectoryPath.h"
3737
#include "velox/row/CompactRow.h"
3838
#include "velox/vector/fuzzer/VectorFuzzer.h"
3939

@@ -191,7 +191,7 @@ class ShuffleTest : public exec::test::OperatorTestBase {
191191
std::make_unique<LocalPersistentShuffleFactory>());
192192
registerExchangeSource(std::string(shuffleName_));
193193
// Create a temporary directory for shuffle files
194-
tempDir_ = exec::test::TempDirectoryPath::create();
194+
tempDir_ = TempDirectoryPath::create();
195195
}
196196

197197
void TearDown() override {
@@ -660,7 +660,7 @@ class ShuffleTest : public exec::test::OperatorTestBase {
660660
{"c16", MAP(TINYINT(), REAL())},
661661
});
662662

663-
auto rootDirectory = velox::exec::test::TempDirectoryPath::create();
663+
auto rootDirectory = TempDirectoryPath::create();
664664
auto rootPath = rootDirectory->getPath();
665665
const std::string shuffleWriteInfo =
666666
localShuffleWriteInfo(rootPath, numPartitions);
@@ -701,7 +701,7 @@ class ShuffleTest : public exec::test::OperatorTestBase {
701701
}
702702

703703
std::string_view shuffleName_;
704-
std::shared_ptr<exec::test::TempDirectoryPath> tempDir_;
704+
std::shared_ptr<TempDirectoryPath> tempDir_;
705705
enum class DataType {
706706
BASIC,
707707
BASIC_WITH_NULLS,
@@ -1412,10 +1412,10 @@ TEST_F(ShuffleTest, shuffleEndToEnd) {
14121412
for (const auto& config : testSettings) {
14131413
SCOPED_TRACE(config.debugString());
14141414

1415-
std::shared_ptr<exec::test::TempDirectoryPath> customTempDir;
1415+
std::shared_ptr<TempDirectoryPath> customTempDir;
14161416
std::string rootPath;
14171417
if (config.useCustomTempDir) {
1418-
customTempDir = exec::test::TempDirectoryPath::create();
1418+
customTempDir = TempDirectoryPath::create();
14191419
rootPath = customTempDir->getPath();
14201420
} else {
14211421
rootPath = tempDir_->getPath();
@@ -1564,7 +1564,7 @@ TEST_F(ShuffleTest, shuffleWriterReader) {
15641564
for (const auto& config : testSettings) {
15651565
SCOPED_TRACE(config.debugString());
15661566

1567-
auto tempRootDir = velox::exec::test::TempDirectoryPath::create();
1567+
auto tempRootDir = TempDirectoryPath::create();
15681568
const auto testRootPath = tempRootDir->getPath();
15691569

15701570
LocalShuffleWriteInfo writeInfo = LocalShuffleWriteInfo::deserialize(

presto-native-execution/presto_cpp/main/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if(PRESTO_ENABLE_REMOTE_FUNCTIONS)
9090
presto_server_remote_function_test
9191
presto_server_remote_function
9292
velox_expression
93-
velox_temp_path
93+
velox_test_util
9494
GTest::gmock
9595
GTest::gtest
9696
GTest::gtest_main

presto-native-execution/presto_cpp/main/tests/LinuxMemoryCheckerTest.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
#include <gtest/gtest.h>
1818
#include "velox/common/base/VeloxException.h"
1919
#include "velox/common/base/tests/GTestUtils.h"
20-
#include "velox/exec/tests/utils/TempFilePath.h"
20+
#include "velox/common/testutil/TempFilePath.h"
2121

2222
using namespace facebook::velox;
23+
using namespace facebook::velox::common::testutil;
2324

2425
namespace facebook::presto {
2526
class LinuxMemoryCheckerTest : public testing::Test {
@@ -31,11 +32,11 @@ class LinuxMemoryCheckerTest : public testing::Test {
3132
void checkAvailableMemoryOfDeployment(
3233
const std::string& content,
3334
int64_t expectedMemoryMax) {
34-
auto tempMemInfoFile = exec::test::TempFilePath::create();
35+
auto tempMemInfoFile = TempFilePath::create();
3536
tempMemInfoFile->append(kMemInfoText_);
3637
auto memInfoPath = tempMemInfoFile->getPath();
3738

38-
auto tempMemMaxFile = exec::test::TempFilePath::create();
39+
auto tempMemMaxFile = TempFilePath::create();
3940
tempMemMaxFile->append(content);
4041
auto tempMemMaxFilePath = tempMemMaxFile->getPath();
4142

@@ -47,7 +48,7 @@ class LinuxMemoryCheckerTest : public testing::Test {
4748
void checkMemoryUsage(
4849
const std::string& content,
4950
int64_t expectedMemoryUsage) {
50-
auto tempTestFile = exec::test::TempFilePath::create();
51+
auto tempTestFile = TempFilePath::create();
5152
tempTestFile->append(content);
5253
auto testFilePath = tempTestFile->getPath();
5354

@@ -147,11 +148,11 @@ TEST_F(LinuxMemoryCheckerTest, basic) {
147148
}
148149

149150
TEST_F(LinuxMemoryCheckerTest, sysMemLimitBytesCheck) {
150-
auto tempMemInfoFile = exec::test::TempFilePath::create();
151+
auto tempMemInfoFile = TempFilePath::create();
151152
tempMemInfoFile->append(kMemInfoText_);
152153
auto memInfoPath = tempMemInfoFile->getPath();
153154

154-
auto tempTestFile = exec::test::TempFilePath::create();
155+
auto tempTestFile = TempFilePath::create();
155156
tempTestFile->append("131000000000\n");
156157
auto memMaxFilePath = tempTestFile->getPath();
157158

presto-native-execution/presto_cpp/main/tests/RemoteFunctionRegistererTest.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
#include <gtest/gtest.h>
1717
#include <fstream>
1818
#include "velox/common/base/Fs.h"
19-
#include "velox/exec/tests/utils/TempDirectoryPath.h"
20-
#include "velox/exec/tests/utils/TempFilePath.h"
19+
#include "velox/common/testutil/TempDirectoryPath.h"
20+
#include "velox/common/testutil/TempFilePath.h"
2121
#include "velox/expression/VectorFunction.h"
2222

2323
using namespace facebook::velox;
24+
using namespace facebook::velox::common::testutil;
2425

2526
namespace facebook::presto::test {
2627
namespace {
@@ -56,7 +57,7 @@ TEST_F(RemoteFunctionRegistererTest, singleFile) {
5657
})";
5758

5859
// Write to a single output file.
59-
auto path = exec::test::TempFilePath::create();
60+
auto path = TempFilePath::create();
6061
writeToFile(path->getPath(), json);
6162

6263
// Check functions do not exist first.
@@ -86,7 +87,7 @@ TEST_F(RemoteFunctionRegistererTest, prefixes) {
8687
})";
8788

8889
// Write to a single output file.
89-
auto path = exec::test::TempFilePath::create();
90+
auto path = TempFilePath::create();
9091
writeToFile(path->getPath(), json);
9192

9293
EXPECT_TRUE(exec::getVectorFunctionSignatures("mock3") == std::nullopt);
@@ -124,7 +125,7 @@ std::string getJson(const std::string& functionName) {
124125
}
125126

126127
TEST_F(RemoteFunctionRegistererTest, directory) {
127-
auto tempDir = exec::test::TempDirectoryPath::create();
128+
auto tempDir = TempDirectoryPath::create();
128129

129130
// Create the following structure:
130131
//

presto-native-execution/presto_cpp/main/tests/TaskManagerTest.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "velox/common/base/Fs.h"
2727
#include "velox/common/base/tests/GTestUtils.h"
2828
#include "velox/common/file/FileSystems.h"
29+
#include "velox/common/testutil/TempDirectoryPath.h"
2930
#include "velox/connectors/hive/HiveConnector.h"
3031
#include "velox/dwio/common/FileSink.h"
3132
#include "velox/dwio/common/WriterFactory.h"
@@ -36,7 +37,6 @@
3637
#include "velox/exec/tests/utils/OperatorTestBase.h"
3738
#include "velox/exec/tests/utils/PlanBuilder.h"
3839
#include "velox/exec/tests/utils/QueryAssertions.h"
39-
#include "velox/exec/tests/utils/TempDirectoryPath.h"
4040
#include "velox/type/Type.h"
4141

4242
DECLARE_int32(old_task_ms);
@@ -45,6 +45,7 @@ DECLARE_bool(velox_memory_leak_check_enabled);
4545
static const std::string kHiveConnectorId = "test-hive";
4646

4747
using namespace facebook::velox;
48+
using namespace facebook::velox::common::testutil;
4849
using namespace facebook::velox::exec;
4950
using namespace facebook::velox::exec::test;
5051

@@ -609,8 +610,8 @@ class TaskManagerTest : public exec::test::OperatorTestBase,
609610
// Setup the temporary spilling directory and initialize the system config
610611
// file (in the same temporary directory) to contain the spilling path
611612
// setting.
612-
static std::shared_ptr<exec::test::TempDirectoryPath> setupSpillPath() {
613-
auto spillDirectory = exec::test::TempDirectoryPath::create();
613+
static std::shared_ptr<TempDirectoryPath> setupSpillPath() {
614+
auto spillDirectory = TempDirectoryPath::create();
614615
auto sysConfigFilePath =
615616
fmt::format("{}/config.properties", spillDirectory->getPath());
616617
auto fileSystem = filesystems::getFileSystem(sysConfigFilePath, nullptr);
@@ -692,7 +693,7 @@ class TaskManagerTest : public exec::test::OperatorTestBase,
692693
// Runs "select * from t where c0 % 5 = 0" query.
693694
// Creates one task and provides all splits at once.
694695
TEST_P(TaskManagerTest, tableScanAllSplitsAtOnce) {
695-
const auto tableDir = exec::test::TempDirectoryPath::create();
696+
const auto tableDir = TempDirectoryPath::create();
696697
auto filePaths = makeFilePaths(tableDir, 5);
697698
auto vectors = makeVectors(filePaths.size(), 1'000);
698699
for (int i = 0; i < filePaths.size(); i++) {
@@ -720,7 +721,7 @@ TEST_P(TaskManagerTest, tableScanAllSplitsAtOnce) {
720721
}
721722

722723
TEST_P(TaskManagerTest, addSplitsWithSameSourceNode) {
723-
const auto tableDir = exec::test::TempDirectoryPath::create();
724+
const auto tableDir = TempDirectoryPath::create();
724725
auto filePaths = makeFilePaths(tableDir, 5);
725726
auto vectors = makeVectors(filePaths.size(), 1'000);
726727
for (int i = 0; i < filePaths.size(); i++) {
@@ -755,7 +756,7 @@ TEST_P(TaskManagerTest, addSplitsWithSameSourceNode) {
755756
}
756757

757758
TEST_P(TaskManagerTest, fecthFromFinishedTask) {
758-
const auto tableDir = exec::test::TempDirectoryPath::create();
759+
const auto tableDir = TempDirectoryPath::create();
759760
auto filePaths = makeFilePaths(tableDir, 5);
760761
auto vectors = makeVectors(filePaths.size(), 1'000);
761762
for (int i = 0; i < filePaths.size(); i++) {
@@ -872,7 +873,7 @@ TEST_P(TaskManagerTest, taskCleanupWithPendingResultData) {
872873
// Trigger old task cleanup immediately.
873874
taskManager_->setOldTaskCleanUpMs(0);
874875

875-
const auto tableDir = exec::test::TempDirectoryPath::create();
876+
const auto tableDir = TempDirectoryPath::create();
876877
auto filePaths = makeFilePaths(tableDir, 5);
877878
auto vectors = makeVectors(filePaths.size(), 1'000);
878879
for (int i = 0; i < filePaths.size(); i++) {
@@ -977,7 +978,7 @@ TEST_P(TaskManagerTest, queuedEmptyGroupedExecutionTask) {
977978
// Runs "select * from t where c0 % 5 = 1" query.
978979
// Creates one task and provides splits one at a time.
979980
TEST_P(TaskManagerTest, tableScanOneSplitAtATime) {
980-
const auto tableDir = exec::test::TempDirectoryPath::create();
981+
const auto tableDir = TempDirectoryPath::create();
981982
auto filePaths = makeFilePaths(tableDir, 5);
982983
auto vectors = makeVectors(filePaths.size(), 1'000);
983984
for (int i = 0; i < filePaths.size(); i++) {
@@ -1013,7 +1014,7 @@ TEST_P(TaskManagerTest, tableScanOneSplitAtATime) {
10131014

10141015
// Runs 2-stage tableScan: (1) multiple table scan tasks; (2) single output task
10151016
TEST_P(TaskManagerTest, tableScanMultipleTasks) {
1016-
const auto tableDir = exec::test::TempDirectoryPath::create();
1017+
const auto tableDir = TempDirectoryPath::create();
10171018
auto filePaths = makeFilePaths(tableDir, 5);
10181019
auto vectors = makeVectors(filePaths.size(), 1'000);
10191020
for (int i = 0; i < filePaths.size(); i++) {
@@ -1047,7 +1048,7 @@ TEST_P(TaskManagerTest, tableScanMultipleTasks) {
10471048
}
10481049

10491050
TEST_P(TaskManagerTest, countAggregation) {
1050-
const auto tableDir = exec::test::TempDirectoryPath::create();
1051+
const auto tableDir = TempDirectoryPath::create();
10511052
auto filePaths = makeFilePaths(tableDir, 5);
10521053
auto vectors = makeVectors(filePaths.size(), 1'000);
10531054
for (int i = 0; i < filePaths.size(); i++) {
@@ -1061,7 +1062,7 @@ TEST_P(TaskManagerTest, countAggregation) {
10611062
// Run distributed sort query that has 2 stages. First stage runs multiple
10621063
// tasks with partial sort. Second stage runs single task with merge exchange.
10631064
TEST_P(TaskManagerTest, distributedSort) {
1064-
const auto tableDir = exec::test::TempDirectoryPath::create();
1065+
const auto tableDir = TempDirectoryPath::create();
10651066
auto filePaths = makeFilePaths(tableDir, 5);
10661067
auto vectors = makeVectors(filePaths.size(), 1'000);
10671068
for (int i = 0; i < filePaths.size(); i++) {
@@ -1136,7 +1137,7 @@ TEST_P(TaskManagerTest, distributedSort) {
11361137
}
11371138

11381139
TEST_P(TaskManagerTest, outOfQueryUserMemory) {
1139-
const auto tableDir = exec::test::TempDirectoryPath::create();
1140+
const auto tableDir = TempDirectoryPath::create();
11401141
auto filePaths = makeFilePaths(tableDir, 5);
11411142
auto vectors = makeVectors(filePaths.size(), 1'000);
11421143
for (auto i = 0; i < filePaths.size(); i++) {
@@ -1175,7 +1176,7 @@ TEST_P(TaskManagerTest, outOfOrderRequests) {
11751176
auto longWait = protocol::Duration("300s");
11761177
auto shortWait = std::chrono::seconds(1);
11771178

1178-
const auto tableDir = exec::test::TempDirectoryPath::create();
1179+
const auto tableDir = TempDirectoryPath::create();
11791180
auto filePaths = makeFilePaths(tableDir, 5);
11801181
auto vectors = makeVectors(filePaths.size(), 1000);
11811182
duckDbQueryRunner_.createTable("tmp", vectors);
@@ -1261,7 +1262,7 @@ TEST_P(TaskManagerTest, aggregationSpill) {
12611262
// trigger spill.
12621263
const int numBatchesPerFile = 5;
12631264
const int numFiles = 5;
1264-
const auto tableDir = exec::test::TempDirectoryPath::create();
1265+
const auto tableDir = TempDirectoryPath::create();
12651266
auto filePaths = makeFilePaths(tableDir, numFiles);
12661267
std::vector<std::vector<RowVectorPtr>> batches(numFiles);
12671268
for (int i = 0; i < numFiles; ++i) {
@@ -1279,7 +1280,7 @@ TEST_P(TaskManagerTest, aggregationSpill) {
12791280
int queryId = 0;
12801281
for (const bool doSpill : {false, true}) {
12811282
SCOPED_TRACE(fmt::format("doSpill: {}", doSpill));
1282-
std::shared_ptr<exec::test::TempDirectoryPath> spillDirectory;
1283+
std::shared_ptr<TempDirectoryPath> spillDirectory;
12831284
std::map<std::string, std::string> queryConfigs;
12841285

12851286
int32_t spillPct{0};
@@ -1655,7 +1656,7 @@ TEST_P(TaskManagerTest, buildSpillDirectoryFailure) {
16551656
}
16561657

16571658
TEST_P(TaskManagerTest, summarize) {
1658-
const auto tableDir = exec::test::TempDirectoryPath::create();
1659+
const auto tableDir = TempDirectoryPath::create();
16591660
auto filePaths = makeFilePaths(tableDir, 5);
16601661
auto vectors = makeVectors(filePaths.size(), 1'000);
16611662
for (int i = 0; i < filePaths.size(); i++) {

0 commit comments

Comments
 (0)