Skip to content

Commit 50c7cb9

Browse files
committed
RCBC-472: Ping management service when specified in options
1 parent 6218e75 commit 50c7cb9

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ task :cache_cxx_dependencies do
202202
rm_rf(cpm_cache_dir, verbose: true)
203203

204204
untar = ["tar", "-x"]
205-
untar << "--force-local" unless RUBY_PLATFORM.match?(/darwin/)
205+
untar << "--force-local" unless RUBY_PLATFORM.include?('darwin')
206206

207207
puts("-----> verify that tarball works as a cache for CPM")
208208
cxx_core_build_dir = Dir.mktmpdir("cxx_build_")

ext/couchbase.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,10 @@ cb_Backend_ping(VALUE self, VALUE bucket, VALUE options)
24722472
selected_services.insert(couchbase::core::service_type::search);
24732473
} else if (entry == rb_id2sym(rb_intern("views"))) {
24742474
selected_services.insert(couchbase::core::service_type::view);
2475+
} else if (entry == rb_id2sym(rb_intern("management"))) {
2476+
selected_services.insert(couchbase::core::service_type::management);
2477+
} else if (entry == rb_id2sym(rb_intern("eventing"))) {
2478+
selected_services.insert(couchbase::core::service_type::eventing);
24752479
}
24762480
}
24772481
}
@@ -2510,7 +2514,7 @@ cb_Backend_ping(VALUE self, VALUE bucket, VALUE options)
25102514
type = rb_id2sym(rb_intern("views"));
25112515
break;
25122516
case couchbase::core::service_type::management:
2513-
type = rb_id2sym(rb_intern("mgmt"));
2517+
type = rb_id2sym(rb_intern("management"));
25142518
break;
25152519
case couchbase::core::service_type::eventing:
25162520
type = rb_id2sym(rb_intern("eventing"));

test/diagnostics_test.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024. Couchbase, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
require_relative "test_helper"
15+
module Couchbase
16+
class DiagnosticsTest < Minitest::Test
17+
include Couchbase::TestUtilities
18+
19+
def setup
20+
skip("#{name}: The #{Couchbase::Protostellar::NAME} protocol does not support ping/diagnostics") if env.protostellar?
21+
22+
connect
23+
end
24+
25+
def teardown
26+
disconnect
27+
end
28+
29+
def test_cluster_ping_multiple_services
30+
service_types = [:kv, :query, :search, :management]
31+
res = @cluster.ping(Options::Ping.new(service_types: service_types))
32+
33+
assert_equal service_types.size, res.services.size
34+
service_types.each do |s|
35+
assert_includes res.services.keys, s
36+
end
37+
end
38+
39+
def test_cluster_ping_single_service
40+
[:kv, :query, :search, :management].each do |service_type|
41+
res = @cluster.ping(Options::Ping.new(service_types: [service_type]))
42+
43+
assert_equal 1, res.services.size
44+
assert_equal service_type, res.services.keys[0]
45+
end
46+
end
47+
end
48+
end

0 commit comments

Comments
 (0)