Skip to content

Commit

Permalink
Convert lsqb cpp tests to end to end tests (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfdavid committed May 29, 2023
1 parent e0f3fbc commit 2478bc8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 31 deletions.
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ add_subdirectory(processor)
add_subdirectory(runner)
add_subdirectory(storage)
add_subdirectory(transaction)
add_subdirectory(lsqb)
2 changes: 2 additions & 0 deletions test/include/test_runner/test_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct TestStatement {
struct TestGroup {
std::string group;
std::string dataset;
uint64_t bufferPoolSize =
kuzu::common::BufferPoolConstants::DEFAULT_BUFFER_POOL_SIZE_FOR_TESTING;
std::unordered_map<std::string, std::vector<std::unique_ptr<TestStatement>>> testCases;
std::unordered_map<std::string, std::vector<std::unique_ptr<TestStatement>>>
testCasesStatementBlocks;
Expand Down
5 changes: 3 additions & 2 deletions test/include/test_runner/test_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum class TokenType {
GROUP,
DATASET,
TEST,
BUFFER_POOL_SIZE,
CASE,
CHECK_ORDER,
DEFINE_STATEMENT_BLOCK,
Expand All @@ -36,8 +37,8 @@ const std::unordered_map<std::string, TokenType> tokenMap = {{"-GROUP", TokenTyp
{"-PARALLELISM", TokenType::PARALLELISM}, {"-QUERY", TokenType::QUERY},
{"-READ_ONLY", TokenType::READ_ONLY}, {"-SKIP", TokenType::SKIP},
{"-STATEMENT", TokenType::STATEMENT}, {"-STATEMENT_BLOCK", TokenType::STATEMENT_BLOCK},
{"]", TokenType::END_OF_STATEMENT_BLOCK}, {"----", TokenType::RESULT},
{"--", TokenType::SEPARATOR}, {"#", TokenType::EMPTY}};
{"-BUFFER_POOL_SIZE", TokenType::BUFFER_POOL_SIZE}, {"]", TokenType::END_OF_STATEMENT_BLOCK},
{"----", TokenType::RESULT}, {"--", TokenType::SEPARATOR}, {"#", TokenType::EMPTY}};

const std::unordered_map<std::string, std::string> variableMap = {
{"${KUZU_ROOT_DIRECTORY}", KUZU_ROOT_DIRECTORY}};
Expand Down
1 change: 0 additions & 1 deletion test/lsqb/CMakeLists.txt

This file was deleted.

21 changes: 0 additions & 21 deletions test/lsqb/lsqb.cpp

This file was deleted.

21 changes: 16 additions & 5 deletions test/runner/e2e_read_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ using namespace kuzu::common;

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

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

std::string getInputDir() override {
return TestHelper::appendKuzuRootPath("dataset/" + dataset + "/");
Expand All @@ -18,6 +26,7 @@ class EndToEndReadTest : public DBTest {

private:
std::string dataset;
uint64_t bufferPoolSize;
std::vector<std::unique_ptr<TestStatement>> testStatements;
};

Expand All @@ -27,11 +36,13 @@ void parseAndRegisterTestGroup(const std::string& path) {
if (testGroup->isValid() && testGroup->hasStatements()) {
auto dataset = testGroup->dataset;
auto testCases = std::move(testGroup->testCases);
auto bufferPoolSize = testGroup->bufferPoolSize;
for (auto& [testCaseName, testStatements] : testCases) {
testing::RegisterTest(testGroup->group.c_str(), testCaseName.c_str(), nullptr, nullptr,
__FILE__, __LINE__,
[dataset, testStatements = std::move(testStatements)]() mutable -> DBTest* {
return new EndToEndReadTest(dataset, std::move(testStatements));
[dataset, bufferPoolSize,
testStatements = std::move(testStatements)]() mutable -> DBTest* {
return new EndToEndReadTest(dataset, bufferPoolSize, std::move(testStatements));
});
}
}
Expand Down
8 changes: 7 additions & 1 deletion test/test_files/lsqb/lsqb_queries.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
-SKIP
-GROUP LSQBTest
-DATASET sf-0.1
-BUFFER_POOL_SIZE 1073741824

--

-CASE LSQBTest

-NAME q1
-QUERY MATCH (:Country)<-[:City_isPartOf_Country]-(:City)<-[:Person_isLocatedIn_City]-(:Person)<-[:Forum_hasMember_Person]-(:Forum)-[:Forum_containerOf_Post]->(:Post)<-[Comment_replyOf_Post]-(:Comment)-[:Comment_hasTag_Tag]->(:Tag)-[:Tag_hasType_TagClass]->(:TagClass) RETURN count(*) as count;
Expand Down
5 changes: 5 additions & 0 deletions test/test_runner/test_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ void TestParser::parseHeader() {
testGroup->dataset = currentToken.params[1];
break;
}
case TokenType::BUFFER_POOL_SIZE: {
checkMinimumParams(1);
testGroup->bufferPoolSize = stoi(currentToken.params[1]);
break;
}
case TokenType::SKIP: {
testGroup->skipTest = true;
return;
Expand Down

0 comments on commit 2478bc8

Please sign in to comment.