Stephan Pleines | bad7007 | 2024-05-22 16:48:01 -0700 | [diff] [blame^] | 1 | #include <stdint.h> |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 2 | |
milind | 1f1dca3 | 2021-07-03 13:50:07 -0700 | [diff] [blame] | 3 | #include <chrono> |
Stephan Pleines | bad7007 | 2024-05-22 16:48:01 -0700 | [diff] [blame^] | 4 | #include <functional> |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 5 | #include <memory> |
Stephan Pleines | bad7007 | 2024-05-22 16:48:01 -0700 | [diff] [blame^] | 6 | #include <ostream> |
| 7 | #include <string> |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 8 | |
Stephan Pleines | bad7007 | 2024-05-22 16:48:01 -0700 | [diff] [blame^] | 9 | #include "flatbuffers/buffer.h" |
| 10 | #include "glog/logging.h" |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 11 | #include "gtest/gtest.h" |
| 12 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 13 | #include "aos/actions/actions.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 14 | #include "aos/actions/actions_generated.h" |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 15 | #include "aos/actions/actor.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 16 | #include "aos/actions/test_action_generated.h" |
Stephan Pleines | bad7007 | 2024-05-22 16:48:01 -0700 | [diff] [blame^] | 17 | #include "aos/configuration.h" |
| 18 | #include "aos/events/event_loop.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 19 | #include "aos/events/simulated_event_loop.h" |
Stephan Pleines | bad7007 | 2024-05-22 16:48:01 -0700 | [diff] [blame^] | 20 | #include "aos/flatbuffers.h" |
| 21 | #include "aos/json_to_flatbuffer.h" |
| 22 | #include "aos/logging/implementations.h" |
Austin Schuh | 373f176 | 2021-06-02 21:07:09 -0700 | [diff] [blame] | 23 | #include "aos/testing/path.h" |
Stephan Pleines | bad7007 | 2024-05-22 16:48:01 -0700 | [diff] [blame^] | 24 | #include "aos/time/time.h" |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 25 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 26 | namespace aos::common::actions::testing { |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 27 | |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 28 | namespace chrono = ::std::chrono; |
| 29 | |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 30 | class TestActorIndex |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 31 | : public aos::common::actions::ActorBase<actions::TestActionGoal> { |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 32 | public: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 33 | typedef TypedActionFactory<actions::TestActionGoal> Factory; |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 34 | |
| 35 | explicit TestActorIndex(::aos::EventLoop *event_loop) |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 36 | : aos::common::actions::ActorBase<actions::TestActionGoal>( |
| 37 | event_loop, "/test_action") {} |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 38 | |
| 39 | static Factory MakeFactory(::aos::EventLoop *event_loop) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 40 | return Factory(event_loop, "/test_action"); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 41 | } |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 42 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 43 | bool RunAction(const UInt *new_index) override { |
| 44 | VLOG(1) << "New index " << FlatbufferToJson(new_index); |
| 45 | index = new_index->val(); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 46 | return true; |
| 47 | } |
| 48 | |
| 49 | uint32_t index = 0; |
| 50 | }; |
| 51 | |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 52 | class TestActorNOP |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 53 | : public aos::common::actions::ActorBase<actions::TestActionGoal> { |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 54 | public: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 55 | typedef TypedActionFactory<actions::TestActionGoal> Factory; |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 56 | |
| 57 | explicit TestActorNOP(::aos::EventLoop *event_loop) |
milind | 1f1dca3 | 2021-07-03 13:50:07 -0700 | [diff] [blame] | 58 | : actions::ActorBase<actions::TestActionGoal>(event_loop, |
| 59 | "/test_action") {} |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 60 | |
| 61 | static Factory MakeFactory(::aos::EventLoop *event_loop) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 62 | return Factory(event_loop, "/test_action"); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 63 | } |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 64 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 65 | bool RunAction(const UInt *) override { return true; } |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 66 | }; |
| 67 | |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 68 | class TestActorShouldCancel |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 69 | : public aos::common::actions::ActorBase<actions::TestActionGoal> { |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 70 | public: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 71 | typedef TypedActionFactory<actions::TestActionGoal> Factory; |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 72 | |
| 73 | explicit TestActorShouldCancel(::aos::EventLoop *event_loop) |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 74 | : aos::common::actions::ActorBase<actions::TestActionGoal>( |
| 75 | event_loop, "/test_action") {} |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 76 | |
| 77 | static Factory MakeFactory(::aos::EventLoop *event_loop) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 78 | return Factory(event_loop, "/test_action"); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 79 | } |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 80 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 81 | bool RunAction(const UInt *) override { |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 82 | while (!ShouldCancel()) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 83 | AOS_LOG(FATAL, "NOT CANCELED!!\n"); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 84 | } |
Daniel Petti | 3b1e48f | 2015-02-15 15:57:53 -0800 | [diff] [blame] | 85 | return true; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 86 | } |
| 87 | }; |
| 88 | |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 89 | class TestActor2Nop |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 90 | : public aos::common::actions::ActorBase<actions::TestAction2Goal> { |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 91 | public: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 92 | typedef TypedActionFactory<actions::TestAction2Goal> Factory; |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 93 | |
| 94 | explicit TestActor2Nop(::aos::EventLoop *event_loop) |
milind | 1f1dca3 | 2021-07-03 13:50:07 -0700 | [diff] [blame] | 95 | : actions::ActorBase<actions::TestAction2Goal>(event_loop, |
| 96 | "/test_action2") {} |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 97 | |
| 98 | static Factory MakeFactory(::aos::EventLoop *event_loop) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 99 | return Factory(event_loop, "/test_action2"); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 100 | } |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 101 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 102 | bool RunAction(const actions::MyParams *) { return true; } |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 103 | }; |
| 104 | |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 105 | class ActionTest : public ::testing::Test { |
| 106 | protected: |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 107 | ActionTest() |
Austin Schuh | 373f176 | 2021-06-02 21:07:09 -0700 | [diff] [blame] | 108 | : configuration_(configuration::ReadConfig( |
| 109 | aos::testing::ArtifactPath("aos/actions/action_test_config.json"))), |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 110 | event_loop_factory_(&configuration_.message()), |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 111 | actor1_event_loop_(event_loop_factory_.MakeEventLoop("actor1")), |
| 112 | actor2_event_loop_(event_loop_factory_.MakeEventLoop("actor2")), |
Brian Silverman | 13065ed | 2020-12-16 15:15:27 -0800 | [diff] [blame] | 113 | test_event_loop_(event_loop_factory_.MakeEventLoop("test")) {} |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 114 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 115 | void RunAt(monotonic_clock::time_point exec_time, std::function<void()> fn) { |
| 116 | TimerHandler *timer = test_event_loop_->AddTimer(fn); |
Philipp Schrader | a671252 | 2023-07-05 20:25:11 -0700 | [diff] [blame] | 117 | test_event_loop_->OnRun( |
| 118 | [timer, exec_time]() { timer->Schedule(exec_time); }); |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 119 | } |
| 120 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 121 | FlatbufferDetachedBuffer<Configuration> configuration_; |
| 122 | |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 123 | // Bring up and down Core. |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 124 | ::aos::SimulatedEventLoopFactory event_loop_factory_; |
| 125 | |
| 126 | ::std::unique_ptr<::aos::EventLoop> actor1_event_loop_; |
| 127 | ::std::unique_ptr<::aos::EventLoop> actor2_event_loop_; |
| 128 | ::std::unique_ptr<::aos::EventLoop> test_event_loop_; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | // Tests that the the actions exist in a safe state at startup. |
| 132 | TEST_F(ActionTest, DoesNothing) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 133 | ActionQueue action_queue; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 134 | // Tick an empty queue and make sure it was not running. |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 135 | EXPECT_FALSE(action_queue.Running()); |
| 136 | action_queue.Tick(); |
| 137 | EXPECT_FALSE(action_queue.Running()); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 140 | // Tests that starting with an old run message in the goal queue actually works. |
| 141 | // This used to result in the client hanging, waiting for a response to its |
| 142 | // cancel message. |
| 143 | TEST_F(ActionTest, StartWithOldGoal) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 144 | ::std::unique_ptr<::aos::EventLoop> test2_event_loop = |
Austin Schuh | 5f1cc5c | 2019-12-01 18:01:11 -0800 | [diff] [blame] | 145 | event_loop_factory_.MakeEventLoop("test2"); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 146 | ::aos::Sender<TestActionGoal> goal_sender = |
| 147 | test2_event_loop->MakeSender<TestActionGoal>("/test_action"); |
| 148 | ::aos::Fetcher<Status> status_fetcher = |
| 149 | test2_event_loop->MakeFetcher<Status>("/test_action"); |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 150 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 151 | TestActorIndex::Factory nop_actor_factory = |
| 152 | TestActorNOP::MakeFactory(test_event_loop_.get()); |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 153 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 154 | ActionQueue action_queue; |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 155 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 156 | { |
milind | 1f1dca3 | 2021-07-03 13:50:07 -0700 | [diff] [blame] | 157 | ::aos::Sender<TestActionGoal>::Builder builder = goal_sender.MakeBuilder(); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 158 | |
| 159 | TestActionGoal::Builder goal_builder = |
| 160 | builder.MakeBuilder<TestActionGoal>(); |
| 161 | |
| 162 | goal_builder.add_run(971); |
milind | 1f1dca3 | 2021-07-03 13:50:07 -0700 | [diff] [blame] | 163 | builder.CheckOk(builder.Send(goal_builder.Finish())); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | TestActorNOP nop_act(actor1_event_loop_.get()); |
| 167 | |
| 168 | ASSERT_FALSE(status_fetcher.Fetch()); |
| 169 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 170 | RunAt(monotonic_clock::time_point(chrono::seconds(1)), [&]() { |
| 171 | ASSERT_TRUE(status_fetcher.Fetch()); |
| 172 | EXPECT_EQ(0u, status_fetcher->running()); |
| 173 | EXPECT_EQ(0u, status_fetcher->last_running()); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 174 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 175 | { |
| 176 | UIntT uint; |
| 177 | uint.val = 0; |
| 178 | action_queue.EnqueueAction(nop_actor_factory.Make(uint)); |
| 179 | } |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 180 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 181 | // We started an action and it should be running. |
| 182 | EXPECT_TRUE(action_queue.Running()); |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 183 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 184 | action_queue.CancelAllActions(); |
| 185 | action_queue.Tick(); |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 186 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 187 | EXPECT_TRUE(action_queue.Running()); |
| 188 | }); |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 189 | |
| 190 | // Run the action so it can signal completion. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 191 | RunAt(monotonic_clock::time_point(chrono::seconds(2)), [&]() { |
| 192 | action_queue.Tick(); |
Brian Silverman | a2ae62d | 2015-03-15 15:55:22 -0700 | [diff] [blame] | 193 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 194 | // Make sure it stopped. |
| 195 | EXPECT_FALSE(action_queue.Running()); |
| 196 | }); |
| 197 | |
| 198 | event_loop_factory_.RunFor(chrono::seconds(3)); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | // Tests that an action starts and stops. |
| 202 | TEST_F(ActionTest, ActionQueueWasRunning) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 203 | TestActorNOP nop_act(actor1_event_loop_.get()); |
| 204 | |
| 205 | TestActorIndex::Factory nop_actor_factory = |
| 206 | TestActorNOP::MakeFactory(test_event_loop_.get()); |
| 207 | |
| 208 | ActionQueue action_queue; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 209 | |
| 210 | // Tick an empty queue and make sure it was not running. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 211 | RunAt(monotonic_clock::time_point(chrono::seconds(1)), [&]() { |
| 212 | action_queue.Tick(); |
| 213 | EXPECT_FALSE(action_queue.Running()); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 214 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 215 | { |
| 216 | UIntT uint; |
| 217 | uint.val = 0; |
| 218 | action_queue.EnqueueAction(nop_actor_factory.Make(uint)); |
| 219 | } |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 220 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 221 | // We started an action and it should be running. |
| 222 | EXPECT_TRUE(action_queue.Running()); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 223 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 224 | // Tick it and make sure it is still running. |
| 225 | action_queue.Tick(); |
| 226 | EXPECT_TRUE(action_queue.Running()); |
| 227 | }); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 228 | |
| 229 | // Run the action so it can signal completion. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 230 | RunAt(monotonic_clock::time_point(chrono::seconds(2)), [&]() { |
| 231 | action_queue.Tick(); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 232 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 233 | // Make sure it stopped. |
| 234 | EXPECT_FALSE(action_queue.Running()); |
| 235 | }); |
| 236 | |
| 237 | event_loop_factory_.RunFor(chrono::seconds(3)); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | // Tests that we can cancel two actions and have them both stop. |
| 241 | TEST_F(ActionTest, ActionQueueCancelAll) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 242 | TestActorNOP nop_act(actor1_event_loop_.get()); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 243 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 244 | TestActorIndex::Factory nop_actor_factory = |
| 245 | TestActorNOP::MakeFactory(test_event_loop_.get()); |
| 246 | |
| 247 | ActionQueue action_queue; |
| 248 | |
| 249 | // Let the actor and action queue start up and confirm nothing is running. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 250 | RunAt(monotonic_clock::time_point(chrono::seconds(1)), [&]() { |
| 251 | action_queue.Tick(); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 252 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 253 | EXPECT_FALSE(action_queue.Running()); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 254 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 255 | // Enqueue two actions to test both cancel. We can have an action and a next |
| 256 | // action so we want to test that. |
| 257 | { |
| 258 | UIntT uint; |
| 259 | uint.val = 0; |
| 260 | action_queue.EnqueueAction(nop_actor_factory.Make(uint)); |
| 261 | action_queue.EnqueueAction(nop_actor_factory.Make(uint)); |
| 262 | } |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 263 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 264 | action_queue.Tick(); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 265 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 266 | // Check that current and next exist. |
| 267 | EXPECT_TRUE(action_queue.GetCurrentActionState(nullptr, nullptr, nullptr, |
| 268 | nullptr, nullptr, nullptr)); |
| 269 | EXPECT_TRUE(action_queue.GetNextActionState(nullptr, nullptr, nullptr, |
| 270 | nullptr, nullptr, nullptr)); |
| 271 | |
| 272 | action_queue.CancelAllActions(); |
| 273 | action_queue.Tick(); |
| 274 | |
| 275 | // It should still be running as the actor could not have signaled. |
| 276 | EXPECT_TRUE(action_queue.Running()); |
| 277 | |
| 278 | bool sent_started, sent_cancel, interrupted; |
| 279 | EXPECT_TRUE(action_queue.GetCurrentActionState( |
| 280 | nullptr, &sent_started, &sent_cancel, &interrupted, nullptr, nullptr)); |
| 281 | EXPECT_TRUE(sent_started); |
| 282 | EXPECT_TRUE(sent_cancel); |
| 283 | EXPECT_FALSE(interrupted); |
| 284 | |
| 285 | EXPECT_FALSE(action_queue.GetNextActionState(nullptr, nullptr, nullptr, |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 286 | nullptr, nullptr, nullptr)); |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 287 | }); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 288 | |
| 289 | // Run the action so it can signal completion. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 290 | RunAt(monotonic_clock::time_point(chrono::seconds(2)), [&]() { |
| 291 | action_queue.Tick(); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 292 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 293 | // Make sure it stopped. |
| 294 | EXPECT_FALSE(action_queue.Running()); |
| 295 | EXPECT_EQ(1, nop_act.running_count()); |
| 296 | }); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 297 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 298 | event_loop_factory_.RunFor(chrono::seconds(3)); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | // Tests that an action that would block forever stops when canceled. |
| 302 | TEST_F(ActionTest, ActionQueueCancelOne) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 303 | TestActorShouldCancel cancel_act(actor1_event_loop_.get()); |
| 304 | |
| 305 | TestActorShouldCancel::Factory cancel_action_factory = |
| 306 | TestActorShouldCancel::MakeFactory(test_event_loop_.get()); |
| 307 | |
| 308 | ActionQueue action_queue; |
| 309 | |
| 310 | // Let the actor and action queue start up. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 311 | RunAt(monotonic_clock::time_point(chrono::seconds(1)), [&]() { |
| 312 | action_queue.Tick(); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 313 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 314 | // Enqueue blocking action. |
| 315 | { |
| 316 | UIntT uint; |
| 317 | uint.val = 0; |
| 318 | action_queue.EnqueueAction(cancel_action_factory.Make(uint)); |
| 319 | } |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 320 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 321 | action_queue.Tick(); |
| 322 | EXPECT_TRUE(action_queue.Running()); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 323 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 324 | // Tell action to cancel. |
| 325 | action_queue.CancelCurrentAction(); |
| 326 | action_queue.Tick(); |
| 327 | }); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 328 | |
| 329 | // This will block forever on failure. |
| 330 | // TODO(ben): prolly a bad way to fail |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 331 | RunAt(monotonic_clock::time_point(chrono::seconds(2)), [&]() { |
| 332 | action_queue.Tick(); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 333 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 334 | // It should still be running as the actor could not have signalled. |
| 335 | EXPECT_FALSE(action_queue.Running()); |
| 336 | }); |
| 337 | |
| 338 | event_loop_factory_.RunFor(chrono::seconds(3)); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 339 | } |
| 340 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 341 | // Tests that 2 actions in a row causes the second one to cancel the first one. |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 342 | TEST_F(ActionTest, ActionQueueTwoActions) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 343 | TestActorNOP nop_actor(actor1_event_loop_.get()); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 344 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 345 | TestActorIndex::Factory nop_actor_factory = |
| 346 | TestActorNOP::MakeFactory(test_event_loop_.get()); |
| 347 | |
| 348 | ActionQueue action_queue; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 349 | |
| 350 | // id for the first time run. |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 351 | uint32_t nop_actor_id = 0; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 352 | // Check the internal state and write down id for later use. |
| 353 | bool sent_started, sent_cancel, interrupted; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 354 | // id for the second run. |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 355 | uint32_t nop_actor2_id = 0; |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 356 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 357 | // Tick an empty queue and make sure it was not running. |
| 358 | RunAt(monotonic_clock::time_point(chrono::seconds(1)), [&]() { |
| 359 | action_queue.Tick(); |
| 360 | EXPECT_FALSE(action_queue.Running()); |
| 361 | |
| 362 | // Enqueue action to be canceled. |
| 363 | { |
| 364 | UIntT uint; |
| 365 | uint.val = 0; |
| 366 | action_queue.EnqueueAction(nop_actor_factory.Make(uint)); |
| 367 | } |
| 368 | action_queue.Tick(); |
| 369 | |
| 370 | // Should still be running as the actor could not have signalled. |
| 371 | EXPECT_TRUE(action_queue.Running()); |
| 372 | |
| 373 | EXPECT_TRUE(action_queue.GetCurrentActionState(nullptr, &sent_started, |
| 374 | &sent_cancel, &interrupted, |
| 375 | &nop_actor_id, nullptr)); |
| 376 | EXPECT_TRUE(sent_started); |
| 377 | EXPECT_FALSE(sent_cancel); |
| 378 | EXPECT_FALSE(interrupted); |
| 379 | ASSERT_NE(0u, nop_actor_id); |
| 380 | |
| 381 | // Add the next action which should ensure the first stopped. |
| 382 | { |
| 383 | UIntT uint; |
| 384 | uint.val = 0; |
| 385 | action_queue.EnqueueAction(nop_actor_factory.Make(uint)); |
| 386 | } |
| 387 | |
| 388 | // Check the internal state and write down id for later use. |
| 389 | EXPECT_TRUE(action_queue.GetNextActionState(nullptr, &sent_started, |
| 390 | &sent_cancel, &interrupted, |
| 391 | &nop_actor2_id, nullptr)); |
| 392 | EXPECT_NE(nop_actor_id, nop_actor2_id); |
| 393 | EXPECT_FALSE(sent_started); |
| 394 | EXPECT_FALSE(sent_cancel); |
| 395 | EXPECT_FALSE(interrupted); |
| 396 | ASSERT_NE(0u, nop_actor2_id); |
| 397 | |
| 398 | action_queue.Tick(); |
| 399 | }); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 400 | |
| 401 | // Run the action so it can signal completion. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 402 | RunAt(monotonic_clock::time_point(chrono::seconds(2)), [&]() { |
| 403 | action_queue.Tick(); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 404 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 405 | // Check the new action is the right one. |
| 406 | uint32_t test_id = 0; |
| 407 | EXPECT_TRUE(action_queue.GetCurrentActionState( |
| 408 | nullptr, &sent_started, &sent_cancel, &interrupted, &test_id, nullptr)); |
| 409 | EXPECT_TRUE(sent_started); |
| 410 | EXPECT_FALSE(sent_cancel); |
| 411 | EXPECT_FALSE(interrupted); |
| 412 | EXPECT_EQ(nop_actor2_id, test_id); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 413 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 414 | // Make sure it is still going. |
| 415 | EXPECT_TRUE(action_queue.Running()); |
| 416 | }); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 417 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 418 | // Now let everything finish. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 419 | RunAt(monotonic_clock::time_point(chrono::seconds(3)), [&]() { |
| 420 | action_queue.Tick(); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 421 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 422 | // Make sure it stopped. |
| 423 | EXPECT_FALSE(action_queue.Running()); |
| 424 | }); |
| 425 | |
| 426 | event_loop_factory_.RunFor(chrono::seconds(4)); |
Ben Fredrickson | d69f38b | 2015-01-28 20:06:15 -0800 | [diff] [blame] | 427 | } |
| 428 | |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 429 | // Tests that we do get an index with our goal |
| 430 | TEST_F(ActionTest, ActionIndex) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 431 | TestActorIndex idx_actor(actor1_event_loop_.get()); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 432 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 433 | TestActorIndex::Factory test_actor_index_factory = |
| 434 | TestActorIndex::MakeFactory(test_event_loop_.get()); |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 435 | ::aos::Fetcher<actions::TestActionGoal> goal_fetcher_ = |
| 436 | test_event_loop_->MakeFetcher<actions::TestActionGoal>("/test_action"); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 437 | |
| 438 | ActionQueue action_queue; |
| 439 | // Tick an empty queue and make sure it was not running. Also tick the |
| 440 | // factory to allow it to send out the initial cancel message. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 441 | RunAt(monotonic_clock::time_point(chrono::seconds(1)), [&]() { |
| 442 | action_queue.Tick(); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 443 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 444 | EXPECT_FALSE(action_queue.Running()); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 445 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 446 | // Enqueue action to post index. |
| 447 | { |
| 448 | UIntT uint; |
| 449 | uint.val = 5; |
| 450 | action_queue.EnqueueAction(test_actor_index_factory.Make(uint)); |
| 451 | } |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 452 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 453 | ASSERT_TRUE(goal_fetcher_.Fetch()); |
| 454 | EXPECT_EQ(5u, goal_fetcher_->params()->val()); |
| 455 | EXPECT_EQ(0u, idx_actor.index); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 456 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 457 | action_queue.Tick(); |
| 458 | }); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 459 | |
| 460 | // Run the next action so it can accomplish signal completion. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 461 | RunAt(monotonic_clock::time_point(chrono::seconds(2)), [&]() { |
| 462 | action_queue.Tick(); |
| 463 | EXPECT_EQ(5u, idx_actor.index); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 464 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 465 | // Enqueue action to post index. |
| 466 | { |
| 467 | UIntT uint; |
| 468 | uint.val = 3; |
| 469 | action_queue.EnqueueAction(test_actor_index_factory.Make(uint)); |
| 470 | } |
| 471 | ASSERT_TRUE(goal_fetcher_.Fetch()); |
| 472 | EXPECT_EQ(3u, goal_fetcher_->params()->val()); |
| 473 | }); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 474 | |
| 475 | // Run the next action so it can accomplish signal completion. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 476 | RunAt(monotonic_clock::time_point(chrono::seconds(3)), [&]() { |
| 477 | action_queue.Tick(); |
| 478 | EXPECT_EQ(3u, idx_actor.index); |
| 479 | }); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 480 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 481 | event_loop_factory_.RunFor(chrono::seconds(3)); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | // Tests that an action with a structure params works. |
| 485 | TEST_F(ActionTest, StructParamType) { |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 486 | TestActor2Nop nop_actor(actor2_event_loop_.get()); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 487 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 488 | TestActor2Nop::Factory test_action_2_nop_factory = |
| 489 | TestActor2Nop::MakeFactory(test_event_loop_.get()); |
| 490 | |
| 491 | ActionQueue action_queue; |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 492 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 493 | RunAt(monotonic_clock::time_point(chrono::seconds(0)), [&]() { |
| 494 | // Tick an empty queue and make sure it was not running. |
| 495 | action_queue.Tick(); |
| 496 | EXPECT_FALSE(action_queue.Running()); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 497 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 498 | actions::MyParamsT p; |
| 499 | p.param1 = 5.0; |
| 500 | p.param2 = 7; |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 501 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 502 | action_queue.EnqueueAction(test_action_2_nop_factory.Make(p)); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 503 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 504 | // We started an action and it should be running. |
| 505 | EXPECT_TRUE(action_queue.Running()); |
| 506 | |
| 507 | // Tick it and make sure it is still running. |
| 508 | action_queue.Tick(); |
| 509 | EXPECT_TRUE(action_queue.Running()); |
| 510 | }); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 511 | |
| 512 | // Run the action so it can signal completion. |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 513 | // The actor takes no time, but running for a second is the best way to get it |
| 514 | // to go. |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 515 | RunAt(monotonic_clock::time_point(chrono::seconds(1)), [&]() { |
| 516 | action_queue.Tick(); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 517 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 518 | // Make sure it stopped. |
| 519 | EXPECT_FALSE(action_queue.Running()); |
| 520 | }); |
Ben Fredrickson | 9fb2ab1 | 2015-02-16 16:42:08 -0800 | [diff] [blame] | 521 | |
Austin Schuh | 02e2aeb | 2020-02-10 21:51:30 -0800 | [diff] [blame] | 522 | event_loop_factory_.RunFor(chrono::seconds(2)); |
Brian Silverman | 237a554 | 2015-03-29 17:59:29 -0400 | [diff] [blame] | 523 | } |
| 524 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 525 | } // namespace aos::common::actions::testing |