Commit ab822407 authored by Jakob Otto's avatar Jakob Otto

Fix remote_actor test

parent 7b7870ad
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "caf/net/ip.hpp" #include "caf/net/ip.hpp"
#include "caf/net/make_endpoint_manager.hpp" #include "caf/net/make_endpoint_manager.hpp"
#include "caf/net/middleman.hpp" #include "caf/net/middleman.hpp"
#include "caf/net/multiplexer.hpp"
#include "caf/net/socket_guard.hpp" #include "caf/net/socket_guard.hpp"
#include "caf/net/stream_transport.hpp" #include "caf/net/stream_transport.hpp"
#include "caf/net/tcp_accept_socket.hpp" #include "caf/net/tcp_accept_socket.hpp"
...@@ -47,7 +46,7 @@ tcp::~tcp() { ...@@ -47,7 +46,7 @@ tcp::~tcp() {
error tcp::init() { error tcp::init() {
uint16_t conf_port = get_or<uint16_t>( uint16_t conf_port = get_or<uint16_t>(
mm_.system().config(), "middleman.tcp_port", defaults::middleman::tcp_port); mm_.system().config(), "middleman.tcp-port", defaults::middleman::tcp_port);
ip_endpoint ep; ip_endpoint ep;
auto local_address = std::string("[::]:") + std::to_string(conf_port); auto local_address = std::string("[::]:") + std::to_string(conf_port);
if (auto err = detail::parse(local_address, ep)) if (auto err = detail::parse(local_address, ep))
...@@ -61,6 +60,7 @@ error tcp::init() { ...@@ -61,6 +60,7 @@ error tcp::init() {
if (!port) if (!port)
return port.error(); return port.error();
listening_port_ = *port; listening_port_ = *port;
CAF_LOG_INFO("doorman spawned on " << CAF_ARG(*port));
auto doorman_uri = make_uri("tcp://doorman"); auto doorman_uri = make_uri("tcp://doorman");
if (!doorman_uri) if (!doorman_uri)
return doorman_uri.error(); return doorman_uri.error();
......
...@@ -47,13 +47,21 @@ behavior dummy_actor(event_based_actor*) { ...@@ -47,13 +47,21 @@ behavior dummy_actor(event_based_actor*) {
struct earth_node { struct earth_node {
uri operator()() { uri operator()() {
return unbox(make_uri("tcp://earth")); return unbox(make_uri("tcp://localhost:12345"));
}
uint16_t port() {
return 12345;
} }
}; };
struct mars_node { struct mars_node {
uri operator()() { uri operator()() {
return unbox(make_uri("tcp://mars")); return unbox(make_uri("tcp://localhost:12346"));
}
uint16_t port() {
return 12346;
} }
}; };
...@@ -62,6 +70,7 @@ struct config : actor_system_config { ...@@ -62,6 +70,7 @@ struct config : actor_system_config {
config() { config() {
Node this_node; Node this_node;
put(content, "middleman.this-node", this_node()); put(content, "middleman.this-node", this_node());
put(content, "middleman.tcp-port", this_node.port());
load<middleman, backend::tcp>(); load<middleman, backend::tcp>();
} }
}; };
...@@ -202,8 +211,8 @@ CAF_TEST(remote_actor) { ...@@ -202,8 +211,8 @@ CAF_TEST(remote_actor) {
using std::chrono::milliseconds; using std::chrono::milliseconds;
using std::chrono::seconds; using std::chrono::seconds;
auto dummy = earth.sys.spawn(dummy_actor); auto dummy = earth.sys.spawn(dummy_actor);
auto path = "name/dummy"s; auto name = "dummy"s;
earth.mm.publish(dummy, path); earth.mm.publish(dummy, name);
auto port = unbox(earth.mm.port("tcp")); auto port = unbox(earth.mm.port("tcp"));
auto ep_str = "tcp://localhost:"s + std::to_string(port); auto ep_str = "tcp://localhost:"s + std::to_string(port);
auto locator = unbox(make_uri(ep_str)); auto locator = unbox(make_uri(ep_str));
...@@ -212,7 +221,7 @@ CAF_TEST(remote_actor) { ...@@ -212,7 +221,7 @@ CAF_TEST(remote_actor) {
handle_io_event(); handle_io_event();
CAF_CHECK_EQUAL(mars.mpx->num_socket_managers(), 3); CAF_CHECK_EQUAL(mars.mpx->num_socket_managers(), 3);
CAF_CHECK_EQUAL(earth.mpx->num_socket_managers(), 3); CAF_CHECK_EQUAL(earth.mpx->num_socket_managers(), 3);
locator = unbox(make_uri(ep_str + "/"s + path)); locator = unbox(make_uri(ep_str + "/name/"s + name));
CAF_MESSAGE("resolve " << CAF_ARG(locator)); CAF_MESSAGE("resolve " << CAF_ARG(locator));
mars.mm.resolve(locator, mars.self); mars.mm.resolve(locator, mars.self);
bool running = true; bool running = true;
...@@ -226,6 +235,7 @@ CAF_TEST(remote_actor) { ...@@ -226,6 +235,7 @@ CAF_TEST(remote_actor) {
std::thread t{f}; std::thread t{f};
auto proxy = unbox(mars.mm.remote_actor(locator)); auto proxy = unbox(mars.mm.remote_actor(locator));
CAF_MESSAGE("resolved actor"); CAF_MESSAGE("resolved actor");
CAF_CHECK(proxy != nullptr);
running = false; running = false;
t.join(); t.join();
set_thread_id(); set_thread_id();
......
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