couchbase 4.2.5-dev.3 → 4.2.6-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +81 -9
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +9 -1
  3. package/deps/couchbase-cxx-client/bin/api.rb +234 -0
  4. package/deps/couchbase-cxx-client/bin/create-search-index +18 -135
  5. package/deps/couchbase-cxx-client/bin/init-cluster +17 -139
  6. package/deps/couchbase-cxx-client/bin/load-sample-buckets +54 -0
  7. package/deps/couchbase-cxx-client/core/cluster.hxx +33 -12
  8. package/deps/couchbase-cxx-client/core/cluster_options.hxx +3 -0
  9. package/deps/couchbase-cxx-client/core/crud_component.cxx +51 -22
  10. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +115 -50
  11. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +6 -0
  12. package/deps/couchbase-cxx-client/core/impl/create_bucket.cxx +155 -0
  13. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +172 -59
  14. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +2 -1
  15. package/deps/couchbase-cxx-client/core/impl/drop_bucket.cxx +66 -0
  16. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +138 -59
  17. package/deps/couchbase-cxx-client/core/impl/flush_bucket.cxx +66 -0
  18. package/deps/couchbase-cxx-client/core/impl/get_all_buckets.cxx +163 -0
  19. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +67 -37
  20. package/deps/couchbase-cxx-client/core/impl/get_bucket.cxx +153 -0
  21. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.cxx +113 -0
  22. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.hxx +60 -0
  23. package/deps/couchbase-cxx-client/core/impl/key_value_error_category.cxx +2 -4
  24. package/deps/couchbase-cxx-client/core/impl/manager_error_context.cxx +100 -0
  25. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  26. package/deps/couchbase-cxx-client/core/impl/update_bucket.cxx +130 -0
  27. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +53 -29
  28. package/deps/couchbase-cxx-client/core/io/dns_client.cxx +71 -38
  29. package/deps/couchbase-cxx-client/core/io/dns_config.cxx +5 -4
  30. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +5 -6
  31. package/deps/couchbase-cxx-client/core/meta/features.hxx +6 -0
  32. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +11 -0
  33. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  34. package/deps/couchbase-cxx-client/core/origin.cxx +270 -0
  35. package/deps/couchbase-cxx-client/core/origin.hxx +2 -0
  36. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -2
  37. package/deps/couchbase-cxx-client/core/range_scan_options.cxx +3 -27
  38. package/deps/couchbase-cxx-client/core/range_scan_options.hxx +13 -17
  39. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +367 -170
  40. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.hxx +13 -2
  41. package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +5 -3
  42. package/deps/couchbase-cxx-client/core/scan_options.hxx +0 -19
  43. package/deps/couchbase-cxx-client/core/scan_result.cxx +19 -5
  44. package/deps/couchbase-cxx-client/core/scan_result.hxx +5 -2
  45. package/deps/couchbase-cxx-client/core/timeout_defaults.hxx +2 -3
  46. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +1 -0
  47. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +2 -0
  48. package/deps/couchbase-cxx-client/core/topology/collections_manifest_fmt.hxx +1 -1
  49. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +5 -0
  50. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +4 -0
  52. package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +19 -2
  53. package/deps/couchbase-cxx-client/couchbase/bucket_manager.hxx +135 -0
  54. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +0 -30
  55. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +14 -0
  56. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +7 -48
  57. package/deps/couchbase-cxx-client/couchbase/create_bucket_options.hxx +41 -0
  58. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +0 -29
  59. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +0 -33
  60. package/deps/couchbase-cxx-client/couchbase/drop_bucket_options.hxx +41 -0
  61. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +0 -30
  62. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +0 -31
  63. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +1 -2
  64. package/deps/couchbase-cxx-client/couchbase/flush_bucket_options.hxx +41 -0
  65. package/deps/couchbase-cxx-client/couchbase/get_all_buckets_options.hxx +44 -0
  66. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +0 -30
  67. package/deps/couchbase-cxx-client/couchbase/get_bucket_options.hxx +43 -0
  68. package/deps/couchbase-cxx-client/couchbase/management/bucket_settings.hxx +116 -0
  69. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +29 -53
  70. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +16 -83
  71. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +18 -0
  72. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +15 -0
  73. package/deps/couchbase-cxx-client/couchbase/update_bucket_options.hxx +41 -0
  74. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +0 -31
  75. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +1 -0
  76. package/deps/couchbase-cxx-client/docs/cbc-get.md +1 -0
  77. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +1 -0
  78. package/deps/couchbase-cxx-client/docs/cbc-query.md +1 -0
  79. package/deps/couchbase-cxx-client/docs/cbc.md +10 -0
  80. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  81. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +6 -0
  82. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +5 -0
  83. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +137 -1
  84. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +709 -266
  85. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +19 -7
  86. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +351 -112
  87. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +10 -1
  88. package/deps/couchbase-cxx-client/test/test_transaction_public_async_api.cxx +13 -12
  89. package/deps/couchbase-cxx-client/test/test_transaction_public_blocking_api.cxx +27 -21
  90. package/deps/couchbase-cxx-client/test/test_unit_query.cxx +75 -0
  91. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +5 -0
  92. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +29 -10
  93. package/deps/couchbase-cxx-client/test/utils/wait_until.hxx +3 -1
  94. package/deps/couchbase-cxx-client/tools/utils.cxx +4 -1
  95. package/dist/binding.d.ts +21 -16
  96. package/dist/binding.js +1 -4
  97. package/dist/bindingutilities.d.ts +6 -1
  98. package/dist/bindingutilities.js +36 -1
  99. package/dist/collection.d.ts +65 -3
  100. package/dist/collection.js +107 -0
  101. package/dist/crudoptypes.d.ts +34 -0
  102. package/dist/crudoptypes.js +18 -1
  103. package/dist/queryexecutor.js +1 -0
  104. package/dist/querytypes.d.ts +7 -0
  105. package/dist/rangeScan.d.ts +107 -0
  106. package/dist/rangeScan.js +91 -0
  107. package/dist/streamablepromises.d.ts +6 -0
  108. package/dist/streamablepromises.js +25 -1
  109. package/package.json +13 -14
  110. package/scripts/createPlatformPackages.js +1 -4
  111. package/src/addondata.hpp +1 -0
  112. package/src/binding.cpp +5 -2
  113. package/src/connection.cpp +108 -2
  114. package/src/connection.hpp +1 -0
  115. package/src/constants.cpp +2 -12
  116. package/src/jstocbpp_autogen.hpp +49 -22
  117. package/src/jstocbpp_basic.hpp +2 -8
  118. package/src/mutationtoken.cpp +13 -0
  119. package/src/scan_iterator.cpp +90 -0
  120. package/src/scan_iterator.hpp +30 -0
  121. package/tools/gen-bindings-json.py +9 -8
  122. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +0 -93
