@@ -78,6 +78,7 @@ TYPED_TEST(ActorRuntimeTest, formats_runtime_and_actor_state) {
78
78
auto actor =
79
79
runtime->template getActorStateByID <pong_actor::Actor>(actorID).value ();
80
80
ASSERT_EQ (fmt::format (" {}" , actor), R"( {"called":1})" );
81
+ runtime->softShutdown ();
81
82
}
82
83
83
84
TYPED_TEST (ActorRuntimeTest, serializes_an_actor_including_its_actor_state) {
@@ -93,6 +94,7 @@ TYPED_TEST(ActorRuntimeTest, serializes_an_actor_including_its_actor_state) {
93
94
R"( {"pid":{"server":"PRMR-1234","id":0},"state":{"state":"foo","called":1},"batchsize":16})" _vpack;
94
95
ASSERT_EQ (runtime->getSerializedActorByID (actor)->toJson (),
95
96
expected.toJson ());
97
+ runtime->softShut
10000
down ();
96
98
}
97
99
98
100
TYPED_TEST (ActorRuntimeTest, spawns_actor) {
@@ -106,6 +108,7 @@ TYPED_TEST(ActorRuntimeTest, spawns_actor) {
106
108
this ->scheduler ->stop ();
107
109
auto state = runtime->template getActorStateByID <TrivialActor>(actor);
108
110
ASSERT_EQ (state, (TrivialState{.state = " foo" , .called = 1 }));
111
+ runtime->softShutdown ();
109
112
}
110
113
111
114
TYPED_TEST (ActorRuntimeTest, sends_initial_message_when_spawning_actor) {
@@ -119,6 +122,7 @@ TYPED_TEST(ActorRuntimeTest, sends_initial_message_when_spawning_actor) {
119
122
this ->scheduler ->stop ();
120
123
auto state = runtime->template getActorStateByID <TrivialActor>(actor);
121
124
ASSERT_EQ (state, (TrivialState{.state = " foobar" , .called = 1 }));
125
+ runtime->softShutdown ();
122
126
}
123
127
124
128
TYPED_TEST (ActorRuntimeTest, gives_all_existing_actor_ids) {
@@ -139,6 +143,7 @@ TYPED_TEST(ActorRuntimeTest, gives_all_existing_actor_ids) {
139
143
ASSERT_EQ (
140
144
(std::unordered_set<ActorID>(allActorIDs.begin (), allActorIDs.end ())),
141
145
(std::unordered_set<ActorID>{actor_foo, actor_bar}));
146
+ runtime->softShutdown ();
142
147
}
143
148
144
149
TYPED_TEST (ActorRuntimeTest, sends_message_to_an_actor) {
@@ -155,6 +160,7 @@ TYPED_TEST(ActorRuntimeTest, sends_message_to_an_actor) {
155
160
this ->scheduler ->stop ();
156
161
auto state = runtime->template getActorStateByID <TrivialActor>(actor);
157
162
ASSERT_EQ (state, (TrivialState{.state = " foobaz" , .called = 2 }));
163
+ runtime->softShutdown ();
158
164
}
159
165
160
166
struct SomeMessage {};
@@ -187,6 +193,7 @@ TYPED_TEST(
187
193
runtime->template getActorStateByID <TrivialActor>(actor_id),
188
194
(TrivialState{.state = fmt::format (" sent unknown message to {}" , actor),
189
195
.called = 2 }));
196
+ runtime->softShutdown ();
190
197
}
191
198
192
199
TYPED_TEST (
@@ -208,6 +215,7 @@ TYPED_TEST(
208
215
(TrivialState{.state = fmt::format (" receiving actor {} not found" ,
209
216
unknown_actor),
210
217
.called = 2 }));
218
+ runtime->softShutdown ();
211
219
}
212
220
213
221
TYPED_TEST (ActorRuntimeTest, ping_pong_game) {
@@ -231,6 +239,7 @@ TYPED_TEST(ActorRuntimeTest, ping_pong_game) {
231
239
auto pong_actor_state =
232
240
runtime->template getActorStateByID <pong_actor::Actor>(pong_actor);
233
241
ASSERT_EQ (pong_actor_state, (pong_actor::PongState{.called = 2 }));
242
+ runtime->softShutdown ();
234
243
}
235
244
236
245
TYPED_TEST (ActorRuntimeTest, spawn_game) {
@@ -250,6 +259,7 @@ TYPED_TEST(ActorRuntimeTest, spawn_game) {
250
259
ASSERT_EQ (runtime->getActorIDs ().size (), 2 );
251
260
ASSERT_EQ (runtime->template getActorStateByID <SpawnActor>(spawn_actor),
252
261
(SpawnState{.called = 2 , .state = " baz" }));
262
+ runtime->softShutdown ();
253
263
}
254
264
255
265
TYPED_TEST (ActorRuntimeTest, finishes_actor_when_actor_says_so) {
@@ -268,6 +278,7 @@ TYPED_TEST(ActorRuntimeTest, finishes_actor_when_actor_says_so) {
268
278
this ->scheduler ->stop ();
269
279
ASSERT_TRUE (
270
280
runtime->actors .find (finishing_actor)->get ()->isFinishedAndIdle ());
281
+ runtime->softShutdown ();
271
282
}
272
283
273
284
TYPED_TEST (ActorRuntimeTest, garbage_collects_finished_actor) {
@@ -289,6 +300,7 @@ TYPED_TEST(ActorRuntimeTest, garbage_collects_finished_actor) {
289
300
290
301
this ->scheduler ->stop ();
291
302
ASSERT_EQ (runtime->actors .size (), 0 );
303
+ runtime->softShutdown ();
292
304
}
293
305
294
306
TYPED_TEST (ActorRuntimeTest, garbage_collects_all_finished_actors) {
@@ -325,6 +337,7 @@ TYPED_TEST(ActorRuntimeTest, garbage_collects_all_finished_actors) {
325
337
remaining_actor_ids.end ());
326
338
ASSERT_FALSE (actor_ids.contains (actor_to_be_finished));
327
339
ASSERT_FALSE (actor_ids.contains (another_actor_to_be_finished));
340
+ runtime->softShutdown ();
328
341
}
329
342
330
343
TYPED_TEST (ActorRuntimeTest,
@@ -342,10 +355,8 @@ TYPED_TEST(ActorRuntimeTest,
342
355
// wait for actor to work off all messages
343
356
while (not runtime->areAllActorsIdle ()) {
344
357
}
345
-
346
- runtime->softShutdown ();
347
-
348
358
this ->scheduler ->stop ();
359
+ runtime->softShutdown ();
349
360
ASSERT_EQ (runtime->actors .size (), 0 );
350
361
}
351
362
@@ -381,4 +392,5 @@ TEST(ActorRuntimeTest, sends_messages_between_lots_of_actors) {
381
392
ASSERT_EQ (runtime->template getActorStateByID <TrivialActor>(ActorID{i}),
382
393
(TrivialState{.state = std::to_string (i), .called = 2 }));
383
394
}
395
+ runtime->softShutdown ();
384
396
}
0 commit comments