Commit 2e655705 authored by Joseph Noir's avatar Joseph Noir

Adapt autoconn test to the peer server, clean it

parent 45fc6641
...@@ -215,13 +215,13 @@ CAF_TEST(break_triangle_simple_tcp) { ...@@ -215,13 +215,13 @@ CAF_TEST(break_triangle_simple_tcp) {
{ {
simple_config conf; simple_config conf;
actor_system mars(conf); actor_system mars(conf);
// Earth.
CAF_MESSAGE("setting up Earth"); CAF_MESSAGE("setting up Earth");
on_earth = earth.spawn(test_actor, "Earth", false); on_earth = earth.spawn(test_actor, "Earth", false);
auto earth_port = earth.middleman().publish(on_earth, 0); auto earth_port = earth.middleman().publish(on_earth, 0);
CAF_REQUIRE(earth_port); CAF_REQUIRE(earth_port);
CAF_MESSAGE("Earth reachable via " << *earth_port); CAF_MESSAGE("Earth reachable via " << *earth_port);
// Mars.
CAF_MESSAGE("setting up Mars"); CAF_MESSAGE("setting up Mars");
auto from_earth = mars.middleman().remote_actor("localhost", *earth_port); auto from_earth = mars.middleman().remote_actor("localhost", *earth_port);
CAF_REQUIRE(from_earth); CAF_REQUIRE(from_earth);
...@@ -230,17 +230,19 @@ CAF_TEST(break_triangle_simple_tcp) { ...@@ -230,17 +230,19 @@ CAF_TEST(break_triangle_simple_tcp) {
auto mars_port = mars.middleman().publish(on_mars, 0); auto mars_port = mars.middleman().publish(on_mars, 0);
CAF_REQUIRE(mars_port); CAF_REQUIRE(mars_port);
CAF_MESSAGE("Mars reachable via " << *mars_port); CAF_MESSAGE("Mars reachable via " << *mars_port);
// Jupiter.
CAF_MESSAGE("setting up Jupiter"); CAF_MESSAGE("setting up Jupiter");
auto from_mars = jupiter.middleman().remote_actor("localhost", *mars_port); auto from_mars = jupiter.middleman().remote_actor("localhost", *mars_port);
CAF_REQUIRE(from_mars); CAF_REQUIRE(from_mars);
on_jupiter = jupiter.spawn(test_actor, "Jupiter", false); on_jupiter = jupiter.spawn(test_actor, "Jupiter", false);
anon_send(on_jupiter, set_atom::value, *from_mars); anon_send(on_jupiter, set_atom::value, *from_mars);
// Trigger the connection setup.
CAF_MESSAGE("forwarding an actor from Jupiter to Earth via Mars"); CAF_MESSAGE("forwarding an actor from Jupiter to Earth via Mars");
anon_send(on_jupiter, begin_atom::value); anon_send(on_jupiter, begin_atom::value);
mars.await_all_actors_done(); mars.await_all_actors_done();
// Leaving the scope will shutdown Mars.
} }
// Let the remaining nodes communicate.
anon_send(on_earth, msg_atom::value); anon_send(on_earth, msg_atom::value);
jupiter.await_all_actors_done(); jupiter.await_all_actors_done();
earth.await_all_actors_done(); earth.await_all_actors_done();
...@@ -254,7 +256,7 @@ CAF_TEST(build_triangle_tcp) { ...@@ -254,7 +256,7 @@ CAF_TEST(build_triangle_tcp) {
CAF_MESSAGE("Earth : " << to_string(earth.sys.node())); CAF_MESSAGE("Earth : " << to_string(earth.sys.node()));
CAF_MESSAGE("Mars : " << to_string(mars.sys.node())); CAF_MESSAGE("Mars : " << to_string(mars.sys.node()));
CAF_MESSAGE("Jupiter: " << to_string(jupiter.sys.node())); CAF_MESSAGE("Jupiter: " << to_string(jupiter.sys.node()));
// Earth.
CAF_MESSAGE("setting up Earth"); CAF_MESSAGE("setting up Earth");
auto on_earth = earth.sys.spawn(test_actor, "Earth", true); auto on_earth = earth.sys.spawn(test_actor, "Earth", true);
CAF_MESSAGE("run initialization code"); CAF_MESSAGE("run initialization code");
...@@ -263,7 +265,7 @@ CAF_TEST(build_triangle_tcp) { ...@@ -263,7 +265,7 @@ CAF_TEST(build_triangle_tcp) {
prepare_connection(earth, mars, "earth", port_earth); prepare_connection(earth, mars, "earth", port_earth);
CAF_MESSAGE("publish dummy on earth"); CAF_MESSAGE("publish dummy on earth");
earth.publish(on_earth, port_earth); earth.publish(on_earth, port_earth);
// Mars.
CAF_MESSAGE("setting up Mars"); CAF_MESSAGE("setting up Mars");
auto from_earth = mars.remote_actor("earth", port_earth); auto from_earth = mars.remote_actor("earth", port_earth);
CAF_REQUIRE(from_earth); CAF_REQUIRE(from_earth);
...@@ -275,21 +277,20 @@ CAF_TEST(build_triangle_tcp) { ...@@ -275,21 +277,20 @@ CAF_TEST(build_triangle_tcp) {
prepare_connection(mars, jupiter, "mars", port_mars); prepare_connection(mars, jupiter, "mars", port_mars);
CAF_MESSAGE("publish dummy on mars"); CAF_MESSAGE("publish dummy on mars");
mars.publish(on_mars, port_mars); mars.publish(on_mars, port_mars);
// Jupiter
CAF_MESSAGE("setting up Jupiter"); CAF_MESSAGE("setting up Jupiter");
auto from_mars = jupiter.remote_actor("mars", port_mars); auto from_mars = jupiter.remote_actor("mars", port_mars);
CAF_REQUIRE(from_mars); CAF_REQUIRE(from_mars);
auto on_jupiter = jupiter.sys.spawn(test_actor, "Jupiter", true); auto on_jupiter = jupiter.sys.spawn(test_actor, "Jupiter", true);
anon_send(on_jupiter, set_atom::value, from_mars); anon_send(on_jupiter, set_atom::value, from_mars);
exec_all(); exec_all();
// This handle will be created by the test multiplexer for the automatically // This handle will be created by the test multiplexer for the automatically
// opened socket when automatic connections are enabled. // opened socket when automatic connections are enabled.
auto hdl_jupiter = accept_handle::from_int(std::numeric_limits<int64_t>::max()); auto hdl_jupiter = accept_handle::from_int(std::numeric_limits<int64_t>::max());
// Prepare automatic connection between Jupiter and Earth. // Prepare automatic connection between Jupiter and Earth.
prepare_connection(jupiter, earth, "jupiter", port_jupiter, hdl_jupiter); prepare_connection(jupiter, earth, "jupiter", port_jupiter, hdl_jupiter);
// Add the address information for this test to the config server on Mars. // Add the address information for this test to the config server on Mars.
auto mars_config_server = mars.sys.registry().get(atom("ConfigServ")); auto mars_config_server = mars.sys.registry().get(atom("PeerServ"));
network::address_listing interfaces{ network::address_listing interfaces{
{network::protocol::ipv4, std::vector<std::string>{"jupiter"}} {network::protocol::ipv4, std::vector<std::string>{"jupiter"}}
}; };
...@@ -298,7 +299,7 @@ CAF_TEST(build_triangle_tcp) { ...@@ -298,7 +299,7 @@ CAF_TEST(build_triangle_tcp) {
}; };
anon_send(actor_cast<actor>(mars_config_server), put_atom::value, anon_send(actor_cast<actor>(mars_config_server), put_atom::value,
to_string(jupiter.sys.node()), make_message(addrs)); to_string(jupiter.sys.node()), make_message(addrs));
// Trigger the automatic connection setup.
CAF_MESSAGE("forwarding an actor from Jupiter to Earth via Mars"); CAF_MESSAGE("forwarding an actor from Jupiter to Earth via Mars");
anon_send(on_jupiter, begin_atom::value); anon_send(on_jupiter, begin_atom::value);
exec_all(); exec_all();
...@@ -309,7 +310,7 @@ CAF_TEST(break_triangle_tcp) { ...@@ -309,7 +310,7 @@ CAF_TEST(break_triangle_tcp) {
CAF_MESSAGE("Mars : " << to_string(mars.sys.node())); CAF_MESSAGE("Mars : " << to_string(mars.sys.node()));
CAF_MESSAGE("Jupiter: " << to_string(jupiter.sys.node())); CAF_MESSAGE("Jupiter: " << to_string(jupiter.sys.node()));
connection_handle em, me, mj, jm; connection_handle em, me, mj, jm;
// Earth.
CAF_MESSAGE("setting up Earth"); CAF_MESSAGE("setting up Earth");
auto on_earth = earth.sys.spawn(test_actor, "Earth", false); auto on_earth = earth.sys.spawn(test_actor, "Earth", false);
CAF_MESSAGE("run initialization code"); CAF_MESSAGE("run initialization code");
...@@ -318,7 +319,7 @@ CAF_TEST(break_triangle_tcp) { ...@@ -318,7 +319,7 @@ CAF_TEST(break_triangle_tcp) {
std::tie(em, me) = prepare_connection(earth, mars, "earth", port_earth); std::tie(em, me) = prepare_connection(earth, mars, "earth", port_earth);
CAF_MESSAGE("publish dummy on earth"); CAF_MESSAGE("publish dummy on earth");
earth.publish(on_earth, port_earth); earth.publish(on_earth, port_earth);
// Mars.
CAF_MESSAGE("setting up Mars"); CAF_MESSAGE("setting up Mars");
auto from_earth = mars.remote_actor("earth", port_earth); auto from_earth = mars.remote_actor("earth", port_earth);
CAF_REQUIRE(from_earth); CAF_REQUIRE(from_earth);
...@@ -330,21 +331,20 @@ CAF_TEST(break_triangle_tcp) { ...@@ -330,21 +331,20 @@ CAF_TEST(break_triangle_tcp) {
std::tie(mj, jm) = prepare_connection(mars, jupiter, "mars", port_mars); std::tie(mj, jm) = prepare_connection(mars, jupiter, "mars", port_mars);
CAF_MESSAGE("publish dummy on mars"); CAF_MESSAGE("publish dummy on mars");
mars.publish(on_mars, port_mars); mars.publish(on_mars, port_mars);
// Jupiter.
CAF_MESSAGE("setting up Jupiter"); CAF_MESSAGE("setting up Jupiter");
auto from_mars = jupiter.remote_actor("mars", port_mars); auto from_mars = jupiter.remote_actor("mars", port_mars);
CAF_REQUIRE(from_mars); CAF_REQUIRE(from_mars);
auto on_jupiter = jupiter.sys.spawn(test_actor, "Jupiter", false); auto on_jupiter = jupiter.sys.spawn(test_actor, "Jupiter", false);
anon_send(on_jupiter, set_atom::value, from_mars); anon_send(on_jupiter, set_atom::value, from_mars);
exec_all(); exec_all();
// This handle will be created by the test multiplexer for the automatically // This handle will be created by the test multiplexer for the automatically
// opened socket when automatic connections are enabled. // opened socket when automatic connections are enabled.
auto hdl_jupiter = accept_handle::from_int(std::numeric_limits<int64_t>::max()); auto hdl_jupiter = accept_handle::from_int(std::numeric_limits<int64_t>::max());
// Prepare automatic connection between Jupiter and Earth. // Prepare automatic connection between Jupiter and Earth.
prepare_connection(jupiter, earth, "jupiter", port_jupiter, hdl_jupiter); prepare_connection(jupiter, earth, "jupiter", port_jupiter, hdl_jupiter);
// Add the address information for this test to the config server on Mars. // Add the address information for this test to the config server on Mars.
auto mars_config_server = mars.sys.registry().get(atom("ConfigServ")); auto mars_config_server = mars.sys.registry().get(atom("PeerServ"));
network::address_listing interfaces{ network::address_listing interfaces{
{network::protocol::ipv4, std::vector<std::string>{"jupiter"}} {network::protocol::ipv4, std::vector<std::string>{"jupiter"}}
}; };
...@@ -353,24 +353,20 @@ CAF_TEST(break_triangle_tcp) { ...@@ -353,24 +353,20 @@ CAF_TEST(break_triangle_tcp) {
}; };
anon_send(actor_cast<actor>(mars_config_server), put_atom::value, anon_send(actor_cast<actor>(mars_config_server), put_atom::value,
to_string(jupiter.sys.node()), make_message(addrs)); to_string(jupiter.sys.node()), make_message(addrs));
// Trigger the automatic connection setup between the edge nodes.
CAF_MESSAGE("forwarding an actor from Jupiter to Earth via Mars"); CAF_MESSAGE("forwarding an actor from Jupiter to Earth via Mars");
anon_send(on_jupiter, begin_atom::value); anon_send(on_jupiter, begin_atom::value);
exec_all(); exec_all();
// Shutdown the connections to the intermediate node.
// TODO: Shut everything the intermediate node
// - send disconnect messages (i.e., detach the related scribes)
// - shutdown the broker
// - do something about the scribes?
earth.mpx.detach(em, true); earth.mpx.detach(em, true);
mars.mpx.detach(me, true); mars.mpx.detach(me, true);
mars.mpx.detach(mj, true); mars.mpx.detach(mj, true);
jupiter.mpx.detach(jm, true); jupiter.mpx.detach(jm, true);
exec_all(); exec_all();
// Shutdown its basp broker.
anon_send_exit(mars.basp, exit_reason::kill); anon_send_exit(mars.basp, exit_reason::kill);
exec_all(); exec_all();
// Let the remaining nodes communicate.
anon_send(on_earth, msg_atom::value); anon_send(on_earth, msg_atom::value);
exec_all(); exec_all();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment