Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
103b08ef
Commit
103b08ef
authored
May 02, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests for autoconnect, remove old tests
parent
cf6952f1
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
273 deletions
+167
-273
libcaf_io/test/automatic_connection.cpp
libcaf_io/test/automatic_connection.cpp
+167
-48
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+0
-225
No files found.
libcaf_io/test/automatic_connection.cpp
View file @
103b08ef
This diff is collapsed.
Click to expand it.
libcaf_io/test/basp.cpp
View file @
103b08ef
...
...
@@ -768,229 +768,4 @@ CAF_TEST(read_address_after_handshake) {
);
}
/*
CAF_TEST(build_connections) {
// this node receives a message from jupiter via mars and responds via mars
// and any ad-hoc automatic connection requests are ignored
CAF_MESSAGE("self: " << to_string(self()->address()));
CAF_MESSAGE("publish self at port 4242");
auto ax = accept_handle::from_int(4242);
mpx()->provide_acceptor(4242, ax);
sys.middleman().publish(self(), 4242);
mpx()->flush_runnables(); // process publish message in basp_broker
CAF_MESSAGE("connect to Mars");
connect_node(mars(), ax, self()->id());
CAF_MESSAGE("actor from Jupiter sends a message to us via Mars");
auto mx = mock(mars().connection,
{basp::message_type::dispatch_message, 0, 0, 0,
jupiter().id, this_node(),
jupiter().dummy_actor->id(), self()->id()},
std::vector<actor_id>{},
make_message("hello from jupiter!"));
CAF_MESSAGE("expect ('sys', 'get', \"info\") from Earth to Jupiter at Mars");
// this asks Jupiter if it has a 'SpawnServ'
mx.receive(mars().connection,
basp::message_type::dispatch_message,
basp::header::named_receiver_flag, any_vals,
no_operation_data, this_node(), jupiter().id,
any_vals, invalid_actor_id,
spawn_serv_atom,
std::vector<actor_id>{},
make_message(sys_atom::value, get_atom::value, "info"));
CAF_MESSAGE("expect announce_proxy message at Mars from Earth to Jupiter");
mx.receive(mars().connection,
basp::message_type::announce_proxy, no_flags, no_payload,
no_operation_data, this_node(), jupiter().id,
invalid_actor_id, jupiter().dummy_actor->id());
CAF_MESSAGE("receive message from jupiter");
self()->receive(
[](const std::string& str) -> std::string {
CAF_CHECK_EQUAL(str, "hello from jupiter!");
return "hello from earth!";
}
);
mpx()->exec_runnable(); // process forwarded message in basp_broker
mock()
.receive(mars().connection,
basp::message_type::dispatch_message, no_flags, any_vals,
no_operation_data, this_node(), jupiter().id,
self()->id(), jupiter().dummy_actor->id(),
std::vector<actor_id>{},
make_message("hello from earth!"));
}
*/
CAF_TEST
(
automatic_connection
)
{
// jupiter [remote hdl 0] -> mars [remote hdl 1] -> earth [this_node]
// (this node receives a message from jupiter via mars and responds via mars,
// but then also establishes a connection to jupiter directly)
/*
CAF_MESSAGE("! This test case changes the node id and dummy actor of jupiter\n"
" to a different actor system to trigger the creation of a\n"
" proxy on receipt of the dummy actor.");
// Create a new system to have an actor with an id from a remote system
// to test the automatic connection setup.
actor_system_config fake_cfg;
fake_cfg.load<caf::io::middleman>();
actor_system fake_sys(fake_cfg);
scoped_actor another_fake_actor(fake_sys);
new (&jupiter().dummy_actor) scoped_actor(fake_sys);
jupiter().id = fake_sys.node();
CAF_MESSAGE("Jupiter: " << to_string(jupiter().id));
*/
/*
auto check_node_in_tbl = [&](node& n) {
io::id_visitor id_vis;
auto lr = tbl().lookup(n.id);
CAF_REQUIRE(lr.hdl);
CAF_CHECK_EQUAL(visit(id_vis, *lr.hdl), n.connection.id());
};
mpx()->provide_scribe("jupiter", 8080, jupiter().connection);
CAF_CHECK(mpx()->has_pending_scribe("jupiter", 8080));
CAF_MESSAGE("Earth actor : " << to_string(self()));
CAF_MESSAGE("Jupiter actor: " << to_string(jupiter().dummy_actor));
CAF_MESSAGE("Mars actor : " << to_string(mars().dummy_actor));
auto ax = accept_handle::from_int(4242);
mpx()->provide_acceptor(4242, ax);
publish(self(), 4242);
mpx()->flush_runnables(); // process publish message in basp_broker
CAF_MESSAGE("connect to mars");
auto& addrs = instance().tbl().local_addresses();
connect_node(mars(), ax, self()->id(), std::set<string>{}, addrs);
//CAF_CHECK_EQUAL(tbl().lookup_direct(mars().id).id(), mars().connection.id());
check_node_in_tbl(mars());
// TODO:
// - Send Jupiter's actor from mars to Earth.
// - Expect the ConfigServ msg at Mars.
// - Reply with the connection info for Mars.
// - Handle the direct handshake.
// - Sounds about right!
// Our dummy actors all belong to the same system,
// here is a fake actor from Jupiter.
// TODO: Should really be an actor ...
CAF_MESSAGE("Mars shares an actor located at Jupiter with Earth.");
// TODO: This fails. Apparently it is not the same thing, sending the actor
// or forwardings an actor received earlier. Not sure how to solve this, yet.
mock(mars().connection,
{basp::message_type::dispatch_message, 0, 0, 0,
mars().id, this_node(),
mars().dummy_actor->id(), self()->id()},
std::vector<actor_id>{},
make_message("Here is jupiter's actor!", on_phobos));
// CAF_MESSAGE("Receive the msg from Mars");
// self()->receive(
// [&](std::string& text, actor sender) {
// CAF_MESSAGE("Received '" << text << "' from '"
// << to_string(sender) << "'.");
// CAF_MESSAGE("Self is '" << to_string(self()) << "'.");
// }
// );
CAF_MESSAGE("Earth announces a proxy for the sender from Mars.");
mock()
.receive(mars().connection,
basp::message_type::announce_proxy,
no_flags, no_payload, no_operation_data,
this_node(), mars().id,
invalid_actor_id, mars().dummy_actor->id());
sched.run();
mpx()->flush_runnables();
CAF_MESSAGE("Earth requests connection info for Jupiter");
mock()
.receive(mars().connection,
basp::message_type::dispatch_message,
basp::header::named_receiver_flag, any_vals, no_operation_data,
this_node(), mars().id, any_vals, invalid_actor_id,
config_serv_atom,
std::vector<actor_id>{},
make_message(get_atom::value, to_string(jupiter().id)));
*/
/*
CAF_MESSAGE("simulate that an actor from jupiter "
"sends a message to us via mars");
mock(mars().connection,
{basp::message_type::dispatch_message, 0, 0, 0,
jupiter().id, this_node(),
jupiter().dummy_actor->id(), self()->id()},
std::vector<actor_id>{},
make_message("hello from jupiter!"))
.receive(mars().connection,
basp::message_type::dispatch_message,
basp::header::named_receiver_flag, any_vals, no_operation_data,
this_node(), jupiter().id, any_vals, invalid_actor_id,
spawn_serv_atom,
std::vector<actor_id>{},
make_message(sys_atom::value, get_atom::value, "info"))
.receive(mars().connection,
basp::message_type::dispatch_message,
basp::header::named_receiver_flag, any_vals,
no_operation_data, this_node(), jupiter().id,
any_vals, // actor ID of an actor spawned by the BASP broker
invalid_actor_id,
config_serv_atom,
std::vector<actor_id>{},
make_message(get_atom::value, "basp.default-connectivity-tcp"))
.receive(mars().connection,
basp::message_type::announce_proxy, no_flags, no_payload,
no_operation_data, this_node(), jupiter().id,
invalid_actor_id, jupiter().dummy_actor->id());
CAF_CHECK_EQUAL(mpx()->output_buffer(mars().connection).size(), 0u);
CAF_CHECK_EQUAL(*tbl().lookup(jupiter().id).hdl, mars().id);
CAF_CHECK_EQUAL(tbl().lookup(mars().id), none);
auto connection_helper_actor = sys.latest_actor_id();
CAF_CHECK_EQUAL(mpx()->output_buffer(mars().connection).size(), 0u);
// create a dummy config server and respond to the name lookup
CAF_MESSAGE("receive ConfigServ of jupiter");
network::address_listing res;
res[network::protocol::ipv4].emplace_back("jupiter");
mock(mars().connection,
{basp::message_type::dispatch_message, 0, 0, 0,
this_node(), jupiter(),
invalid_actor_id, connection_helper_actor},
std::vector<actor_id>{},
make_message("basp.default-connectivity-tcp",
make_message(uint16_t{8080}, std::move(res))));
// our connection helper should now connect to jupiter and
// send the scribe handle over to the BASP broker
while (mpx()->has_pending_scribe("jupiter", 8080)) {
sched.run();
mpx()->flush_runnables();
}
CAF_REQUIRE(mpx()->output_buffer(mars().connection).empty());
// send handshake from jupiter
mock(jupiter().connection,
{basp::message_type::server_handshake, 0, 0, basp::version,
jupiter().id, none,
jupiter().dummy_actor->id(), invalid_actor_id},
std::string{},
jupiter().dummy_actor->id(),
uint32_t{0})
.receive(jupiter().connection,
basp::message_type::client_handshake, no_flags, 1u,
no_operation_data, this_node(), jupiter().id,
invalid_actor_id, invalid_actor_id, std::string{});
CAF_CHECK_EQUAL(tbl().lookup(jupiter().id).hdl, none);
CAF_CHECK_EQUAL(tbl().lookup(mars().id).hdl, none);
check_node_in_tbl(jupiter());
check_node_in_tbl(mars());
CAF_MESSAGE("receive message from jupiter");
self()->receive(
[](const std::string& str) -> std::string {
CAF_CHECK_EQUAL(str, "hello from jupiter!");
return "hello from earth!";
}
);
mpx()->exec_runnable(); // process forwarded message in basp_broker
CAF_MESSAGE("response message must take direct route now");
mock()
.receive(jupiter().connection,
basp::message_type::dispatch_message, no_flags, any_vals,
no_operation_data, this_node(), jupiter().id,
self()->id(), jupiter().dummy_actor->id(),
std::vector<actor_id>{},
make_message("hello from earth!"));
CAF_CHECK_EQUAL(mpx()->output_buffer(mars().connection).size(), 0u);
*/
}
CAF_TEST_FIXTURE_SCOPE_END
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment