Remove Kafka integration implementation and tests
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2525
This commit is contained in:
@@ -2343,250 +2343,6 @@ TEST_P(CypherMainVisitorTest, ShowUsersForRole) {
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateStream) {
|
||||
auto check_create_stream =
|
||||
[this](std::string input, const std::string &stream_name,
|
||||
const std::string &stream_uri, const std::string &stream_topic,
|
||||
const std::string &transform_uri,
|
||||
std::optional<int64_t> batch_interval_in_ms,
|
||||
std::optional<int64_t> batch_size) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *stream_query =
|
||||
dynamic_cast<StreamQuery *>(ast_generator.ParseQuery(input));
|
||||
ASSERT_TRUE(stream_query);
|
||||
EXPECT_EQ(stream_query->action_, StreamQuery::Action::CREATE_STREAM);
|
||||
EXPECT_EQ(stream_query->stream_name_, stream_name);
|
||||
ASSERT_TRUE(stream_query->stream_uri_);
|
||||
ast_generator.CheckLiteral(stream_query->stream_uri_,
|
||||
TypedValue(stream_uri));
|
||||
ASSERT_TRUE(stream_query->stream_topic_);
|
||||
ast_generator.CheckLiteral(stream_query->stream_topic_,
|
||||
TypedValue(stream_topic));
|
||||
ASSERT_TRUE(stream_query->transform_uri_);
|
||||
ast_generator.CheckLiteral(stream_query->transform_uri_,
|
||||
TypedValue(transform_uri));
|
||||
if (batch_interval_in_ms) {
|
||||
ASSERT_TRUE(stream_query->batch_interval_in_ms_);
|
||||
ast_generator.CheckLiteral(stream_query->batch_interval_in_ms_,
|
||||
TypedValue(*batch_interval_in_ms));
|
||||
} else {
|
||||
EXPECT_EQ(stream_query->batch_interval_in_ms_, nullptr);
|
||||
}
|
||||
if (batch_size) {
|
||||
ASSERT_TRUE(stream_query->batch_size_);
|
||||
ast_generator.CheckLiteral(stream_query->batch_size_,
|
||||
TypedValue(*batch_size));
|
||||
} else {
|
||||
EXPECT_EQ(stream_query->batch_size_, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
check_create_stream(
|
||||
"CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' "
|
||||
"WITH TOPIC 'tropika' "
|
||||
"WITH TRANSFORM 'localhost/test.py'",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", std::nullopt,
|
||||
std::nullopt);
|
||||
|
||||
check_create_stream(
|
||||
"CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' "
|
||||
"WitH TopIC 'tropika' "
|
||||
"WITH TRAnsFORM 'localhost/test.py' bAtCH inTErvAL 168",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", 168, std::nullopt);
|
||||
|
||||
check_create_stream(
|
||||
"CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' "
|
||||
"WITH TopIC 'tropika' "
|
||||
"WITH TRAnsFORM 'localhost/test.py' bAtCH SizE 17",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", std::nullopt, 17);
|
||||
|
||||
check_create_stream(
|
||||
"CreaTE StreaM stream AS LOad daTA KAFKA 'localhost' "
|
||||
"WitH TOPic 'tropika' "
|
||||
"WITH TRAnsFORM 'localhost/test.py' bAtCH inTErvAL 168 Batch SIze 17",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", 168, 17);
|
||||
|
||||
EXPECT_THROW(check_create_stream(
|
||||
"CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' "
|
||||
"WITH TRANSFORM 'localhost/test.py' BATCH INTERVAL 'jedan' ",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", 168,
|
||||
std::nullopt),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_create_stream(
|
||||
"CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' "
|
||||
"WITH TOPIC 'tropika' "
|
||||
"WITH TRANSFORM 'localhost/test.py' BATCH SIZE 'jedan' ",
|
||||
"stream", "localhost", "tropika", "localhost/test.py",
|
||||
std::nullopt, 17),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_create_stream(
|
||||
"CREATE STREAM 123 AS LOAD DATA KAFKA 'localhost' "
|
||||
"WITH TOPIC 'tropika' "
|
||||
"WITH TRANSFORM 'localhost/test.py' BATCH INTERVAL 168 ",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", 168,
|
||||
std::nullopt),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(
|
||||
check_create_stream("CREATE STREAM stream AS LOAD DATA KAFKA localhost "
|
||||
"WITH TOPIC 'tropika' "
|
||||
"WITH TRANSFORM 'localhost/test.py'",
|
||||
"stream", "localhost", "tropika", "localhost/test.py",
|
||||
std::nullopt, std::nullopt),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_create_stream(
|
||||
"CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' "
|
||||
"WITH TOPIC 2"
|
||||
"WITH TRANSFORM localhost/test.py BATCH INTERVAL 168 ",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", 168,
|
||||
std::nullopt),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_create_stream(
|
||||
"CREATE STREAM stream AS LOAD DATA KAFKA 'localhost' "
|
||||
"WITH TOPIC 'tropika'"
|
||||
"WITH TRANSFORM localhost/test.py BATCH INTERVAL 168 ",
|
||||
"stream", "localhost", "tropika", "localhost/test.py", 168,
|
||||
std::nullopt),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, DropStream) {
|
||||
auto check_drop_stream = [this](std::string input,
|
||||
const std::string &stream_name) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *stream_query =
|
||||
dynamic_cast<StreamQuery *>(ast_generator.ParseQuery(input));
|
||||
ASSERT_TRUE(stream_query);
|
||||
EXPECT_EQ(stream_query->action_, StreamQuery::Action::DROP_STREAM);
|
||||
EXPECT_EQ(stream_query->stream_name_, stream_name);
|
||||
};
|
||||
|
||||
check_drop_stream("DRop stREAm stream", "stream");
|
||||
check_drop_stream("DRop stREAm strim", "strim");
|
||||
|
||||
EXPECT_THROW(check_drop_stream("DROp sTREAM", ""), SyntaxException);
|
||||
|
||||
EXPECT_THROW(check_drop_stream("DROP STreAM 123", "123"), SyntaxException);
|
||||
|
||||
EXPECT_THROW(check_drop_stream("DroP STREAM '123'", "123"), SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, ShowStreams) {
|
||||
auto check_show_streams = [this](std::string input) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *stream_query =
|
||||
dynamic_cast<StreamQuery *>(ast_generator.ParseQuery(input));
|
||||
ASSERT_TRUE(stream_query);
|
||||
EXPECT_EQ(stream_query->action_, StreamQuery::Action::SHOW_STREAMS);
|
||||
};
|
||||
|
||||
check_show_streams("SHOW STREAMS");
|
||||
|
||||
EXPECT_THROW(check_show_streams("SHOW STREAMS lololo"), SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, StartStopStream) {
|
||||
auto check_start_stop_stream = [this](std::string input,
|
||||
const std::string &stream_name,
|
||||
bool is_start,
|
||||
std::optional<int64_t> limit_batches) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *stream_query =
|
||||
dynamic_cast<StreamQuery *>(ast_generator.ParseQuery(input));
|
||||
ASSERT_TRUE(stream_query);
|
||||
|
||||
EXPECT_EQ(stream_query->stream_name_, stream_name);
|
||||
EXPECT_EQ(stream_query->action_, is_start
|
||||
? StreamQuery::Action::START_STREAM
|
||||
: StreamQuery::Action::STOP_STREAM);
|
||||
|
||||
if (limit_batches) {
|
||||
ASSERT_TRUE(is_start);
|
||||
ASSERT_TRUE(stream_query->limit_batches_);
|
||||
ast_generator.CheckLiteral(stream_query->limit_batches_,
|
||||
TypedValue(*limit_batches));
|
||||
} else {
|
||||
EXPECT_EQ(stream_query->limit_batches_, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
check_start_stop_stream("stARt STreaM STREAM", "STREAM", true, std::nullopt);
|
||||
check_start_stop_stream("stARt STreaM strim", "strim", true, std::nullopt);
|
||||
check_start_stop_stream("StARt STreAM strim LimIT 10 BATchES", "strim", true,
|
||||
10);
|
||||
|
||||
check_start_stop_stream("StoP StrEAM strim", "strim", false, std::nullopt);
|
||||
|
||||
EXPECT_THROW(check_start_stop_stream("staRT STReaM 'strim'", "strim", true,
|
||||
std::nullopt),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_start_stop_stream("sTART STReaM strim LImiT 'dva' BATCheS",
|
||||
"strim", true, 2),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_start_stop_stream("StoP STreAM 'strim'", "strim", false,
|
||||
std::nullopt),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_start_stop_stream("STOp sTREAM strim LIMit 2 baTCHES",
|
||||
"strim", false, 2),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, StartStopAllStreams) {
|
||||
auto check_start_stop_all_streams = [this](std::string input, bool is_start) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *stream_query =
|
||||
dynamic_cast<StreamQuery *>(ast_generator.ParseQuery(input));
|
||||
ASSERT_TRUE(stream_query);
|
||||
EXPECT_EQ(stream_query->action_,
|
||||
is_start ? StreamQuery::Action::START_ALL_STREAMS
|
||||
: StreamQuery::Action::STOP_ALL_STREAMS);
|
||||
};
|
||||
|
||||
check_start_stop_all_streams("STarT AlL StreAMs", true);
|
||||
|
||||
check_start_stop_all_streams("StoP aLL STrEAMs", false);
|
||||
|
||||
EXPECT_THROW(check_start_stop_all_streams("StaRT aLL STreAM", true),
|
||||
SyntaxException);
|
||||
|
||||
EXPECT_THROW(check_start_stop_all_streams("SToP AlL STREaM", false),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, TestStream) {
|
||||
auto check_test_stream = [this](std::string input,
|
||||
const std::string &stream_name,
|
||||
std::optional<int64_t> limit_batches) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *stream_query =
|
||||
dynamic_cast<StreamQuery *>(ast_generator.ParseQuery(input));
|
||||
ASSERT_TRUE(stream_query);
|
||||
EXPECT_EQ(stream_query->stream_name_, stream_name);
|
||||
EXPECT_EQ(stream_query->action_, StreamQuery::Action::TEST_STREAM);
|
||||
|
||||
if (limit_batches) {
|
||||
ASSERT_TRUE(stream_query->limit_batches_);
|
||||
ast_generator.CheckLiteral(stream_query->limit_batches_,
|
||||
TypedValue(*limit_batches));
|
||||
} else {
|
||||
EXPECT_EQ(stream_query->limit_batches_, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
check_test_stream("TesT STreaM strim", "strim", std::nullopt);
|
||||
check_test_stream("TesT STreaM STREAM", "STREAM", std::nullopt);
|
||||
check_test_stream("tESt STreAM STREAM LimIT 10 BATchES", "STREAM", 10);
|
||||
|
||||
check_test_stream("Test StrEAM STREAM", "STREAM", std::nullopt);
|
||||
|
||||
EXPECT_THROW(check_test_stream("tEST STReaM 'strim'", "strim", std::nullopt),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(
|
||||
check_test_stream("test STReaM strim LImiT 'dva' BATCheS", "strim", 2),
|
||||
SyntaxException);
|
||||
EXPECT_THROW(check_test_stream("test STreAM 'strim'", "strim", std::nullopt),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, TestExplainRegularQuery) {
|
||||
auto &ast_generator = *GetParam();
|
||||
EXPECT_TRUE(dynamic_cast<ExplainQuery *>(
|
||||
@@ -2604,12 +2360,6 @@ TEST_P(CypherMainVisitorTest, TestExplainAuthQuery) {
|
||||
EXPECT_THROW(ast_generator.ParseQuery("EXPLAIN SHOW ROLES"), SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, TestExplainStreamQuery) {
|
||||
auto &ast_generator = *GetParam();
|
||||
EXPECT_THROW(ast_generator.ParseQuery("EXPLAIN SHOW STREAMS"),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, TestProfileRegularQuery) {
|
||||
{
|
||||
auto &ast_generator = *GetParam();
|
||||
@@ -2639,12 +2389,6 @@ TEST_P(CypherMainVisitorTest, TestProfileAuthQuery) {
|
||||
EXPECT_THROW(ast_generator.ParseQuery("PROFILE SHOW ROLES"), SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, TestProfileStreamQuery) {
|
||||
auto &ast_generator = *GetParam();
|
||||
EXPECT_THROW(ast_generator.ParseQuery("PROFILE SHOW STREAMS"),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, TestShowStorageInfo) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *query =
|
||||
|
||||
Reference in New Issue
Block a user