-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TEL-26, TEL-29 [9.x]: Add unit tests and MTR tests for Percona Telemetry Component #5473
Conversation
https://perconadev.atlassian.net/browse/TEL-29 Added MTR tests for Percona Telemetry Component.
https://perconadev.atlassian.net/browse/TEL-26 Percona Telemetry Component unit tests added
…ng-8 compilation issues" This reverts commit 24619f5.
This reverts commit 2ffd182.
Fix the following issue: ``` 273: /data/mysql-server/8.x/router/tests/helpers/process_manager.cc:732: Failure 273: Expected equality of these values: 273: expected_exit_status 273: Which is: Exit(0) 273: result 273: Which is: Exit(128) 273: Process 1325111 exited with Exit(128) 273: /data/mysql-server/8.x/router/tests/helpers/process_manager.cc:669: Failure 273: Failed 273: # Process: (pid=1325111) 273: /data/mysql-server/8.x-deb-gcc13-rocks/runtime_output_directory/mysqld --no-defaults --lc-messages-dir=/data/mysql-server/8.x-deb-gcc13-rocks/share --datadir=/tmp/mysqld-debug-0Pfsrx --plugin_dir=/data/mysql-server/8.x-deb-gcc13-rocks/plugin_output_directory --log-error=/tmp/mysqld-debug-0Pfsrx/mysqld-0.err --port=11010 --socket=/tmp/mysqld-debug-0Pfsrx/mysql.sock --mysqlx-port=11011 --mysqlx-socket=/tmp/mysqld-debug-0Pfsrx/mysqlx.sock --secure-file-priv=NULL --innodb_redo_log_capacity=8M --innodb_autoextend_increment=1 --innodb_buffer_pool_size=5M --innodb_use_native_aio=0 --gtid_mode=ON --enforce_gtid_consistency=ON --relay-log=relay-log 273: 273: ## Console output: 273: 273: /data/mysql-server/8.x-deb-gcc13-rocks/runtime_output_directory/mysqld could not be executed: No such file or directory (errno 2) 273: 273: ## Log content: 273: 273: <THIS ERROR COMES FROM TEST FRAMEWORK'S get_file_output(), IT IS NOT PART OF PROCESS OUTPUT: Could not open file '/tmp/mysqld-debug-0Pfsrx/mysqld-0.err' for reading: basic_ios::clear: iostream error> 273: 273: /data/mysql-server/8.x/router/tests/helpers/process_manager.cc:732: Failure 273: Expected equality of these values: 273: expected_exit_status 273: Which is: Exit(0) 273: result 273: Which is: Exit(128) 273: Process 1325111 exited with Exit(128) ```
PS-9328 [8.4]: Revert fixes for unsupported gcc and clang versions
PS-9388 [8.4]: Fix "routertest_integration_routing*"
…mponent https://perconadev.atlassian.net/browse/TEL-26 https://perconadev.atlassian.net/browse/TEL-29 Merge branch 'TEL-26-8.0' into TEL-26-trunk # Conflicts: # unittest/gunit/CMakeLists.txt
TEL-26, TEL-29: Add unit tests and MTR tests for Percona Telemetry Component
Post push fix. 1. Added missing Boost dependency. It caused unit tests build to fail if no Boost was installed in system. 2. Removed unnecessary component dependency. It caused unit tests build to fail if configured with WITH_PERCONA_TELEMETRY=NO
…-fix-8.4 TEL-26: Percona Telemetry Component unit tests added
…from kamil-holubicki/TEL-26-trunk)
…from kamil-holubicki/TEL-26-post-push-fix-8.4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (1/4)
#include "components/percona_telemetry/logger.h" | ||
#undef private | ||
|
||
using ::testing::_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declaration uses identifier _
, which is reserved in the global namespace; cannot be fixed automatically
|
||
class MockDataProvider : public DataProvider { | ||
public: | ||
MockDataProvider() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor does not initialize these fields: gmock04_do_query_41
|
||
class DataProviderTest : public ::testing::Test { | ||
protected: | ||
virtual void SetUp() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer using override
or (rarely) final
instead of virtual
virtual void SetUp() {} | |
void SetUp() override {} |
class DataProviderTest : public ::testing::Test { | ||
protected: | ||
virtual void SetUp() {} | ||
virtual void TearDown() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer using override
or (rarely) final
instead of virtual
virtual void TearDown() {} | |
void TearDown() override {} |
virtual void TearDown() {} | ||
}; | ||
|
||
TEST_F(DataProviderTest, Sanity_test) { EXPECT_EQ(1, 1); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "Sanity_test" according to Googletest FAQ
|
||
TEST_F(DataProviderTest, Sanity_test) { EXPECT_EQ(1, 1); } | ||
|
||
TEST_F(DataProviderTest, get_database_instance_id_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "get_database_instance_id_test" according to Googletest FAQ
TEST_F(DataProviderTest, get_database_instance_id_test) { | ||
MockDataProvider dataProvider; | ||
const std::string expected_id("expected_id"); | ||
Row row{expected_id}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row
is not initialized
Row row{expected_id}; | |
Row row = 0{expected_id}; |
EXPECT_EQ(dataProvider.get_database_instance_id(), expected_id); | ||
} | ||
|
||
TEST_F(DataProviderTest, get_database_instance_id_queries_only_once_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "get_database_instance_id_queries_only_once_test" according to Googletest FAQ
TEST_F(DataProviderTest, get_database_instance_id_queries_only_once_test) { | ||
MockDataProvider dataProvider; | ||
const std::string expected_id("expected_id"); | ||
Row row{expected_id}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row
is not initialized
Row row{expected_id}; | |
Row row = 0{expected_id}; |
EXPECT_EQ(dataProvider.get_database_instance_id(), expected_id); | ||
} | ||
|
||
TEST_F(DataProviderTest, get_database_instance_id_do_query_fails_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "get_database_instance_id_do_query_fails_test" according to Googletest FAQ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (2/4)
TEST_F(DataProviderTest, get_database_instance_id_do_query_fails_test) { | ||
MockDataProvider dataProvider; | ||
const std::string expected_id("expected_id"); | ||
Row row{expected_id}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row
is not initialized
Row row{expected_id}; | |
Row row = 0{expected_id}; |
// Helper function for metrics reported as a single value | ||
static void collect_single_value_common( | ||
const std::string &expected_query, const std::string &expected_json_key, | ||
std::function<bool(MockDataProvider *, rapidjson::Document *)> fn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter fn
is unused
std::function<bool(MockDataProvider *, rapidjson::Document *)> fn, |
bool should_cache_result = false) { | ||
MockDataProvider dataProvider; | ||
const std::string expected_val("expected_val"); | ||
Row row{expected_val}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row
is not initialized
Row row{expected_val}; | |
Row row = 0{expected_val}; |
const std::string &expected_query, const std::string &expected_json_key, | ||
std::function<bool(MockDataProvider *, rapidjson::Document *)> fn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter fn
is unused
const std::string &expected_query, const std::string &expected_json_key, | |
std::function<bool(MockDataProvider *, rapidjson::Document *)> fn) { | |
const std::string &expected_query, const std::string &expected_json_key) { |
MockDataProvider dataProvider; | ||
std::string Item_A("Item_A"); | ||
std::string Item_B("Item_B"); | ||
Row row1{Item_A}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row1
is not initialized
Row row1{Item_A}; | |
Row row1 = 0{Item_A}; |
std::string Item_A("Item_A"); | ||
std::string Item_B("Item_B"); | ||
Row row1{Item_A}; | ||
Row row2{Item_B}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row2
is not initialized
Row row2{Item_B}; | |
Row row2 = 0{Item_B}; |
EXPECT_FALSE(fn(&dataProvider, &document2)); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_db_instance_id_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_db_instance_id_info_test" according to Googletest FAQ
true); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_product_version_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_product_version_info_test" according to Googletest FAQ
|
||
TEST_F(DataProviderTest, collect_product_version_info_test) { | ||
MockDataProvider dataProvider; | ||
Row row{"1.2.3.4", "This is version comment"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row
is not initialized
Row row{"1.2.3.4", "This is version comment"}; | |
Row row = 0{"1.2.3.4", "This is version comment"}; |
EXPECT_FALSE(dataProvider.collect_product_version_info(&document2)); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_product_version_info_pro_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_product_version_info_pro_test" according to Googletest FAQ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (3/4)
|
||
TEST_F(DataProviderTest, collect_product_version_info_pro_test) { | ||
MockDataProvider dataProvider; | ||
Row row{"1.2.3.4", "This is Pro build version comment"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row
is not initialized
Row row{"1.2.3.4", "This is Pro build version comment"}; | |
Row row = 0{"1.2.3.4", "This is Pro build version comment"}; |
EXPECT_STREQ(iter->value.GetString(), "1.2.3.4-pro"); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_plugins_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_plugins_info_test" according to Googletest FAQ
&MockDataProvider::collect_plugins_info); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_components_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_components_info_test" according to Googletest FAQ
&MockDataProvider::collect_components_info); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_uptime_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_uptime_info_test" according to Googletest FAQ
|
||
TEST_F(DataProviderTest, collect_uptime_info_test) { | ||
MockDataProvider dataProvider; | ||
Row row{"Uptime", "12345"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row
is not initialized
Row row{"Uptime", "12345"}; | |
Row row = 0{"Uptime", "12345"}; |
EXPECT_STREQ(iter->value.GetString(), "12345"); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_dbs_number_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_dbs_number_info_test" according to Googletest FAQ
&MockDataProvider::collect_dbs_number_info); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_dbs_size_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_dbs_size_info_test" according to Googletest FAQ
&MockDataProvider::collect_dbs_size_info); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_se_usage_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_se_usage_info_test" according to Googletest FAQ
&MockDataProvider::collect_se_usage_info); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_group_replication_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_group_replication_info_test" according to Googletest FAQ
const std::string role_val("role_val"); | ||
const std::string db_id_val("db_id_val"); | ||
const std::string single_primary_mode_val("single_primary_mode_val"); | ||
Row row1{role_val, db_id_val, single_primary_mode_val}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row1
is not initialized
Row row1{role_val, db_id_val, single_primary_mode_val}; | |
Row row1 = 0{role_val, db_id_val, single_primary_mode_val}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (4/4)
"SELECT COUNT(*) FROM performance_schema.replication_group_members")); | ||
|
||
const std::string count_val("count_val"); | ||
Row row2{count_val}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row2
is not initialized
Row row2{count_val}; | |
Row row2 = 0{count_val}; |
Return(false))); | ||
|
||
const std::string expected_id("expected_id"); | ||
Row row3{expected_id}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable row3
is not initialized
Row row3{expected_id}; | |
Row row3 = 0{expected_id}; |
EXPECT_STREQ(iter->value.GetString(), count_val.c_str()); | ||
} | ||
|
||
TEST_F(DataProviderTest, collect_async_replication_info_test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using "_" in test name "collect_async_replication_info_test" according to Googletest FAQ
@@ -0,0 +1,8 @@ | |||
#include <components/percona_telemetry/logger.h> | |||
|
|||
Logger::Logger(SERVICE_TYPE(log_builtins) &, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor does not initialize these fields: log_level_
bool do_query(const std::string &query, QueryResult *result, | ||
unsigned int *err_no = nullptr, | ||
bool suppress_query_error_log = false); | ||
virtual bool do_query(const std::string &query, QueryResult *result, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default arguments on virtual or override methods are prohibited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
https://perconadev.atlassian.net/browse/TEL-26
https://perconadev.atlassian.net/browse/TEL-29
This PR merges: #5441 and #5448
into
trunk
using GCA.