libcouchbase 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libcouchbase/CMakeLists.txt +6 -8
- data/ext/libcouchbase/README.markdown +2 -2
- data/ext/libcouchbase/RELEASE_NOTES.markdown +229 -2
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +18 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +3 -2
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +4 -0
- data/ext/libcouchbase/cmake/defs.mk.in +0 -2
- data/ext/libcouchbase/cmake/source_files.cmake +21 -5
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +1 -1
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +2 -0
- data/ext/libcouchbase/example/users/README +48 -0
- data/ext/libcouchbase/example/users/users.c +147 -0
- data/ext/libcouchbase/include/libcouchbase/auth.h +175 -31
- data/ext/libcouchbase/include/libcouchbase/cntl.h +82 -1
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +45 -3
- data/ext/libcouchbase/include/libcouchbase/error.h +19 -1
- data/ext/libcouchbase/include/libcouchbase/iops.h +3 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +31 -1
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +4 -1
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +36 -2
- data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
- data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +24 -1146
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
- data/ext/libcouchbase/src/README.md +0 -2
- data/ext/libcouchbase/src/auth-priv.h +23 -4
- data/ext/libcouchbase/src/auth.cc +51 -43
- data/ext/libcouchbase/src/bootstrap.cc +244 -0
- data/ext/libcouchbase/src/bootstrap.h +58 -38
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +120 -158
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +526 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
- data/ext/libcouchbase/src/bucketconfig/bc_static.cc +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +410 -386
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +393 -0
- data/ext/libcouchbase/src/cbft.cc +22 -27
- data/ext/libcouchbase/src/cntl.cc +56 -22
- data/ext/libcouchbase/src/connspec.cc +47 -6
- data/ext/libcouchbase/src/connspec.h +27 -0
- data/ext/libcouchbase/src/dns-srv.cc +147 -0
- data/ext/libcouchbase/src/dump.cc +3 -3
- data/ext/libcouchbase/src/errmap.cc +173 -0
- data/ext/libcouchbase/src/errmap.h +198 -0
- data/ext/libcouchbase/src/getconfig.cc +7 -33
- data/ext/libcouchbase/src/handler.cc +118 -7
- data/ext/libcouchbase/src/hostlist.cc +0 -36
- data/ext/libcouchbase/src/hostlist.h +44 -62
- data/ext/libcouchbase/src/http/http-priv.h +125 -112
- data/ext/libcouchbase/src/http/http.cc +27 -35
- data/ext/libcouchbase/src/http/http.h +1 -34
- data/ext/libcouchbase/src/http/http_io.cc +28 -36
- data/ext/libcouchbase/src/instance.cc +131 -34
- data/ext/libcouchbase/src/internal.h +58 -26
- data/ext/libcouchbase/src/jsparse/parser.cc +136 -210
- data/ext/libcouchbase/src/jsparse/parser.h +84 -98
- data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
- data/ext/libcouchbase/src/lcbio/connect.cc +569 -0
- data/ext/libcouchbase/src/lcbio/connect.h +16 -7
- data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
- data/ext/libcouchbase/src/lcbio/iotable.h +101 -16
- data/ext/libcouchbase/src/lcbio/{ioutils.c → ioutils.cc} +30 -51
- data/ext/libcouchbase/src/lcbio/ioutils.h +29 -90
- data/ext/libcouchbase/src/lcbio/manager.cc +543 -0
- data/ext/libcouchbase/src/lcbio/manager.h +133 -96
- data/ext/libcouchbase/src/lcbio/protoctx.c +2 -2
- data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
- data/ext/libcouchbase/src/mc/mcreq.c +11 -2
- data/ext/libcouchbase/src/mc/mcreq.h +9 -2
- data/ext/libcouchbase/src/mcserver/mcserver.cc +175 -43
- data/ext/libcouchbase/src/mcserver/mcserver.h +9 -13
- data/ext/libcouchbase/src/mcserver/negotiate.cc +181 -62
- data/ext/libcouchbase/src/mcserver/negotiate.h +1 -3
- data/ext/libcouchbase/src/mctx-helper.h +51 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
- data/ext/libcouchbase/src/n1ql/n1ql.cc +74 -42
- data/ext/libcouchbase/src/netbuf/netbuf.c +4 -4
- data/ext/libcouchbase/src/newconfig.cc +6 -6
- data/ext/libcouchbase/src/nodeinfo.cc +2 -2
- data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
- data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
- data/ext/libcouchbase/src/operations/durability.cc +6 -26
- data/ext/libcouchbase/src/operations/durability_internal.h +6 -3
- data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
- data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +68 -93
- data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
- data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
- data/ext/libcouchbase/src/operations/stats.cc +3 -8
- data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
- data/ext/libcouchbase/src/operations/subdoc.cc +129 -42
- data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
- data/ext/libcouchbase/src/packetutils.h +30 -2
- data/ext/libcouchbase/src/probes.d +1 -1
- data/ext/libcouchbase/src/rdb/rope.c +1 -1
- data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +2 -3
- data/ext/libcouchbase/src/retryq.cc +52 -14
- data/ext/libcouchbase/src/retryq.h +3 -3
- data/ext/libcouchbase/src/settings.c +5 -0
- data/ext/libcouchbase/src/settings.h +11 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +2 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +1 -1
- data/ext/libcouchbase/src/trace.h +4 -4
- data/ext/libcouchbase/src/vbucket/vbucket.c +6 -10
- data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
- data/ext/libcouchbase/src/views/docreq.h +24 -30
- data/ext/libcouchbase/src/views/viewreq.cc +318 -0
- data/ext/libcouchbase/src/views/viewreq.h +43 -13
- data/ext/libcouchbase/tests/basic/t_connstr.cc +88 -50
- data/ext/libcouchbase/tests/basic/t_creds.cc +47 -5
- data/ext/libcouchbase/tests/basic/t_host.cc +67 -75
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -82
- data/ext/libcouchbase/tests/basic/t_misc.cc +1 -1
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +0 -1
- data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
- data/ext/libcouchbase/tests/ioserver/connection.cc +1 -1
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +19 -6
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +28 -2
- data/ext/libcouchbase/tests/iotests/mock-environment.h +51 -1
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +1 -7
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +97 -115
- data/ext/libcouchbase/tests/iotests/t_durability.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_eerrs.cc +119 -0
- data/ext/libcouchbase/tests/iotests/t_errmap.cc +178 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +3 -3
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +18 -11
- data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
- data/ext/libcouchbase/tests/socktests/socktest.cc +7 -10
- data/ext/libcouchbase/tests/socktests/socktest.h +2 -3
- data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
- data/ext/libcouchbase/tests/socktests/t_manager.cc +5 -6
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
- data/ext/libcouchbase/tests/vbucket/confdata/ketama_expected.json +2562 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_ketama_config.json +31 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +35 -5
- data/ext/libcouchbase/tools/CMakeLists.txt +2 -2
- data/ext/libcouchbase/tools/cbc-handlers.h +128 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +64 -10
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +2 -2
- data/ext/libcouchbase/tools/cbc.cc +143 -10
- data/ext/libcouchbase/tools/docgen/loc.h +1 -1
- data/lib/libcouchbase/connection.rb +4 -3
- data/lib/libcouchbase/version.rb +1 -1
- metadata +37 -28
- data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
- data/ext/libcouchbase/src/bootstrap.c +0 -269
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
- data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
- data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
- data/ext/libcouchbase/src/lcbio/connect.c +0 -557
- data/ext/libcouchbase/src/lcbio/manager.c +0 -584
- data/ext/libcouchbase/src/packetutils.c +0 -37
- data/ext/libcouchbase/src/simplestring.c +0 -211
- data/ext/libcouchbase/src/simplestring.h +0 -228
- data/ext/libcouchbase/src/ssobuf.h +0 -82
- data/ext/libcouchbase/src/views/viewreq.c +0 -358
- data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
@@ -0,0 +1,119 @@
|
|
1
|
+
#include "config.h"
|
2
|
+
#include "iotests.h"
|
3
|
+
#include "internal.h"
|
4
|
+
|
5
|
+
class EerrsUnitTest : public MockUnitTest {
|
6
|
+
protected:
|
7
|
+
virtual void createEerrConnection(HandleWrap& hw, lcb_t& instance) {
|
8
|
+
MockEnvironment::getInstance()->createConnection(hw, instance);
|
9
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_connect(instance));
|
10
|
+
lcb_wait(instance);
|
11
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_get_bootstrap_status(instance));
|
12
|
+
}
|
13
|
+
|
14
|
+
void enableEnhancedErrors() {
|
15
|
+
MockEnvironment::getInstance()->setEnhancedErrors(true);
|
16
|
+
}
|
17
|
+
|
18
|
+
void disableEnhancedErrors() {
|
19
|
+
MockEnvironment::getInstance()->setEnhancedErrors(false);
|
20
|
+
}
|
21
|
+
|
22
|
+
void checkRetryVerify(uint16_t errcode);
|
23
|
+
|
24
|
+
void TearDown() {
|
25
|
+
MockOpFailClearCommand clearCmd(MockEnvironment::getInstance()->getNumNodes());
|
26
|
+
doMockTxn(clearCmd);
|
27
|
+
MockUnitTest::TearDown();
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
struct EerrsCookie {
|
32
|
+
lcb_error_t rc;
|
33
|
+
bool called;
|
34
|
+
char *err_ref;
|
35
|
+
char *err_ctx;
|
36
|
+
|
37
|
+
void reset() {
|
38
|
+
rc = LCB_SUCCESS;
|
39
|
+
called = false;
|
40
|
+
free(err_ref);
|
41
|
+
err_ref = NULL;
|
42
|
+
free(err_ctx);
|
43
|
+
err_ctx = NULL;
|
44
|
+
}
|
45
|
+
EerrsCookie() : rc(LCB_SUCCESS), called(false), err_ref(NULL), err_ctx(NULL) {
|
46
|
+
}
|
47
|
+
|
48
|
+
~EerrsCookie() {
|
49
|
+
free(err_ref);
|
50
|
+
free(err_ctx);
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
extern "C" {
|
55
|
+
static void opcb(lcb_t, int cbtype, const lcb_RESPBASE* rb) {
|
56
|
+
EerrsCookie *cookie = reinterpret_cast<EerrsCookie*>(rb->cookie);
|
57
|
+
cookie->called = true;
|
58
|
+
cookie->rc = rb->rc;
|
59
|
+
|
60
|
+
const char *ref = lcb_resp_get_error_ref(cbtype, rb);
|
61
|
+
if (ref != NULL) {
|
62
|
+
cookie->err_ref = strdup(ref);
|
63
|
+
}
|
64
|
+
|
65
|
+
const char *ctx = lcb_resp_get_error_context(cbtype, rb);
|
66
|
+
if (ctx != NULL) {
|
67
|
+
cookie->err_ctx = strdup(ctx);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
TEST_F(EerrsUnitTest, testInCallbackWhenEnabled) {
|
73
|
+
SKIP_UNLESS_MOCK();
|
74
|
+
HandleWrap hw;
|
75
|
+
lcb_t instance;
|
76
|
+
|
77
|
+
enableEnhancedErrors();
|
78
|
+
createEerrConnection(hw, instance);
|
79
|
+
lcb_install_callback3(instance, LCB_CALLBACK_DEFAULT, opcb);
|
80
|
+
|
81
|
+
EerrsCookie cookie;
|
82
|
+
|
83
|
+
std::string key("hello");
|
84
|
+
lcb_CMDGET cmd = { 0 };
|
85
|
+
LCB_CMD_SET_KEY(&cmd, key.c_str(), key.size());
|
86
|
+
cmd.lock = 10;
|
87
|
+
lcb_get3(instance, &cookie, &cmd);
|
88
|
+
|
89
|
+
lcb_wait(instance);
|
90
|
+
ASSERT_TRUE(cookie.called);
|
91
|
+
ASSERT_EQ(LCB_KEY_ENOENT, cookie.rc);
|
92
|
+
ASSERT_NE((char *)NULL, cookie.err_ref);
|
93
|
+
ASSERT_EQ(36, strlen(cookie.err_ref)); // java.util.UUID generates 36-bytes long strings
|
94
|
+
ASSERT_STREQ("Failed to lookup item", cookie.err_ctx);
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
TEST_F(EerrsUnitTest, testInCallbackWhenDisabled) {
|
99
|
+
SKIP_UNLESS_MOCK();
|
100
|
+
HandleWrap hw;
|
101
|
+
lcb_t instance;
|
102
|
+
|
103
|
+
disableEnhancedErrors();
|
104
|
+
createEerrConnection(hw, instance);
|
105
|
+
lcb_install_callback3(instance, LCB_CALLBACK_DEFAULT, opcb);
|
106
|
+
|
107
|
+
EerrsCookie cookie;
|
108
|
+
|
109
|
+
std::string key("hello");
|
110
|
+
lcb_CMDGET cmd = { 0 };
|
111
|
+
LCB_CMD_SET_KEY(&cmd, key.c_str(), key.size());
|
112
|
+
cmd.lock = 10;
|
113
|
+
lcb_get3(instance, &cookie, &cmd);
|
114
|
+
|
115
|
+
lcb_wait(instance);
|
116
|
+
ASSERT_TRUE(cookie.called);
|
117
|
+
ASSERT_EQ((char *)NULL, cookie.err_ref);
|
118
|
+
ASSERT_EQ((char *)NULL, cookie.err_ctx);
|
119
|
+
}
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#include "config.h"
|
2
|
+
#include "iotests.h"
|
3
|
+
#include "internal.h"
|
4
|
+
#include <map>
|
5
|
+
|
6
|
+
class ErrmapUnitTest : public MockUnitTest {
|
7
|
+
protected:
|
8
|
+
virtual void createErrmapConnection(HandleWrap& hw, lcb_t& instance) {
|
9
|
+
MockEnvironment::getInstance()->createConnection(hw, instance);
|
10
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_cntl_string(instance, "enable_errmap", "true"));
|
11
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_connect(instance));
|
12
|
+
lcb_wait(instance);
|
13
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_get_bootstrap_status(instance));
|
14
|
+
}
|
15
|
+
|
16
|
+
void checkRetryVerify(uint16_t errcode);
|
17
|
+
|
18
|
+
void TearDown() {
|
19
|
+
MockOpFailClearCommand clearCmd(MockEnvironment::getInstance()->getNumNodes());
|
20
|
+
doMockTxn(clearCmd);
|
21
|
+
MockUnitTest::TearDown();
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
struct ResultCookie {
|
26
|
+
lcb_error_t rc;
|
27
|
+
bool called;
|
28
|
+
|
29
|
+
void reset() {
|
30
|
+
rc = LCB_SUCCESS;
|
31
|
+
called = false;
|
32
|
+
}
|
33
|
+
ResultCookie() : rc(LCB_SUCCESS), called(false) {
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
extern "C" {
|
38
|
+
static void opcb(lcb_t,int,const lcb_RESPBASE* rb) {
|
39
|
+
ResultCookie *cookie = reinterpret_cast<ResultCookie*>(rb->cookie);
|
40
|
+
cookie->called = true;
|
41
|
+
cookie->rc = rb->rc;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
TEST_F(ErrmapUnitTest, hasRecognizedErrors) {
|
46
|
+
SKIP_UNLESS_MOCK();
|
47
|
+
HandleWrap hw;
|
48
|
+
lcb_t instance;
|
49
|
+
|
50
|
+
createErrmapConnection(hw, instance);
|
51
|
+
|
52
|
+
// Test the actual error map..
|
53
|
+
using namespace lcb;
|
54
|
+
const errmap::ErrorMap& em = *instance->settings->errmap;
|
55
|
+
const errmap::Error& err = em.getError(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT);
|
56
|
+
ASSERT_TRUE(err.isValid());
|
57
|
+
ASSERT_TRUE(err.hasAttribute(errmap::CONSTRAINT_FAILURE));
|
58
|
+
}
|
59
|
+
|
60
|
+
TEST_F(ErrmapUnitTest, closesOnUnrecognizedError) {
|
61
|
+
// For now, EINTERNAL is an error code we don't know!
|
62
|
+
SKIP_UNLESS_MOCK();
|
63
|
+
HandleWrap hw;
|
64
|
+
lcb_t instance;
|
65
|
+
createErrmapConnection(hw, instance);
|
66
|
+
|
67
|
+
const char *key = "key";
|
68
|
+
lcb_CMDSTORE scmd = { 0 };
|
69
|
+
LCB_CMD_SET_KEY(&scmd, key, strlen(key));
|
70
|
+
LCB_CMD_SET_VALUE(&scmd, "val", 3);
|
71
|
+
|
72
|
+
ResultCookie cookie;
|
73
|
+
lcb_install_callback3(instance, LCB_CALLBACK_STORE, opcb);
|
74
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_store3(instance, &cookie, &scmd));
|
75
|
+
lcb_wait(instance);
|
76
|
+
ASSERT_EQ(LCB_SUCCESS, cookie.rc);
|
77
|
+
|
78
|
+
MockCommand cmd(MockCommand::OPFAIL);
|
79
|
+
|
80
|
+
// Determine the server
|
81
|
+
int srvix = instance->map_key(key);
|
82
|
+
|
83
|
+
cmd.set("server", srvix);
|
84
|
+
cmd.set("code", PROTOCOL_BINARY_RESPONSE_EINTERNAL); // Invalidate the connection!
|
85
|
+
cmd.set("count", 1);
|
86
|
+
doMockTxn(cmd);
|
87
|
+
|
88
|
+
cookie.reset();
|
89
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_store3(instance, &cookie, &scmd));
|
90
|
+
lcb_wait(instance);
|
91
|
+
|
92
|
+
ASSERT_TRUE(cookie.called);
|
93
|
+
ASSERT_NE(LCB_SUCCESS, cookie.rc);
|
94
|
+
|
95
|
+
cookie.reset();
|
96
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_store3(instance, &cookie, &scmd));
|
97
|
+
lcb_wait(instance);
|
98
|
+
ASSERT_TRUE(cookie.called);
|
99
|
+
|
100
|
+
// Note, we can't determine what the actual error here is. It would be nice
|
101
|
+
// if we were able to reconnect and retry the other commands, but right now
|
102
|
+
// detecting a failed connection is better than having no detection at all:
|
103
|
+
//
|
104
|
+
// ASSERT_EQ(LCB_SUCCESS, cookie.rc);
|
105
|
+
}
|
106
|
+
|
107
|
+
void ErrmapUnitTest::checkRetryVerify(uint16_t errcode) {
|
108
|
+
HandleWrap hw;
|
109
|
+
lcb_t instance;
|
110
|
+
createErrmapConnection(hw, instance);
|
111
|
+
lcb_install_callback3(instance, LCB_CALLBACK_DEFAULT, opcb);
|
112
|
+
|
113
|
+
ResultCookie cookie;
|
114
|
+
|
115
|
+
std::string key("hello");
|
116
|
+
lcb_CMDSTORE scmd = { 0 };
|
117
|
+
LCB_CMD_SET_KEY(&scmd, key.c_str(), key.size());
|
118
|
+
LCB_CMD_SET_VALUE(&scmd, "Val", 3);
|
119
|
+
|
120
|
+
// Store the item once to ensure the server is actually connected
|
121
|
+
// (we don't want opfail to be active during negotiation).
|
122
|
+
lcb_store3(instance, &cookie, &scmd);
|
123
|
+
lcb_wait(instance);
|
124
|
+
ASSERT_TRUE(cookie.called);
|
125
|
+
ASSERT_EQ(LCB_SUCCESS, cookie.rc);
|
126
|
+
|
127
|
+
// Figure out the server this key belongs to.
|
128
|
+
int srvix = instance->map_key(key);
|
129
|
+
|
130
|
+
MockCommand cmd(MockCommand::START_RETRY_VERIFY);
|
131
|
+
cmd.set("idx", srvix);
|
132
|
+
cmd.set("bucket", instance->get_bucketname());
|
133
|
+
doMockTxn(cmd);
|
134
|
+
|
135
|
+
// Set up opfail
|
136
|
+
MockOpfailCommand failCmd(errcode, srvix, -1, instance->get_bucketname());
|
137
|
+
doMockTxn(failCmd);
|
138
|
+
|
139
|
+
// Run the command!
|
140
|
+
cookie.reset();
|
141
|
+
lcb_error_t rc = lcb_store3(instance, &cookie, &scmd);
|
142
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
143
|
+
lcb_wait(instance);
|
144
|
+
|
145
|
+
ASSERT_TRUE(cookie.called);
|
146
|
+
ASSERT_EQ(LCB_GENERIC_TMPERR, cookie.rc);
|
147
|
+
|
148
|
+
// Check that we executed correctly:
|
149
|
+
MockBucketCommand verifyCmd(MockCommand::CHECK_RETRY_VERIFY, srvix, instance->get_bucketname());
|
150
|
+
verifyCmd.set("opcode", PROTOCOL_BINARY_CMD_SET);
|
151
|
+
verifyCmd.set("errcode", errcode);
|
152
|
+
#ifdef __APPLE__
|
153
|
+
// FIXME: on Jenkins OSX actual expected time does not match actual and mock raises exception like following:
|
154
|
+
// VerificationException: Not enough/too many retries. Last TS=1498594892704. Last expected=1498594892728. Diff=24. MaxDiff=20
|
155
|
+
verifyCmd.set("fuzz_ms", 25);
|
156
|
+
#else
|
157
|
+
verifyCmd.set("fuzz_ms", 20);
|
158
|
+
#endif
|
159
|
+
doMockTxn(verifyCmd);
|
160
|
+
}
|
161
|
+
|
162
|
+
static const uint16_t ERRCODE_CONSTANT = 0x7ff0;
|
163
|
+
static const uint16_t ERRCODE_LINEAR = 0x7ff1;
|
164
|
+
static const uint16_t ERRCODE_EXPONENTIAL = 0x7ff2;
|
165
|
+
|
166
|
+
TEST_F(ErrmapUnitTest, retrySpecConstant) {
|
167
|
+
SKIP_UNLESS_MOCK();
|
168
|
+
checkRetryVerify(ERRCODE_CONSTANT);
|
169
|
+
}
|
170
|
+
|
171
|
+
TEST_F(ErrmapUnitTest, retrySpecLinear) {
|
172
|
+
SKIP_UNLESS_MOCK();
|
173
|
+
checkRetryVerify(ERRCODE_LINEAR);
|
174
|
+
}
|
175
|
+
|
176
|
+
TEST_F(ErrmapUnitTest, retrySpecExponential) {
|
177
|
+
checkRetryVerify(ERRCODE_EXPONENTIAL);
|
178
|
+
}
|
@@ -293,7 +293,7 @@ TEST_F(MockUnitTest, testGetHostInfo)
|
|
293
293
|
map<string,bool> smap;
|
294
294
|
|
295
295
|
// Ensure we only get unique nodes
|
296
|
-
for (
|
296
|
+
for (lcb_S32 ii = 0; ii < lcb_get_num_nodes(instance); ii++) {
|
297
297
|
const char *cur = lcb_get_node(instance, LCB_NODE_DATA, ii);
|
298
298
|
ASSERT_FALSE(cur == NULL);
|
299
299
|
ASSERT_FALSE(smap[cur]);
|
@@ -435,7 +435,7 @@ TEST_F(MockUnitTest, testCtls)
|
|
435
435
|
lcbvb_CONFIG *cfg = ctlGet<lcbvb_CONFIG*>(instance, LCB_CNTL_VBCONFIG);
|
436
436
|
// Do we have a way to verify this?
|
437
437
|
ASSERT_FALSE(cfg == NULL);
|
438
|
-
ASSERT_GT(cfg->nsrv, 0);
|
438
|
+
ASSERT_GT(cfg->nsrv, (unsigned int)0);
|
439
439
|
|
440
440
|
lcb_io_opt_t io = ctlGet<lcb_io_opt_t>(instance, LCB_CNTL_IOPS);
|
441
441
|
ASSERT_TRUE(io == instance->getIOT()->p);
|
@@ -517,7 +517,7 @@ TEST_F(MockUnitTest, testCtls)
|
|
517
517
|
|
518
518
|
ctlGetSet<int>(instance, LCB_CNTL_DETAILED_ERRCODES, 1);
|
519
519
|
ctlGetSet<lcb_U32>(instance, LCB_CNTL_RETRY_INTERVAL, UINT_MAX);
|
520
|
-
ctlGetSet<float>(instance, LCB_CNTL_RETRY_BACKOFF, 3.4);
|
520
|
+
ctlGetSet<float>(instance, LCB_CNTL_RETRY_BACKOFF, (float)3.4);
|
521
521
|
ctlGetSet<lcb_SIZE>(instance, LCB_CNTL_HTTP_POOLSIZE, UINT_MAX);
|
522
522
|
ctlGetSet<int>(instance, LCB_CNTL_HTTP_REFRESH_CONFIG_ON_ERROR, 0);
|
523
523
|
|
@@ -506,7 +506,7 @@ TEST_F(MockUnitTest, testSaslMechs)
|
|
506
506
|
doLcbCreate(&instance, &crParams, protectedEnv);
|
507
507
|
|
508
508
|
// Make the socket pool disallow idle connections
|
509
|
-
instance->memd_sockpool->maxidle = 0;
|
509
|
+
instance->memd_sockpool->get_options().maxidle = 0;
|
510
510
|
|
511
511
|
err = lcb_connect(instance);
|
512
512
|
ASSERT_EQ(LCB_SUCCESS, err);
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
namespace std {
|
24
24
|
inline ostream& operator<<(ostream& os, const lcb_error_t& rc) {
|
25
|
-
os << "LcbError<";
|
25
|
+
os << "LcbError <0x";
|
26
26
|
os << std::hex << static_cast<unsigned>(rc);
|
27
27
|
os << " (";
|
28
28
|
os << lcb_strerror(NULL, rc);
|
@@ -300,7 +300,6 @@ TEST_F(SubdocUnitTest, testSdGetExists)
|
|
300
300
|
CREATE_SUBDOC_CONNECTION(hw, instance);
|
301
301
|
|
302
302
|
MultiResult res;
|
303
|
-
lcb_error_t rc;
|
304
303
|
lcb_SDSPEC spec = { 0 };
|
305
304
|
lcb_CMDSUBDOC cmd = { 0 };
|
306
305
|
LCB_CMD_SET_KEY(&cmd, key.c_str(), key.size());
|
@@ -403,7 +402,6 @@ TEST_F(SubdocUnitTest, testSdStore)
|
|
403
402
|
{
|
404
403
|
HandleWrap hw;
|
405
404
|
lcb_t instance;
|
406
|
-
lcb_error_t rc;
|
407
405
|
CREATE_SUBDOC_CONNECTION(hw, instance);
|
408
406
|
lcb_CMDSUBDOC cmd = { 0 };
|
409
407
|
lcb_SDSPEC spec = { 0 };
|
@@ -495,7 +493,7 @@ TEST_F(SubdocUnitTest, testMkdoc) {
|
|
495
493
|
HandleWrap hw;
|
496
494
|
lcb_t instance;
|
497
495
|
lcb_CMDSUBDOC cmd = { 0 };
|
498
|
-
lcb_SDSPEC spec = {
|
496
|
+
lcb_SDSPEC spec[2] = {{0}};
|
499
497
|
MultiResult res;
|
500
498
|
|
501
499
|
CREATE_SUBDOC_CONNECTION(hw, instance);
|
@@ -504,16 +502,27 @@ TEST_F(SubdocUnitTest, testMkdoc) {
|
|
504
502
|
removeKey(instance, key);
|
505
503
|
|
506
504
|
LCB_CMD_SET_KEY(&cmd, key.c_str(), key.size());
|
507
|
-
cmd.specs =
|
505
|
+
cmd.specs = spec;
|
508
506
|
cmd.nspecs = 1;
|
507
|
+
cmd.cmdflags = LCB_CMDSUBDOC_F_UPSERT_DOC;
|
509
508
|
|
510
|
-
LCB_SDSPEC_SET_PATH(&spec, "pth", 3);
|
511
|
-
LCB_SDSPEC_SET_VALUE(&spec, "123", 3);
|
512
|
-
spec.
|
513
|
-
spec.sdcmd = LCB_SDCMD_DICT_UPSERT;
|
509
|
+
LCB_SDSPEC_SET_PATH(&spec[0], "pth", 3);
|
510
|
+
LCB_SDSPEC_SET_VALUE(&spec[0], "123", 3);
|
511
|
+
spec[0].sdcmd = LCB_SDCMD_DICT_UPSERT;
|
514
512
|
|
515
513
|
ASSERT_EQ(LCB_SUCCESS, schedwait(instance, &res, &cmd, lcb_subdoc3));
|
514
|
+
|
516
515
|
ASSERT_PATHVAL_EQ("123", instance, key, "pth");
|
516
|
+
|
517
|
+
removeKey(instance, key);
|
518
|
+
LCB_SDSPEC_SET_PATH(&spec[1], "pth2", 4);
|
519
|
+
LCB_SDSPEC_SET_VALUE(&spec[1], "456", 3);
|
520
|
+
spec[1].sdcmd = LCB_SDCMD_DICT_UPSERT;
|
521
|
+
cmd.nspecs = 2;
|
522
|
+
ASSERT_EQ(LCB_SUCCESS, schedwait(instance, &res, &cmd, lcb_subdoc3));
|
523
|
+
|
524
|
+
ASSERT_PATHVAL_EQ("123", instance, key, "pth");
|
525
|
+
ASSERT_PATHVAL_EQ("456", instance, key, "pth2");
|
517
526
|
}
|
518
527
|
|
519
528
|
TEST_F(SubdocUnitTest, testUnique)
|
@@ -572,7 +581,6 @@ TEST_F(SubdocUnitTest, testCounter)
|
|
572
581
|
lcb_t instance;
|
573
582
|
lcb_CMDSUBDOC cmd = { 0 };
|
574
583
|
lcb_SDSPEC spec = { 0 };
|
575
|
-
lcb_error_t rc;
|
576
584
|
MultiResult res;
|
577
585
|
|
578
586
|
CREATE_SUBDOC_CONNECTION(hw, instance);
|
@@ -788,7 +796,6 @@ TEST_F(SubdocUnitTest, testGetCount) {
|
|
788
796
|
lcb_t instance;
|
789
797
|
lcb_CMDSUBDOC cmd = { 0 };
|
790
798
|
lcb_SDSPEC spec = { 0 };
|
791
|
-
lcb_error_t rc;
|
792
799
|
MultiResult mres;
|
793
800
|
|
794
801
|
CREATE_SUBDOC_CONNECTION(hw, instance);
|
@@ -223,15 +223,16 @@ TEST_F(McAlloc, testValueAlloc)
|
|
223
223
|
mcreq_release_packet(pipeline, packet);
|
224
224
|
}
|
225
225
|
|
226
|
-
struct ExtraCookie {
|
227
|
-
mc_REQDATAEX base;
|
226
|
+
struct ExtraCookie : mc_REQDATAEX {
|
228
227
|
int remaining;
|
228
|
+
ExtraCookie(const mc_REQDATAPROCS& procs_)
|
229
|
+
: mc_REQDATAEX(NULL, procs_, 0), remaining(0) {
|
230
|
+
}
|
229
231
|
};
|
230
232
|
|
231
233
|
extern "C" {
|
232
234
|
static void pkt_dtor(mc_PACKET *pkt) {
|
233
|
-
|
234
|
-
ExtraCookie *ec = (ExtraCookie *)rd;
|
235
|
+
ExtraCookie *ec = static_cast<ExtraCookie*>(pkt->u_rdata.exdata);
|
235
236
|
ec->remaining--;
|
236
237
|
}
|
237
238
|
}
|
@@ -240,18 +241,17 @@ TEST_F(McAlloc, testRdataExDtor)
|
|
240
241
|
{
|
241
242
|
CQWrap q;
|
242
243
|
lcb_CMDBASE basecmd;
|
243
|
-
|
244
|
+
const static mc_REQDATAPROCS procs = { NULL, pkt_dtor };
|
244
245
|
protocol_binary_request_header hdr;
|
245
246
|
|
246
247
|
memset(&hdr, 0, sizeof hdr);
|
247
248
|
memset(&basecmd, 0, sizeof basecmd);
|
248
|
-
memset(&ec, 0, sizeof ec);
|
249
249
|
|
250
|
-
mc_REQDATAPROCS procs = { NULL, pkt_dtor };
|
251
|
-
ec.base.procs = &procs;
|
252
250
|
basecmd.key.contig.bytes = "foo";
|
253
251
|
basecmd.key.contig.nbytes = 3;
|
254
252
|
|
253
|
+
ExtraCookie ec(procs);
|
254
|
+
|
255
255
|
mcreq_sched_enter(&q);
|
256
256
|
for (unsigned ii = 0; ii < 5; ii++) {
|
257
257
|
lcb_error_t err;
|
@@ -260,7 +260,7 @@ TEST_F(McAlloc, testRdataExDtor)
|
|
260
260
|
err = mcreq_basic_packet(&q, &basecmd, &hdr, 0, &pkt, &pl, 0);
|
261
261
|
ASSERT_EQ(LCB_SUCCESS, err);
|
262
262
|
pkt->flags |= MCREQ_F_REQEXT;
|
263
|
-
pkt->u_rdata.exdata = &ec
|
263
|
+
pkt->u_rdata.exdata = &ec;
|
264
264
|
mcreq_sched_add(pl, pkt);
|
265
265
|
ec.remaining++;
|
266
266
|
}
|