|
6 | 6 |
|
7 | 7 | #include <gtest/gtest.h> |
8 | 8 |
|
| 9 | +#include <optional> |
9 | 10 | #include <thread> |
10 | 11 | #include <chrono> |
11 | 12 |
|
@@ -1116,6 +1117,37 @@ TEST_P(ClientCase, OnProfileEvents) { |
1116 | 1117 | } |
1117 | 1118 | } |
1118 | 1119 |
|
| 1120 | +TEST_P(ClientCase, OnProfile) { |
| 1121 | + Query query("SELECT * FROM system.numbers LIMIT 10;"); |
| 1122 | + |
| 1123 | + std::optional<Profile> profile; |
| 1124 | + query.OnProfile([&profile](const Profile & new_profile) { |
| 1125 | + profile = new_profile; |
| 1126 | + |
| 1127 | + std::cout << |
| 1128 | + "Profile:" << |
| 1129 | + "\n\trows: " << new_profile.rows << |
| 1130 | + "\n\tblocks: " << new_profile.blocks << |
| 1131 | + "\n\tbytes: " << new_profile.bytes << |
| 1132 | + "\n\trows_before_limit: " << new_profile.rows_before_limit << |
| 1133 | + "\n\tapplied_limit: " << new_profile.applied_limit << |
| 1134 | + "\n\tcalculated_rows_before_limit: " << new_profile.calculated_rows_before_limit << |
| 1135 | + std::endl; |
| 1136 | + }); |
| 1137 | + |
| 1138 | + client_->Execute(query); |
| 1139 | + |
| 1140 | + // Make sure that profile event came through |
| 1141 | + ASSERT_NE(profile, std::nullopt); |
| 1142 | + |
| 1143 | + EXPECT_GE(profile->rows, 10u); |
| 1144 | + EXPECT_GE(profile->blocks, 1u); |
| 1145 | + EXPECT_GT(profile->bytes, 1u); |
| 1146 | + EXPECT_GE(profile->rows_before_limit, 10u); |
| 1147 | + EXPECT_EQ(profile->applied_limit, true); |
| 1148 | + EXPECT_EQ(profile->calculated_rows_before_limit, true); |
| 1149 | +} |
| 1150 | + |
1119 | 1151 | TEST_P(ClientCase, SelectAggregateFunction) { |
1120 | 1152 | // Verifies that perofing SELECT value of type AggregateFunction(...) doesn't crash the client. |
1121 | 1153 | // For details: https://github.com/ClickHouse/clickhouse-cpp/issues/266 |
|
0 commit comments