|
| 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