@@ -25,6 +25,8 @@
25
25
 
26
26
  #include <couchbase/query_string_query.hxx>
27
27
 
28
+ #include <regex>
29
+
28
30
  using Catch::Matchers::StartsWith;
29
31
 
30
32
  TEST_CASE("integration: search query")
@@ -567,7 +569,14 @@ TEST_CASE("integration: search query collections")
567
569
  }
568
570
  couchbase::core::operations::management::search_index_upsert_request req{};
569
571
  req.index = index;
570
- auto resp = test::utils::execute(integration.cluster, req);
572
+
573
+ couchbase::core::operations::management::search_index_upsert_response resp;
574
+ bool operation_completed = test::utils::wait_until([&integration, &resp, req]() {
575
+ resp = test::utils::execute(integration.cluster, req);
576
+ std::regex scope_not_found("collection: '.+' doesn't belong to scope");
577
+ return !std::regex_search(resp.error, scope_not_found);
578
+ });
579
+ REQUIRE(operation_completed);
571
580
  REQUIRE_SUCCESS(resp.ctx.ec);
572
581
  if (index_name != resp.name) {
573
582
  CB_LOG_INFO("update index name \"{}\" -> \"{}\"", index_name, resp.name);
@@ -32,7 +32,7 @@ async_options()
32
32
  return cfg;
33
33
  }
34
34
 
35
- TEST_CASE("can async get", "[transactions]")
35
+ TEST_CASE("transactions public async API: can async get", "[transactions]")
36
36
  {
37
37
  test::utils::integration_test_guard integration;
38
38
 
@@ -62,7 +62,7 @@ TEST_CASE("can async get", "[transactions]")
62
62
  f.get();
63
63
  }
64
64
 
65
- TEST_CASE("can get fail as expected", "[transactions]")
65
+ TEST_CASE("transactions public async API: can get fail as expected", "[transactions]")
66
66
  {
67
67
  test::utils::integration_test_guard integration;
68
68
 
@@ -85,7 +85,7 @@ TEST_CASE("can get fail as expected", "[transactions]")
85
85
  async_options());
86
86
  f.get();
87
87
  }
88
- TEST_CASE("can async remove", "[transactions]")
88
+ TEST_CASE("transactions public async API: can async remove", "[transactions]")
89
89
  {
90
90
  test::utils::integration_test_guard integration;
91
91
 
@@ -114,7 +114,7 @@ TEST_CASE("can async remove", "[transactions]")
114
114
  f.get();
115
115
  }
116
116
 
117
- TEST_CASE("async remove with bad cas fails as expected", "[transactions]")
117
+ TEST_CASE("transactions public async API: async remove with bad cas fails as expected", "[transactions]")
118
118
  {
119
119
  test::utils::integration_test_guard integration;
120
120
 
@@ -144,7 +144,8 @@ TEST_CASE("async remove with bad cas fails as expected", "[transactions]")
144
144
  async_options());
145
145
  f.get();
146
146
  }
147
- TEST_CASE("can async insert", "[transactions]")
147
+
148
+ TEST_CASE("transactions public async API: can async insert", "[transactions]")
148
149
  {
149
150
  test::utils::integration_test_guard integration;
150
151
 
@@ -168,7 +169,7 @@ TEST_CASE("can async insert", "[transactions]")
168
169
  f.get();
169
170
  }
170
171
 
171
- TEST_CASE("async insert fails when doc already exists, but doesn't rollback", "[transactions]")
172
+ TEST_CASE("transactions public async API: async insert fails when doc already exists, but doesn't rollback", "[transactions]")
172
173
  {
173
174
  test::utils::integration_test_guard integration;
174
175
 
@@ -196,7 +197,7 @@ TEST_CASE("async insert fails when doc already exists, but doesn't rollback", "[
196
197
  f.get();
197
198
  }
198
199
 
199
- TEST_CASE("can async replace", "[transactions]")
200
+ TEST_CASE("transactions public async API: can async replace", "[transactions]")
200
201
  {
201
202
  test::utils::integration_test_guard integration;
202
203
 
@@ -227,7 +228,7 @@ TEST_CASE("can async replace", "[transactions]")
227
228
  async_options());
228
229
  f.get();
229
230
  }
230
- TEST_CASE("async replace fails as expected with bad cas", "[transactions]")
231
+ TEST_CASE("transactions public async API: async replace fails as expected with bad cas", "[transactions]")
231
232
  {
232
233
  test::utils::integration_test_guard integration;
233
234
 
@@ -259,7 +260,7 @@ TEST_CASE("async replace fails as expected with bad cas", "[transactions]")
259
260
  f.get();
260
261
  }
261
262
 
262
- TEST_CASE("uncaught exception will rollback", "[transactions]")
263
+ TEST_CASE("transactions public async API: uncaught exception will rollback", "[transactions]")
263
264
  {
264
265
  test::utils::integration_test_guard integration;
265
266
 
@@ -293,7 +294,7 @@ TEST_CASE("uncaught exception will rollback", "[transactions]")
293
294
  f.get();
294
295
  }
295
296
 
296
- TEST_CASE("can set transaction options", "[transactions]")
297
+ TEST_CASE("transactions public async API: can set transaction options", "[transactions]")
297
298
  {
298
299
  test::utils::integration_test_guard integration;
299
300
 
@@ -334,7 +335,7 @@ TEST_CASE("can set transaction options", "[transactions]")
334
335
  f.get();
335
336
  }
336
337
 
337
- TEST_CASE("can do mutating query", "[transactions]")
338
+ TEST_CASE("transactions public async API: can do mutating query", "[transactions]")
338
339
  {
339
340
 
340
341
  test::utils::integration_test_guard integration;
@@ -360,7 +361,7 @@ TEST_CASE("can do mutating query", "[transactions]")
360
361
  f.get();
361
362
  }
362
363
 
363
- TEST_CASE("some query errors rollback", "[transactions]")
364
+ TEST_CASE("transactions public async API: some query errors rollback", "[transactions]")
364
365
  {
365
366
  test::utils::integration_test_guard integration;
366
367
 
@@ -94,7 +94,7 @@ upsert_scope_and_collection(std::shared_ptr<couchbase::core::cluster> cluster,
94
94
  }
95
95
  }
96
96
 
97
- TEST_CASE("can get", "[transactions]")
97
+ TEST_CASE("transactions public blocking API: can get", "[transactions]")
98
98
  {
99
99
  test::utils::integration_test_guard integration;
100
100
 
@@ -118,7 +118,7 @@ TEST_CASE("can get", "[transactions]")
118
118
  CHECK_FALSE(tx_err.ec());
119
119
  }
120
120
 
121
- TEST_CASE("get returns error if doc doesn't exist", "[transactions]")
121
+ TEST_CASE("transactions public blocking API: get returns error if doc doesn't exist", "[transactions]")
122
122
  {
123
123
  test::utils::integration_test_guard integration;
124
124
 
@@ -137,7 +137,7 @@ TEST_CASE("get returns error if doc doesn't exist", "[transactions]")
137
137
  CHECK_FALSE(tx_err.ec());
138
138
  }
139
139
 
140
- TEST_CASE("can insert", "[transactions]")
140
+ TEST_CASE("transactions public blocking API: can insert", "[transactions]")
141
141
  {
142
142
  test::utils::integration_test_guard integration;
143
143
 
@@ -165,7 +165,7 @@ TEST_CASE("can insert", "[transactions]")
165
165
  REQUIRE(final_doc.content_as<tao::json::value>() == content);
166
166
  }
167
167
 
168
- TEST_CASE("insert has error as expected when doc already exists", "[transactions]")
168
+ TEST_CASE("transactions public blocking API: insert has error as expected when doc already exists", "[transactions]")
169
169
  {
170
170
 
171
171
  test::utils::integration_test_guard integration;
@@ -193,7 +193,7 @@ TEST_CASE("insert has error as expected when doc already exists", "[transactions
193
193
  REQUIRE(final_doc.content_as<tao::json::value>() == content);
194
194
  }
195
195
 
196
- TEST_CASE("can replace", "[transactions]")
196
+ TEST_CASE("transactions public blocking API: can replace", "[transactions]")
197
197
  {
198
198
  test::utils::integration_test_guard integration;
199
199
 
@@ -225,7 +225,7 @@ TEST_CASE("can replace", "[transactions]")
225
225
  couchbase::core::utils::json::generate_binary(new_content));
226
226
  }
227
227
 
228
- TEST_CASE("replace fails as expected with bad cas", "[transactions]")
228
+ TEST_CASE("transactions public blocking API: replace fails as expected with bad cas", "[transactions]")
229
229
  {
230
230
 
231
231
  test::utils::integration_test_guard integration;
@@ -255,7 +255,7 @@ TEST_CASE("replace fails as expected with bad cas", "[transactions]")
255
255
  REQUIRE(final_doc.content_as<tao::json::value>() == content);
256
256
  }
257
257
 
258
- TEST_CASE("can remove", "[transactions]")
258
+ TEST_CASE("transactions public blocking API: can remove", "[transactions]")
259
259
  {
260
260
  test::utils::integration_test_guard integration;
261
261
 
@@ -280,7 +280,7 @@ TEST_CASE("can remove", "[transactions]")
280
280
  REQUIRE(final_err.ec() == couchbase::errc::key_value::document_not_found);
281
281
  }
282
282
 
283
- TEST_CASE("remove fails as expected with bad cas", "[transactions]")
283
+ TEST_CASE("transactions public blocking API: remove fails as expected with bad cas", "[transactions]")
284
284
  {
285
285
 
286
286
  test::utils::integration_test_guard integration;
@@ -307,7 +307,7 @@ TEST_CASE("remove fails as expected with bad cas", "[transactions]")
307
307
  CHECK(tx_err.ec());
308
308
  }
