Skip to content

Commit 55f3119

Browse files
committed
fix failing test testScheduleQueryBeforeConnection
Change-Id: Iaf474c17ee17562f121c3545da2bdde7e4b29b78 Reviewed-on: https://review.couchbase.org/c/libcouchbase/+/195267 Reviewed-by: Mateusz <matt.wozakowski@couchbase.com> Reviewed-by: Dimitris Christodoulou <dimitris.christodoulou@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
1 parent 2df2c58 commit 55f3119

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

tests/iotests/t_sched.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,11 @@ TEST_F(SchedUnitTests, testScheduleQueryBeforeConnection)
318318

319319
lcb_CMDQUERY *cmd;
320320
lcb_cmdquery_create(&cmd);
321-
std::string statement("SELECT 'hello' AS greeting");
321+
322+
// the statement must be valid, and always return success, otherwise the library might try to refresh config, which
323+
// will interfere with has_pending() check
324+
std::string statement =
325+
MockEnvironment::getInstance()->isRealCluster() ? "SELECT 'hello' AS greeting" : "SELECT mockrow";
322326
lcb_cmdquery_statement(cmd, statement.c_str(), statement.size());
323327
lcb_cmdquery_callback(cmd, queryCallback);
324328
size_t counter = 0;
@@ -333,11 +337,7 @@ TEST_F(SchedUnitTests, testScheduleQueryBeforeConnection)
333337
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_get_bootstrap_status(instance));
334338
ASSERT_FALSE(instance->has_deferred_operations());
335339
ASSERT_FALSE(hasPendingOps(instance));
336-
if (MockEnvironment::getInstance()->isRealCluster()) {
337-
ASSERT_EQ(2, counter); /* single row + meta */
338-
} else {
339-
ASSERT_EQ(1, counter); /* reduced implementation */
340-
}
340+
ASSERT_EQ(2, counter); /* single row + meta */
341341
}
342342

343343
static void searchCallback(lcb_INSTANCE *, int, const lcb_RESPSEARCH *resp)
@@ -434,6 +434,10 @@ TEST_F(SchedUnitTests, testScheduleViewBeforeConnection)
434434

435435
MockEnvironment::getInstance()->createConnection(hw, &instance);
436436

437+
/* disable config refresh after http failure to make pending request check more predictable */
438+
int enable = 0;
439+
lcb_cntl(instance, LCB_CNTL_SET, LCB_CNTL_HTTP_REFRESH_CONFIG_ON_ERROR, &enable);
440+
437441
lcb_CMDVIEW *cmd;
438442
lcb_cmdview_create(&cmd);
439443
std::string design_document("does_not_exist");

0 commit comments

Comments
 (0)