James Kuszmaul | 38735e8 | 2019-12-07 16:42:06 -0800 | [diff] [blame] | 1 | #include "aos/events/logging/logger.h" |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 2 | |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 3 | #include "absl/strings/str_format.h" |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 4 | #include "aos/events/event_loop.h" |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 5 | #include "aos/events/message_counter.h" |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 6 | #include "aos/events/ping_lib.h" |
| 7 | #include "aos/events/pong_lib.h" |
| 8 | #include "aos/events/simulated_event_loop.h" |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 9 | #include "aos/network/remote_message_generated.h" |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 10 | #include "aos/network/timestamp_generated.h" |
Austin Schuh | c243b42 | 2020-10-11 15:35:08 -0700 | [diff] [blame] | 11 | #include "aos/testing/tmpdir.h" |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 12 | #include "aos/util/file.h" |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 13 | #include "glog/logging.h" |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 14 | #include "gmock/gmock.h" |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 15 | #include "gtest/gtest.h" |
| 16 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 17 | #ifdef LZMA |
| 18 | #include "aos/events/logging/lzma_encoder.h" |
| 19 | #endif |
| 20 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 21 | namespace aos { |
| 22 | namespace logger { |
| 23 | namespace testing { |
| 24 | |
| 25 | namespace chrono = std::chrono; |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 26 | using aos::message_bridge::RemoteMessage; |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 27 | using aos::testing::MessageCounter; |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 28 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 29 | constexpr std::string_view kConfigSha1( |
| 30 | "0000c81e444ac470b8d29fb864621ae93a0e294a7e90c0dc4840d0f0d40fd72e"); |
| 31 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 32 | class LoggerTest : public ::testing::Test { |
| 33 | public: |
| 34 | LoggerTest() |
| 35 | : config_( |
| 36 | aos::configuration::ReadConfig("aos/events/pingpong_config.json")), |
| 37 | event_loop_factory_(&config_.message()), |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 38 | ping_event_loop_(event_loop_factory_.MakeEventLoop("ping")), |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 39 | ping_(ping_event_loop_.get()), |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 40 | pong_event_loop_(event_loop_factory_.MakeEventLoop("pong")), |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 41 | pong_(pong_event_loop_.get()) {} |
| 42 | |
| 43 | // Config and factory. |
| 44 | aos::FlatbufferDetachedBuffer<aos::Configuration> config_; |
| 45 | SimulatedEventLoopFactory event_loop_factory_; |
| 46 | |
| 47 | // Event loop and app for Ping |
| 48 | std::unique_ptr<EventLoop> ping_event_loop_; |
| 49 | Ping ping_; |
| 50 | |
| 51 | // Event loop and app for Pong |
| 52 | std::unique_ptr<EventLoop> pong_event_loop_; |
| 53 | Pong pong_; |
| 54 | }; |
| 55 | |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 56 | using LoggerDeathTest = LoggerTest; |
| 57 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 58 | // Tests that we can startup at all. This confirms that the channels are all in |
| 59 | // the config. |
| 60 | TEST_F(LoggerTest, Starts) { |
Austin Schuh | c243b42 | 2020-10-11 15:35:08 -0700 | [diff] [blame] | 61 | const ::std::string tmpdir = aos::testing::TestTmpDir(); |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 62 | const ::std::string base_name = tmpdir + "/logfile"; |
| 63 | const ::std::string logfile = base_name + ".part0.bfbs"; |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 64 | // Remove it. |
| 65 | unlink(logfile.c_str()); |
| 66 | |
| 67 | LOG(INFO) << "Logging data to " << logfile; |
| 68 | |
| 69 | { |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 70 | std::unique_ptr<EventLoop> logger_event_loop = |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 71 | event_loop_factory_.MakeEventLoop("logger"); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 72 | |
| 73 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 74 | |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 75 | Logger logger(logger_event_loop.get()); |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 76 | logger.set_separate_config(false); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 77 | logger.set_polling_period(std::chrono::milliseconds(100)); |
| 78 | logger.StartLoggingLocalNamerOnRun(base_name); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 79 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 80 | } |
| 81 | |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 82 | // Even though it doesn't make any difference here, exercise the logic for |
| 83 | // passing in a separate config. |
| 84 | LogReader reader(logfile, &config_.message()); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 85 | |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 86 | // Confirm that we can remap logged channels to point to new buses. |
| 87 | reader.RemapLoggedChannel<aos::examples::Ping>("/test", "/original"); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 88 | |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 89 | // This sends out the fetched messages and advances time to the start of the |
| 90 | // log file. |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 91 | reader.Register(); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 92 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 93 | EXPECT_THAT(reader.Nodes(), ::testing::ElementsAre(nullptr)); |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 94 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 95 | std::unique_ptr<EventLoop> test_event_loop = |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 96 | reader.event_loop_factory()->MakeEventLoop("log_reader"); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 97 | |
| 98 | int ping_count = 10; |
| 99 | int pong_count = 10; |
| 100 | |
James Kuszmaul | c7bbb3e | 2020-01-03 20:01:00 -0800 | [diff] [blame] | 101 | // Confirm that the ping value matches in the remapped channel location. |
| 102 | test_event_loop->MakeWatcher("/original/test", |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 103 | [&ping_count](const examples::Ping &ping) { |
| 104 | EXPECT_EQ(ping.value(), ping_count + 1); |
| 105 | ++ping_count; |
| 106 | }); |
| 107 | // Confirm that the ping and pong counts both match, and the value also |
| 108 | // matches. |
| 109 | test_event_loop->MakeWatcher( |
| 110 | "/test", [&pong_count, &ping_count](const examples::Pong &pong) { |
| 111 | EXPECT_EQ(pong.value(), pong_count + 1); |
| 112 | ++pong_count; |
| 113 | EXPECT_EQ(ping_count, pong_count); |
| 114 | }); |
| 115 | |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 116 | reader.event_loop_factory()->RunFor(std::chrono::seconds(100)); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 117 | EXPECT_EQ(ping_count, 2010); |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 118 | } |
| 119 | |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 120 | // Tests calling StartLogging twice. |
| 121 | TEST_F(LoggerDeathTest, ExtraStart) { |
Austin Schuh | c6f8f1b | 2020-12-02 23:23:39 -0800 | [diff] [blame] | 122 | const ::std::string tmpdir = aos::testing::TestTmpDir(); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 123 | const ::std::string base_name1 = tmpdir + "/logfile1"; |
| 124 | const ::std::string logfile1 = base_name1 + ".part0.bfbs"; |
| 125 | const ::std::string base_name2 = tmpdir + "/logfile2"; |
| 126 | const ::std::string logfile2 = base_name2 + ".part0.bfbs"; |
| 127 | unlink(logfile1.c_str()); |
| 128 | unlink(logfile2.c_str()); |
| 129 | |
| 130 | LOG(INFO) << "Logging data to " << logfile1 << " then " << logfile2; |
| 131 | |
| 132 | { |
| 133 | std::unique_ptr<EventLoop> logger_event_loop = |
| 134 | event_loop_factory_.MakeEventLoop("logger"); |
| 135 | |
| 136 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 137 | |
| 138 | Logger logger(logger_event_loop.get()); |
| 139 | logger.set_polling_period(std::chrono::milliseconds(100)); |
| 140 | logger_event_loop->OnRun( |
| 141 | [base_name1, base_name2, &logger_event_loop, &logger]() { |
| 142 | logger.StartLogging(std::make_unique<LocalLogNamer>( |
| 143 | base_name1, logger_event_loop->node())); |
| 144 | EXPECT_DEATH(logger.StartLogging(std::make_unique<LocalLogNamer>( |
| 145 | base_name2, logger_event_loop->node())), |
| 146 | "Already logging"); |
| 147 | }); |
| 148 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // Tests calling StopLogging twice. |
| 153 | TEST_F(LoggerDeathTest, ExtraStop) { |
Austin Schuh | c6f8f1b | 2020-12-02 23:23:39 -0800 | [diff] [blame] | 154 | const ::std::string tmpdir = aos::testing::TestTmpDir(); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 155 | const ::std::string base_name = tmpdir + "/logfile"; |
| 156 | const ::std::string logfile = base_name + ".part0.bfbs"; |
| 157 | // Remove it. |
| 158 | unlink(logfile.c_str()); |
| 159 | |
| 160 | LOG(INFO) << "Logging data to " << logfile; |
| 161 | |
| 162 | { |
| 163 | std::unique_ptr<EventLoop> logger_event_loop = |
| 164 | event_loop_factory_.MakeEventLoop("logger"); |
| 165 | |
| 166 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 167 | |
| 168 | Logger logger(logger_event_loop.get()); |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 169 | logger.set_separate_config(false); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 170 | logger.set_polling_period(std::chrono::milliseconds(100)); |
| 171 | logger_event_loop->OnRun([base_name, &logger_event_loop, &logger]() { |
| 172 | logger.StartLogging(std::make_unique<LocalLogNamer>( |
| 173 | base_name, logger_event_loop->node())); |
| 174 | logger.StopLogging(aos::monotonic_clock::min_time); |
| 175 | EXPECT_DEATH(logger.StopLogging(aos::monotonic_clock::min_time), |
| 176 | "Not logging right now"); |
| 177 | }); |
| 178 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // Tests that we can startup twice. |
| 183 | TEST_F(LoggerTest, StartsTwice) { |
Austin Schuh | c6f8f1b | 2020-12-02 23:23:39 -0800 | [diff] [blame] | 184 | const ::std::string tmpdir = aos::testing::TestTmpDir(); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 185 | const ::std::string base_name1 = tmpdir + "/logfile1"; |
| 186 | const ::std::string logfile1 = base_name1 + ".part0.bfbs"; |
| 187 | const ::std::string base_name2 = tmpdir + "/logfile2"; |
| 188 | const ::std::string logfile2 = base_name2 + ".part0.bfbs"; |
| 189 | unlink(logfile1.c_str()); |
| 190 | unlink(logfile2.c_str()); |
| 191 | |
| 192 | LOG(INFO) << "Logging data to " << logfile1 << " then " << logfile2; |
| 193 | |
| 194 | { |
| 195 | std::unique_ptr<EventLoop> logger_event_loop = |
| 196 | event_loop_factory_.MakeEventLoop("logger"); |
| 197 | |
| 198 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 199 | |
| 200 | Logger logger(logger_event_loop.get()); |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 201 | logger.set_separate_config(false); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 202 | logger.set_polling_period(std::chrono::milliseconds(100)); |
| 203 | logger.StartLogging( |
| 204 | std::make_unique<LocalLogNamer>(base_name1, logger_event_loop->node())); |
| 205 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 206 | logger.StopLogging(logger_event_loop->monotonic_now()); |
| 207 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 208 | logger.StartLogging( |
| 209 | std::make_unique<LocalLogNamer>(base_name2, logger_event_loop->node())); |
| 210 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 211 | } |
| 212 | |
| 213 | for (const auto &logfile : |
| 214 | {std::make_tuple(logfile1, 10), std::make_tuple(logfile2, 2010)}) { |
| 215 | SCOPED_TRACE(std::get<0>(logfile)); |
| 216 | LogReader reader(std::get<0>(logfile)); |
| 217 | reader.Register(); |
| 218 | |
| 219 | EXPECT_THAT(reader.Nodes(), ::testing::ElementsAre(nullptr)); |
| 220 | |
| 221 | std::unique_ptr<EventLoop> test_event_loop = |
| 222 | reader.event_loop_factory()->MakeEventLoop("log_reader"); |
| 223 | |
| 224 | int ping_count = std::get<1>(logfile); |
| 225 | int pong_count = std::get<1>(logfile); |
| 226 | |
| 227 | // Confirm that the ping and pong counts both match, and the value also |
| 228 | // matches. |
| 229 | test_event_loop->MakeWatcher("/test", |
| 230 | [&ping_count](const examples::Ping &ping) { |
| 231 | EXPECT_EQ(ping.value(), ping_count + 1); |
| 232 | ++ping_count; |
| 233 | }); |
| 234 | test_event_loop->MakeWatcher( |
| 235 | "/test", [&pong_count, &ping_count](const examples::Pong &pong) { |
| 236 | EXPECT_EQ(pong.value(), pong_count + 1); |
| 237 | ++pong_count; |
| 238 | EXPECT_EQ(ping_count, pong_count); |
| 239 | }); |
| 240 | |
| 241 | reader.event_loop_factory()->RunFor(std::chrono::seconds(100)); |
| 242 | EXPECT_EQ(ping_count, std::get<1>(logfile) + 1000); |
| 243 | } |
| 244 | } |
| 245 | |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 246 | // Tests that we can read and write rotated log files. |
| 247 | TEST_F(LoggerTest, RotatedLogFile) { |
Austin Schuh | c6f8f1b | 2020-12-02 23:23:39 -0800 | [diff] [blame] | 248 | const ::std::string tmpdir = aos::testing::TestTmpDir(); |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 249 | const ::std::string base_name = tmpdir + "/logfile"; |
| 250 | const ::std::string logfile0 = base_name + ".part0.bfbs"; |
| 251 | const ::std::string logfile1 = base_name + ".part1.bfbs"; |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 252 | // Remove it. |
| 253 | unlink(logfile0.c_str()); |
| 254 | unlink(logfile1.c_str()); |
| 255 | |
| 256 | LOG(INFO) << "Logging data to " << logfile0 << " and " << logfile1; |
| 257 | |
| 258 | { |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 259 | std::unique_ptr<EventLoop> logger_event_loop = |
| 260 | event_loop_factory_.MakeEventLoop("logger"); |
| 261 | |
| 262 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 263 | |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 264 | Logger logger(logger_event_loop.get()); |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 265 | logger.set_separate_config(false); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 266 | logger.set_polling_period(std::chrono::milliseconds(100)); |
| 267 | logger.StartLoggingLocalNamerOnRun(base_name); |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 268 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 269 | logger.Rotate(); |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 270 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 271 | } |
| 272 | |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 273 | { |
| 274 | // Confirm that the UUIDs match for both the parts and the logger, and the |
| 275 | // parts_index increments. |
Austin Schuh | add6eb3 | 2020-11-09 21:24:26 -0800 | [diff] [blame] | 276 | std::vector<SizePrefixedFlatbufferVector<LogFileHeader>> log_header; |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 277 | for (std::string_view f : {logfile0, logfile1}) { |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 278 | log_header.emplace_back(ReadHeader(f).value()); |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Brian Silverman | ae7c033 | 2020-09-30 16:58:23 -0700 | [diff] [blame] | 281 | EXPECT_EQ(log_header[0].message().log_event_uuid()->string_view(), |
| 282 | log_header[1].message().log_event_uuid()->string_view()); |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 283 | EXPECT_EQ(log_header[0].message().parts_uuid()->string_view(), |
| 284 | log_header[1].message().parts_uuid()->string_view()); |
| 285 | |
| 286 | EXPECT_EQ(log_header[0].message().parts_index(), 0); |
| 287 | EXPECT_EQ(log_header[1].message().parts_index(), 1); |
| 288 | } |
| 289 | |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 290 | // Even though it doesn't make any difference here, exercise the logic for |
| 291 | // passing in a separate config. |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 292 | LogReader reader(SortParts({logfile0, logfile1}), &config_.message()); |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 293 | |
| 294 | // Confirm that we can remap logged channels to point to new buses. |
| 295 | reader.RemapLoggedChannel<aos::examples::Ping>("/test", "/original"); |
| 296 | |
| 297 | // This sends out the fetched messages and advances time to the start of the |
| 298 | // log file. |
| 299 | reader.Register(); |
| 300 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 301 | EXPECT_THAT(reader.Nodes(), ::testing::ElementsAre(nullptr)); |
Austin Schuh | fa89589 | 2020-01-07 20:07:41 -0800 | [diff] [blame] | 302 | |
| 303 | std::unique_ptr<EventLoop> test_event_loop = |
| 304 | reader.event_loop_factory()->MakeEventLoop("log_reader"); |
| 305 | |
| 306 | int ping_count = 10; |
| 307 | int pong_count = 10; |
| 308 | |
| 309 | // Confirm that the ping value matches in the remapped channel location. |
| 310 | test_event_loop->MakeWatcher("/original/test", |
| 311 | [&ping_count](const examples::Ping &ping) { |
| 312 | EXPECT_EQ(ping.value(), ping_count + 1); |
| 313 | ++ping_count; |
| 314 | }); |
| 315 | // Confirm that the ping and pong counts both match, and the value also |
| 316 | // matches. |
| 317 | test_event_loop->MakeWatcher( |
| 318 | "/test", [&pong_count, &ping_count](const examples::Pong &pong) { |
| 319 | EXPECT_EQ(pong.value(), pong_count + 1); |
| 320 | ++pong_count; |
| 321 | EXPECT_EQ(ping_count, pong_count); |
| 322 | }); |
| 323 | |
| 324 | reader.event_loop_factory()->RunFor(std::chrono::seconds(100)); |
| 325 | EXPECT_EQ(ping_count, 2010); |
| 326 | } |
| 327 | |
Austin Schuh | 4c4e009 | 2019-12-22 16:18:03 -0800 | [diff] [blame] | 328 | // Tests that a large number of messages per second doesn't overwhelm writev. |
| 329 | TEST_F(LoggerTest, ManyMessages) { |
Austin Schuh | c6f8f1b | 2020-12-02 23:23:39 -0800 | [diff] [blame] | 330 | const ::std::string tmpdir = aos::testing::TestTmpDir(); |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 331 | const ::std::string base_name = tmpdir + "/logfile"; |
| 332 | const ::std::string logfile = base_name + ".part0.bfbs"; |
Austin Schuh | 4c4e009 | 2019-12-22 16:18:03 -0800 | [diff] [blame] | 333 | // Remove the log file. |
| 334 | unlink(logfile.c_str()); |
| 335 | |
| 336 | LOG(INFO) << "Logging data to " << logfile; |
Austin Schuh | 4c3b970 | 2020-08-30 11:34:55 -0700 | [diff] [blame] | 337 | ping_.set_quiet(true); |
Austin Schuh | 4c4e009 | 2019-12-22 16:18:03 -0800 | [diff] [blame] | 338 | |
| 339 | { |
Austin Schuh | 4c4e009 | 2019-12-22 16:18:03 -0800 | [diff] [blame] | 340 | std::unique_ptr<EventLoop> logger_event_loop = |
| 341 | event_loop_factory_.MakeEventLoop("logger"); |
| 342 | |
| 343 | std::unique_ptr<EventLoop> ping_spammer_event_loop = |
| 344 | event_loop_factory_.MakeEventLoop("ping_spammer"); |
| 345 | aos::Sender<examples::Ping> ping_sender = |
| 346 | ping_spammer_event_loop->MakeSender<examples::Ping>("/test"); |
| 347 | |
| 348 | aos::TimerHandler *timer_handler = |
| 349 | ping_spammer_event_loop->AddTimer([&ping_sender]() { |
| 350 | aos::Sender<examples::Ping>::Builder builder = |
| 351 | ping_sender.MakeBuilder(); |
| 352 | examples::Ping::Builder ping_builder = |
| 353 | builder.MakeBuilder<examples::Ping>(); |
| 354 | CHECK(builder.Send(ping_builder.Finish())); |
| 355 | }); |
| 356 | |
| 357 | // 100 ms / 0.05 ms -> 2000 messages. Should be enough to crash it. |
| 358 | ping_spammer_event_loop->OnRun([&ping_spammer_event_loop, timer_handler]() { |
| 359 | timer_handler->Setup(ping_spammer_event_loop->monotonic_now(), |
| 360 | chrono::microseconds(50)); |
| 361 | }); |
| 362 | |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 363 | Logger logger(logger_event_loop.get()); |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 364 | logger.set_separate_config(false); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 365 | logger.set_polling_period(std::chrono::milliseconds(100)); |
| 366 | logger.StartLoggingLocalNamerOnRun(base_name); |
Austin Schuh | 4c4e009 | 2019-12-22 16:18:03 -0800 | [diff] [blame] | 367 | |
| 368 | event_loop_factory_.RunFor(chrono::milliseconds(1000)); |
| 369 | } |
| 370 | } |
| 371 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 372 | std::vector<std::string> MakeLogFiles(std::string logfile_base1, std::string logfile_base2) { |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 373 | return std::vector<std::string>( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 374 | {logfile_base1 + "_pi1_data.part0.bfbs", |
| 375 | logfile_base1 + "_pi2_data/test/aos.examples.Pong.part0.bfbs", |
| 376 | logfile_base1 + "_pi2_data/test/aos.examples.Pong.part1.bfbs", |
| 377 | logfile_base2 + "_pi2_data.part0.bfbs", |
| 378 | logfile_base1 + "_timestamps/pi1/aos/remote_timestamps/pi2/" |
| 379 | "aos.message_bridge.RemoteMessage.part0.bfbs", |
| 380 | logfile_base1 + "_timestamps/pi1/aos/remote_timestamps/pi2/" |
| 381 | "aos.message_bridge.RemoteMessage.part1.bfbs", |
| 382 | logfile_base2 + "_timestamps/pi2/aos/remote_timestamps/pi1/" |
| 383 | "aos.message_bridge.RemoteMessage.part0.bfbs", |
| 384 | logfile_base2 + "_timestamps/pi2/aos/remote_timestamps/pi1/" |
| 385 | "aos.message_bridge.RemoteMessage.part1.bfbs", |
| 386 | logfile_base2 + |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 387 | "_pi1_data/pi1/aos/aos.message_bridge.Timestamp.part0.bfbs", |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 388 | logfile_base2 + |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 389 | "_pi1_data/pi1/aos/aos.message_bridge.Timestamp.part1.bfbs", |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 390 | logfile_base1 + |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 391 | "_pi2_data/pi2/aos/aos.message_bridge.Timestamp.part0.bfbs", |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 392 | logfile_base1 + |
| 393 | "_pi2_data/pi2/aos/aos.message_bridge.Timestamp.part1.bfbs", |
| 394 | absl::StrCat(logfile_base1, "_", kConfigSha1, ".bfbs"), |
| 395 | absl::StrCat(logfile_base2, "_", kConfigSha1, ".bfbs")}); |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 396 | } |
| 397 | |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 398 | class MultinodeLoggerTest : public ::testing::Test { |
| 399 | public: |
| 400 | MultinodeLoggerTest() |
| 401 | : config_(aos::configuration::ReadConfig( |
Austin Schuh | e84c3ed | 2019-12-14 15:29:48 -0800 | [diff] [blame] | 402 | "aos/events/logging/multinode_pingpong_config.json")), |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 403 | event_loop_factory_(&config_.message()), |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 404 | pi1_( |
| 405 | configuration::GetNode(event_loop_factory_.configuration(), "pi1")), |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 406 | pi2_( |
| 407 | configuration::GetNode(event_loop_factory_.configuration(), "pi2")), |
Austin Schuh | c6f8f1b | 2020-12-02 23:23:39 -0800 | [diff] [blame] | 408 | tmp_dir_(aos::testing::TestTmpDir()), |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 409 | logfile_base1_(tmp_dir_ + "/multi_logfile1"), |
| 410 | logfile_base2_(tmp_dir_ + "/multi_logfile2"), |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 411 | pi1_reboot_logfiles_( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 412 | {logfile_base1_ + "_pi1_data.part0.bfbs", |
| 413 | logfile_base1_ + "_pi2_data/test/aos.examples.Pong.part0.bfbs", |
| 414 | logfile_base1_ + "_pi2_data/test/aos.examples.Pong.part1.bfbs", |
| 415 | logfile_base1_ + "_pi2_data/test/aos.examples.Pong.part2.bfbs", |
| 416 | logfile_base1_ + "_timestamps/pi1/aos/remote_timestamps/pi2/" |
| 417 | "aos.message_bridge.RemoteMessage.part0.bfbs", |
| 418 | logfile_base1_ + "_timestamps/pi1/aos/remote_timestamps/pi2/" |
| 419 | "aos.message_bridge.RemoteMessage.part1.bfbs", |
| 420 | logfile_base1_ + "_timestamps/pi1/aos/remote_timestamps/pi2/" |
| 421 | "aos.message_bridge.RemoteMessage.part2.bfbs", |
| 422 | logfile_base1_ + |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 423 | "_pi2_data/pi2/aos/aos.message_bridge.Timestamp.part0.bfbs", |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 424 | logfile_base1_ + |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 425 | "_pi2_data/pi2/aos/aos.message_bridge.Timestamp.part1.bfbs", |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 426 | logfile_base1_ + |
| 427 | "_pi2_data/pi2/aos/aos.message_bridge.Timestamp.part2.bfbs", |
| 428 | absl::StrCat(logfile_base1_, "_", kConfigSha1, ".bfbs")}), |
| 429 | logfiles_(MakeLogFiles(logfile_base1_, logfile_base2_)), |
Austin Schuh | c904973 | 2020-12-21 22:27:15 -0800 | [diff] [blame] | 430 | pi1_single_direction_logfiles_( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 431 | {logfile_base1_ + "_pi1_data.part0.bfbs", |
| 432 | logfile_base1_ + "_pi2_data/test/aos.examples.Pong.part0.bfbs", |
| 433 | logfile_base1_ + "_timestamps/pi1/aos/remote_timestamps/pi2/" |
| 434 | "aos.message_bridge.RemoteMessage.part0.bfbs", |
| 435 | logfile_base1_ + |
| 436 | "_pi2_data/pi2/aos/aos.message_bridge.Timestamp.part0.bfbs", |
| 437 | absl::StrCat(logfile_base1_, "_", kConfigSha1, ".bfbs")}), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 438 | structured_logfiles_{ |
| 439 | std::vector<std::string>{logfiles_[0]}, |
| 440 | std::vector<std::string>{logfiles_[1], logfiles_[2]}, |
| 441 | std::vector<std::string>{logfiles_[3]}, |
| 442 | std::vector<std::string>{logfiles_[4], logfiles_[5]}, |
| 443 | std::vector<std::string>{logfiles_[6], logfiles_[7]}, |
| 444 | std::vector<std::string>{logfiles_[8], logfiles_[9]}, |
| 445 | std::vector<std::string>{logfiles_[10], logfiles_[11]}}, |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 446 | ping_event_loop_(event_loop_factory_.MakeEventLoop("ping", pi1_)), |
| 447 | ping_(ping_event_loop_.get()), |
| 448 | pong_event_loop_(event_loop_factory_.MakeEventLoop("pong", pi2_)), |
| 449 | pong_(pong_event_loop_.get()) { |
| 450 | // Go through and remove the logfiles if they already exist. |
| 451 | for (const auto file : logfiles_) { |
| 452 | unlink(file.c_str()); |
Austin Schuh | c6f8f1b | 2020-12-02 23:23:39 -0800 | [diff] [blame] | 453 | unlink((file + ".xz").c_str()); |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 454 | } |
| 455 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 456 | for (const auto file : MakeLogFiles("relogged1", "relogged2")) { |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 457 | unlink(file.c_str()); |
| 458 | } |
| 459 | |
| 460 | for (const auto file : pi1_reboot_logfiles_) { |
| 461 | unlink(file.c_str()); |
| 462 | } |
| 463 | |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 464 | LOG(INFO) << "Logging data to " << logfiles_[0] << ", " << logfiles_[1] |
| 465 | << " and " << logfiles_[2]; |
| 466 | } |
| 467 | |
| 468 | struct LoggerState { |
| 469 | std::unique_ptr<EventLoop> event_loop; |
| 470 | std::unique_ptr<Logger> logger; |
| 471 | }; |
| 472 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 473 | LoggerState MakeLogger(const Node *node, |
| 474 | SimulatedEventLoopFactory *factory = nullptr) { |
| 475 | if (factory == nullptr) { |
| 476 | factory = &event_loop_factory_; |
| 477 | } |
| 478 | return {factory->MakeEventLoop("logger", node), {}}; |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 481 | void StartLogger(LoggerState *logger, std::string logfile_base = "", |
| 482 | bool compress = false) { |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 483 | if (logfile_base.empty()) { |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 484 | if (logger->event_loop->node()->name()->string_view() == "pi1") { |
| 485 | logfile_base = logfile_base1_; |
| 486 | } else { |
| 487 | logfile_base = logfile_base2_; |
| 488 | } |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 489 | } |
| 490 | |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 491 | logger->logger = std::make_unique<Logger>(logger->event_loop.get()); |
| 492 | logger->logger->set_polling_period(std::chrono::milliseconds(100)); |
Austin Schuh | 0ca51f3 | 2020-12-25 21:51:45 -0800 | [diff] [blame] | 493 | logger->logger->set_name(absl::StrCat( |
| 494 | "name_prefix_", logger->event_loop->node()->name()->str())); |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 495 | logger->event_loop->OnRun([logger, logfile_base, compress]() { |
| 496 | std::unique_ptr<MultiNodeLogNamer> namer = |
| 497 | std::make_unique<MultiNodeLogNamer>( |
| 498 | logfile_base, logger->event_loop->configuration(), |
| 499 | logger->event_loop->node()); |
| 500 | if (compress) { |
| 501 | #ifdef LZMA |
| 502 | namer->set_extension(".xz"); |
| 503 | namer->set_encoder_factory( |
| 504 | []() { return std::make_unique<aos::logger::LzmaEncoder>(3); }); |
| 505 | #else |
| 506 | LOG(FATAL) << "Compression unsupported"; |
| 507 | #endif |
| 508 | } |
| 509 | |
| 510 | logger->logger->StartLogging(std::move(namer)); |
Brian Silverman | 1f34522 | 2020-09-24 21:14:48 -0700 | [diff] [blame] | 511 | }); |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 512 | } |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 513 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 514 | void VerifyParts(const std::vector<LogFile> &sorted_parts, |
| 515 | const std::vector<std::string> &corrupted_parts = {}) { |
| 516 | EXPECT_EQ(sorted_parts.size(), 2u); |
| 517 | |
| 518 | // Count up the number of UUIDs and make sure they are what we expect as a |
| 519 | // sanity check. |
| 520 | std::set<std::string> log_event_uuids; |
| 521 | std::set<std::string> parts_uuids; |
| 522 | std::set<std::string> both_uuids; |
| 523 | |
| 524 | size_t missing_rt_count = 0; |
| 525 | |
| 526 | std::vector<std::string> logger_nodes; |
| 527 | for (const LogFile &log_file : sorted_parts) { |
| 528 | EXPECT_FALSE(log_file.log_event_uuid.empty()); |
| 529 | log_event_uuids.insert(log_file.log_event_uuid); |
| 530 | logger_nodes.emplace_back(log_file.logger_node); |
| 531 | both_uuids.insert(log_file.log_event_uuid); |
Austin Schuh | 0ca51f3 | 2020-12-25 21:51:45 -0800 | [diff] [blame] | 532 | EXPECT_TRUE(log_file.config); |
| 533 | EXPECT_EQ(log_file.name, |
| 534 | absl::StrCat("name_prefix_", log_file.logger_node)); |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 535 | |
| 536 | for (const LogParts &part : log_file.parts) { |
| 537 | EXPECT_NE(part.monotonic_start_time, aos::monotonic_clock::min_time) |
| 538 | << ": " << part; |
| 539 | missing_rt_count += |
| 540 | part.realtime_start_time == aos::realtime_clock::min_time; |
| 541 | |
| 542 | EXPECT_TRUE(log_event_uuids.find(part.log_event_uuid) != |
| 543 | log_event_uuids.end()); |
| 544 | EXPECT_NE(part.node, ""); |
Austin Schuh | 0ca51f3 | 2020-12-25 21:51:45 -0800 | [diff] [blame] | 545 | EXPECT_TRUE(log_file.config); |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 546 | parts_uuids.insert(part.parts_uuid); |
| 547 | both_uuids.insert(part.parts_uuid); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | // We won't have RT timestamps for 5 log files. We don't log the RT start |
| 552 | // time on remote nodes because we don't know it and would be guessing. And |
| 553 | // the log reader can actually do a better job. |
| 554 | EXPECT_EQ(missing_rt_count, 5u); |
| 555 | |
| 556 | EXPECT_EQ(log_event_uuids.size(), 2u); |
| 557 | EXPECT_EQ(parts_uuids.size(), ToLogReaderVector(sorted_parts).size()); |
| 558 | EXPECT_EQ(log_event_uuids.size() + parts_uuids.size(), both_uuids.size()); |
| 559 | |
| 560 | // Test that each list of parts is in order. Don't worry about the ordering |
| 561 | // between part file lists though. |
| 562 | // (inner vectors all need to be in order, but outer one doesn't matter). |
| 563 | EXPECT_THAT(ToLogReaderVector(sorted_parts), |
| 564 | ::testing::UnorderedElementsAreArray(structured_logfiles_)); |
| 565 | |
| 566 | EXPECT_THAT(logger_nodes, ::testing::UnorderedElementsAre("pi1", "pi2")); |
| 567 | |
| 568 | EXPECT_NE(sorted_parts[0].realtime_start_time, |
| 569 | aos::realtime_clock::min_time); |
| 570 | EXPECT_NE(sorted_parts[1].realtime_start_time, |
| 571 | aos::realtime_clock::min_time); |
| 572 | |
| 573 | EXPECT_NE(sorted_parts[0].monotonic_start_time, |
| 574 | aos::monotonic_clock::min_time); |
| 575 | EXPECT_NE(sorted_parts[1].monotonic_start_time, |
| 576 | aos::monotonic_clock::min_time); |
| 577 | |
| 578 | EXPECT_THAT(sorted_parts[0].corrupted, ::testing::Eq(corrupted_parts)); |
| 579 | EXPECT_THAT(sorted_parts[1].corrupted, ::testing::Eq(corrupted_parts)); |
| 580 | } |
| 581 | |
Austin Schuh | c904973 | 2020-12-21 22:27:15 -0800 | [diff] [blame] | 582 | void ConfirmReadable(const std::vector<std::string> &files) { |
| 583 | LogReader reader(SortParts(files)); |
| 584 | |
| 585 | SimulatedEventLoopFactory log_reader_factory(reader.configuration()); |
| 586 | reader.Register(&log_reader_factory); |
| 587 | |
| 588 | log_reader_factory.Run(); |
| 589 | |
| 590 | reader.Deregister(); |
| 591 | } |
| 592 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 593 | void AddExtension(std::string_view extension) { |
| 594 | std::transform(logfiles_.begin(), logfiles_.end(), logfiles_.begin(), |
| 595 | [extension](const std::string &in) { |
| 596 | return absl::StrCat(in, extension); |
| 597 | }); |
| 598 | |
| 599 | std::transform(structured_logfiles_.begin(), structured_logfiles_.end(), |
| 600 | structured_logfiles_.begin(), |
| 601 | [extension](std::vector<std::string> in) { |
| 602 | std::transform(in.begin(), in.end(), in.begin(), |
| 603 | [extension](const std::string &in_str) { |
| 604 | return absl::StrCat(in_str, extension); |
| 605 | }); |
| 606 | return in; |
| 607 | }); |
| 608 | } |
| 609 | |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 610 | // Config and factory. |
| 611 | aos::FlatbufferDetachedBuffer<aos::Configuration> config_; |
| 612 | SimulatedEventLoopFactory event_loop_factory_; |
| 613 | |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 614 | const Node *pi1_; |
| 615 | const Node *pi2_; |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 616 | |
| 617 | std::string tmp_dir_; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 618 | std::string logfile_base1_; |
| 619 | std::string logfile_base2_; |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 620 | std::vector<std::string> pi1_reboot_logfiles_; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 621 | std::vector<std::string> logfiles_; |
Austin Schuh | c904973 | 2020-12-21 22:27:15 -0800 | [diff] [blame] | 622 | std::vector<std::string> pi1_single_direction_logfiles_; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 623 | |
| 624 | std::vector<std::vector<std::string>> structured_logfiles_; |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 625 | |
| 626 | std::unique_ptr<EventLoop> ping_event_loop_; |
| 627 | Ping ping_; |
| 628 | std::unique_ptr<EventLoop> pong_event_loop_; |
| 629 | Pong pong_; |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 630 | }; |
| 631 | |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 632 | // Counts the number of messages on a channel. Returns (channel name, channel |
| 633 | // type, count) for every message matching matcher() |
| 634 | std::vector<std::tuple<std::string, std::string, int>> CountChannelsMatching( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 635 | std::shared_ptr<const aos::Configuration> config, |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 636 | std::string_view filename, |
| 637 | std::function<bool(const MessageHeader *)> matcher) { |
| 638 | MessageReader message_reader(filename); |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 639 | std::vector<int> counts(config->channels()->size(), 0); |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 640 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 641 | while (true) { |
Austin Schuh | add6eb3 | 2020-11-09 21:24:26 -0800 | [diff] [blame] | 642 | std::optional<SizePrefixedFlatbufferVector<MessageHeader>> msg = |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 643 | message_reader.ReadMessage(); |
| 644 | if (!msg) { |
| 645 | break; |
| 646 | } |
| 647 | |
| 648 | if (matcher(&msg.value().message())) { |
| 649 | counts[msg.value().message().channel_index()]++; |
| 650 | } |
| 651 | } |
| 652 | |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 653 | std::vector<std::tuple<std::string, std::string, int>> result; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 654 | int channel = 0; |
| 655 | for (size_t i = 0; i < counts.size(); ++i) { |
| 656 | if (counts[i] != 0) { |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 657 | const Channel *channel = config->channels()->Get(i); |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 658 | result.push_back(std::make_tuple(channel->name()->str(), |
| 659 | channel->type()->str(), counts[i])); |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 660 | } |
| 661 | ++channel; |
| 662 | } |
| 663 | |
| 664 | return result; |
| 665 | } |
| 666 | |
| 667 | // Counts the number of messages (channel, count) for all data messages. |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 668 | std::vector<std::tuple<std::string, std::string, int>> CountChannelsData( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 669 | std::shared_ptr<const aos::Configuration> config, |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 670 | std::string_view filename) { |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 671 | return CountChannelsMatching(config, filename, [](const MessageHeader *msg) { |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 672 | if (msg->has_data()) { |
| 673 | CHECK(!msg->has_monotonic_remote_time()); |
| 674 | CHECK(!msg->has_realtime_remote_time()); |
| 675 | CHECK(!msg->has_remote_queue_index()); |
| 676 | return true; |
| 677 | } |
| 678 | return false; |
| 679 | }); |
| 680 | } |
| 681 | |
| 682 | // Counts the number of messages (channel, count) for all timestamp messages. |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 683 | std::vector<std::tuple<std::string, std::string, int>> CountChannelsTimestamp( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 684 | std::shared_ptr<const aos::Configuration> config, |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 685 | std::string_view filename) { |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 686 | return CountChannelsMatching(config, filename, [](const MessageHeader *msg) { |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 687 | if (!msg->has_data()) { |
| 688 | CHECK(msg->has_monotonic_remote_time()); |
| 689 | CHECK(msg->has_realtime_remote_time()); |
| 690 | CHECK(msg->has_remote_queue_index()); |
| 691 | return true; |
| 692 | } |
| 693 | return false; |
| 694 | }); |
| 695 | } |
| 696 | |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 697 | // Tests that we can write and read simple multi-node log files. |
| 698 | TEST_F(MultinodeLoggerTest, SimpleMultiNode) { |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 699 | { |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 700 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 701 | LoggerState pi2_logger = MakeLogger(pi2_); |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 702 | |
| 703 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 704 | |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 705 | StartLogger(&pi1_logger); |
| 706 | StartLogger(&pi2_logger); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 707 | |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 708 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 709 | } |
| 710 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 711 | { |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 712 | std::set<std::string> logfile_uuids; |
| 713 | std::set<std::string> parts_uuids; |
| 714 | // Confirm that we have the expected number of UUIDs for both the logfile |
| 715 | // UUIDs and parts UUIDs. |
Austin Schuh | add6eb3 | 2020-11-09 21:24:26 -0800 | [diff] [blame] | 716 | std::vector<SizePrefixedFlatbufferVector<LogFileHeader>> log_header; |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 717 | for (std::string_view f : logfiles_) { |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 718 | log_header.emplace_back(ReadHeader(f).value()); |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 719 | if (!log_header.back().message().has_configuration()) { |
| 720 | logfile_uuids.insert( |
| 721 | log_header.back().message().log_event_uuid()->str()); |
| 722 | parts_uuids.insert(log_header.back().message().parts_uuid()->str()); |
| 723 | } |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 724 | } |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 725 | |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 726 | EXPECT_EQ(logfile_uuids.size(), 2u); |
| 727 | EXPECT_EQ(parts_uuids.size(), 7u); |
| 728 | |
| 729 | // And confirm everything is on the correct node. |
| 730 | EXPECT_EQ(log_header[0].message().node()->name()->string_view(), "pi1"); |
| 731 | EXPECT_EQ(log_header[1].message().node()->name()->string_view(), "pi2"); |
| 732 | EXPECT_EQ(log_header[2].message().node()->name()->string_view(), "pi2"); |
| 733 | EXPECT_EQ(log_header[3].message().node()->name()->string_view(), "pi2"); |
| 734 | EXPECT_EQ(log_header[4].message().node()->name()->string_view(), "pi2"); |
| 735 | EXPECT_EQ(log_header[5].message().node()->name()->string_view(), "pi2"); |
| 736 | EXPECT_EQ(log_header[6].message().node()->name()->string_view(), "pi1"); |
| 737 | EXPECT_EQ(log_header[7].message().node()->name()->string_view(), "pi1"); |
| 738 | EXPECT_EQ(log_header[8].message().node()->name()->string_view(), "pi1"); |
| 739 | EXPECT_EQ(log_header[9].message().node()->name()->string_view(), "pi1"); |
| 740 | EXPECT_EQ(log_header[10].message().node()->name()->string_view(), "pi2"); |
| 741 | EXPECT_EQ(log_header[11].message().node()->name()->string_view(), "pi2"); |
| 742 | |
| 743 | // And the parts index matches. |
| 744 | EXPECT_EQ(log_header[0].message().parts_index(), 0); |
| 745 | EXPECT_EQ(log_header[1].message().parts_index(), 0); |
| 746 | EXPECT_EQ(log_header[2].message().parts_index(), 1); |
| 747 | EXPECT_EQ(log_header[3].message().parts_index(), 0); |
| 748 | EXPECT_EQ(log_header[4].message().parts_index(), 0); |
| 749 | EXPECT_EQ(log_header[5].message().parts_index(), 1); |
| 750 | EXPECT_EQ(log_header[6].message().parts_index(), 0); |
| 751 | EXPECT_EQ(log_header[7].message().parts_index(), 1); |
| 752 | EXPECT_EQ(log_header[8].message().parts_index(), 0); |
| 753 | EXPECT_EQ(log_header[9].message().parts_index(), 1); |
| 754 | EXPECT_EQ(log_header[10].message().parts_index(), 0); |
| 755 | EXPECT_EQ(log_header[11].message().parts_index(), 1); |
| 756 | } |
| 757 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 758 | const std::vector<LogFile> sorted_log_files = SortParts(logfiles_); |
Austin Schuh | 64fab80 | 2020-09-09 22:47:47 -0700 | [diff] [blame] | 759 | { |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 760 | using ::testing::UnorderedElementsAre; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 761 | std::shared_ptr<const aos::Configuration> config = |
| 762 | sorted_log_files[0].config; |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 763 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 764 | // Timing reports, pings |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 765 | EXPECT_THAT( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 766 | CountChannelsData(config, logfiles_[0]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 767 | UnorderedElementsAre( |
| 768 | std::make_tuple("/pi1/aos", "aos.message_bridge.Timestamp", 200), |
| 769 | std::make_tuple("/pi1/aos", "aos.timing.Report", 40), |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 770 | std::make_tuple("/test", "aos.examples.Ping", 2001))) |
| 771 | << " : " << logfiles_[0]; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 772 | // Timestamps for pong |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 773 | EXPECT_THAT( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 774 | CountChannelsTimestamp(config, logfiles_[0]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 775 | UnorderedElementsAre( |
| 776 | std::make_tuple("/test", "aos.examples.Pong", 2001), |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 777 | std::make_tuple("/pi2/aos", "aos.message_bridge.Timestamp", 200))) |
| 778 | << " : " << logfiles_[0]; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 779 | |
| 780 | // Pong data. |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 781 | EXPECT_THAT( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 782 | CountChannelsData(config, logfiles_[1]), |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 783 | UnorderedElementsAre(std::make_tuple("/test", "aos.examples.Pong", 91))) |
| 784 | << " : " << logfiles_[1]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 785 | EXPECT_THAT(CountChannelsData(config, logfiles_[2]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 786 | UnorderedElementsAre( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 787 | std::make_tuple("/test", "aos.examples.Pong", 1910))) |
| 788 | << " : " << logfiles_[1]; |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 789 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 790 | // No timestamps |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 791 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[1]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 792 | << " : " << logfiles_[1]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 793 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[2]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 794 | << " : " << logfiles_[2]; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 795 | |
| 796 | // Timing reports and pongs. |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 797 | EXPECT_THAT( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 798 | CountChannelsData(config, logfiles_[3]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 799 | UnorderedElementsAre( |
| 800 | std::make_tuple("/pi2/aos", "aos.message_bridge.Timestamp", 200), |
| 801 | std::make_tuple("/pi2/aos", "aos.timing.Report", 40), |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 802 | std::make_tuple("/test", "aos.examples.Pong", 2001))) |
| 803 | << " : " << logfiles_[3]; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 804 | // And ping timestamps. |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 805 | EXPECT_THAT( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 806 | CountChannelsTimestamp(config, logfiles_[3]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 807 | UnorderedElementsAre( |
| 808 | std::make_tuple("/test", "aos.examples.Ping", 2001), |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 809 | std::make_tuple("/pi1/aos", "aos.message_bridge.Timestamp", 200))) |
| 810 | << " : " << logfiles_[3]; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 811 | |
| 812 | // Timestamps from pi2 on pi1, and the other way. |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 813 | EXPECT_THAT(CountChannelsData(config, logfiles_[4]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 814 | << " : " << logfiles_[4]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 815 | EXPECT_THAT(CountChannelsData(config, logfiles_[5]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 816 | << " : " << logfiles_[5]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 817 | EXPECT_THAT(CountChannelsData(config, logfiles_[6]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 818 | << " : " << logfiles_[6]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 819 | EXPECT_THAT(CountChannelsData(config, logfiles_[7]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 820 | << " : " << logfiles_[7]; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 821 | EXPECT_THAT( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 822 | CountChannelsTimestamp(config, logfiles_[4]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 823 | UnorderedElementsAre( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 824 | std::make_tuple("/pi1/aos", "aos.message_bridge.Timestamp", 9), |
| 825 | std::make_tuple("/test", "aos.examples.Ping", 91))) |
| 826 | << " : " << logfiles_[4]; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 827 | EXPECT_THAT( |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 828 | CountChannelsTimestamp(config, logfiles_[5]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 829 | UnorderedElementsAre( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 830 | std::make_tuple("/pi1/aos", "aos.message_bridge.Timestamp", 191), |
| 831 | std::make_tuple("/test", "aos.examples.Ping", 1910))) |
| 832 | << " : " << logfiles_[5]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 833 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[6]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 834 | UnorderedElementsAre(std::make_tuple( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 835 | "/pi2/aos", "aos.message_bridge.Timestamp", 9))) |
| 836 | << " : " << logfiles_[6]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 837 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[7]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 838 | UnorderedElementsAre(std::make_tuple( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 839 | "/pi2/aos", "aos.message_bridge.Timestamp", 191))) |
| 840 | << " : " << logfiles_[7]; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 841 | |
| 842 | // And then test that the remotely logged timestamp data files only have |
| 843 | // timestamps in them. |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 844 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[8]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 845 | << " : " << logfiles_[8]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 846 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[9]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 847 | << " : " << logfiles_[9]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 848 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[10]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 849 | << " : " << logfiles_[10]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 850 | EXPECT_THAT(CountChannelsTimestamp(config, logfiles_[11]), UnorderedElementsAre()) |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 851 | << " : " << logfiles_[11]; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 852 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 853 | EXPECT_THAT(CountChannelsData(config, logfiles_[8]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 854 | UnorderedElementsAre(std::make_tuple( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 855 | "/pi1/aos", "aos.message_bridge.Timestamp", 9))) |
| 856 | << " : " << logfiles_[8]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 857 | EXPECT_THAT(CountChannelsData(config, logfiles_[9]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 858 | UnorderedElementsAre(std::make_tuple( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 859 | "/pi1/aos", "aos.message_bridge.Timestamp", 191))) |
| 860 | << " : " << logfiles_[9]; |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 861 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 862 | EXPECT_THAT(CountChannelsData(config, logfiles_[10]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 863 | UnorderedElementsAre(std::make_tuple( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 864 | "/pi2/aos", "aos.message_bridge.Timestamp", 9))) |
| 865 | << " : " << logfiles_[10]; |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 866 | EXPECT_THAT(CountChannelsData(config, logfiles_[11]), |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 867 | UnorderedElementsAre(std::make_tuple( |
Austin Schuh | 20ac95d | 2020-12-05 17:24:19 -0800 | [diff] [blame] | 868 | "/pi2/aos", "aos.message_bridge.Timestamp", 191))) |
| 869 | << " : " << logfiles_[11]; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 870 | } |
| 871 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 872 | LogReader reader(sorted_log_files); |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 873 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 874 | SimulatedEventLoopFactory log_reader_factory(reader.configuration()); |
Austin Schuh | 6331ef9 | 2020-01-07 18:28:09 -0800 | [diff] [blame] | 875 | log_reader_factory.set_send_delay(chrono::microseconds(0)); |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 876 | |
| 877 | // This sends out the fetched messages and advances time to the start of the |
| 878 | // log file. |
Austin Schuh | 6331ef9 | 2020-01-07 18:28:09 -0800 | [diff] [blame] | 879 | reader.Register(&log_reader_factory); |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 880 | |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 881 | const Node *pi1 = |
| 882 | configuration::GetNode(log_reader_factory.configuration(), "pi1"); |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 883 | const Node *pi2 = |
| 884 | configuration::GetNode(log_reader_factory.configuration(), "pi2"); |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 885 | |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 886 | LOG(INFO) << "Start time " << reader.monotonic_start_time(pi1) << " pi1"; |
| 887 | LOG(INFO) << "Start time " << reader.monotonic_start_time(pi2) << " pi2"; |
| 888 | LOG(INFO) << "now pi1 " |
| 889 | << log_reader_factory.GetNodeEventLoopFactory(pi1)->monotonic_now(); |
| 890 | LOG(INFO) << "now pi2 " |
| 891 | << log_reader_factory.GetNodeEventLoopFactory(pi2)->monotonic_now(); |
| 892 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 893 | EXPECT_THAT(reader.Nodes(), ::testing::ElementsAre(pi1, pi2)); |
James Kuszmaul | 84ff3e5 | 2020-01-03 19:48:53 -0800 | [diff] [blame] | 894 | |
| 895 | reader.event_loop_factory()->set_send_delay(chrono::microseconds(0)); |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 896 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 897 | std::unique_ptr<EventLoop> pi1_event_loop = |
Austin Schuh | ac0771c | 2020-01-07 18:36:30 -0800 | [diff] [blame] | 898 | log_reader_factory.MakeEventLoop("test", pi1); |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 899 | std::unique_ptr<EventLoop> pi2_event_loop = |
| 900 | log_reader_factory.MakeEventLoop("test", pi2); |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 901 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 902 | int pi1_ping_count = 10; |
| 903 | int pi2_ping_count = 10; |
| 904 | int pi1_pong_count = 10; |
| 905 | int pi2_pong_count = 10; |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 906 | |
| 907 | // Confirm that the ping value matches. |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 908 | pi1_event_loop->MakeWatcher( |
| 909 | "/test", [&pi1_ping_count, &pi1_event_loop](const examples::Ping &ping) { |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 910 | VLOG(1) << "Pi1 ping " << FlatbufferToJson(&ping) << " at " |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 911 | << pi1_event_loop->context().monotonic_remote_time << " -> " |
| 912 | << pi1_event_loop->context().monotonic_event_time; |
| 913 | EXPECT_EQ(ping.value(), pi1_ping_count + 1); |
| 914 | EXPECT_EQ(pi1_event_loop->context().monotonic_remote_time, |
| 915 | pi1_ping_count * chrono::milliseconds(10) + |
| 916 | monotonic_clock::epoch()); |
| 917 | EXPECT_EQ(pi1_event_loop->context().realtime_remote_time, |
| 918 | pi1_ping_count * chrono::milliseconds(10) + |
| 919 | realtime_clock::epoch()); |
| 920 | EXPECT_EQ(pi1_event_loop->context().monotonic_remote_time, |
| 921 | pi1_event_loop->context().monotonic_event_time); |
| 922 | EXPECT_EQ(pi1_event_loop->context().realtime_remote_time, |
| 923 | pi1_event_loop->context().realtime_event_time); |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 924 | |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 925 | ++pi1_ping_count; |
| 926 | }); |
| 927 | pi2_event_loop->MakeWatcher( |
| 928 | "/test", [&pi2_ping_count, &pi2_event_loop](const examples::Ping &ping) { |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 929 | VLOG(1) << "Pi2 ping " << FlatbufferToJson(&ping) << " at " |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 930 | << pi2_event_loop->context().monotonic_remote_time << " -> " |
| 931 | << pi2_event_loop->context().monotonic_event_time; |
| 932 | EXPECT_EQ(ping.value(), pi2_ping_count + 1); |
| 933 | |
| 934 | EXPECT_EQ(pi2_event_loop->context().monotonic_remote_time, |
| 935 | pi2_ping_count * chrono::milliseconds(10) + |
| 936 | monotonic_clock::epoch()); |
| 937 | EXPECT_EQ(pi2_event_loop->context().realtime_remote_time, |
| 938 | pi2_ping_count * chrono::milliseconds(10) + |
| 939 | realtime_clock::epoch()); |
| 940 | EXPECT_EQ(pi2_event_loop->context().monotonic_remote_time + |
| 941 | chrono::microseconds(150), |
| 942 | pi2_event_loop->context().monotonic_event_time); |
| 943 | EXPECT_EQ(pi2_event_loop->context().realtime_remote_time + |
| 944 | chrono::microseconds(150), |
| 945 | pi2_event_loop->context().realtime_event_time); |
| 946 | ++pi2_ping_count; |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 947 | }); |
| 948 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 949 | constexpr ssize_t kQueueIndexOffset = -9; |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 950 | // Confirm that the ping and pong counts both match, and the value also |
| 951 | // matches. |
| 952 | pi1_event_loop->MakeWatcher( |
| 953 | "/test", [&pi1_event_loop, &pi1_ping_count, |
| 954 | &pi1_pong_count](const examples::Pong &pong) { |
| 955 | VLOG(1) << "Pi1 pong " << FlatbufferToJson(&pong) << " at " |
| 956 | << pi1_event_loop->context().monotonic_remote_time << " -> " |
| 957 | << pi1_event_loop->context().monotonic_event_time; |
| 958 | |
| 959 | EXPECT_EQ(pi1_event_loop->context().remote_queue_index, |
| 960 | pi1_pong_count + kQueueIndexOffset); |
| 961 | EXPECT_EQ(pi1_event_loop->context().monotonic_remote_time, |
| 962 | chrono::microseconds(200) + |
| 963 | pi1_pong_count * chrono::milliseconds(10) + |
| 964 | monotonic_clock::epoch()); |
| 965 | EXPECT_EQ(pi1_event_loop->context().realtime_remote_time, |
| 966 | chrono::microseconds(200) + |
| 967 | pi1_pong_count * chrono::milliseconds(10) + |
| 968 | realtime_clock::epoch()); |
| 969 | |
| 970 | EXPECT_EQ(pi1_event_loop->context().monotonic_remote_time + |
| 971 | chrono::microseconds(150), |
| 972 | pi1_event_loop->context().monotonic_event_time); |
| 973 | EXPECT_EQ(pi1_event_loop->context().realtime_remote_time + |
| 974 | chrono::microseconds(150), |
| 975 | pi1_event_loop->context().realtime_event_time); |
| 976 | |
| 977 | EXPECT_EQ(pong.value(), pi1_pong_count + 1); |
| 978 | ++pi1_pong_count; |
| 979 | EXPECT_EQ(pi1_ping_count, pi1_pong_count); |
| 980 | }); |
| 981 | pi2_event_loop->MakeWatcher( |
| 982 | "/test", [&pi2_event_loop, &pi2_ping_count, |
| 983 | &pi2_pong_count](const examples::Pong &pong) { |
| 984 | VLOG(1) << "Pi2 pong " << FlatbufferToJson(&pong) << " at " |
| 985 | << pi2_event_loop->context().monotonic_remote_time << " -> " |
| 986 | << pi2_event_loop->context().monotonic_event_time; |
| 987 | |
| 988 | EXPECT_EQ(pi2_event_loop->context().remote_queue_index, |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 989 | pi2_pong_count + kQueueIndexOffset); |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 990 | |
| 991 | EXPECT_EQ(pi2_event_loop->context().monotonic_remote_time, |
| 992 | chrono::microseconds(200) + |
| 993 | pi2_pong_count * chrono::milliseconds(10) + |
| 994 | monotonic_clock::epoch()); |
| 995 | EXPECT_EQ(pi2_event_loop->context().realtime_remote_time, |
| 996 | chrono::microseconds(200) + |
| 997 | pi2_pong_count * chrono::milliseconds(10) + |
| 998 | realtime_clock::epoch()); |
| 999 | |
| 1000 | EXPECT_EQ(pi2_event_loop->context().monotonic_remote_time, |
| 1001 | pi2_event_loop->context().monotonic_event_time); |
| 1002 | EXPECT_EQ(pi2_event_loop->context().realtime_remote_time, |
| 1003 | pi2_event_loop->context().realtime_event_time); |
| 1004 | |
| 1005 | EXPECT_EQ(pong.value(), pi2_pong_count + 1); |
| 1006 | ++pi2_pong_count; |
| 1007 | EXPECT_EQ(pi2_ping_count, pi2_pong_count); |
| 1008 | }); |
| 1009 | |
| 1010 | log_reader_factory.Run(); |
| 1011 | EXPECT_EQ(pi1_ping_count, 2010); |
| 1012 | EXPECT_EQ(pi2_ping_count, 2010); |
| 1013 | EXPECT_EQ(pi1_pong_count, 2010); |
| 1014 | EXPECT_EQ(pi2_pong_count, 2010); |
Austin Schuh | 6331ef9 | 2020-01-07 18:28:09 -0800 | [diff] [blame] | 1015 | |
| 1016 | reader.Deregister(); |
Austin Schuh | 15649d6 | 2019-12-28 16:36:38 -0800 | [diff] [blame] | 1017 | } |
| 1018 | |
James Kuszmaul | 46d8258 | 2020-05-09 19:50:09 -0700 | [diff] [blame] | 1019 | typedef MultinodeLoggerTest MultinodeLoggerDeathTest; |
| 1020 | |
| 1021 | // Test that if we feed the replay with a mismatched node list that we die on |
| 1022 | // the LogReader constructor. |
| 1023 | TEST_F(MultinodeLoggerDeathTest, MultiNodeBadReplayConfig) { |
James Kuszmaul | 46d8258 | 2020-05-09 19:50:09 -0700 | [diff] [blame] | 1024 | { |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1025 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1026 | LoggerState pi2_logger = MakeLogger(pi2_); |
James Kuszmaul | 46d8258 | 2020-05-09 19:50:09 -0700 | [diff] [blame] | 1027 | |
| 1028 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1029 | |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1030 | StartLogger(&pi1_logger); |
| 1031 | StartLogger(&pi2_logger); |
James Kuszmaul | 46d8258 | 2020-05-09 19:50:09 -0700 | [diff] [blame] | 1032 | |
James Kuszmaul | 46d8258 | 2020-05-09 19:50:09 -0700 | [diff] [blame] | 1033 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 1034 | } |
| 1035 | |
| 1036 | // Test that, if we add an additional node to the replay config that the |
| 1037 | // logger complains about the mismatch in number of nodes. |
| 1038 | FlatbufferDetachedBuffer<Configuration> extra_nodes_config = |
| 1039 | configuration::MergeWithConfig(&config_.message(), R"({ |
| 1040 | "nodes": [ |
| 1041 | { |
| 1042 | "name": "extra-node" |
| 1043 | } |
| 1044 | ] |
| 1045 | } |
| 1046 | )"); |
| 1047 | |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 1048 | const std::vector<LogFile> sorted_parts = SortParts(logfiles_); |
| 1049 | EXPECT_DEATH(LogReader(sorted_parts, &extra_nodes_config.message()), |
James Kuszmaul | 46d8258 | 2020-05-09 19:50:09 -0700 | [diff] [blame] | 1050 | "Log file and replay config need to have matching nodes lists."); |
James Kuszmaul | 46d8258 | 2020-05-09 19:50:09 -0700 | [diff] [blame] | 1051 | } |
| 1052 | |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1053 | // Tests that we can read log files where they don't start at the same monotonic |
| 1054 | // time. |
| 1055 | TEST_F(MultinodeLoggerTest, StaggeredStart) { |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1056 | { |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1057 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1058 | LoggerState pi2_logger = MakeLogger(pi2_); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1059 | |
| 1060 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1061 | |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1062 | StartLogger(&pi1_logger); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1063 | |
| 1064 | event_loop_factory_.RunFor(chrono::milliseconds(200)); |
| 1065 | |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1066 | StartLogger(&pi2_logger); |
| 1067 | |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1068 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 1069 | } |
| 1070 | |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 1071 | LogReader reader(SortParts(logfiles_)); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1072 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1073 | SimulatedEventLoopFactory log_reader_factory(reader.configuration()); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1074 | log_reader_factory.set_send_delay(chrono::microseconds(0)); |
| 1075 | |
| 1076 | // This sends out the fetched messages and advances time to the start of the |
| 1077 | // log file. |
| 1078 | reader.Register(&log_reader_factory); |
| 1079 | |
| 1080 | const Node *pi1 = |
| 1081 | configuration::GetNode(log_reader_factory.configuration(), "pi1"); |
| 1082 | const Node *pi2 = |
| 1083 | configuration::GetNode(log_reader_factory.configuration(), "pi2"); |
| 1084 | |
| 1085 | EXPECT_THAT(reader.Nodes(), ::testing::ElementsAre(pi1, pi2)); |
| 1086 | |
| 1087 | reader.event_loop_factory()->set_send_delay(chrono::microseconds(0)); |
| 1088 | |
| 1089 | std::unique_ptr<EventLoop> pi1_event_loop = |
| 1090 | log_reader_factory.MakeEventLoop("test", pi1); |
| 1091 | std::unique_ptr<EventLoop> pi2_event_loop = |
| 1092 | log_reader_factory.MakeEventLoop("test", pi2); |
| 1093 | |
| 1094 | int pi1_ping_count = 30; |
| 1095 | int pi2_ping_count = 30; |
| 1096 | int pi1_pong_count = 30; |
| 1097 | int pi2_pong_count = 30; |
| 1098 | |
| 1099 | // Confirm that the ping value matches. |
| 1100 | pi1_event_loop->MakeWatcher( |
| 1101 | "/test", [&pi1_ping_count, &pi1_event_loop](const examples::Ping &ping) { |
| 1102 | VLOG(1) << "Pi1 ping " << FlatbufferToJson(&ping) |
| 1103 | << pi1_event_loop->context().monotonic_remote_time << " -> " |
| 1104 | << pi1_event_loop->context().monotonic_event_time; |
| 1105 | EXPECT_EQ(ping.value(), pi1_ping_count + 1); |
| 1106 | |
| 1107 | ++pi1_ping_count; |
| 1108 | }); |
| 1109 | pi2_event_loop->MakeWatcher( |
| 1110 | "/test", [&pi2_ping_count, &pi2_event_loop](const examples::Ping &ping) { |
| 1111 | VLOG(1) << "Pi2 ping " << FlatbufferToJson(&ping) |
| 1112 | << pi2_event_loop->context().monotonic_remote_time << " -> " |
| 1113 | << pi2_event_loop->context().monotonic_event_time; |
| 1114 | EXPECT_EQ(ping.value(), pi2_ping_count + 1); |
| 1115 | |
| 1116 | ++pi2_ping_count; |
| 1117 | }); |
| 1118 | |
| 1119 | // Confirm that the ping and pong counts both match, and the value also |
| 1120 | // matches. |
| 1121 | pi1_event_loop->MakeWatcher( |
| 1122 | "/test", [&pi1_event_loop, &pi1_ping_count, |
| 1123 | &pi1_pong_count](const examples::Pong &pong) { |
| 1124 | VLOG(1) << "Pi1 pong " << FlatbufferToJson(&pong) << " at " |
| 1125 | << pi1_event_loop->context().monotonic_remote_time << " -> " |
| 1126 | << pi1_event_loop->context().monotonic_event_time; |
| 1127 | |
| 1128 | EXPECT_EQ(pong.value(), pi1_pong_count + 1); |
| 1129 | ++pi1_pong_count; |
| 1130 | EXPECT_EQ(pi1_ping_count, pi1_pong_count); |
| 1131 | }); |
| 1132 | pi2_event_loop->MakeWatcher( |
| 1133 | "/test", [&pi2_event_loop, &pi2_ping_count, |
| 1134 | &pi2_pong_count](const examples::Pong &pong) { |
| 1135 | VLOG(1) << "Pi2 pong " << FlatbufferToJson(&pong) << " at " |
| 1136 | << pi2_event_loop->context().monotonic_remote_time << " -> " |
| 1137 | << pi2_event_loop->context().monotonic_event_time; |
| 1138 | |
| 1139 | EXPECT_EQ(pong.value(), pi2_pong_count + 1); |
| 1140 | ++pi2_pong_count; |
| 1141 | EXPECT_EQ(pi2_ping_count, pi2_pong_count); |
| 1142 | }); |
| 1143 | |
| 1144 | log_reader_factory.Run(); |
| 1145 | EXPECT_EQ(pi1_ping_count, 2030); |
| 1146 | EXPECT_EQ(pi2_ping_count, 2030); |
| 1147 | EXPECT_EQ(pi1_pong_count, 2030); |
| 1148 | EXPECT_EQ(pi2_pong_count, 2030); |
| 1149 | |
| 1150 | reader.Deregister(); |
| 1151 | } |
Austin Schuh | 6f3babe | 2020-01-26 20:34:50 -0800 | [diff] [blame] | 1152 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1153 | // Tests that we can read log files where the monotonic clocks drift and don't |
| 1154 | // match correctly. While we are here, also test that different ending times |
| 1155 | // also is readable. |
| 1156 | TEST_F(MultinodeLoggerTest, MismatchedClocks) { |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1157 | { |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1158 | LoggerState pi2_logger = MakeLogger(pi2_); |
| 1159 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1160 | NodeEventLoopFactory *pi2 = |
| 1161 | event_loop_factory_.GetNodeEventLoopFactory(pi2_); |
| 1162 | LOG(INFO) << "pi2 times: " << pi2->monotonic_now() << " " |
| 1163 | << pi2->realtime_now() << " distributed " |
| 1164 | << pi2->ToDistributedClock(pi2->monotonic_now()); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1165 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1166 | const chrono::nanoseconds initial_pi2_offset = -chrono::seconds(1000); |
| 1167 | chrono::nanoseconds pi2_offset = initial_pi2_offset; |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1168 | |
Austin Schuh | be69cf3 | 2020-08-27 11:38:33 -0700 | [diff] [blame] | 1169 | pi2->SetDistributedOffset(-pi2_offset, 1.0); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1170 | LOG(INFO) << "pi2 times: " << pi2->monotonic_now() << " " |
| 1171 | << pi2->realtime_now() << " distributed " |
| 1172 | << pi2->ToDistributedClock(pi2->monotonic_now()); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1173 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1174 | for (int i = 0; i < 95; ++i) { |
| 1175 | pi2_offset += chrono::nanoseconds(200); |
Austin Schuh | be69cf3 | 2020-08-27 11:38:33 -0700 | [diff] [blame] | 1176 | pi2->SetDistributedOffset(-pi2_offset, 1.0); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1177 | event_loop_factory_.RunFor(chrono::milliseconds(1)); |
| 1178 | } |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1179 | |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1180 | StartLogger(&pi2_logger); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1181 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1182 | event_loop_factory_.RunFor(chrono::milliseconds(200)); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1183 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1184 | { |
| 1185 | // Run pi1's logger for only part of the time. |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1186 | LoggerState pi1_logger = MakeLogger(pi1_); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1187 | |
James Kuszmaul | bb28ef2 | 2020-05-09 22:30:38 -0700 | [diff] [blame] | 1188 | StartLogger(&pi1_logger); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1189 | |
| 1190 | for (int i = 0; i < 20000; ++i) { |
| 1191 | pi2_offset += chrono::nanoseconds(200); |
Austin Schuh | be69cf3 | 2020-08-27 11:38:33 -0700 | [diff] [blame] | 1192 | pi2->SetDistributedOffset(-pi2_offset, 1.0); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1193 | event_loop_factory_.RunFor(chrono::milliseconds(1)); |
| 1194 | } |
| 1195 | |
| 1196 | EXPECT_GT(pi2_offset - initial_pi2_offset, |
| 1197 | event_loop_factory_.send_delay() + |
| 1198 | event_loop_factory_.network_delay()); |
| 1199 | |
| 1200 | for (int i = 0; i < 40000; ++i) { |
| 1201 | pi2_offset -= chrono::nanoseconds(200); |
Austin Schuh | be69cf3 | 2020-08-27 11:38:33 -0700 | [diff] [blame] | 1202 | pi2->SetDistributedOffset(-pi2_offset, 1.0); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1203 | event_loop_factory_.RunFor(chrono::milliseconds(1)); |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | // And log a bit more on pi2. |
| 1208 | event_loop_factory_.RunFor(chrono::milliseconds(400)); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1209 | } |
| 1210 | |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 1211 | LogReader reader(SortParts(logfiles_)); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1212 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1213 | SimulatedEventLoopFactory log_reader_factory(reader.configuration()); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1214 | log_reader_factory.set_send_delay(chrono::microseconds(0)); |
| 1215 | |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1216 | const Node *pi1 = |
| 1217 | configuration::GetNode(log_reader_factory.configuration(), "pi1"); |
| 1218 | const Node *pi2 = |
| 1219 | configuration::GetNode(log_reader_factory.configuration(), "pi2"); |
| 1220 | |
Austin Schuh | 2f8fd75 | 2020-09-01 22:38:28 -0700 | [diff] [blame] | 1221 | // This sends out the fetched messages and advances time to the start of the |
| 1222 | // log file. |
| 1223 | reader.Register(&log_reader_factory); |
| 1224 | |
| 1225 | LOG(INFO) << "Start time " << reader.monotonic_start_time(pi1) << " pi1"; |
| 1226 | LOG(INFO) << "Start time " << reader.monotonic_start_time(pi2) << " pi2"; |
| 1227 | LOG(INFO) << "now pi1 " |
| 1228 | << log_reader_factory.GetNodeEventLoopFactory(pi1)->monotonic_now(); |
| 1229 | LOG(INFO) << "now pi2 " |
| 1230 | << log_reader_factory.GetNodeEventLoopFactory(pi2)->monotonic_now(); |
| 1231 | |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1232 | LOG(INFO) << "Done registering (pi1) " |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 1233 | << log_reader_factory.GetNodeEventLoopFactory(pi1)->monotonic_now() |
| 1234 | << " " |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1235 | << log_reader_factory.GetNodeEventLoopFactory(pi1)->realtime_now(); |
| 1236 | LOG(INFO) << "Done registering (pi2) " |
Austin Schuh | 391e317 | 2020-09-01 22:48:18 -0700 | [diff] [blame] | 1237 | << log_reader_factory.GetNodeEventLoopFactory(pi2)->monotonic_now() |
| 1238 | << " " |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1239 | << log_reader_factory.GetNodeEventLoopFactory(pi2)->realtime_now(); |
| 1240 | |
| 1241 | EXPECT_THAT(reader.Nodes(), ::testing::ElementsAre(pi1, pi2)); |
| 1242 | |
| 1243 | reader.event_loop_factory()->set_send_delay(chrono::microseconds(0)); |
| 1244 | |
| 1245 | std::unique_ptr<EventLoop> pi1_event_loop = |
| 1246 | log_reader_factory.MakeEventLoop("test", pi1); |
| 1247 | std::unique_ptr<EventLoop> pi2_event_loop = |
| 1248 | log_reader_factory.MakeEventLoop("test", pi2); |
| 1249 | |
| 1250 | int pi1_ping_count = 30; |
| 1251 | int pi2_ping_count = 30; |
| 1252 | int pi1_pong_count = 30; |
| 1253 | int pi2_pong_count = 30; |
| 1254 | |
| 1255 | // Confirm that the ping value matches. |
| 1256 | pi1_event_loop->MakeWatcher( |
| 1257 | "/test", [&pi1_ping_count, &pi1_event_loop](const examples::Ping &ping) { |
| 1258 | VLOG(1) << "Pi1 ping " << FlatbufferToJson(&ping) |
| 1259 | << pi1_event_loop->context().monotonic_remote_time << " -> " |
| 1260 | << pi1_event_loop->context().monotonic_event_time; |
| 1261 | EXPECT_EQ(ping.value(), pi1_ping_count + 1); |
| 1262 | |
| 1263 | ++pi1_ping_count; |
| 1264 | }); |
| 1265 | pi2_event_loop->MakeWatcher( |
| 1266 | "/test", [&pi2_ping_count, &pi2_event_loop](const examples::Ping &ping) { |
| 1267 | VLOG(1) << "Pi2 ping " << FlatbufferToJson(&ping) |
| 1268 | << pi2_event_loop->context().monotonic_remote_time << " -> " |
| 1269 | << pi2_event_loop->context().monotonic_event_time; |
| 1270 | EXPECT_EQ(ping.value(), pi2_ping_count + 1); |
| 1271 | |
| 1272 | ++pi2_ping_count; |
| 1273 | }); |
| 1274 | |
| 1275 | // Confirm that the ping and pong counts both match, and the value also |
| 1276 | // matches. |
| 1277 | pi1_event_loop->MakeWatcher( |
| 1278 | "/test", [&pi1_event_loop, &pi1_ping_count, |
| 1279 | &pi1_pong_count](const examples::Pong &pong) { |
| 1280 | VLOG(1) << "Pi1 pong " << FlatbufferToJson(&pong) << " at " |
| 1281 | << pi1_event_loop->context().monotonic_remote_time << " -> " |
| 1282 | << pi1_event_loop->context().monotonic_event_time; |
| 1283 | |
| 1284 | EXPECT_EQ(pong.value(), pi1_pong_count + 1); |
| 1285 | ++pi1_pong_count; |
| 1286 | EXPECT_EQ(pi1_ping_count, pi1_pong_count); |
| 1287 | }); |
| 1288 | pi2_event_loop->MakeWatcher( |
| 1289 | "/test", [&pi2_event_loop, &pi2_ping_count, |
| 1290 | &pi2_pong_count](const examples::Pong &pong) { |
| 1291 | VLOG(1) << "Pi2 pong " << FlatbufferToJson(&pong) << " at " |
| 1292 | << pi2_event_loop->context().monotonic_remote_time << " -> " |
| 1293 | << pi2_event_loop->context().monotonic_event_time; |
| 1294 | |
| 1295 | EXPECT_EQ(pong.value(), pi2_pong_count + 1); |
| 1296 | ++pi2_pong_count; |
| 1297 | EXPECT_EQ(pi2_ping_count, pi2_pong_count); |
| 1298 | }); |
| 1299 | |
| 1300 | log_reader_factory.Run(); |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1301 | EXPECT_EQ(pi1_ping_count, 6030); |
| 1302 | EXPECT_EQ(pi2_ping_count, 6030); |
| 1303 | EXPECT_EQ(pi1_pong_count, 6030); |
| 1304 | EXPECT_EQ(pi2_pong_count, 6030); |
Austin Schuh | cde938c | 2020-02-02 17:30:07 -0800 | [diff] [blame] | 1305 | |
| 1306 | reader.Deregister(); |
| 1307 | } |
| 1308 | |
Austin Schuh | 5212cad | 2020-09-09 23:12:09 -0700 | [diff] [blame] | 1309 | // Tests that we can sort a bunch of parts into the pre-determined sorted parts. |
| 1310 | TEST_F(MultinodeLoggerTest, SortParts) { |
| 1311 | // Make a bunch of parts. |
| 1312 | { |
| 1313 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1314 | LoggerState pi2_logger = MakeLogger(pi2_); |
| 1315 | |
| 1316 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1317 | |
| 1318 | StartLogger(&pi1_logger); |
| 1319 | StartLogger(&pi2_logger); |
| 1320 | |
| 1321 | event_loop_factory_.RunFor(chrono::milliseconds(2000)); |
| 1322 | } |
| 1323 | |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 1324 | const std::vector<LogFile> sorted_parts = SortParts(logfiles_); |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1325 | VerifyParts(sorted_parts); |
| 1326 | } |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 1327 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1328 | // Tests that we can sort a bunch of parts with an empty part. We should ignore |
| 1329 | // it and remove it from the sorted list. |
| 1330 | TEST_F(MultinodeLoggerTest, SortEmptyParts) { |
| 1331 | // Make a bunch of parts. |
| 1332 | { |
| 1333 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1334 | LoggerState pi2_logger = MakeLogger(pi2_); |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 1335 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1336 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 1337 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1338 | StartLogger(&pi1_logger); |
| 1339 | StartLogger(&pi2_logger); |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 1340 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1341 | event_loop_factory_.RunFor(chrono::milliseconds(2000)); |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 1342 | } |
| 1343 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1344 | // TODO(austin): Should we flip out if the file can't open? |
| 1345 | const std::string kEmptyFile("foobarinvalidfiledoesnotexist.bfbs"); |
Austin Schuh | 11d4373 | 2020-09-21 17:28:30 -0700 | [diff] [blame] | 1346 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1347 | aos::util::WriteStringToFileOrDie(kEmptyFile, ""); |
| 1348 | logfiles_.emplace_back(kEmptyFile); |
Austin Schuh | 5212cad | 2020-09-09 23:12:09 -0700 | [diff] [blame] | 1349 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1350 | const std::vector<LogFile> sorted_parts = SortParts(logfiles_); |
| 1351 | VerifyParts(sorted_parts, {kEmptyFile}); |
Austin Schuh | 5212cad | 2020-09-09 23:12:09 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
Austin Schuh | 3bd4c40 | 2020-11-06 18:19:06 -0800 | [diff] [blame] | 1354 | #ifdef LZMA |
| 1355 | // Tests that we can sort a bunch of parts with an empty .xz file in there. The |
| 1356 | // empty file should be ignored. |
| 1357 | TEST_F(MultinodeLoggerTest, SortEmptyCompressedParts) { |
| 1358 | // Make a bunch of parts. |
| 1359 | { |
| 1360 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1361 | LoggerState pi2_logger = MakeLogger(pi2_); |
| 1362 | |
| 1363 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1364 | |
| 1365 | StartLogger(&pi1_logger, "", true); |
| 1366 | StartLogger(&pi2_logger, "", true); |
| 1367 | |
| 1368 | event_loop_factory_.RunFor(chrono::milliseconds(2000)); |
| 1369 | } |
| 1370 | |
| 1371 | // TODO(austin): Should we flip out if the file can't open? |
| 1372 | const std::string kEmptyFile("foobarinvalidfiledoesnotexist.bfbs.xz"); |
| 1373 | |
| 1374 | AddExtension(".xz"); |
| 1375 | |
| 1376 | aos::util::WriteStringToFileOrDie(kEmptyFile, ""); |
| 1377 | logfiles_.emplace_back(kEmptyFile); |
| 1378 | |
| 1379 | const std::vector<LogFile> sorted_parts = SortParts(logfiles_); |
| 1380 | VerifyParts(sorted_parts, {kEmptyFile}); |
| 1381 | } |
| 1382 | |
| 1383 | // Tests that we can sort a bunch of parts with the end missing off a compressed |
| 1384 | // file. We should use the part we can read. |
| 1385 | TEST_F(MultinodeLoggerTest, SortTruncatedCompressedParts) { |
| 1386 | // Make a bunch of parts. |
| 1387 | { |
| 1388 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1389 | LoggerState pi2_logger = MakeLogger(pi2_); |
| 1390 | |
| 1391 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1392 | |
| 1393 | StartLogger(&pi1_logger, "", true); |
| 1394 | StartLogger(&pi2_logger, "", true); |
| 1395 | |
| 1396 | event_loop_factory_.RunFor(chrono::milliseconds(2000)); |
| 1397 | } |
| 1398 | |
| 1399 | // Append everything with .xz. |
| 1400 | AddExtension(".xz"); |
| 1401 | |
| 1402 | // Strip off the end of one of the files. Pick one with a lot of data. |
| 1403 | ::std::string compressed_contents = |
| 1404 | aos::util::ReadFileToStringOrDie(logfiles_[0]); |
| 1405 | |
| 1406 | aos::util::WriteStringToFileOrDie( |
| 1407 | logfiles_[0], |
| 1408 | compressed_contents.substr(0, compressed_contents.size() - 100)); |
| 1409 | |
| 1410 | const std::vector<LogFile> sorted_parts = SortParts(logfiles_); |
| 1411 | VerifyParts(sorted_parts); |
| 1412 | } |
| 1413 | #endif |
| 1414 | |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 1415 | // Tests that if we remap a remapped channel, it shows up correctly. |
| 1416 | TEST_F(MultinodeLoggerTest, RemapLoggedChannel) { |
| 1417 | { |
| 1418 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1419 | LoggerState pi2_logger = MakeLogger(pi2_); |
| 1420 | |
| 1421 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1422 | |
| 1423 | StartLogger(&pi1_logger); |
| 1424 | StartLogger(&pi2_logger); |
| 1425 | |
| 1426 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 1427 | } |
| 1428 | |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 1429 | LogReader reader(SortParts(logfiles_)); |
Austin Schuh | 01b4c35 | 2020-09-21 23:09:39 -0700 | [diff] [blame] | 1430 | |
| 1431 | // Remap just on pi1. |
| 1432 | reader.RemapLoggedChannel<aos::timing::Report>( |
| 1433 | "/aos", configuration::GetNode(reader.configuration(), "pi1")); |
| 1434 | |
| 1435 | SimulatedEventLoopFactory log_reader_factory(reader.configuration()); |
| 1436 | log_reader_factory.set_send_delay(chrono::microseconds(0)); |
| 1437 | |
| 1438 | reader.Register(&log_reader_factory); |
| 1439 | |
| 1440 | const Node *pi1 = |
| 1441 | configuration::GetNode(log_reader_factory.configuration(), "pi1"); |
| 1442 | const Node *pi2 = |
| 1443 | configuration::GetNode(log_reader_factory.configuration(), "pi2"); |
| 1444 | |
| 1445 | // Confirm we can read the data on the remapped channel, just for pi1. Nothing |
| 1446 | // else should have moved. |
| 1447 | std::unique_ptr<EventLoop> pi1_event_loop = |
| 1448 | log_reader_factory.MakeEventLoop("test", pi1); |
| 1449 | pi1_event_loop->SkipTimingReport(); |
| 1450 | std::unique_ptr<EventLoop> full_pi1_event_loop = |
| 1451 | log_reader_factory.MakeEventLoop("test", pi1); |
| 1452 | full_pi1_event_loop->SkipTimingReport(); |
| 1453 | std::unique_ptr<EventLoop> pi2_event_loop = |
| 1454 | log_reader_factory.MakeEventLoop("test", pi2); |
| 1455 | pi2_event_loop->SkipTimingReport(); |
| 1456 | |
| 1457 | MessageCounter<aos::timing::Report> pi1_timing_report(pi1_event_loop.get(), |
| 1458 | "/aos"); |
| 1459 | MessageCounter<aos::timing::Report> full_pi1_timing_report( |
| 1460 | full_pi1_event_loop.get(), "/pi1/aos"); |
| 1461 | MessageCounter<aos::timing::Report> pi1_original_timing_report( |
| 1462 | pi1_event_loop.get(), "/original/aos"); |
| 1463 | MessageCounter<aos::timing::Report> full_pi1_original_timing_report( |
| 1464 | full_pi1_event_loop.get(), "/original/pi1/aos"); |
| 1465 | MessageCounter<aos::timing::Report> pi2_timing_report(pi2_event_loop.get(), |
| 1466 | "/aos"); |
| 1467 | |
| 1468 | log_reader_factory.Run(); |
| 1469 | |
| 1470 | EXPECT_EQ(pi1_timing_report.count(), 0u); |
| 1471 | EXPECT_EQ(full_pi1_timing_report.count(), 0u); |
| 1472 | EXPECT_NE(pi1_original_timing_report.count(), 0u); |
| 1473 | EXPECT_NE(full_pi1_original_timing_report.count(), 0u); |
| 1474 | EXPECT_NE(pi2_timing_report.count(), 0u); |
| 1475 | |
| 1476 | reader.Deregister(); |
| 1477 | } |
| 1478 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1479 | // Tests that we properly recreate forwarded timestamps when replaying a log. |
| 1480 | // This should be enough that we can then re-run the logger and get a valid log |
| 1481 | // back. |
| 1482 | TEST_F(MultinodeLoggerTest, MessageHeader) { |
| 1483 | { |
| 1484 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1485 | LoggerState pi2_logger = MakeLogger(pi2_); |
| 1486 | |
| 1487 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1488 | |
| 1489 | StartLogger(&pi1_logger); |
| 1490 | StartLogger(&pi2_logger); |
| 1491 | |
| 1492 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 1493 | } |
| 1494 | |
Austin Schuh | 287d43d | 2020-12-04 20:19:33 -0800 | [diff] [blame] | 1495 | LogReader reader(SortParts(logfiles_)); |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1496 | |
| 1497 | SimulatedEventLoopFactory log_reader_factory(reader.configuration()); |
| 1498 | log_reader_factory.set_send_delay(chrono::microseconds(0)); |
| 1499 | |
| 1500 | // This sends out the fetched messages and advances time to the start of the |
| 1501 | // log file. |
| 1502 | reader.Register(&log_reader_factory); |
| 1503 | |
| 1504 | const Node *pi1 = |
| 1505 | configuration::GetNode(log_reader_factory.configuration(), "pi1"); |
| 1506 | const Node *pi2 = |
| 1507 | configuration::GetNode(log_reader_factory.configuration(), "pi2"); |
| 1508 | |
| 1509 | LOG(INFO) << "Start time " << reader.monotonic_start_time(pi1) << " pi1"; |
| 1510 | LOG(INFO) << "Start time " << reader.monotonic_start_time(pi2) << " pi2"; |
| 1511 | LOG(INFO) << "now pi1 " |
| 1512 | << log_reader_factory.GetNodeEventLoopFactory(pi1)->monotonic_now(); |
| 1513 | LOG(INFO) << "now pi2 " |
| 1514 | << log_reader_factory.GetNodeEventLoopFactory(pi2)->monotonic_now(); |
| 1515 | |
| 1516 | EXPECT_THAT(reader.Nodes(), ::testing::ElementsAre(pi1, pi2)); |
| 1517 | |
| 1518 | reader.event_loop_factory()->set_send_delay(chrono::microseconds(0)); |
| 1519 | |
| 1520 | std::unique_ptr<EventLoop> pi1_event_loop = |
| 1521 | log_reader_factory.MakeEventLoop("test", pi1); |
| 1522 | std::unique_ptr<EventLoop> pi2_event_loop = |
| 1523 | log_reader_factory.MakeEventLoop("test", pi2); |
| 1524 | |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 1525 | MessageCounter<RemoteMessage> pi1_original_message_header_counter( |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1526 | pi1_event_loop.get(), "/original/aos/remote_timestamps/pi2"); |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 1527 | MessageCounter<RemoteMessage> pi2_original_message_header_counter( |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1528 | pi2_event_loop.get(), "/original/aos/remote_timestamps/pi1"); |
| 1529 | |
| 1530 | aos::Fetcher<message_bridge::Timestamp> pi1_timestamp_on_pi1_fetcher = |
| 1531 | pi1_event_loop->MakeFetcher<message_bridge::Timestamp>("/pi1/aos"); |
| 1532 | aos::Fetcher<message_bridge::Timestamp> pi1_timestamp_on_pi2_fetcher = |
| 1533 | pi2_event_loop->MakeFetcher<message_bridge::Timestamp>("/pi1/aos"); |
| 1534 | |
| 1535 | aos::Fetcher<examples::Ping> ping_on_pi1_fetcher = |
| 1536 | pi1_event_loop->MakeFetcher<examples::Ping>("/test"); |
| 1537 | aos::Fetcher<examples::Ping> ping_on_pi2_fetcher = |
| 1538 | pi2_event_loop->MakeFetcher<examples::Ping>("/test"); |
| 1539 | |
| 1540 | aos::Fetcher<message_bridge::Timestamp> pi2_timestamp_on_pi2_fetcher = |
| 1541 | pi2_event_loop->MakeFetcher<message_bridge::Timestamp>("/pi2/aos"); |
| 1542 | aos::Fetcher<message_bridge::Timestamp> pi2_timestamp_on_pi1_fetcher = |
| 1543 | pi1_event_loop->MakeFetcher<message_bridge::Timestamp>("/pi2/aos"); |
| 1544 | |
| 1545 | aos::Fetcher<examples::Pong> pong_on_pi2_fetcher = |
| 1546 | pi2_event_loop->MakeFetcher<examples::Pong>("/test"); |
| 1547 | aos::Fetcher<examples::Pong> pong_on_pi1_fetcher = |
| 1548 | pi1_event_loop->MakeFetcher<examples::Pong>("/test"); |
| 1549 | |
| 1550 | const size_t pi1_timestamp_channel = configuration::ChannelIndex( |
| 1551 | pi1_event_loop->configuration(), pi1_timestamp_on_pi1_fetcher.channel()); |
| 1552 | const size_t ping_timestamp_channel = configuration::ChannelIndex( |
| 1553 | pi2_event_loop->configuration(), ping_on_pi2_fetcher.channel()); |
| 1554 | |
| 1555 | const size_t pi2_timestamp_channel = configuration::ChannelIndex( |
| 1556 | pi2_event_loop->configuration(), pi2_timestamp_on_pi2_fetcher.channel()); |
| 1557 | const size_t pong_timestamp_channel = configuration::ChannelIndex( |
| 1558 | pi1_event_loop->configuration(), pong_on_pi1_fetcher.channel()); |
| 1559 | |
| 1560 | pi1_event_loop->MakeWatcher( |
| 1561 | "/aos/remote_timestamps/pi2", |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 1562 | [&pi1_event_loop, &pi2_event_loop, pi1_timestamp_channel, |
| 1563 | ping_timestamp_channel, &pi1_timestamp_on_pi1_fetcher, |
| 1564 | &pi1_timestamp_on_pi2_fetcher, &ping_on_pi1_fetcher, |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 1565 | &ping_on_pi2_fetcher](const RemoteMessage &header) { |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1566 | const aos::monotonic_clock::time_point header_monotonic_sent_time( |
| 1567 | chrono::nanoseconds(header.monotonic_sent_time())); |
| 1568 | const aos::realtime_clock::time_point header_realtime_sent_time( |
| 1569 | chrono::nanoseconds(header.realtime_sent_time())); |
| 1570 | const aos::monotonic_clock::time_point header_monotonic_remote_time( |
| 1571 | chrono::nanoseconds(header.monotonic_remote_time())); |
| 1572 | const aos::realtime_clock::time_point header_realtime_remote_time( |
| 1573 | chrono::nanoseconds(header.realtime_remote_time())); |
| 1574 | |
| 1575 | const Context *pi1_context = nullptr; |
| 1576 | const Context *pi2_context = nullptr; |
| 1577 | |
| 1578 | if (header.channel_index() == pi1_timestamp_channel) { |
| 1579 | ASSERT_TRUE(pi1_timestamp_on_pi1_fetcher.FetchNext()); |
| 1580 | ASSERT_TRUE(pi1_timestamp_on_pi2_fetcher.FetchNext()); |
| 1581 | pi1_context = &pi1_timestamp_on_pi1_fetcher.context(); |
| 1582 | pi2_context = &pi1_timestamp_on_pi2_fetcher.context(); |
| 1583 | } else if (header.channel_index() == ping_timestamp_channel) { |
| 1584 | ASSERT_TRUE(ping_on_pi1_fetcher.FetchNext()); |
| 1585 | ASSERT_TRUE(ping_on_pi2_fetcher.FetchNext()); |
| 1586 | pi1_context = &ping_on_pi1_fetcher.context(); |
| 1587 | pi2_context = &ping_on_pi2_fetcher.context(); |
| 1588 | } else { |
| 1589 | LOG(FATAL) << "Unknown channel " << FlatbufferToJson(&header) << " " |
| 1590 | << configuration::CleanedChannelToString( |
| 1591 | pi1_event_loop->configuration()->channels()->Get( |
| 1592 | header.channel_index())); |
| 1593 | } |
| 1594 | |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 1595 | ASSERT_TRUE(header.has_boot_uuid()); |
| 1596 | EXPECT_EQ(header.boot_uuid()->string_view(), |
| 1597 | pi2_event_loop->boot_uuid().string_view()); |
| 1598 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1599 | EXPECT_EQ(pi1_context->queue_index, header.remote_queue_index()); |
| 1600 | EXPECT_EQ(pi2_context->remote_queue_index, header.remote_queue_index()); |
| 1601 | EXPECT_EQ(pi2_context->queue_index, header.queue_index()); |
| 1602 | |
| 1603 | EXPECT_EQ(pi2_context->monotonic_event_time, |
| 1604 | header_monotonic_sent_time); |
| 1605 | EXPECT_EQ(pi2_context->realtime_event_time, header_realtime_sent_time); |
| 1606 | EXPECT_EQ(pi2_context->realtime_remote_time, |
| 1607 | header_realtime_remote_time); |
| 1608 | EXPECT_EQ(pi2_context->monotonic_remote_time, |
| 1609 | header_monotonic_remote_time); |
| 1610 | |
| 1611 | EXPECT_EQ(pi1_context->realtime_event_time, |
| 1612 | header_realtime_remote_time); |
| 1613 | EXPECT_EQ(pi1_context->monotonic_event_time, |
| 1614 | header_monotonic_remote_time); |
| 1615 | }); |
| 1616 | pi2_event_loop->MakeWatcher( |
| 1617 | "/aos/remote_timestamps/pi1", |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 1618 | [&pi2_event_loop, &pi1_event_loop, pi2_timestamp_channel, |
| 1619 | pong_timestamp_channel, &pi2_timestamp_on_pi2_fetcher, |
| 1620 | &pi2_timestamp_on_pi1_fetcher, &pong_on_pi2_fetcher, |
Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame] | 1621 | &pong_on_pi1_fetcher](const RemoteMessage &header) { |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1622 | const aos::monotonic_clock::time_point header_monotonic_sent_time( |
| 1623 | chrono::nanoseconds(header.monotonic_sent_time())); |
| 1624 | const aos::realtime_clock::time_point header_realtime_sent_time( |
| 1625 | chrono::nanoseconds(header.realtime_sent_time())); |
| 1626 | const aos::monotonic_clock::time_point header_monotonic_remote_time( |
| 1627 | chrono::nanoseconds(header.monotonic_remote_time())); |
| 1628 | const aos::realtime_clock::time_point header_realtime_remote_time( |
| 1629 | chrono::nanoseconds(header.realtime_remote_time())); |
| 1630 | |
| 1631 | const Context *pi2_context = nullptr; |
| 1632 | const Context *pi1_context = nullptr; |
| 1633 | |
| 1634 | if (header.channel_index() == pi2_timestamp_channel) { |
| 1635 | ASSERT_TRUE(pi2_timestamp_on_pi2_fetcher.FetchNext()); |
| 1636 | ASSERT_TRUE(pi2_timestamp_on_pi1_fetcher.FetchNext()); |
| 1637 | pi2_context = &pi2_timestamp_on_pi2_fetcher.context(); |
| 1638 | pi1_context = &pi2_timestamp_on_pi1_fetcher.context(); |
| 1639 | } else if (header.channel_index() == pong_timestamp_channel) { |
| 1640 | ASSERT_TRUE(pong_on_pi2_fetcher.FetchNext()); |
| 1641 | ASSERT_TRUE(pong_on_pi1_fetcher.FetchNext()); |
| 1642 | pi2_context = &pong_on_pi2_fetcher.context(); |
| 1643 | pi1_context = &pong_on_pi1_fetcher.context(); |
| 1644 | } else { |
| 1645 | LOG(FATAL) << "Unknown channel " << FlatbufferToJson(&header) << " " |
| 1646 | << configuration::CleanedChannelToString( |
| 1647 | pi2_event_loop->configuration()->channels()->Get( |
| 1648 | header.channel_index())); |
| 1649 | } |
| 1650 | |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 1651 | ASSERT_TRUE(header.has_boot_uuid()); |
| 1652 | EXPECT_EQ(header.boot_uuid()->string_view(), |
| 1653 | pi1_event_loop->boot_uuid().string_view()); |
| 1654 | |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1655 | EXPECT_EQ(pi2_context->queue_index, header.remote_queue_index()); |
| 1656 | EXPECT_EQ(pi1_context->remote_queue_index, header.remote_queue_index()); |
| 1657 | EXPECT_EQ(pi1_context->queue_index, header.queue_index()); |
| 1658 | |
| 1659 | EXPECT_EQ(pi1_context->monotonic_event_time, |
| 1660 | header_monotonic_sent_time); |
| 1661 | EXPECT_EQ(pi1_context->realtime_event_time, header_realtime_sent_time); |
| 1662 | EXPECT_EQ(pi1_context->realtime_remote_time, |
| 1663 | header_realtime_remote_time); |
| 1664 | EXPECT_EQ(pi1_context->monotonic_remote_time, |
| 1665 | header_monotonic_remote_time); |
| 1666 | |
| 1667 | EXPECT_EQ(pi2_context->realtime_event_time, |
| 1668 | header_realtime_remote_time); |
| 1669 | EXPECT_EQ(pi2_context->monotonic_event_time, |
| 1670 | header_monotonic_remote_time); |
| 1671 | }); |
| 1672 | |
| 1673 | // And confirm we can re-create a log again, while checking the contents. |
| 1674 | { |
| 1675 | LoggerState pi1_logger = MakeLogger( |
| 1676 | configuration::GetNode(log_reader_factory.configuration(), pi1_), |
| 1677 | &log_reader_factory); |
| 1678 | LoggerState pi2_logger = MakeLogger( |
| 1679 | configuration::GetNode(log_reader_factory.configuration(), pi2_), |
| 1680 | &log_reader_factory); |
| 1681 | |
Austin Schuh | 8c39996 | 2020-12-25 21:51:45 -0800 | [diff] [blame^] | 1682 | StartLogger(&pi1_logger, "relogged1"); |
| 1683 | StartLogger(&pi2_logger, "relogged2"); |
Austin Schuh | 8d7e0bb | 2020-10-02 17:57:00 -0700 | [diff] [blame] | 1684 | |
| 1685 | log_reader_factory.Run(); |
| 1686 | } |
| 1687 | |
| 1688 | EXPECT_EQ(pi2_original_message_header_counter.count(), 0u); |
| 1689 | EXPECT_EQ(pi1_original_message_header_counter.count(), 0u); |
| 1690 | |
| 1691 | reader.Deregister(); |
| 1692 | } |
| 1693 | |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 1694 | // Tests that we properly populate and extract the logger_start time by setting |
| 1695 | // up a clock difference between 2 nodes and looking at the resulting parts. |
| 1696 | TEST_F(MultinodeLoggerTest, LoggerStartTime) { |
| 1697 | { |
| 1698 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1699 | LoggerState pi2_logger = MakeLogger(pi2_); |
| 1700 | |
| 1701 | NodeEventLoopFactory *pi2 = |
| 1702 | event_loop_factory_.GetNodeEventLoopFactory(pi2_); |
| 1703 | |
| 1704 | pi2->SetDistributedOffset(chrono::seconds(1000), 1.0); |
| 1705 | |
| 1706 | StartLogger(&pi1_logger); |
| 1707 | StartLogger(&pi2_logger); |
| 1708 | |
| 1709 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 1710 | } |
| 1711 | |
| 1712 | for (const LogFile &log_file : SortParts(logfiles_)) { |
| 1713 | for (const LogParts &log_part : log_file.parts) { |
| 1714 | if (log_part.node == log_file.logger_node) { |
| 1715 | EXPECT_EQ(log_part.logger_monotonic_start_time, |
| 1716 | aos::monotonic_clock::min_time); |
| 1717 | EXPECT_EQ(log_part.logger_realtime_start_time, |
| 1718 | aos::realtime_clock::min_time); |
| 1719 | } else { |
| 1720 | const chrono::seconds offset = log_file.logger_node == "pi1" |
| 1721 | ? -chrono::seconds(1000) |
| 1722 | : chrono::seconds(1000); |
| 1723 | EXPECT_EQ(log_part.logger_monotonic_start_time, |
| 1724 | log_part.monotonic_start_time + offset); |
| 1725 | EXPECT_EQ(log_part.logger_realtime_start_time, |
| 1726 | log_file.realtime_start_time + |
| 1727 | (log_part.logger_monotonic_start_time - |
| 1728 | log_file.monotonic_start_time)); |
| 1729 | } |
| 1730 | } |
| 1731 | } |
| 1732 | } |
| 1733 | |
Austin Schuh | 8bd9632 | 2020-02-13 21:18:22 -0800 | [diff] [blame] | 1734 | // TODO(austin): We can write a test which recreates a logfile and confirms that |
| 1735 | // we get it back. That is the ultimate test. |
| 1736 | |
Austin Schuh | 315b96b | 2020-12-11 21:21:12 -0800 | [diff] [blame] | 1737 | // Tests that we properly recreate forwarded timestamps when replaying a log. |
| 1738 | // This should be enough that we can then re-run the logger and get a valid log |
| 1739 | // back. |
| 1740 | TEST_F(MultinodeLoggerDeathTest, RemoteReboot) { |
| 1741 | std::string pi2_boot1; |
| 1742 | std::string pi2_boot2; |
| 1743 | { |
| 1744 | pi2_boot1 = event_loop_factory_.GetNodeEventLoopFactory(pi2_) |
| 1745 | ->boot_uuid() |
| 1746 | .string_view(); |
| 1747 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1748 | |
| 1749 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1750 | |
| 1751 | StartLogger(&pi1_logger); |
| 1752 | |
| 1753 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 1754 | |
| 1755 | event_loop_factory_.GetNodeEventLoopFactory(pi2_)->Reboot(); |
| 1756 | |
| 1757 | pi2_boot2 = event_loop_factory_.GetNodeEventLoopFactory(pi2_) |
| 1758 | ->boot_uuid() |
| 1759 | .string_view(); |
| 1760 | |
| 1761 | event_loop_factory_.RunFor(chrono::milliseconds(20000)); |
| 1762 | } |
| 1763 | |
| 1764 | // Confirm that we refuse to replay logs with missing boot uuids. |
| 1765 | EXPECT_DEATH( |
| 1766 | { |
| 1767 | LogReader reader(SortParts(pi1_reboot_logfiles_)); |
| 1768 | |
| 1769 | SimulatedEventLoopFactory log_reader_factory(reader.configuration()); |
| 1770 | log_reader_factory.set_send_delay(chrono::microseconds(0)); |
| 1771 | |
| 1772 | // This sends out the fetched messages and advances time to the start of |
| 1773 | // the log file. |
| 1774 | reader.Register(&log_reader_factory); |
| 1775 | }, |
| 1776 | absl::StrFormat("(%s|%s).*(%s|%s).*Found parts from different boots", |
| 1777 | pi2_boot1, pi2_boot2, pi2_boot2, pi2_boot1)); |
| 1778 | } |
| 1779 | |
Austin Schuh | c904973 | 2020-12-21 22:27:15 -0800 | [diff] [blame] | 1780 | // Tests that we properly handle one direction of message_bridge being |
| 1781 | // unavailable. |
| 1782 | TEST_F(MultinodeLoggerTest, OneDirectionWithNegativeSlope) { |
| 1783 | event_loop_factory_.GetNodeEventLoopFactory(pi1_)->Disconnect(pi2_); |
| 1784 | event_loop_factory_.GetNodeEventLoopFactory(pi2_)->SetDistributedOffset( |
| 1785 | chrono::seconds(1000), 0.99999); |
| 1786 | { |
| 1787 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1788 | |
| 1789 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1790 | |
| 1791 | StartLogger(&pi1_logger); |
| 1792 | |
| 1793 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 1794 | } |
| 1795 | |
| 1796 | // Confirm that we can parse the result. LogReader has enough internal CHECKs |
| 1797 | // to confirm the right thing happened. |
| 1798 | ConfirmReadable(pi1_single_direction_logfiles_); |
| 1799 | } |
| 1800 | |
| 1801 | // Tests that we properly handle one direction of message_bridge being |
| 1802 | // unavailable. |
| 1803 | TEST_F(MultinodeLoggerTest, OneDirectionWithPositiveSlope) { |
| 1804 | event_loop_factory_.GetNodeEventLoopFactory(pi1_)->Disconnect(pi2_); |
| 1805 | event_loop_factory_.GetNodeEventLoopFactory(pi2_)->SetDistributedOffset( |
| 1806 | chrono::seconds(500), 1.00001); |
| 1807 | { |
| 1808 | LoggerState pi1_logger = MakeLogger(pi1_); |
| 1809 | |
| 1810 | event_loop_factory_.RunFor(chrono::milliseconds(95)); |
| 1811 | |
| 1812 | StartLogger(&pi1_logger); |
| 1813 | |
| 1814 | event_loop_factory_.RunFor(chrono::milliseconds(10000)); |
| 1815 | } |
| 1816 | |
| 1817 | // Confirm that we can parse the result. LogReader has enough internal CHECKs |
| 1818 | // to confirm the right thing happened. |
| 1819 | ConfirmReadable(pi1_single_direction_logfiles_); |
| 1820 | } |
| 1821 | |
Austin Schuh | e309d2a | 2019-11-29 13:25:21 -0800 | [diff] [blame] | 1822 | } // namespace testing |
| 1823 | } // namespace logger |
| 1824 | } // namespace aos |