309
309
 
310
- TEST_CASE("remove fails as expected with missing doc", "[transactions]")
310
+ TEST_CASE("transactions public blocking API: remove fails as expected with missing doc", "[transactions]")
311
311
  {
312
312
  test::utils::integration_test_guard integration;
313
313
 
@@ -331,7 +331,7 @@ TEST_CASE("remove fails as expected with missing doc", "[transactions]")
331
331
  CHECK(tx_err.cause() == couchbase::errc::transaction_op::unknown);
332
332
  }
333
333
 
334
- TEST_CASE("uncaught exception in lambda will rollback without retry", "[transactions]")
334
+ TEST_CASE("transactions public blocking API: uncaught exception in lambda will rollback without retry", "[transactions]")
335
335
  {
336
336
  test::utils::integration_test_guard integration;
337
337
 
@@ -352,7 +352,7 @@ TEST_CASE("uncaught exception in lambda will rollback without retry", "[transact
352
352
  CHECK(tx_err.cause() == couchbase::errc::transaction_op::unknown);
353
353
  }
354
354
 
355
- TEST_CASE("can pass per-transaction configs", "[transactions]")
355
+ TEST_CASE("transactions public blocking API: can pass per-transaction configs", "[transactions]")
356
356
  {
357
357
  test::utils::integration_test_guard integration;
358
358
 
@@ -386,7 +386,7 @@ TEST_CASE("can pass per-transaction configs", "[transactions]")
386
386
  CHECK(tx_err.ec());
387
387
  }
388
388
 
389
- TEST_CASE("can do simple query", "[transactions]")
389
+ TEST_CASE("transactions public blocking API: can do simple query", "[transactions]")
390
390
  {
391
391
  test::utils::integration_test_guard integration;
392
392
 
@@ -407,7 +407,7 @@ TEST_CASE("can do simple query", "[transactions]")
407
407
  CHECK_FALSE(result.transaction_id.empty());
408
408
  }
409
409
 
410
- TEST_CASE("can do simple mutating query", "[transactions]")
410
+ TEST_CASE("transactions public blocking API: can do simple mutating query", "[transactions]")
411
411
  {
412
412
  test::utils::integration_test_guard integration;
413
413
 
@@ -430,7 +430,7 @@ TEST_CASE("can do simple mutating query", "[transactions]")
430
430
  CHECK(final_doc.content_as<tao::json::value>().at("some_number") == 10);
431
431
  }
432
432
 
433
- TEST_CASE("some query errors don't force rollback", "[transactions]")
433
+ TEST_CASE("transactions public blocking API: some query errors don't force rollback", "[transactions]")
434
434
  {
435
435
  test::utils::integration_test_guard integration;
436
436
 
@@ -455,7 +455,7 @@ TEST_CASE("some query errors don't force rollback", "[transactions]")
455
455
  CHECK(final_doc.content_as<tao::json::value>() == content);
456
456
  }
457
457
 
458
- TEST_CASE("some query errors do rollback", "[transactions]")
458
+ TEST_CASE("transactions public blocking API: some query errors do rollback", "[transactions]")
459
459
  {
460
460
  test::utils::integration_test_guard integration;
461
461
 
@@ -484,7 +484,7 @@ TEST_CASE("some query errors do rollback", "[transactions]")
484
484
  CHECK(doc2.cas().empty());
485
485
  }
486
486
 
487
- TEST_CASE("some query errors are seen immediately", "[transactions]")
487
+ TEST_CASE("transactions public blocking API: some query errors are seen immediately", "[transactions]")
488
488
  {
489
489
  test::utils::integration_test_guard integration;
490
490
 
@@ -503,7 +503,7 @@ TEST_CASE("some query errors are seen immediately", "[transactions]")
503
503
  CHECK(result.unstaging_complete);
504
504
  }
505
505
 
506
- TEST_CASE("can query from a scope", "[transactions]")
506
+ TEST_CASE("transactions public blocking API: can query from a scope", "[transactions]")
507
507
  {
508
508
  const std::string new_scope_name("newscope");
509
509
  const std::string new_coll_name("newcoll");
@@ -529,9 +529,15 @@ TEST_CASE("can query from a scope", "[transactions]")
529
529
  txn_opts());
530
530
  CHECK_FALSE(tx_err.ec());
531
531
  CHECK_FALSE(result.transaction_id.empty());
532
+
533
+ {
534
+ couchbase::core::operations::management::scope_drop_request req{ integration.ctx.bucket, new_scope_name };
535
+ auto resp = test::utils::execute(integration.cluster, req);
536
+ REQUIRE_SUCCESS(resp.ctx.ec);
537
+ }
532
538
  }
533
539
 
534
- TEST_CASE("can get doc from bucket not yet opened", "[transactions]")
540
+ TEST_CASE("transactions public blocking API: can get doc from bucket not yet opened", "[transactions]")
535
541
  {
536
542
 
537
543
  auto id = test::utils::uniq_id("txn");
@@ -559,7 +565,7 @@ TEST_CASE("can get doc from bucket not yet opened", "[transactions]")
559
565
  });
560
566
  }
561
567
 
562
- TEST_CASE("can insert doc into bucket not yet opened", "[transactions]")
568
+ TEST_CASE("transactions public blocking API: can insert doc into bucket not yet opened", "[transactions]")
563
569
  {
564
570
  test::utils::integration_test_guard integration;
565
571
 
@@ -585,7 +591,7 @@ TEST_CASE("can insert doc into bucket not yet opened", "[transactions]")
585
591
  });
