Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/actions/create-cluster/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: create-cluster
description: Sets up a Couchbase cluster using cbdinocluster
inputs:
version:
description: 'Couchbase Server version to use'
required: true
outputs:
ip:
description: 'The IP address of a node of the cluster'
value: ${{ steps.start-cluster.outputs.ip }}
connstr:
description: 'Connection string to connect to the cluster'
value: ${{ steps.start-cluster.outputs.connstr }}
tls-connstr:
description: 'Connection string to connect to the cluster over TLS'
value: ${{ steps.start-cluster.outputs.tls-connstr }}
id:
description: 'The cbdinocluster ID of the created cluster'
value: ${{ steps.start-cluster.outputs.id }}
runs:
using: composite
steps:
- name: Install cbdinocluster
shell: bash
run: |
mkdir -p "$HOME/bin"
wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.113/cbdinocluster-linux-amd64
chmod +x $HOME/bin/cbdinocluster
echo "$HOME/bin" >> $GITHUB_PATH
- name: Initialize cbdinocluster
shell: bash
run: |
cbdinocluster -v init --auto
- name: Start Couchbase cluster
id: start-cluster
shell: bash
env:
CLUSTER_CONFIG: |
nodes:
- count: 2
version: ${{ inputs.version }}
services:
- kv
- n1ql
- index
- count: 1
version: ${{ inputs.version }}
services:
- kv
- fts
- cbas
docker:
kv-memory: 1500
fts-memory: 3000
expiry: 1h
Comment thread
DemetrisChr marked this conversation as resolved.
run: |
CBDC_ID=$(cbdinocluster -v alloc --def="${CLUSTER_CONFIG}")
echo "CBDC_ID=$CBDC_ID" >> "$GITHUB_ENV"
echo "ip=$(cbdinocluster -v ip $CBDC_ID)" >> "$GITHUB_OUTPUT"
echo "connstr=$(cbdinocluster -v connstr --no-tls $CBDC_ID)" >> "$GITHUB_OUTPUT"
echo "tls-connstr=$(cbdinocluster -v connstr --tls $CBDC_ID)" >> "$GITHUB_OUTPUT"
echo "id=$CBDC_ID" >> "$GITHUB_OUTPUT"
cbdinocluster certificates get-ca $CBDC_ID >> "$GITHUB_WORKSPACE/cluster.crt"
- name: Add default bucket
shell: bash
run: |
cbdinocluster buckets add $CBDC_ID default --ram-quota-mb 100 --flush-enabled true
- name: Load travel-sample bucket
shell: bash
run: |
cbdinocluster buckets load-sample $CBDC_ID travel-sample
63 changes: 63 additions & 0 deletions .github/actions/start-cng/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Start CNG (Stellar Gateway)"
description: "Checks out and starts the Couchbase Stellar Gateway (CNG), generating a self-signed certificate for TLS."

inputs:
couchbase-hostname:
description: "Hostname of the Couchbase cluster to connect CNG to"
required: true
cng-ref:
description: "The git ref (branch, tag, or SHA) of CNG to use"
required: false
default: master

outputs:
ca-cert-path:
description: "Absolute path to the self-signed CA certificate"
value: ${{ steps.generate-cert.outputs.ca-cert-path }}
cng-connection-string:
description: "The connection string for CNG"
value: "couchbase2://localhost:18098"

runs:
using: "composite"
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Checkout Stellar Gateway
uses: actions/checkout@v4
with:
repository: couchbase/stellar-gateway
path: stellar-gateway
ref: ${{ inputs.cng-ref }}

Comment thread
DemetrisChr marked this conversation as resolved.
- name: Generate self-signed certificate
id: generate-cert
shell: bash
working-directory: stellar-gateway
run: |
openssl req -x509 -newkey rsa:4096 -keyout key.pem \
-out cert.pem -days 365 -nodes \
-subj "/CN=CNG Local CA" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"

echo "ca-cert-path=$(pwd)/cert.pem" >> "$GITHUB_OUTPUT"

- name: Build Stellar Gateway
shell: bash
working-directory: stellar-gateway
run: |
go generate ./...
go build -o stellar-gateway ./cmd/gateway

