Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use get_restart_count from the monkey-masterwork, for simplicity and to test it
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 9 Mar 2022 08:50:08 +0000 (09:50 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 9 Mar 2022 09:08:51 +0000 (10:08 +0100)
teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp
teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.tesh

index aef2566..183179a 100644 (file)
@@ -31,7 +31,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example")
 static simgrid::config::Flag<int> cfg_host_count{"host-count", "Host count (master on one, workers on the others)", 3};
 static simgrid::config::Flag<double> cfg_deadline{"deadline", "When to fail the simulation (infinite loop detection)",
                                                   120};
-static simgrid::config::Flag<int> cfg_task_count{"task-count", "Amount of tasks that must be executed to succeed", 2};
+static simgrid::config::Flag<int> cfg_task_count{"task-count", "Amount of tasks that must be executed to succeed", 1};
 
 int todo; // remaining amount of tasks to execute, a global variable
 sg4::Mailbox* mailbox; // as a global to reduce the amount of simcalls during actor reboot
@@ -40,10 +40,12 @@ XBT_ATTRIB_NORETURN static void master()
 {
   double comp_size = 1e6;
   long comm_size   = 1e6;
-  XBT_INFO("Master booting");
-  sg4::Actor::self()->daemonize();
-  sg4::this_actor::on_exit(
-      [](bool forcefully) { XBT_INFO("Master dying %s.", forcefully ? "forcefully" : "peacefully"); });
+  bool rebooting   = sg4::Actor::self()->get_restart_count() > 0;
+
+  XBT_INFO("Master %s", rebooting ? "rebooting" : "booting");
+  if (not rebooting) // Starting for the first time
+    sg4::this_actor::on_exit(
+        [](bool forcefully) { XBT_INFO("Master dying %s.", forcefully ? "forcefully" : "peacefully"); });
 
   while (true) { // This is a daemon
     xbt_assert(sg4::Engine::get_clock() < cfg_deadline,
@@ -66,9 +68,12 @@ XBT_ATTRIB_NORETURN static void master()
 
 static void worker(int id)
 {
-  XBT_INFO("Worker booting");
-  sg4::this_actor::on_exit(
-      [id](bool forcefully) { XBT_INFO("worker %d dying %s.", id, forcefully ? "forcefully" : "peacefully"); });
+  bool rebooting = sg4::Actor::self()->get_restart_count() > 0;
+
+  XBT_INFO("Worker %s", rebooting ? "rebooting" : "booting");
+  if (not rebooting) // Starting for the first time
+    sg4::this_actor::on_exit(
+        [id](bool forcefully) { XBT_INFO("worker %d dying %s.", id, forcefully ? "forcefully" : "peacefully"); });
 
   while (todo > 0) {
     xbt_assert(sg4::Engine::get_clock() < cfg_deadline,
@@ -115,7 +120,7 @@ int main(int argc, char* argv[])
   }
   rootzone->seal();
 
-  sg4::Actor::create("master", main, master)->set_auto_restart(true);
+  sg4::Actor::create("master", main, master)->daemonize()->set_auto_restart(true);
   int id = 0;
   for (auto* h : worker_hosts) {
     sg4::Actor::create("worker", h, worker, id)->set_auto_restart(true);
index 4d09ca2..e7f9e55 100644 (file)
@@ -1,17 +1,18 @@
 
 p Smoke test: do one arbitrary run of the monkey, just to make sure that *something* is happening.
 
-$ ${bindir:=.}/monkey-masterworkers --cfg=plugin:cmonkey --cfg=cmonkey/time:1 --cfg=cmonkey/host:1
+$ ${bindir:=.}/monkey-masterworkers --cfg=plugin:cmonkey --cfg=cmonkey/time:1 --cfg=cmonkey/host:1 --cfg=task-count:2
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'plugin' to 'cmonkey'
 > [0.000000] [cmonkey/INFO] Initializing the chaos monkey
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cmonkey/time' to '1'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cmonkey/host' to '1'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'task-count' to '2'
 > [lilibeth 0:master:(1) 0.000000] [s4u_test/INFO] Master booting
 > [lilibeth 1:worker:(2) 0.000000] [s4u_test/INFO] Worker booting
 > [lilibeth 2:worker:(3) 0.000000] [s4u_test/INFO] Worker booting
+> [lilibeth 0:master:(1) 0.000000] [s4u_test/INFO] Try to send a message
 > [lilibeth 1:worker:(2) 0.000000] [s4u_test/INFO] Waiting a message on mailbox
 > [lilibeth 2:worker:(3) 0.000000] [s4u_test/INFO] Waiting a message on mailbox
-> [lilibeth 0:master:(1) 0.000000] [s4u_test/INFO] Try to send a message
 > [1.000000] [cmonkey/INFO] Kill host lilibeth 1
 > [lilibeth 0:master:(1) 1.000000] [s4u_test/INFO] Got a NetworkFailureException. Wait a second before starting again.
 > [lilibeth 1:worker:(2) 1.000000] [s4u_test/INFO] worker 0 dying forcefully.
@@ -26,8 +27,7 @@ $ ${bindir:=.}/monkey-masterworkers --cfg=plugin:cmonkey --cfg=cmonkey/time:1 --
 > [lilibeth 2:worker:(3) 4.167573] [s4u_test/INFO] worker 1 dying peacefully.
 > [lilibeth 0:master:(1) 4.167573] [s4u_test/INFO] Master dying forcefully.
 > [31.000000] [cmonkey/INFO] Restart host lilibeth 1
-> [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] Worker booting
-> [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] worker 0 dying peacefully.
+> [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] Worker rebooting
 > [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] worker 0 dying peacefully.
 > [31.000000] [cmonkey/INFO] Chaos Monkey done!
 > [31.000000] [s4u_test/INFO] WE SURVIVED!