Skip to content

Commit

Permalink
Use testcase name in parquet temp dir name
Browse files Browse the repository at this point in the history
  • Loading branch information
rfdavid committed Jun 10, 2023
1 parent 2df3459 commit b5b851e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
13 changes: 9 additions & 4 deletions test/include/graph_test/graph_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,21 @@ class BaseGraphTest : public Test {
void commitOrRollbackConnectionAndInitDBIfNecessary(
bool isCommit, TransactionTestType transactionTestType);

inline std::string getTestGroupAndName() {
const ::testing::TestInfo* const testInfo =
::testing::UnitTest::GetInstance()->current_test_info();
return std::string(testInfo->test_case_name()) + "." + std::string(testInfo->name());
}

private:
void setDatabasePath() {
databasePath = TestHelper::getTmpTestDir();
uint64_t milliseconds = duration_cast<std::chrono::milliseconds>(
uint64_t ms = duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
.count();
const ::testing::TestInfo* const testInfo =
::testing::UnitTest::GetInstance()->current_test_info();
databasePath = databasePath + testInfo->test_case_name() + testInfo->name() +
std::to_string(milliseconds);
databasePath = databasePath + getTestGroupAndName() + std::to_string(ms);
}

void validateRelPropertyFiles(catalog::RelTableSchema* relTableSchema,
Expand Down
2 changes: 1 addition & 1 deletion test/include/test_helper/test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestHelper {
static constexpr char E2E_TEST_FILES_DIRECTORY[] = "test/test_files";
static constexpr char SCHEMA_FILE_NAME[] = "schema.cypher";
static constexpr char COPY_FILE_NAME[] = "copy.cypher";
static constexpr char PARQUET_TEMP_DATASET_PATH[] = "dataset/parquet_temp/";
static constexpr char PARQUET_TEMP_DATASET_PATH[] = "dataset/parquet_temp";

static std::string getTmpTestDir() { return appendKuzuRootPath("test/unittest_temp"); }
static std::string getTestListFile() {
Expand Down
27 changes: 11 additions & 16 deletions test/runner/e2e_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,44 @@ using ::testing::Test;
using namespace kuzu::testing;
using namespace kuzu::common;

class EndToEndEnvironment : public testing::Environment {
public:
virtual void SetUp() {
FileUtils::createDirIfNotExists(
TestHelper::appendKuzuRootPath(TestHelper::PARQUET_TEMP_DATASET_PATH));
}
virtual void TearDown() {
FileUtils::removeDir(TestHelper::appendKuzuRootPath(TestHelper::PARQUET_TEMP_DATASET_PATH));
}
};

class EndToEndTest : public DBTest {
public:
explicit EndToEndTest(TestGroup::DatasetType datasetType, std::string dataset,
uint64_t bufferPoolSize, std::vector<std::unique_ptr<TestStatement>> testStatements)
: datasetType{datasetType}, dataset{dataset}, bufferPoolSize{bufferPoolSize},
testStatements{std::move(testStatements)} {}

void SetUp() override {
setUpDataset();
BaseGraphTest::SetUp();
systemConfig->bufferPoolSize = bufferPoolSize;
createDBAndConn();
initGraph();
}

void setUpDataset() {
parquetTempDatasetPath = TestHelper::appendKuzuRootPath(
TestHelper::PARQUET_TEMP_DATASET_PATH + getTestGroupAndName());
if (datasetType == TestGroup::DatasetType::CSV_TO_PARQUET) {
FileUtils::createDirIfNotExists(parquetTempDatasetPath);
CSVToParquetConverter::convertCSVDatasetToParquet(dataset);
} else {
dataset = TestHelper::appendKuzuRootPath("dataset/" + dataset);
}
}

void TearDown() override {
// FileUtils::removeDir(TestHelper::appendKuzuRootPath(TestHelper::PARQUET_TEMP_DATASET_PATH));
FileUtils::removeDir(databasePath);
FileUtils::removeDir(parquetTempDatasetPath);
}

std::string getInputDir() override { return dataset + "/"; }
void TestBody() override { runTest(testStatements); }
std::string getInputDir() override { return dataset + "/"; }

private:
TestGroup::DatasetType datasetType;
std::string dataset;
std::string parquetTempDatasetPath;
uint64_t bufferPoolSize;
std::vector<std::unique_ptr<TestStatement>> testStatements;
};
Expand Down Expand Up @@ -106,7 +102,7 @@ std::string findTestFile(std::string testCase) {
return "";
}

void checkCtestParams(int argc, char** argv) {
void checkGtestParams(int argc, char** argv) {
if (argc > 1) {
std::string argument = argv[1];
if (argument == "--gtest_list_tests") {
Expand All @@ -124,9 +120,8 @@ void checkCtestParams(int argc, char** argv) {
}

int main(int argc, char** argv) {
checkCtestParams(argc, argv);
checkGtestParams(argc, argv);
testing::InitGoogleTest(&argc, argv);
testing::AddGlobalTestEnvironment(new EndToEndEnvironment);
if (argc > 1) {
auto path = TestHelper::appendKuzuRootPath(
FileUtils::joinPath(TestHelper::E2E_TEST_FILES_DIRECTORY, argv[1]));
Expand Down

0 comments on commit b5b851e

Please sign in to comment.