8000 Shutdown runtimes after tests; fixes memory leak · arangodb/arangodb@949490c · GitHub
[go: up one dir, main page]

Skip to content

Commit 949490c

Browse files
author
Markus Pfeiffer
committed
Shutdown runtimes after tests; fixes memory leak
1 parent d118701 commit 949490c

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

tests/Pregel/Actor/MultiRuntimeTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ TYPED_TEST(ActorMultiRuntimeTest, sends_message_to_actor_in_another_runtime) {
132132
receiving_actor_id);
133133
ASSERT_EQ(receiving_actor_state,
134134
(TrivialActor::State{.state = "foobaz", .called = 2}));
135+
for (auto& [_, runtime] : runtimes) {
136+
runtime->softShutdown();
137+
}
135138
}
136139

137140
struct SomeMessage {};
@@ -201,6 +204,9 @@ TYPED_TEST(
201204
(TrivialActor::State{
202205
.state = fmt::format("sent unknown message to {}", receiving_actor),
203206
.called = 2}));
207+
for (auto& [_, runtime] : runtimes) {
208+
runtime->softShutdown();
209+
}
204210
}
205211

206212
TYPED_TEST(
@@ -246,6 +252,9 @@ TYPED_TEST(
246252
(TrivialActor::State{
247253
.state = fmt::format("receiving actor {} not found", unknown_actor),
248254
.called = 2}));
255+
for (auto& [_, runtime] : runtimes) {
256+
runtime->softShutdown();
257+
}
249258
}
250259

251260
TYPED_TEST(
@@ -284,6 +293,9 @@ TYPED_TEST(
284293
(TrivialActor::State{
285294
.state = fmt::format("receiving server {} not found", unknown_server),
286295
.called = 2}));
296+
for (auto& [_, runtime] : runtimes) {
297+
runtime->softShutdown();
298+
}
287299
}
288300

289301
TYPED_TEST(ActorMultiRuntimeTest, ping_pong_game) {
@@ -326,4 +338,7 @@ TYPED_TEST(ActorMultiRuntimeTest, ping_pong_game) {
326338
ping_actor);
327339
ASSERT_EQ(ping_actor_state,
328340
(ping_actor::PingState{.called = 2, .message = "hello world"}));
341+
for (auto& [_, runtime] : runtimes) {
342+
runtime->softShutdown();
343+
}
329344
}

tests/Pregel/Actor/RuntimeTest.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ TYPED_TEST(ActorRuntimeTest, formats_runtime_and_actor_state) {
7878
auto actor =
7979
runtime->template getActorStateByID<pong_actor::Actor>(actorID).value();
8080
ASSERT_EQ(fmt::format("{}", actor), R"({"called":1})");
81+
runtime->softShutdown();
8182
}
8283