586
592
  }
587
593
 
588
- TEST_CASE("can replace doc in bucket not yet opened", "[transactions]")
594
+ TEST_CASE("transactions public blocking API: can replace doc in bucket not yet opened", "[transactions]")
589
595
  {
590
596
 
591
597
  auto id = test::utils::uniq_id("txn");
@@ -620,7 +626,7 @@ TEST_CASE("can replace doc in bucket not yet opened", "[transactions]")
620
626
  });
621
627
  }
622
628
 
623
- TEST_CASE("can remove doc in bucket not yet opened", "[transactions]")
629
+ TEST_CASE("transactions public blocking API: can remove doc in bucket not yet opened", "[transactions]")
624
630
  {
625
631
 
626
632
  auto id = test::utils::uniq_id("txn");
@@ -0,0 +1,75 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include "test_helper_integration.hxx"
19
+
20
+ #include "utils/move_only_context.hxx"
21
+
22
+ #include "core/operations/document_query.hxx"
23
+
24
+ couchbase::core::http_context
25
+ make_http_context(couchbase::core::topology::configuration& config)
26
+ {
27
+ static couchbase::core::query_cache query_cache{};
28
+ static couchbase::core::cluster_options cluster_options{};
29
+ std::string hostname{};
30
+ std::uint16_t port{};
31
+ couchbase::core::http_context ctx{ config, cluster_options, query_cache, hostname, port };
32
+ return ctx;
33
+ }
34
+
35
+ TEST_CASE("unit: query with read from replica", "[unit]")
36
+ {
37
+ couchbase::core::topology::configuration config{};
38
+ config.cluster_capabilities.insert(couchbase::core::cluster_capability::n1ql_read_from_replica);
39
+ auto ctx = make_http_context(config);
40
+
41
+ SECTION("use_replica true")
42
+ {
43
+ couchbase::core::io::http_request http_req;
44
+ couchbase::core::operations::query_request req{};
45
+ req.use_replica = true;
46
+ auto ec = req.encode_to(http_req, ctx);
47
+ REQUIRE_SUCCESS(ec);
48
+ auto body = couchbase::core::utils::json::parse(http_req.body);
49
+ REQUIRE(body.is_object());
50
+ REQUIRE(body.get_object().at("use_replica").get_string() == "on");
51
+ }
52
+
53
+ SECTION("use_replica false")
54
+ {
55
+ couchbase::core::io::http_request http_req;
56
+ couchbase::core::operations::query_request req{};
57
+ req.use_replica = false;
58
+ auto ec = req.encode_to(http_req, ctx);
59
+ REQUIRE_SUCCESS(ec);
60
+ auto body = couchbase::core::utils::json::parse(http_req.body);
61
+ REQUIRE(body.is_object());
62
+ REQUIRE(body.get_object().at("use_replica").get_string() == "off");
63
+ }
64
+
65
+ SECTION("use_replica not set")
66
+ {
67
+ couchbase::core::io::http_request http_req;
68
+ couchbase::core::operations::query_request req{};
69
+ auto ec = req.encode_to(http_req, ctx);
70
+ REQUIRE_SUCCESS(ec);
71
+ auto body = couchbase::core::utils::json::parse(http_req.body);
72
+ REQUIRE(body.is_object());
73
+ REQUIRE_FALSE(body.get_object().count("use_replica"));
74
+ }
75
+ }
@@ -215,6 +215,11 @@ struct server_version {
215
215
  {
216
216
  return supports_search() && (is_mad_hatter() || is_cheshire_cat() || is_neo());
217
217
  }
218
+
219
+ [[nodiscard]] bool is_capella() const
220
+ {
221
+ return deployment == deployment_type::capella;
222
+ }
218
223
  };
219
224
 
220
225
  } // namespace test::utils
@@ -21,8 +21,11 @@
21
21
  #include "core/operations/management/collections_manifest_get.hxx"
22
22
  #include "core/operations/management/search_get_stats.hxx"
23
23
  #include "core/operations/management/search_index_get_documents_count.hxx"
24
+ #include "core/topology/collections_manifest_fmt.hxx"
24
25
  #include "core/utils/json.hxx"
25
26
 
27
+ #include <fmt/chrono.h>
28
+
26
29
  namespace test::utils
