Unverified Commit 9df6a8e0 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #715

Simplify UDP test, use dynamic ports
parents 36fb5045 38e0f0b9
...@@ -621,7 +621,7 @@ if(NOT CAF_NO_UNIT_TESTS) ...@@ -621,7 +621,7 @@ if(NOT CAF_NO_UNIT_TESTS)
macro (make_test suite) macro (make_test suite)
string(REPLACE " " "_" test_name ${suite}) string(REPLACE " " "_" test_name ${suite})
set(caf_test ${EXECUTABLE_OUTPUT_PATH}/caf-test) set(caf_test ${EXECUTABLE_OUTPUT_PATH}/caf-test)
add_test(${test_name} ${caf_test} -n -v 5 -s "${suite}" ${ARGN}) add_test(${test_name} ${caf_test} -r 300 -n -v 5 -s "${suite}" ${ARGN})
endmacro () endmacro ()
list(LENGTH suites num_suites) list(LENGTH suites num_suites)
message(STATUS "Found ${num_suites} test suites") message(STATUS "Found ${num_suites} test suites")
......
...@@ -203,10 +203,7 @@ pipeline { ...@@ -203,10 +203,7 @@ pipeline {
steps { steps {
deleteDir() deleteDir()
dir('caf-sources') { dir('caf-sources') {
git([ checkout scm
url: 'https://github.com/actor-framework/actor-framework.git',
branch: 'master',
])
} }
stash includes: 'caf-sources/**', name: 'caf-sources' stash includes: 'caf-sources/**', name: 'caf-sources'
} }
......
...@@ -196,7 +196,7 @@ CAF_TEST(remote_link_udp) { ...@@ -196,7 +196,7 @@ CAF_TEST(remote_link_udp) {
CAF_TEST(multiple_endpoints_udp) { CAF_TEST(multiple_endpoints_udp) {
config cfg; config cfg;
// setup server // Setup server.
CAF_MESSAGE("creating server"); CAF_MESSAGE("creating server");
actor_system server_sys{cfg}; actor_system server_sys{cfg};
auto mirror = server_sys.spawn([]() -> behavior { auto mirror = server_sys.spawn([]() -> behavior {
...@@ -207,7 +207,9 @@ CAF_TEST(multiple_endpoints_udp) { ...@@ -207,7 +207,9 @@ CAF_TEST(multiple_endpoints_udp) {
} }
}; };
}); });
server_sys.middleman().publish_udp(mirror, 12345); auto port = server_sys.middleman().publish_udp(mirror, 0);
CAF_REQUIRE(port);
CAF_MESSAGE("server running on port " << port);
auto client_fun = [](event_based_actor* self) -> behavior { auto client_fun = [](event_based_actor* self) -> behavior {
return { return {
[=](actor s) { [=](actor s) {
...@@ -220,29 +222,29 @@ CAF_TEST(multiple_endpoints_udp) { ...@@ -220,29 +222,29 @@ CAF_TEST(multiple_endpoints_udp) {
} }
}; };
}; };
// setup client a // Setup a client.
CAF_MESSAGE("creating first client"); CAF_MESSAGE("creating first client");
config client_cfg; config client_cfg;
actor_system client_sys{client_cfg}; actor_system client_sys{client_cfg};
auto client = client_sys.spawn(client_fun); auto client = client_sys.spawn(client_fun);
// acquire remote actor from the server // Acquire remote actor from the server.
auto client_srv = client_sys.middleman().remote_actor_udp("localhost", 12345); auto client_srv = client_sys.middleman().remote_actor_udp("localhost", *port);
CAF_REQUIRE(client_srv); CAF_REQUIRE(client_srv);
// setup other clients // Setup other clients.
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
config other_cfg; config other_cfg;
actor_system other_sys{other_cfg}; actor_system other_sys{other_cfg};
CAF_MESSAGE("creating new client"); CAF_MESSAGE("creating new client");
auto other = other_sys.spawn(client_fun); auto other = other_sys.spawn(client_fun);
// acquire remote actor from the server // Acquire remote actor from the new server.
auto other_srv = other_sys.middleman().remote_actor_udp("localhost", 12345); auto other_srv = other_sys.middleman().remote_actor_udp("localhost", *port);
CAF_REQUIRE(other_srv); CAF_REQUIRE(other_srv);
// establish communication and exit // Establish communication and exit.
CAF_MESSAGE("client contacts server and exits"); CAF_MESSAGE("client contacts server and exits");
anon_send(other, *other_srv); anon_send(other, *other_srv);
other_sys.await_all_actors_done(); other_sys.await_all_actors_done();
} }
// establish communication and exit // Start communicate from the first actor.
CAF_MESSAGE("first client contacts server and exits"); CAF_MESSAGE("first client contacts server and exits");
anon_send(client, *client_srv); anon_send(client, *client_srv);
client_sys.await_all_actors_done(); client_sys.await_all_actors_done();
......
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