8384
TYPED_TEST(ActorRuntimeTest, serializes_an_actor_including_its_actor_state) {
@@ -93,6 +94,7 @@ TYPED_TEST(ActorRuntimeTest, serializes_an_actor_including_its_actor_state) {
9394
R"({"pid":{"server":"PRMR-1234","id":0},"state":{"state":"foo","called":1},"batchsize":16})"_vpack;
9495
ASSERT_EQ(runtime->getSerializedActorByID(actor)->toJson(),
9596
expected.toJson());
97+
runtime->softShut 10000 down();
9698
}
9799

98100
TYPED_TEST(ActorRuntimeTest, spawns_actor) {
@@ -106,6 +108,7 @@ TYPED_TEST(ActorRuntimeTest, spawns_actor) {
106108
this->scheduler->stop();
107109
auto state = runtime->template getActorStateByID<TrivialActor>(actor);
108110
ASSERT_EQ(state, (TrivialState{.state = "foo", .called = 1}));
111+
runtime->softShutdown();
109112
}
110113

111114
TYPED_TEST(ActorRuntimeTest, sends_initial_message_when_spawning_actor) {
@@ -119,6 +122,7 @@ TYPED_TEST(ActorRuntimeTest, sends_initial_message_when_spawning_actor) {
119122
this->scheduler->stop();
120123
auto state = runtime->template getActorStateByID<TrivialActor>(actor);
121124
ASSERT_EQ(state, (TrivialState{.state = "foobar", .called = 1}));
125+
runtime->softShutdown();
122126
}
123127

124128
TYPED_TEST(ActorRuntimeTest, gives_all_existing_actor_ids) {
@@ -139,6 +143,7 @@ TYPED_TEST(ActorRuntimeTest, gives_all_existing_actor_ids) {
139143
ASSERT_EQ(
140144
(std::unordered_set<ActorID>(allActorIDs.begin(), allActorIDs.end())),
141145
(std::unordered_set<ActorID>{actor_foo, actor_bar}));
146+
runtime->softShutdown();
142147
}
143148

144149
TYPED_TEST(ActorRuntimeTest, sends_message_to_an_actor) {
@@ -155,6 +160,7 @@ TYPED_TEST(ActorRuntimeTest, sends_message_to_an_actor) {
155160
this->scheduler->stop();
156161
auto state = runtime->template getActorStateByID<TrivialActor>(actor);
157162
ASSERT_EQ(state, (TrivialState{.state = "foobaz", .called = 2}));
163+
runtime->softShutdown();
158164
}
159165

160166
struct SomeMessage {};
@@ -187,6 +193,7 @@ TYPED_TEST(
187193
runtime->template getActorStateByID<TrivialActor>(actor_id),
188194
(TrivialState{.state = fmt::format("sent unknown message to {}", actor),
189195
.called = 2}));
196+
runtime->softShutdown();
190197
}
191198

192199
TYPED_TEST(
@@ -208,6 +215,7 @@ TYPED_TEST(
208215
(TrivialState{.state = fmt::format("receiving actor {} not found",
209216
unknown_actor),
210217
.called = 2}));
218+
runtime->softShutdown();
211219
}
212220

213221
TYPED_TEST(ActorRuntimeTest, ping_pong_game) {
@@ -231,6 +239,7 @@ TYPED_TEST(ActorRuntimeTest, ping_pong_game) {
231239
auto pong_actor_state =
232240
runtime->template getActorStateByID<pong_actor::Actor>(pong_actor);
233241
ASSERT_EQ(pong_actor_state, (pong_actor::PongState{.called = 2}));
242+
runtime->softShutdown();
234243
}
235244

236245
TYPED_TEST(ActorRuntimeTest, spawn_game) {
@@ -250,6 +259,7 @@ TYPED_TEST(ActorRuntimeTest, spawn_game) {
250259
ASSERT_EQ(runtime->getActorIDs().size(), 2);
251260
ASSERT_EQ(runtime->template getActorStateByID<SpawnActor>(spawn_actor),
252261
(SpawnState{.called = 2, .state = "baz"}));
262+
runtime->softShutdown();
253263
}
254264

255265
TYPED_TEST(ActorRuntimeTest, finishes_actor_when_actor_says_so) {
@@ -268,6 +278,7 @@ TYPED_TEST(ActorRuntimeTest, finishes_actor_when_actor_says_so) {
268278
this->scheduler->stop();
269279
ASSERT_TRUE(
270280
runtime->actors.find(finishing_actor)->get()->isFinishedAndIdle());
281+
runtime->softShutdown();
271282
}
272283

273284
TYPED_TEST(ActorRuntimeTest, garbage_collects_finished_actor) {
@@ -289,6 +300,7 @@ TYPED_TEST(ActorRuntimeTest, garbage_collects_finished_actor) {
289300

290301
this->scheduler->stop();
291302
ASSERT_EQ(runtime->actors.size(), 0);
303+
runtime->softShutdown();
292304
}
293305

294306
TYPED_TEST(ActorRuntimeTest, garbage_collects_all_finished_actors) {
@@ -325,6 +337,7 @@ TYPED_TEST(ActorRuntimeTest, garbage_collects_all_finished_actors) {
325337
remaining_actor_ids.end());
326338
ASSERT_FALSE(actor_ids.contains(actor_to_be_finished));
327339
ASSERT_FALSE(actor_ids.contains(another_actor_to_be_finished));
340+
runtime->softShutdown();
328341
}
329342

330343
TYPED_TEST(ActorRuntimeTest,
@@ -342,10 +355,8 @@ TYPED_TEST(ActorRuntimeTest,
342355
// wait for actor to work off all messages
343356
while (not runtime->areAllActorsIdle()) {
344357
}
345-
346-
runtime->softShutdown();
347-
348358
this->scheduler->stop();
359+
runtime->softShutdown();
349360
ASSERT_EQ(runtime->actors.size(), 0);
350361
}
351362

@@ -381,4 +392,5 @@ TEST(ActorRuntimeTest, sends_messages_between_lots_of_actors) {
381392
ASSERT_EQ(runtime->template getActorStateByID<TrivialActor>(ActorID{i}),
382393
(TrivialState{.state = std::to_string(i), .called = 2}));
383394
}
395+
runtime->softShutdown();
384396
}

0 commit comments

Comments
 (0)
0