27
30
  {
28
31
  bool
@@ -49,18 +52,34 @@ wait_until_bucket_healthy(std::shared_ptr<couchbase::core::cluster> cluster, con
49
52
  bool
50
53
  wait_until_collection_manifest_propagated(std::shared_ptr<couchbase::core::cluster> cluster,
51
54
  const std::string& bucket_name,
52
- const std::uint64_t current_manifest_uid)
55
+ const std::uint64_t current_manifest_uid,
56
+ std::size_t successful_rounds,
57
+ std::chrono::seconds total_timeout)
53
58
  {
54
- auto propagated = test::utils::wait_until([cluster, bucket_name, current_manifest_uid]() {
55
- couchbase::core::operations::management::collections_manifest_get_request req{ { bucket_name, "_default", "_default", "" } };
56
- auto resp = test::utils::execute(cluster, req);
57
- return resp.manifest.uid >= current_manifest_uid;
58
- });
59
- if (propagated) {
60
- // FIXME: The above check does not wait for all nodes to be up to date
61
- std::this_thread::sleep_for(std::chrono::seconds(1));
59
+ std::size_t round = 0;
60
+ auto deadline = std::chrono::system_clock::now() + total_timeout;
61
+ while (std::chrono::system_clock::now() < deadline) {
62
+ auto propagated = test::utils::wait_until([cluster, bucket_name, current_manifest_uid, round, successful_rounds]() {
63
+ couchbase::core::operations::management::collections_manifest_get_request req{ { bucket_name, "_default", "_default", "" } };
64
+ auto resp = test::utils::execute(cluster, req);
65
+ CB_LOG_INFO("wait_until_collection_manifest_propagated \"{}\", expected: {}, actual: {}, round: {} ({}), manifest: {}",
66
+ bucket_name,
67
+ current_manifest_uid,
68
+ resp.manifest.uid,
69
+ round,
70
+ successful_rounds,
71
+ resp.manifest);
72
+ return resp.manifest.uid >= current_manifest_uid;
73
+ });
74
+ if (propagated) {
75
+ round += 1;
76
+ if (round >= successful_rounds) {
77
+ std::this_thread::sleep_for(std::chrono::seconds{ 1 });
78
+ return propagated;
79
+ }
80
+ }
62
81
  }
63
- return propagated;
82
+ return false;
64
83
  }
65
84
 
66
85
  bool
@@ -61,7 +61,9 @@ wait_until_bucket_healthy(std::shared_ptr<couchbase::core::cluster> cluster, con
61
61
  bool
62
62
  wait_until_collection_manifest_propagated(std::shared_ptr<couchbase::core::cluster> cluster,
63
63
  const std::string& bucket_name,
64
- const std::uint64_t current_manifest_uid);
64
+ const std::uint64_t current_manifest_uid,
65
+ std::size_t successful_rounds = 4,
66
+ std::chrono::seconds total_timeout = std::chrono::minutes{ 5 });
65
67
  bool
66
68
  wait_until_user_present(const std::shared_ptr<couchbase::core::cluster>& cluster, const std::string& username);
67
69
 
@@ -82,6 +82,7 @@ auto
82
82
  usage_block_for_cluster_options() -> std::string
83
83
  {
84
84
  const auto default_user_agent_extra{ "cbc" };
85
+ const auto default_network{ "auto" };
85
86
  const auto default_options = default_cluster_options().build();
86
87
  const auto connection_string = default_connection_string();
87
88
 
@@ -161,6 +162,7 @@ Tracing options:
161
162
 
162
163
  Behavior options:
163
164
  --user-agent-extra=STRING Append extra string SDK identifiers (full user-agent is "{sdk_id};{user_agent_extra}"). [default: {user_agent_extra}].
165
+ --network=STRING Network (a.k.a. Alternate Addresses) to use. [default: {network}]
164
166
  --show-queries Log queries on INFO level.
165
167
  --enable-clustermap-notifications Allow server to send notifications when cluster configuration changes.
166
168
  --disable-mutation-tokens Do not request Key/Value service to send mutation tokens.
@@ -209,7 +211,8 @@ Behavior options:
209
211
  fmt::arg("tracing_threshold_management", default_options.tracing.management_threshold),
210
212
  fmt::arg("tracing_threshold_eventing", default_options.tracing.eventing_threshold),
211
213
  fmt::arg("sdk_id", couchbase::core::meta::sdk_id()),
212
- fmt::arg("user_agent_extra", default_user_agent_extra));
214
+ fmt::arg("user_agent_extra", default_user_agent_extra),
215
+ fmt::arg("network", default_network));
213
216
  }
214
217
 
215
218
  void
package/dist/binding.d.ts CHANGED
@@ -36,6 +36,11 @@ export interface CppQueryContext {
36
36
  bucket_name: string;
37
37
  scope_name: string;
38
38
  }
39
+ export interface CppScanIterator {
40
+ cancelled: boolean;
41
+ next(callback: (err: CppError | null, result: CppRangeScanItem | undefined) => void): void;
42
+ cancel(): boolean;
43
+ }
39
44
  export declare enum CppManagementAnalyticsCouchbaseLinkEncryptionLevel {
40
45
  }
