Skip to content

Commit dd093c0

Browse files
committed
fix tests on 7.6
1 parent 8300ae9 commit dd093c0

File tree

10 files changed

+100
-31
lines changed

10 files changed

+100
-31
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ jobs:
135135
fail-fast: false
136136
matrix:
137137
ruby:
138-
- '3.0'
139138
- '3.1'
140139
- '3.2'
141140
- '3.3'
@@ -174,10 +173,6 @@ jobs:
174173
- uses: actions/download-artifact@v4
175174
with:
176175
name: scripts-${{ needs.source.outputs.gem_version }}
177-
- uses: actions/download-artifact@v4
178-
with:
179-
path: pkg/binary/3.0
180-
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-linux-3.0
181176
- uses: actions/download-artifact@v4
182177
with:
183178
path: pkg/binary/3.1
@@ -209,7 +204,6 @@ jobs:
209204
fail-fast: false
210205
matrix:
211206
ruby:
212-
- '3.0'
213207
- '3.1'
214208
- '3.2'
215209
- '3.3'
@@ -248,10 +242,6 @@ jobs:
248242
- uses: actions/download-artifact@v4
249243
with:
250244
name: scripts-${{ needs.source.outputs.gem_version }}
251-
- uses: actions/download-artifact@v4
252-
with:
253-
path: pkg/binary/3.0
254-
name: couchbase-${{ needs.source.outputs.gem_version }}-arm64-darwin-3.0
255245
- uses: actions/download-artifact@v4
256246
with:
257247
path: pkg/binary/3.1
@@ -283,7 +273,6 @@ jobs:
283273
fail-fast: false
284274
matrix:
285275
ruby:
286-
- '3.0'
287276
- '3.1'
288277
- '3.2'
289278
- '3.3'
@@ -322,10 +311,6 @@ jobs:
322311
- uses: actions/download-artifact@v4
323312
with:
324313
name: scripts-${{ needs.source.outputs.gem_version }}
325-
- uses: actions/download-artifact@v4
326-
with:
327-
path: pkg/binary/3.0
328-
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-darwin-3.0
329314
- uses: actions/download-artifact@v4
330315
with:
331316
path: pkg/binary/3.1
@@ -360,7 +345,6 @@ jobs:
360345
fail-fast: false
361346
matrix:
362347
ruby:
363-
- '3.0'
364348
- '3.1'
365349
- '3.2'
366350
- '3.3'
@@ -421,7 +405,6 @@ jobs:
421405
fail-fast: false
422406
matrix:
423407
ruby:
424-
- '3.0'
425408
- '3.1'
426409
- '3.2'
427410
- '3.3'
@@ -485,7 +468,6 @@ jobs:
485468
fail-fast: false
486469
matrix:
487470
ruby:
488-
- '3.0'
489471
- '3.1'
490472
- '3.2'
491473
- '3.3'

lib/active_support/cache/couchbase_store.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def delete_matched(matcher, _options = nil)
108108
operation_options = ::Couchbase::Options::Query(named_parameters: {"pattern" => pattern}, metrics: true)
109109
operation_options.consistent_with(::Couchbase::MutationState.new(@last_mutation_token)) if @last_mutation_token
110110
begin
111-
result = cluster.query("DELETE FROM #{scope_qualifier} cache WHERE REGEXP_MATCHES(META(cache).id, $pattern)", operation_options)
111+
result = cluster.query("DELETE FROM #{scope_qualifier} cache_store_ WHERE REGEXP_MATCHES(META(cache_store_).id, $pattern)",
112+
operation_options)
112113
result.meta_data.metrics.mutation_count
113114
rescue ::Couchbase::Error::ParsingFailure, ::Couchbase::Error::ServiceNotAvailable
114115
raise NotImplementedError, "The server does not support delete_matched operation"

test/active_support/behaviors/local_cache_behavior.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ def test_local_cache_of_delete_matched
151151
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support consistent_with yet") if env.protostellar?
152152

153153
skip("#{name}: delete_matched is not stable on 6.x servers, version=#{env.server_version}") if use_caves? || env.server_version.mad_hatter?
154+
155+
ensure_primary_index!
156+
154157
begin
155158
@cache.delete_matched("*")
156159
rescue NotImplementedError

test/crud_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_reads_from_replica
5757
doc_id = uniq_id(:foo)
5858
document = {"value" => 42}
5959
options =
60-
if env.jenkins?
60+
if env.jenkins? || use_caves?
6161
Options::Upsert(persist_to: :active, replicate_to: :one)
6262
else
6363
Options::Upsert(persist_to: :active)

test/ds_map_test.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,7 @@ def test_changes_the_value_by_key
129129
refute_empty map
130130
map["baz"] = "bar"
131131

132-
pairs = map.map do |*pair|
133-
pair
134-
end
135-
136-
assert_equal [%w[baz bar], ["foo", 100]], pairs.sort
132+
assert_equal [%w[baz bar], ["foo", 100]], map.entries.sort
137133
end
138134

139135
def test_removes_key

