static void test_change_group(session &sess) { server_node &node = global_data->nodes.back(); const uint32_t backend_id = 4; const int old_group_id = 2; const int new_group_id = 10; std::string host = node.remote().to_string(); auto old_tuple = std::make_tuple(host, old_group_id, backend_id); auto new_tuple = std::make_tuple(host, new_group_id, backend_id); auto unique_hosts = get_unique_hosts(sess); BOOST_REQUIRE_MESSAGE(unique_hosts.find(old_tuple) != unique_hosts.end(), "Host must not exist: " + host + ", group: 2, backend: 1"); BOOST_REQUIRE_MESSAGE(unique_hosts.find(new_tuple) == unique_hosts.end(), "Host must not exist: " + host + ", group: 10, backend: 1"); server_config server = node.config(); config_data &backend = server.backends[backend_id]; backend("group", new_group_id); server.write(node.config_path()); ELLIPTICS_REQUIRE(stop_result, sess.disable_backend(node.remote(), backend_id)); ELLIPTICS_REQUIRE(start_result, sess.enable_backend(node.remote(), backend_id)); // Wait 0.1 secs to ensure that route list was changed usleep(100 * 1000); unique_hosts = get_unique_hosts(sess); BOOST_REQUIRE_MESSAGE(unique_hosts.find(old_tuple) == unique_hosts.end(), "Host must not exist: " + host + ", group: 2, backend: 1"); BOOST_REQUIRE_MESSAGE(unique_hosts.find(new_tuple) != unique_hosts.end(), "Host must not exist: " + host + ", group: 10, backend: 1"); }
static void test_disable_backend(session &sess) { server_node &node = global_data->nodes[0]; std::string host = node.remote().to_string(); auto tuple = std::make_tuple(host, 0, 1); auto unique_hosts = get_unique_hosts(sess); BOOST_REQUIRE_MESSAGE(unique_hosts.find(tuple) != unique_hosts.end(), "Host must exist: " + host + ", group: 0, backend: 1"); ELLIPTICS_REQUIRE(enable_result, sess.disable_backend(node.remote(), 1)); // Wait 0.1 secs to ensure that route list was changed usleep(100 * 1000); unique_hosts = get_unique_hosts(sess); BOOST_REQUIRE_MESSAGE(unique_hosts.find(tuple) == unique_hosts.end(), "Host must not exist: " + host + ", group: 0, backend: 1"); }
static void test_disable_backend_again(session &sess) { server_node &node = global_data->nodes[0]; ELLIPTICS_REQUIRE_ERROR(enable_result, sess.disable_backend(node.remote(), 1), -EALREADY); }