static void setup(char **argv) { const char *endpoint; assert(session == NULL); assert(mock == NULL); assert(io == NULL); io = get_test_io_opts(); if (io == NULL) { err_exit("Failed to create IO session"); } mock = start_mock_server(argv); if (mock == NULL) { err_exit("Failed to start mock server"); } endpoint = get_mock_http_server(mock); session = libcouchbase_create(endpoint, "Administrator", "password", NULL, io); if (session == NULL) { err_exit("Failed to create libcouchbase session"); } (void)libcouchbase_set_error_callback(session, error_callback); if (libcouchbase_connect(session) != LIBCOUCHBASE_SUCCESS) { err_exit("Failed to connect to server"); } libcouchbase_wait(session); }
static void setup(char **argv, const char *username, const char *password, const char *bucket) { const char *endpoint; struct lcb_create_st options; lcb_assert(session == NULL); lcb_assert(mock == NULL); lcb_assert(io == NULL); if (lcb_create_io_ops(&io, NULL) != LCB_SUCCESS) { fprintf(stderr, "Failed to create IO instance\n"); exit(1); } mock = start_test_server(argv); if (mock == NULL) { err_exit("Failed to start mock server"); } endpoint = get_mock_http_server(mock); memset(&options, 0, sizeof(options)); if (!mock->is_mock) { username = mock->username; password = mock->password; bucket = mock->bucket; } options.version = 2; options.v.v2.host = endpoint; options.v.v2.user = username; options.v.v2.passwd = password; options.v.v2.bucket = bucket; options.v.v2.io = io; options.v.v2.transports = enabled_transports; if (lcb_create(&session, &options) != LCB_SUCCESS) { err_exit("Failed to create libcouchbase session"); } (void)lcb_set_error_callback(session, error_callback); if (lcb_connect(session) != LCB_SUCCESS) { err_exit("Failed to connect to server"); } lcb_wait(session); if (!mock->is_mock) { const char *const *servers; total_node_count = 0; servers = lcb_get_server_list(session); for (; *servers; servers++, total_node_count++); } }
static lcb_error_t test_connect(char **argv, const char *username, const char *password, const char *bucket) { const char *endpoint; lcb_error_t rc; struct lcb_create_st options; lcb_assert(session == NULL); lcb_assert(mock == NULL); lcb_assert(io == NULL); if (lcb_create_io_ops(&io, NULL) != LCB_SUCCESS) { fprintf(stderr, "Failed to create IO instance\n"); exit(1); } mock = start_test_server(argv); if (mock == NULL) { err_exit("Failed to start mock server"); } endpoint = get_mock_http_server(mock); memset(&options, 0, sizeof(options)); options.version = 2; options.v.v2.host = endpoint; options.v.v2.user = username; options.v.v2.passwd = password; options.v.v2.bucket = bucket; options.v.v2.io = io; options.v.v2.transports = enabled_transports; if (lcb_create(&session, &options) != LCB_SUCCESS) { err_exit("Failed to create libcouchbase session"); } (void)lcb_set_error_callback(session, error_callback2); if (lcb_connect(session) != LCB_SUCCESS) { err_exit("Failed to connect to server"); } lcb_wait(session); rc = global_error; lcb_destroy(session); lcb_destroy_io_ops(io); session = NULL; io = NULL; shutdown_mock_server(mock); mock = NULL; return rc; }