41
46
  export declare enum CppManagementClusterBucketType {
@@ -126,8 +131,6 @@ export declare enum CppPersistTo {
126
131
  }
127
132
  export declare enum CppReplicateTo {
128
133
  }
129
- export declare enum CppScanSort {
130
- }
131
134
  export interface CppManagementAnalyticsDataset {
132
135
  name: string;
133
136
  dataverse_name: string;
@@ -577,6 +580,7 @@ export interface CppQueryRequest {
577
580
  readonly: boolean;
578
581
  flex_index: boolean;
579
582
  preserve_expiry: boolean;
583
+ use_replica?: boolean;
580
584
  max_parallelism?: number;
581
585
  scan_cap?: number;
582
586
  scan_wait?: CppMilliseconds;
@@ -1789,12 +1793,15 @@ export interface CppImplSubdocCommand {
1789
1793
  original_index_: number;
1790
1794
  }
1791
1795
  export interface CppScanTerm {
1792
- id: Buffer;
1796
+ term: string;
1793
1797
  exclusive: boolean;
1794
1798
  }
1795
1799
  export interface CppRangeScan {
1796
- start_: CppScanTerm;
1797
- end_: CppScanTerm;
1800
+ from?: CppScanTerm;
1801
+ to?: CppScanTerm;
1802
+ }
1803
+ export interface CppPrefixScan {
1804
+ prefix: string;
1798
1805
  }
1799
1806
  export interface CppSamplingScan {
1800
1807
  limit: number;
@@ -1809,7 +1816,7 @@ export interface CppRangeScanCreateOptions {
1809
1816
  scope_name: string;
1810
1817
  collection_name: string;
1811
1818
  scan_type_name: string;
1812
- scan_type_value: undefined | CppRangeScan | CppSamplingScan;
1819
+ scan_type_value: undefined | CppRangeScan | CppPrefixScan | CppSamplingScan;
1813
1820
  timeout: CppMilliseconds;
1814
1821
  collection_id: number;
1815
1822
  snapshot_requirements?: CppRangeSnapshotRequirements;
@@ -1822,8 +1829,8 @@ export interface CppRangeScanCreateResult {
1822
1829
  export interface CppRangeScanContinueOptions {
1823
1830
  batch_item_limit: number;
1824
1831
  batch_byte_limit: number;
1832
+ timeout: CppMilliseconds;
1825
1833
  batch_time_limit: CppMilliseconds;
1826
- ids_only: boolean;
1827
1834
  }
1828
1835
  export interface CppRangeScanContinueResult {
1829
1836
  more: boolean;
@@ -1842,7 +1849,7 @@ export interface CppRangeScanItemBody {
1842
1849
  value: Buffer;
1843
1850
  }
1844
1851
  export interface CppRangeScanItem {
1845
- key: Buffer;
1852
+ key: string;
1846
1853
  body?: CppRangeScanItemBody;
1847
1854
  }
1848
1855
  export interface CppRangeScanCancelResult {
@@ -1853,10 +1860,9 @@ export interface CppMutationState {
1853
1860
  export interface CppRangeScanOrchestratorOptions {
1854
1861
  ids_only: boolean;
1855
1862
  consistent_with?: CppMutationState;
1856
- sort: CppScanSort;
1857
1863
  batch_item_limit: number;
1858
1864
  batch_byte_limit: number;
1859
- batch_time_limit: CppMilliseconds;
1865
+ concurrency: number;
1860
1866
  timeout: CppMilliseconds;
1861
1867
  }
1862
1868
  export interface CppConnectionAutogen {
@@ -2212,8 +2218,7 @@ export interface CppBindingAutogen {
2212
2218
  xattr_cannot_modify_virtual_attribute: CppErrcKeyValue;
2213
2219
  xattr_no_access: CppErrcKeyValue;
2214
2220
  cannot_revive_living_document: CppErrcKeyValue;
2215
- range_scan_cancelled: CppErrcKeyValue;
2216
- range_scan_vb_uuid_not_equal: CppErrcKeyValue;
2221
+ mutation_token_outdated: CppErrcKeyValue;
2217
2222
  range_scan_completed: CppErrcKeyValue;
2218
2223
  };
2219
2224
  errc_query: {
@@ -2393,10 +2398,6 @@ export interface CppBindingAutogen {
2393
2398
  two: CppReplicateTo;
2394
2399
  three: CppReplicateTo;
2395
2400
  };
2396
- scan_sort: {
2397
- none: CppScanSort;
2398
- ascending: CppScanSort;
2399
- };
2400
2401
  }
2401
2402
  export type CppErrc = CppErrcCommon | CppErrcKeyValue | CppErrcQuery | CppErrcAnalytics | CppErrcSearch | CppErrcView | CppErrcManagement | CppErrcFieldLevelEncryption | CppErrcNetwork;
2402
2403
  export declare enum CppTxnFailureType {
@@ -2570,6 +2571,10 @@ export interface CppConnection extends CppConnectionAutogen {
2570
2571
  }[];
2571
2572
  };
2572
2573
  }) => void): void;
2574
+ scan(bucket_name: string, scope_name: string, collection_name: string, scan_type_name: string, scan_type_value: CppRangeScan | CppSamplingScan | CppPrefixScan, options: CppRangeScanOrchestratorOptions): {
2575
+ cppErr: CppError | null;
2576
+ result: CppScanIterator;
2577
+ };
2573
2578
  }
2574
2579
  export interface CppTransactionsConfig {
2575
2580
  durability_level?: CppDurabilityLevel;
package/dist/binding.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CppTxnExternalException = exports.CppTxnFailureType = exports.CppScanSort = exports.CppReplicateTo = exports.CppPersistTo = exports.CppStoreSemantics = exports.CppImplSubdocOpcode = exports.CppKeyValueStatusCode = exports.CppErrcNetwork = exports.CppErrcFieldLevelEncryption = exports.CppErrcManagement = exports.CppErrcView = exports.CppErrcSearch = exports.CppErrcAnalytics = exports.CppErrcQuery = exports.CppErrcKeyValue = exports.CppErrcCommon = exports.CppDurabilityLevel = exports.CppAnalyticsResponseAnalyticsStatus = exports.CppViewSortOrder = exports.CppViewScanConsistency = exports.CppViewOnError = exports.CppServiceType = exports.CppSearchScanConsistency = exports.CppSearchHighlightStyle = exports.CppQueryScanConsistency = exports.CppQueryProfile = exports.CppDiagPingState = exports.CppDiagEndpointState = exports.CppDiagClusterState = exports.CppDesignDocumentNamespace = exports.CppAnalyticsScanConsistency = exports.CppProtocolSubdocOpcode = exports.CppRetryReason = exports.CppManagementRbacAuthDomain = exports.CppManagementEventingFunctionProcessingStatus = exports.CppManagementEventingFunctionDeploymentStatus = exports.CppManagementEventingFunctionStatus = exports.CppManagementEventingFunctionBucketAccess = exports.CppManagementEventingFunctionLogLevel = exports.CppManagementEventingFunctionLanguageCompatibility = exports.CppManagementEventingFunctionDcpBoundary = exports.CppManagementClusterBucketStorageBackend = exports.CppManagementClusterBucketConflictResolution = exports.CppManagementClusterBucketEvictionPolicy = exports.CppManagementClusterBucketCompression = exports.CppManagementClusterBucketType = exports.CppManagementAnalyticsCouchbaseLinkEncryptionLevel = exports.zeroCas = void 0;
6
+ exports.CppTxnExternalException = exports.CppTxnFailureType = exports.CppReplicateTo = exports.CppPersistTo = exports.CppStoreSemantics = exports.CppImplSubdocOpcode = exports.CppKeyValueStatusCode = exports.CppErrcNetwork = exports.CppErrcFieldLevelEncryption = exports.CppErrcManagement = exports.CppErrcView = exports.CppErrcSearch = exports.CppErrcAnalytics = exports.CppErrcQuery = exports.CppErrcKeyValue = exports.CppErrcCommon = exports.CppDurabilityLevel = exports.CppAnalyticsResponseAnalyticsStatus = exports.CppViewSortOrder = exports.CppViewScanConsistency = exports.CppViewOnError = exports.CppServiceType = exports.CppSearchScanConsistency = exports.CppSearchHighlightStyle = exports.CppQueryScanConsistency = exports.CppQueryProfile = exports.CppDiagPingState = exports.CppDiagEndpointState = exports.CppDiagClusterState = exports.CppDesignDocumentNamespace = exports.CppAnalyticsScanConsistency = exports.CppProtocolSubdocOpcode = exports.CppRetryReason = exports.CppManagementRbacAuthDomain = exports.CppManagementEventingFunctionProcessingStatus = exports.CppManagementEventingFunctionDeploymentStatus = exports.CppManagementEventingFunctionStatus = exports.CppManagementEventingFunctionBucketAccess = exports.CppManagementEventingFunctionLogLevel = exports.CppManagementEventingFunctionLanguageCompatibility = exports.CppManagementEventingFunctionDcpBoundary = exports.CppManagementClusterBucketStorageBackend = exports.CppManagementClusterBucketConflictResolution = exports.CppManagementClusterBucketEvictionPolicy = exports.CppManagementClusterBucketCompression = exports.CppManagementClusterBucketType = exports.CppManagementAnalyticsCouchbaseLinkEncryptionLevel = exports.zeroCas = void 0;
7
7
  /*
8
8
  eslint
9
9
  jsdoc/require-jsdoc: off,
@@ -147,9 +147,6 @@ var CppPersistTo;
147
147
  var CppReplicateTo;
148
148
  (function (CppReplicateTo) {
149
149
  })(CppReplicateTo = exports.CppReplicateTo || (exports.CppReplicateTo = {}));
150
- var CppScanSort;
151
- (function (CppScanSort) {
152
- })(CppScanSort = exports.CppScanSort || (exports.CppScanSort = {}));
153
150
  var CppTxnFailureType;
154
151
  (function (CppTxnFailureType) {
155
152
  })(CppTxnFailureType = exports.CppTxnFailureType || (exports.CppTxnFailureType = {}));
@@ -1,11 +1,12 @@
1
1
  import { AnalyticsScanConsistency, AnalyticsStatus } from './analyticstypes';
2
- import { CppAnalyticsScanConsistency, CppAnalyticsResponseAnalyticsStatus, CppDurabilityLevel, CppDiagEndpointState, CppMutationState, CppDiagPingState, CppQueryProfile, CppQueryScanConsistency, CppSearchHighlightStyle, CppSearchScanConsistency, CppServiceType, CppStoreSemantics, CppTxnExternalException, CppViewScanConsistency, CppViewSortOrder, CppPersistTo, CppReplicateTo, CppTxnOpException } from './binding';
2
+ import { CppAnalyticsScanConsistency, CppAnalyticsResponseAnalyticsStatus, CppDurabilityLevel, CppDiagEndpointState, CppMutationState, CppDiagPingState, CppQueryProfile, CppQueryScanConsistency, CppSearchHighlightStyle, CppSearchScanConsistency, CppServiceType, CppStoreSemantics, CppTxnExternalException, CppViewScanConsistency, CppViewSortOrder, CppPersistTo, CppReplicateTo, CppTxnOpException, CppRangeScan, CppSamplingScan, CppPrefixScan } from './binding';
3
3
  import { CppError } from './binding';
4
4
  import { EndpointState, PingState } from './diagnosticstypes';
5
5
  import { ErrorContext } from './errorcontexts';
6
6
  import { DurabilityLevel, ServiceType, StoreSemantics } from './generaltypes';
7
7
  import { MutationState } from './mutationstate';
8
8
  import { QueryProfileMode, QueryScanConsistency } from './querytypes';
9
+ import { RangeScan, SamplingScan, PrefixScan } from './rangeScan';
9
10
  import { SearchScanConsistency, HighlightStyle } from './searchtypes';
10
11
  import { ViewOrdering, ViewScanConsistency } from './viewtypes';
11
12
  /**
@@ -92,3 +93,7 @@ export declare function contextFromCpp(err: CppError | null): ErrorContext | nul
92
93
  * @internal
93
94
  */
94
95
  export declare function errorFromCpp(err: CppError | null): Error | null;
96
+ /**
97
+ * @internal
98
+ */
99
+ export declare function scanTypeToCpp(scanType: RangeScan | SamplingScan | PrefixScan): CppRangeScan | CppSamplingScan | CppPrefixScan;