Skip to content

Commit db7187e

Browse files
committed
Fix tests on 7.6 server
Change-Id: I911539e6dc0592ba5cc748aaa116322365b11e6a Reviewed-on: https://review.couchbase.org/c/libcouchbase/+/216944 Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com> Tested-by: Build Bot <build@couchbase.com>
1 parent 5cc3e4e commit db7187e

9 files changed

Lines changed: 34 additions & 7 deletions

File tree

include/libcouchbase/error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ X(LCB_ERR_SUBDOC_XATTR_INVALID_KEY_COMBO, 326, LCB_ERROR_TYPE_KEYV
119119
X(LCB_ERR_SUBDOC_XATTR_UNKNOWN_VIRTUAL_ATTRIBUTE, 327, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR unknown virtual attribute") \
120120
X(LCB_ERR_SUBDOC_XATTR_CANNOT_MODIFY_VIRTUAL_ATTRIBUTE, 328, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR cannot modify virtual attribute") \
121121
X(LCB_ERR_SUBDOC_XATTR_INVALID_ORDER, 329, LCB_ERROR_TYPE_KEYVALUE, LCB_ERROR_FLAG_SUBDOC | LCB_ERROR_FLAG_INPUT, "Subdoc: XATTR invalid order") \
122+
X(LCB_ERR_DOCUMENT_NOT_LOCKED, 330, LCB_ERROR_TYPE_KEYVALUE, 0, "Document is not locked") \
122123
\
123124
/* Query Error Definitions */ \
124125
X(LCB_ERR_PLANNING_FAILURE, 401, LCB_ERROR_TYPE_QUERY, 0, "Planning failed") \

include/memcached/protocol_binary.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ typedef enum {
113113
/** The requested resource is locked */
114114
PROTOCOL_BINARY_RESPONSE_LOCKED = 0x09,
115115

116+
/** The requested resource is not locked */
117+
PROTOCOL_BINARY_RESPONSE_NOT_LOCKED = 0x0e,
116118
/** The node cannot execute operation, because the bucket is in config-only mode */
117119
PROTOCOL_BINARY_RESPONSE_CONFIG_ONLY = 0x0d,
118120

src/handler.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ lcb_STATUS lcb_map_error(lcb_INSTANCE *instance, int in)
157157
return LCB_ERR_DURABILITY_AMBIGUOUS;
158158
case PROTOCOL_BINARY_RESPONSE_LOCKED:
159159
return LCB_ERR_DOCUMENT_LOCKED;
160+
case PROTOCOL_BINARY_RESPONSE_NOT_LOCKED:
161+
return LCB_ERR_DOCUMENT_NOT_LOCKED;
160162
case PROTOCOL_BINARY_RATE_LIMITED_NETWORK_INGRESS:
161163
case PROTOCOL_BINARY_RATE_LIMITED_NETWORK_EGRESS:
162164
case PROTOCOL_BINARY_RATE_LIMITED_MAX_CONNECTIONS:

tests/iotests/mock-environment.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ static void statsCallback(lcb_INSTANCE *instance, lcb_CALLBACK_TYPE, const lcb_R
433433
case 2:
434434
version = MockEnvironment::VERSION_72;
435435
break;
436+
case 6:
437+
version = MockEnvironment::VERSION_76;
438+
break;
436439
default:
437440
break;
438441
}

tests/iotests/mock-environment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class MockEnvironment : public ::testing::Environment
249249
VERSION_70 = 13,
250250
VERSION_71 = 14,
251251
VERSION_72 = 15,
252+
VERSION_76 = 16,
252253
};
253254

254255
void SetUp() override;

tests/iotests/t_lock.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ TEST_F(LockUnitTest, testUnlockMissingCas)
183183

184184
lcb_cmdunlock_destroy(cmd);
185185
lcb_wait(instance, LCB_WAIT_DEFAULT);
186-
if (CLUSTER_VERSION_IS_HIGHER_THAN(MockEnvironment::VERSION_50)) {
186+
if (CLUSTER_VERSION_IS_HIGHER_THAN(MockEnvironment::VERSION_76)) {
187+
ASSERT_EQ(LCB_ERR_DOCUMENT_NOT_LOCKED, reserr);
188+
} else if (CLUSTER_VERSION_IS_HIGHER_THAN(MockEnvironment::VERSION_50)) {
187189
ASSERT_EQ(LCB_ERR_TEMPORARY_FAILURE, reserr);
188190
} else {
189191
if (MockEnvironment::getInstance()->isRealCluster()) {

tests/iotests/t_ratelimit.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ TEST_F(RateLimitTest, testRateLimitsQueryNumQueries)
246246
{
247247
SKIP_IF_MOCK()
248248
SKIP_IF_CLUSTER_VERSION_IS_LOWER_THAN(MockEnvironment::VERSION_71)
249+
SKIP_IF_CLUSTER_VERSION_IS_HIGHER_THAN(MockEnvironment::VERSION_72)
249250
HandleWrap hw;
250251
lcb_INSTANCE *instance;
251252
createConnection(hw, &instance);
@@ -291,6 +292,7 @@ TEST_F(RateLimitTest, testRateLimitsQueryEgress)
291292
{
292293
SKIP_IF_MOCK()
293294
SKIP_IF_CLUSTER_VERSION_IS_LOWER_THAN(MockEnvironment::VERSION_71)
295+
SKIP_IF_CLUSTER_VERSION_IS_HIGHER_THAN(MockEnvironment::VERSION_72)
294296
HandleWrap hw;
295297
lcb_INSTANCE *instance;
296298
createConnection(hw, &instance);
@@ -343,6 +345,7 @@ TEST_F(RateLimitTest, testRateLimitsQueryIngress)
343345
{
344346
SKIP_IF_MOCK()
345347
SKIP_IF_CLUSTER_VERSION_IS_LOWER_THAN(MockEnvironment::VERSION_71)
348+
SKIP_IF_CLUSTER_VERSION_IS_HIGHER_THAN(MockEnvironment::VERSION_72)
346349
HandleWrap hw;
347350
lcb_INSTANCE *instance;
348351
createConnection(hw, &instance);
@@ -393,6 +396,7 @@ TEST_F(RateLimitTest, testRateLimitsQueryConcurrentRequests)
393396
{
394397
SKIP_IF_MOCK()
395398
SKIP_IF_CLUSTER_VERSION_IS_LOWER_THAN(MockEnvironment::VERSION_71)
399+
SKIP_IF_CLUSTER_VERSION_IS_HIGHER_THAN(MockEnvironment::VERSION_72)
396400
HandleWrap hw;
397401
lcb_INSTANCE *instance;
398402
createConnection(hw, &instance);

tests/iotests/t_views.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ static void bktCreateCb(lcb_INSTANCE *, int, const lcb_RESPHTTP *resp)
4141
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_resphttp_status(resp));
4242
uint16_t status;
4343
lcb_resphttp_http_status(resp, &status);
44+
const char *body = nullptr;
45+
std::size_t body_len = 0;
46+
lcb_resphttp_body(resp, &body, &body_len);
47+
fprintf(stderr, "-----\n\n%d\n%.*s\n\n-----\n", (int)status, (int)body_len, body);
4448
ASSERT_TRUE(status > 199 && status < 300);
4549
}
4650
}
@@ -107,6 +111,7 @@ void ViewsUnitTest::connectBeerSample(HandleWrap &hw, lcb_INSTANCE **instance, b
107111
lcb_wait(*instance, LCB_WAIT_DEFAULT);
108112
hw.destroy();
109113

114+
sleep(5);
110115
// Now it should all be good, so we can call recursively..
111116
connectBeerSample(hw, instance, false);
112117
}

tests/iotests/testutil.cc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,11 @@ std::ostream &operator<<(std::ostream &out, const Item &item)
248248

249249
struct http_result {
250250
lcb_STATUS rc{LCB_SUCCESS};
251-
uint16_t status{0};
251+
std::uint16_t status{0};
252252
std::string path{};
253253
std::string body{};
254254
std::map<std::string, std::string> headers{};
255+
std::uint16_t expected_status{200};
255256
};
256257

257258
struct manifest_result {
@@ -290,7 +291,9 @@ static void http_callback(lcb_INSTANCE * /* instance */, int /* cbtype */, const
290291
}
291292
}
292293

293-
EXPECT_EQ(200, result->status) << result->path << ": " << result->body;
294+
if (result->expected_status > 0) {
295+
EXPECT_EQ(result->expected_status, result->status) << result->path << ": " << result->body;
296+
}
294297
}
295298

296299
static void get_manifest_callback(lcb_INSTANCE *, int, const lcb_RESPGETMANIFEST *resp)
@@ -348,7 +351,7 @@ static void wait_for_manifest_uid(lcb_INSTANCE *instance, std::uint64_t uid)
348351

349352
void create_scope(lcb_INSTANCE *instance, const std::string &scope, bool wait)
350353
{
351-
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
354+
auto *old_http_callback = lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
352355

353356
lcb_CMDHTTP *cmd;
354357
std::string path = "/pools/default/buckets/" + MockEnvironment::getInstance()->getBucket() + "/scopes";
@@ -374,11 +377,12 @@ void create_scope(lcb_INSTANCE *instance, const std::string &scope, bool wait)
374377
if (wait) {
375378
wait_for_manifest_uid(instance, uid);
376379
}
380+
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
377381
}
378382

379383
void create_collection(lcb_INSTANCE *instance, const std::string &scope, const std::string &collection, bool wait)
380384
{
381-
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
385+
auto *old_http_callback = lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
382386

383387
lcb_CMDHTTP *cmd;
384388
std::string path =
@@ -406,11 +410,12 @@ void create_collection(lcb_INSTANCE *instance, const std::string &scope, const s
406410
if (wait) {
407411
wait_for_manifest_uid(instance, uid);
408412
}
413+
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
409414
}
410415

411416
void drop_scope(lcb_INSTANCE *instance, const std::string &scope, bool wait)
412417
{
413-
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
418+
auto *old_http_callback = lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
414419

415420
lcb_CMDHTTP *cmd;
416421
std::string path = "/pools/default/buckets/default/scopes/" + scope;
@@ -433,11 +438,12 @@ void drop_scope(lcb_INSTANCE *instance, const std::string &scope, bool wait)
433438
if (wait) {
434439
wait_for_manifest_uid(instance, uid);
435440
}
441+
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
436442
}
437443

438444
void drop_collection(lcb_INSTANCE *instance, const std::string &scope, const std::string &collection, bool wait)
439445
{
440-
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
446+
auto *old_http_callback = lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
441447

442448
lcb_CMDHTTP *cmd;
443449
std::string path = "/pools/default/buckets/default/scopes/" + scope + "/collections/" + collection;
@@ -460,6 +466,7 @@ void drop_collection(lcb_INSTANCE *instance, const std::string &scope, const std
460466
if (wait) {
461467
wait_for_manifest_uid(instance, uid);
462468
}
469+
(void)lcb_install_callback(instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
463470
}
464471

465472
std::string unique_name(const std::string &prefix)

0 commit comments

Comments
 (0)