test/query_index_manager_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class QueryIndexManagerTest < Minitest::Test
2222
include TestUtilities
2323

2424
def setup
25+
return if use_caves?
26+
2527
connect
2628
@bucket_name = 'query-idx-test-bucket'
2729
@cluster.buckets.create_bucket(
@@ -47,6 +49,8 @@ def setup
4749
end
4850

4951
def teardown
52+
return if use_caves?
53+
5054
@cluster.buckets.drop_bucket(@bucket_name)
5155
disconnect
5256
end

test/search_test.rb

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ class SearchTest < Minitest::Test
2121
include TestUtilities
2222

2323
def setup
24-
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
24+
return if use_caves?
2525

2626
connect
27-
skip("#{name}: CAVES does not support query service yet") if use_caves?
2827
@bucket = @cluster.bucket(env.bucket)
2928
@scope = @bucket.default_scope
3029
@collection = @bucket.default_collection
@@ -72,10 +71,16 @@ def setup
7271
end
7372

7473
def teardown
74+
return if use_caves?
75+
76+
@cluster.search_indexes.drop_index(@index_name)
7577
disconnect
7678
end
7779

7880
def test_simple_search
81+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
82+
skip("#{name}: CAVES does not support search service yet") if use_caves?
83+
7984
doc_id = uniq_id(:foo)
8085
res = @collection.insert(doc_id, {"type" => "character", "name" => "Arthur"})
8186
mutation_state = MutationState.new(res.mutation_token)
@@ -108,6 +113,9 @@ def test_simple_search
108113
end
109114

110115
def test_doc_id_search_query
116+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
117+
skip("#{name}: CAVES does not support search service yet") if use_caves?
118+
111119
doc_ids = [uniq_id(:foo), uniq_id(:bar)]
112120
res1 = @collection.insert(doc_ids[0], {"type" => "character", "name" => "Arthur"})
113121
res2 = @collection.insert(doc_ids[1], {"type" => "character", "name" => "Brodie"})
@@ -145,6 +153,9 @@ def test_doc_id_search_query
145153
end
146154

147155
def test_search_request_backend_encoding
156+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
157+
skip("#{name}: CAVES does not support search service yet") if use_caves?
158+
148159
vec1 = [-0.00810323283, 0.0727998167, 0.0211895034, -0.0254271757]
149160
vec2 = [-0.005610323283, 0.023427998167, 0.0132511895034, 0.03466271757]
150161

@@ -200,6 +211,9 @@ def test_search_request_backend_encoding
200211
end
201212

202213
def test_search_request_invalid_argument
214+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
215+
skip("#{name}: CAVES does not support search service yet") if use_caves?
216+
203217
vec1 = [-0.00810323283, 0.0727998167, 0.0211895034, -0.0254271757]
204218
vec2 = [-0.005610323283, 0.023427998167, 0.0132511895034, 0.03466271757]
205219

@@ -223,24 +237,36 @@ def test_search_request_invalid_argument
223237
end
224238

225239
def test_vector_query_empty
240+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
241+
skip("#{name}: CAVES does not support search service yet") if use_caves?
242+
226243
vector_query = VectorQuery.new("foo", [])
227244

228245
assert_raises(Error::InvalidArgument) { vector_query.to_json }
229246
end
230247

231248
def test_base64_vector_query_empty
249+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
250+
skip("#{name}: CAVES does not support search service yet") if use_caves?
251+
232252
vector_query = VectorQuery.new("foo", "")
233253

234254
assert_raises(Error::InvalidArgument) { vector_query.to_json }
235255
end
236256

237257
def test_vector_query_nil
258+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
259+
skip("#{name}: CAVES does not support search service yet") if use_caves?
260+
238261
vector_query = VectorQuery.new("foo", nil)
239262

240263
assert_raises(Error::InvalidArgument) { vector_query.to_json }
241264
end
242265

243266
def test_vector_query_invalid_candidate_number
267+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
268+
skip("#{name}: CAVES does not support search service yet") if use_caves?
269+
244270
vector_query = VectorQuery.new("foo", [-1.1, 1.2]) do |q|
245271
q.num_candidates = 0
246272
end
@@ -251,6 +277,9 @@ def test_vector_query_invalid_candidate_number
251277
end
252278

253279
def test_vector_search_empty_vector_query_array
280+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
281+
skip("#{name}: CAVES does not support search service yet") if use_caves?
282+
254283
vector_search = VectorSearch.new([])
255284

256285
assert_raises(Error::InvalidArgument) do
@@ -259,13 +288,19 @@ def test_vector_search_empty_vector_query_array
259288
end
260289

261290
def test_vector_search_query_defaults_to_match_none
291+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
292+
skip("#{name}: CAVES does not support search service yet") if use_caves?
293+
262294
vector_search = VectorSearch.new(VectorQuery.new("foo", [-1.1, 1.2]))
263295
enc_query, = SearchRequest.new(vector_search).to_backend
264296

265297
assert_equal SearchQuery.match_none.to_json, enc_query
266298
end
267299

268300
def test_vector_search_query_base64
301+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
302+
skip("#{name}: CAVES does not support search service yet") if use_caves?
303+
269304
base64_query = "aOeYBEXJ4kI="
270305
enc_vector_query = VectorQuery.new("foo", base64_query).to_h
271306

@@ -275,6 +310,9 @@ def test_vector_search_query_base64
275310
end
276311

277312
def test_vector_search_not_supported
313+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
314+
skip("#{name}: CAVES does not support search service yet") if use_caves?
315+
278316
skip("#{name}: Server supports vector search") if !env.protostellar? && env.server_version.supports_vector_search?
279317

280318
req = SearchRequest.new(VectorSearch.new(VectorQuery.new("foo", [-1.1, 1.2])))
@@ -284,6 +322,9 @@ def test_vector_search_not_supported
284322
end
285323

286324
def test_scope_search_not_supported
325+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support search index management yet") if env.protostellar?
326+
skip("#{name}: CAVES does not support search service yet") if use_caves?
327+
287328
skip("#{name}: Server supports scope search") if !env.protostellar? && env.server_version.supports_scoped_search_indexes?
288329

289330
req = SearchRequest.new(SearchQuery.match_all)

test/subdoc_test.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ def test_macros
359359
end
360360

361361
def test_mad_hatter_macros
362-
skip("The server does not support MadHatter macros (#{env.server_version})") unless env.server_version.mad_hatter?
362+
unless env.server_version.supports_mad_hatter_subdoc_macros?
363+
skip("The server does not support MadHatter macros (#{env.server_version})")
364+
end
363365

364366
doc_id = uniq_id(:foo)
365367

@@ -1272,7 +1274,17 @@ def test_multiple_xattr_keys_should_fail
12721274

12731275
options = Collection::MutateInOptions.new
12741276
options.store_semantics = :upsert
1275-
assert_raises env.protostellar? ? Error::InvalidArgument : Error::XattrInvalidKeyCombo do
1277+
exception_check =
1278+
if env.server_version.supports_multiple_xattr_keys_mutation?
1279+
lambda { |&block| block.call }
1280+
elsif env.protostellar?
1281+
# FIXME: most likely Protostellar/7.6.0+ will not not fail too
1282+
lambda { |&block| assert_raises(Error::InvalidArgument) { block.call } }
1283+
else
1284+
lambda { |&block| assert_raises(Error::XattrInvalidKeyCombo) { block.call } }
1285+
end
1286+
1287+
exception_check.call do
12761288
@collection.mutate_in(doc_id, [
12771289
MutateInSpec.increment("count", 1).xattr.create_path,
12781290
MutateInSpec.insert("logs", "bar1").xattr.create_path,

test/test_helper.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ def supports_preserve_expiry?
9393
cheshire_cat?
9494
end
9595

96+
def supports_mad_hatter_subdoc_macros?
97+
mad_hatter? || cheshire_cat?
98+
end
99+
96100
def is_rcbc_408_applicable?
97101
@version < Gem::Version.create("7.0.0")
98102
end
@@ -128,6 +132,10 @@ def supports_scoped_search_indexes?
128132
def supports_vector_search?
129133
trinity?
130134
end
135+
136+
def supports_multiple_xattr_keys_mutation?
137+
trinity?
138+
end
131139
end
132140

133141
require "couchbase"
@@ -164,7 +172,15 @@ def bucket
164172
end
165173

166174
def management_endpoint
167-
@management_endpoint = ENV.fetch("TEST_MANAGEMENT_ENDPOINT", nil)
175+
@management_endpoint = ENV.fetch("TEST_MANAGEMENT_ENDPOINT") do
176+
if connection_string
177+
parsed = Couchbase::Backend.parse_connection_string(connection_string)
178+
first_node_address = parsed[:nodes].first[:address]
179+
scheme = parsed[:tls] ? "https" : "http"
180+
port = parsed[:tls] ? 18091 : 8091
181+
"#{scheme}://#{first_node_address}:#{port}"
182+
end
183+
end
168184
end
169185

170186
def jenkins?
@@ -188,7 +204,12 @@ def protostellar?
188204
end
189205

190206
def consistency
191-
@consistency ||= TestUtilities::ConsistencyHelper.new(management_endpoint, username, password)
207+
@consistency ||=
208+
if ENV.fetch("TEST_CONNECTION_STRING", nil)
209+
TestUtilities::ConsistencyHelper.new(management_endpoint, username, password)
210+
else
211+
TestUtilities::MockConsistencyHelper.new
212+
end
192213
end
193214
end
194215

test/utils/consistency_helper.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020
module Couchbase
2121
module TestUtilities
22+
# CAVES does not support management API, but fast enough to be consistent
23+
class MockConsistencyHelper < BasicObject
24+
def method_missing(*); end
25+
26+
def respond_to_missing?(*)
27+
true
28+
end
29+
end
30+
2231
class ConsistencyHelper
2332
attr_reader :management_hosts
2433

0 commit comments

Comments
 (0)