Exemplo n.º 1
0
static void test_set_backend_ids_for_disabled(session &sess)
{
	server_node &node = global_data->nodes.back();

	auto ids = generate_ids(16);

	ELLIPTICS_REQUIRE(async_set_result, sess.set_backend_ids(node.remote(), 4, ids));

	backend_status_result_entry result = async_set_result.get_one();
	BOOST_REQUIRE(result.is_valid());
	BOOST_REQUIRE_EQUAL(result.count(), 1);

	dnet_backend_status *status = result.backend(0);
	BOOST_REQUIRE_EQUAL(status->backend_id, 4);
	BOOST_REQUIRE_EQUAL(status->state, DNET_BACKEND_DISABLED);

	ELLIPTICS_REQUIRE(async_enable_result, sess.enable_backend(node.remote(), 4));

	// Wait 0.1 secs to ensure that route list was changed
	usleep(100 * 1000);

	auto route_ids = backend_ids(sess, node.remote(), 4);
	BOOST_REQUIRE_EQUAL(ids.size(), route_ids.size());
	BOOST_REQUIRE(compare_ids(ids, route_ids));
}
Exemplo n.º 2
0
static void test_enable_backend_after_config_change(session &sess)
{
	server_node &node = get_setup()->nodes[0];

	server_config &config = node.config();
	config_data &hidden_backend = config.backends.back();
	uint32_t backend_id = std::stoi(hidden_backend.string_value("backend_id"));

	ELLIPTICS_REQUIRE_ERROR(enable_result, sess.enable_backend(node.remote(), backend_id), -ENOENT);

	hidden_backend.set_serializable(true);
	config.write(node.config_path());

	test_enable_backend(sess, backend_id);
}
Exemplo n.º 3
0
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");
}
Exemplo n.º 4
0
static void test_enable_backend_at_empty_node(session &sess)
{
	server_node &node = global_data->nodes.back();

	std::string host = node.remote().to_string();
	auto tuple = std::make_tuple(host, groups_count, 1);

	auto unique_hosts = get_unique_hosts(sess);

	BOOST_REQUIRE_MESSAGE(unique_hosts.find(tuple) == unique_hosts.end(),
		"Host must not exist: " + host + ", group: 2, backend: 1");

	ELLIPTICS_REQUIRE(enable_result, sess.enable_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 exist: " + host + ", group: 2, backend: 1");
}
Exemplo n.º 5
0
static void test_enable_backend(session &sess, uint32_t backend_id)
{
	server_node &node = get_setup()->nodes[0];

	std::string host = node.remote().to_string();
	auto tuple = std::make_tuple(host, 0, backend_id);

	auto unique_hosts = get_unique_hosts(sess);

	BOOST_REQUIRE_MESSAGE(unique_hosts.find(tuple) == unique_hosts.end(),
	                      "Host must not exist: " + host + ", group: 0, backend: " +
	                          std::to_string(static_cast<long long>(backend_id)));

	ELLIPTICS_REQUIRE(enable_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(tuple) != unique_hosts.end(),
	                      "Host must exist: " + host + ", group: 0, backend: " +
	                          std::to_string(static_cast<long long>(backend_id)));
}
Exemplo n.º 6
0
static void test_enable_backend_again(session &sess)
{
	server_node &node = global_data->nodes[0];

	ELLIPTICS_REQUIRE_ERROR(enable_result, sess.enable_backend(node.remote(), 1), -EALREADY);
}