- name: Start Stellar Gateway
shell: bash
working-directory: stellar-gateway
run: |
./stellar-gateway \
--cb-host "${{ inputs.couchbase-hostname }}" \
--data-port 18098 \
--cert cert.pem \
--key key.pem &
123 changes: 88 additions & 35 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -724,42 +724,94 @@ jobs:
- 7.6.8
- 7.2.9
steps:
- name: Install cbdinocluster
run: |
mkdir -p "$HOME/bin"
curl -L -o "$HOME/bin/cbdinocluster" https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.98/cbdinocluster-linux-amd64
chmod a+x "$HOME/bin/cbdinocluster"
echo "$HOME/bin" >> $GITHUB_PATH
- name: Initialize cbdinocluster
- uses: actions/checkout@v4
- name: Create Couchbase cluster
id: create-cluster
uses: ./.github/actions/create-cluster
with:
version: ${{ matrix.server }}
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-linux
- uses: actions/download-artifact@v4
with:
name: couchbase-opentelemetry-${{ needs.source.outputs.otel_gem_version }}
- uses: actions/download-artifact@v4
with:
name: scripts-${{ needs.source.outputs.gem_version }}
- uses: actions/download-artifact@v4
with:
name: tests-${{ needs.source.outputs.gem_version }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
- name: Install
run: |
cbdinocluster -v init --auto
- name: Start couchbase cluster
COUCHBASE_GEM_PATH=$(realpath couchbase-${{ needs.source.outputs.gem_version }}-*.gem)
COUCHBASE_OPENTELEMETRY_GEM_PATH=$(realpath couchbase-opentelemetry-${{ needs.source.outputs.otel_gem_version }}.gem)
mkdir -p local-gem-repo/gems
mv ${COUCHBASE_GEM_PATH} local-gem-repo/gems
mv ${COUCHBASE_OPENTELEMETRY_GEM_PATH} local-gem-repo/gems
GEM_REPO_PATH=$(realpath local-gem-repo)
gem generate_index --directory local-gem-repo
ruby -i.bak -pe "gsub(/gemspec$/, 'gem \"couchbase\", source: \"file://${GEM_REPO_PATH}\"')" Gemfile
ruby -i.bak -pe "gsub(/gemspec path: \"couchbase-opentelemetry\"$/, 'gem \"couchbase-opentelemetry\", source: \"file://${GEM_REPO_PATH}\"')" Gemfile
bundle install
bundle exec ruby -r bundler/setup -r couchbase -r couchbase/opentelemetry -e 'pp Couchbase::VERSION, Couchbase::BUILD_INFO, {otel: Couchbase::OpenTelemetry::VERSION}'
- name: Test
env:
CLUSTERCONFIG: |
nodes:
- count: 2
version: ${{ matrix.server }}
services:
- kv
- n1ql
- index
- count: 1
version: ${{ matrix.server }}
services:
- kv
- fts
- cbas
docker:
kv-memory: 1500
fts-memory: 2048
expiry: 1h
TEST_CONNECTION_STRING: ${{ steps.create-cluster.outputs.connstr }}?dump_configuration=true
TEST_SERVER_VERSION: ${{ matrix.server }}
run: |
CLUSTER_ID=$(cbdinocluster -v allocate --def="${CLUSTERCONFIG}")
CONNECTION_STRING=$(cbdinocluster -v connstr "${CLUSTER_ID}")
cbdinocluster -v buckets add ${CLUSTER_ID} default --ram-quota-mb=100 --flush-enabled=true
cbdinocluster -v buckets load-sample ${CLUSTER_ID} travel-sample
echo "CLUSTER_ID=${CLUSTER_ID}" >> "$GITHUB_ENV"
echo "TEST_CONNECTION_STRING=${CONNECTION_STRING}?dump_configuration=true" >> "$GITHUB_ENV"
bundle exec rake test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4.1.0
if: always()
with:
check_name: 🐧server, ee-${{ matrix.server }}
report_paths: test/reports/*.xml
require_tests: true
annotate_only: true
- name: Collect server logs
timeout-minutes: 15
if: failure()
run: |
mkdir -p logs
cbdinocluster -v collect-logs ${{ steps.create-cluster.outputs.id }} ./logs
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ github.run_attempt }}-${{ matrix.server }}-logs
path: |
logs/*
test/**/*.{log,xml}
retention-days: 5

test_cng_linux_x86_64:
timeout-minutes: 60
needs:
- source
- repackage_linux_x86_64
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
server:
- 8.0.0
steps:
- uses: actions/checkout@v4
- name: Create Couchbase cluster
id: create-cluster
uses: ./.github/actions/create-cluster
with:
version: ${{ matrix.server }}
- name: Start CNG
id: start-cng
uses: ./.github/actions/start-cng
with:
couchbase-hostname: ${{ steps.create-cluster.outputs.ip }}
cng-ref: 3949daef30ebe55d75690cd7e487bfae7da82c9f
- uses: actions/download-artifact@v4
with:
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-linux
Expand Down Expand Up @@ -790,14 +842,15 @@ jobs:
bundle exec ruby -r bundler/setup -r couchbase -r couchbase/opentelemetry -e 'pp Couchbase::VERSION, Couchbase::BUILD_INFO, {otel: Couchbase::OpenTelemetry::VERSION}'
- name: Test
env:
TEST_CONNECTION_STRING: ${{ steps.start-cng.outputs.cng-connection-string }}?trust_certificate=${{ steps.start-cng.outputs.ca-cert-path }}
TEST_SERVER_VERSION: ${{ matrix.server }}
run: |
bundle exec rake test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4.1.0
if: always()
with:
check_name: 🐧server, ee-${{ matrix.server }}
check_name: 🐧cng, ee-${{ matrix.server }}
report_paths: test/reports/*.xml
require_tests: true
annotate_only: true
Expand All @@ -806,7 +859,7 @@ jobs:
if: failure()
run: |
mkdir -p logs
cbdinocluster -v collect-logs $CLUSTER_ID ./logs
cbdinocluster -v collect-logs ${{ steps.create-cluster.outputs.id }} ./logs
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions lib/couchbase/datastructures/couchbase_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseList.new)
@options = options
@cas = 0
@observability = @collection.instance_variable_get(:@observability)
@observability = Observability::Wrapper.new if @observability.nil?
end

# Calls the given block once for each element in the list, passing that element as a parameter.
Expand Down
1 change: 1 addition & 0 deletions lib/couchbase/datastructures/couchbase_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseMap.new)
@options = options
@cas = 0
@observability = collection.instance_variable_get(:@observability)
@observability = Observability::Wrapper.new if @observability.nil?
end

# Calls the given block once for each element in the map, passing that element as a parameter.
Expand Down
1 change: 1 addition & 0 deletions lib/couchbase/datastructures/couchbase_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseQueue.new)
@options = options
@cas = 0
@observability = @collection.instance_variable_get(:@observability)
@observability = Observability::Wrapper.new if @observability.nil?
end

# Calls the given block once for each element in the queue, passing that element as a parameter.
Expand Down
1 change: 1 addition & 0 deletions lib/couchbase/datastructures/couchbase_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseSet.new)
@options = options
@cas = 0
@observability = @collection.instance_variable_get(:@observability)
@observability = Observability::Wrapper.new if @observability.nil?
end

# Calls the given block once for each element in the set, passing that element as a parameter.
Expand Down
2 changes: 1 addition & 1 deletion lib/couchbase/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def context=(context)
end

def to_s
result = super
result = +super
result << ", context=#{JSON.generate(@context)}" if @context
result << ", cause=#{@cause}" if @cause
result
Expand Down
2 changes: 0 additions & 2 deletions lib/couchbase/protostellar/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

require_relative "error_handling"

require_relative "generated/routing/v1/routing_services_pb"
require_relative "generated/kv/v1/kv_services_pb"
require_relative "generated/query/v1/query_services_pb"
require_relative "generated/search/v1/search_services_pb"
Expand All @@ -37,7 +36,6 @@ def initialize(host:, credentials:, channel_args:, call_metadata:, timeouts:)
@timeouts = timeouts

@stubs = {
routing: Generated::Routing::V1::RoutingService::Stub.new(host, credentials, channel_override: @channel),
kv: Generated::KV::V1::KvService::Stub.new(host, credentials, channel_override: @channel),
query: Generated::Query::V1::QueryService::Stub.new(host, credentials, channel_override: @channel),
search: Generated::Search::V1::SearchService::Stub.new(host, credentials, channel_override: @channel),
Expand Down
4 changes: 4 additions & 0 deletions lib/couchbase/protostellar/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def ping(_options = Options::Ping::DEFAULT)
raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support ping"
end

def search_indexes
raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support search index management"
end

private

def initialize(host, options = ConnectOptions.new)
Expand Down
Loading
Loading