Skip to content

Commit b495aa4

Browse files
committed
RCBC-541: Update protostellar version to latest & add GHA testing with CNG
1 parent 95134a4 commit b495aa4

54 files changed

Lines changed: 809 additions & 403 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: create-cluster
2+
description: Sets up a Couchbase cluster using cbdinocluster
3+
inputs:
4+
version:
5+
description: 'Couchbase Server version to use'
6+
required: true
7+
outputs:
8+
ip:
9+
description: 'The IP address of a node of the cluster'
10+
value: ${{ steps.start-cluster.outputs.ip }}
11+
connstr:
12+
description: 'Connection string to connect to the cluster'
13+
value: ${{ steps.start-cluster.outputs.connstr }}
14+
tls-connstr:
15+
description: 'Connection string to connect to the cluster over TLS'
16+
value: ${{ steps.start-cluster.outputs.tls-connstr }}
17+
id:
18+
description: 'The cbdinocluster ID of the created cluster'
19+
value: ${{ steps.start-cluster.outputs.id }}
20+
runs:
21+
using: composite
22+
steps:
23+
- name: Install cbdinocluster
24+
shell: bash
25+
run: |
26+
mkdir -p "$HOME/bin"
27+
wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.113/cbdinocluster-linux-amd64
28+
chmod +x $HOME/bin/cbdinocluster
29+
echo "$HOME/bin" >> $GITHUB_PATH
30+
- name: Initialize cbdinocluster
31+
shell: bash
32+
run: |
33+
cbdinocluster -v init --auto
34+
- name: Start Couchbase cluster
35+
id: start-cluster
36+
shell: bash
37+
env:
38+
CLUSTER_CONFIG: |
39+
nodes:
40+
- count: 2
41+
version: ${{ matrix.server }}
42+
services:
43+
- kv
44+
- n1ql
45+
- index
46+
- count: 1
47+
version: ${{ matrix.server }}
48+
services:
49+
- kv
50+
- fts
51+
- cbas
52+
docker:
53+
kv-memory: 1500
54+
fts-memory: 2048
55+
expiry: 1h
56+
run: |
57+
CBDC_ID=$(cbdinocluster -v alloc --def="${CLUSTER_CONFIG}")
58+
echo "CBDC_ID=$CBDC_ID" >> "$GITHUB_ENV"
59+
echo "ip=$(cbdinocluster -v ip $CBDC_ID)" >> "$GITHUB_OUTPUT"
60+
echo "connstr=$(cbdinocluster -v connstr --no-tls $CBDC_ID)" >> "$GITHUB_OUTPUT"
61+
echo "tls-connstr=$(cbdinocluster -v connstr --tls $CBDC_ID)" >> "$GITHUB_OUTPUT"
62+
echo "id=$CBDC_ID" >> "$GITHUB_OUTPUT"
63+
cbdinocluster certificates get-ca $CBDC_ID >> "$GITHUB_WORKSPACE/cluster.crt"
64+
- name: Add default bucket
65+
shell: bash
66+
run: |
67+
cbdinocluster buckets add $CBDC_ID default --ram-quota-mb 100
68+
- name: Load travel-sample bucket
69+
shell: bash
70+
run: |
71+
cbdinocluster buckets load-sample $CBDC_ID travel-sample
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Start CNG (Stellar Gateway)"
2+
description: "Checks out and starts the Couchbase Stellar Gateway (CNG), generating a self-signed certificate for TLS."
3+
4+
inputs:
5+
couchbase-hostname:
6+
description: "Hostname of the Couchbase cluster to connect CNG to"
7+
required: true
8+
9+
outputs:
10+
ca-cert-path:
11+
description: "Absolute path to the self-signed CA certificate"
12+
value: ${{ steps.generate-cert.outputs.ca-cert-path }}
13+
cng-connection-string:
14+
description: "The connection string for CNG"
15+
value: "couchbase2://localhost:18098"
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: stable
24+
25+
- name: Checkout Stellar Gateway
26+
uses: actions/checkout@v4
27+
with:
28+
repository: couchbase/stellar-gateway
29+
path: stellar-gateway
30+
31+
- name: Generate self-signed certificate
32+
id: generate-cert
33+
shell: bash
34+
working-directory: stellar-gateway
35+
run: |
36+
openssl req -x509 -newkey rsa:4096 -keyout key.pem \
37+
-out cert.pem -days 365 -nodes \
38+
-subj "/CN=CNG Local CA" \
39+
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
40+
41+
echo "ca-cert-path=$(pwd)/cert.pem" >> "$GITHUB_OUTPUT"
42+
43+
- name: Build Stellar Gateway
44+
shell: bash
45+
working-directory: stellar-gateway
46+
run: go build -o stellar-gateway ./cmd/gateway
47+
48+
- name: Start Stellar Gateway
49+
shell: bash
50+
working-directory: stellar-gateway
51+
run: |
52+
./stellar-gateway \
53+
--cb-host "${{ inputs.couchbase-hostname }}" \
54+
--data-port 18098 \
55+
--cert cert.pem \
56+
--key key.pem &

.github/workflows/tests.yml

Lines changed: 86 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -724,42 +724,92 @@ jobs:
724724
- 7.6.8
725725
- 7.2.9
726726
steps:
727-
- name: Install cbdinocluster
728-
run: |
729-
mkdir -p "$HOME/bin"
730-
curl -L -o "$HOME/bin/cbdinocluster" https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.98/cbdinocluster-linux-amd64
731-
chmod a+x "$HOME/bin/cbdinocluster"
732-
echo "$HOME/bin" >> $GITHUB_PATH
733-
- name: Initialize cbdinocluster
727+
- name: Create Couchbase cluster
728+
id: create-cluster
729+
uses: ./.github/actions/create-cluster
730+
with:
731+
version: ${{ matrix.server }}
732+
- uses: actions/download-artifact@v4
733+
with:
734+
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-linux
735+
- uses: actions/download-artifact@v4
736+
with:
737+
name: couchbase-opentelemetry-${{ needs.source.outputs.otel_gem_version }}
738+
- uses: actions/download-artifact@v4
739+
with:
740+
name: scripts-${{ needs.source.outputs.gem_version }}
741+
- uses: actions/download-artifact@v4
742+
with:
743+
name: tests-${{ needs.source.outputs.gem_version }}
744+
- uses: ruby/setup-ruby@v1
745+
with:
746+
ruby-version: 3.3
747+
- name: Install
734748
run: |
735-
cbdinocluster -v init --auto
736-
- name: Start couchbase cluster
749+
COUCHBASE_GEM_PATH=$(realpath couchbase-${{ needs.source.outputs.gem_version }}-*.gem)
750+
COUCHBASE_OPENTELEMETRY_GEM_PATH=$(realpath couchbase-opentelemetry-${{ needs.source.outputs.otel_gem_version }}.gem)
751+
mkdir -p local-gem-repo/gems
752+
mv ${COUCHBASE_GEM_PATH} local-gem-repo/gems
753+
mv ${COUCHBASE_OPENTELEMETRY_GEM_PATH} local-gem-repo/gems
754+
GEM_REPO_PATH=$(realpath local-gem-repo)
755+
gem generate_index --directory local-gem-repo
756+
ruby -i.bak -pe "gsub(/gemspec$/, 'gem \"couchbase\", source: \"file://${GEM_REPO_PATH}\"')" Gemfile
757+
ruby -i.bak -pe "gsub(/gemspec path: \"couchbase-opentelemetry\"$/, 'gem \"couchbase-opentelemetry\", source: \"file://${GEM_REPO_PATH}\"')" Gemfile
758+
bundle install
759+
bundle exec ruby -r bundler/setup -r couchbase -r couchbase/opentelemetry -e 'pp Couchbase::VERSION, Couchbase::BUILD_INFO, {otel: Couchbase::OpenTelemetry::VERSION}'
760+
- name: Test
737761
env:
738-
CLUSTERCONFIG: |
739-
nodes:
740-
- count: 2
741-
version: ${{ matrix.server }}
742-
services:
743-
- kv
744-
- n1ql
745-
- index
746-
- count: 1
747-
version: ${{ matrix.server }}
748-
services:
749-
- kv
750-
- fts
751-
- cbas
752-
docker:
753-
kv-memory: 1500
754-
fts-memory: 2048
755-
expiry: 1h
762+
TEST_CONNECTION_STRING: ${{ steps.create-cluster.outputs.connstr }}?dump_configuration=true
763+
TEST_SERVER_VERSION: ${{ matrix.server }}
764+
run: |
765+
bundle exec rake test
766+
- name: Publish Test Report
767+
uses: mikepenz/action-junit-report@v4.1.0
768+
if: always()
769+
with:
770+
check_name: 🐧server, ee-${{ matrix.server }}
771+
report_paths: test/reports/*.xml
772+
require_tests: true
773+
annotate_only: true
774+
- name: Collect server logs
775+
timeout-minutes: 15
776+
if: failure()
756777
run: |
757-
CLUSTER_ID=$(cbdinocluster -v allocate --def="${CLUSTERCONFIG}")
758-
CONNECTION_STRING=$(cbdinocluster -v connstr "${CLUSTER_ID}")
759-
cbdinocluster -v buckets add ${CLUSTER_ID} default --ram-quota-mb=100 --flush-enabled=true
760-
cbdinocluster -v buckets load-sample ${CLUSTER_ID} travel-sample
761-
echo "CLUSTER_ID=${CLUSTER_ID}" >> "$GITHUB_ENV"
762-
echo "TEST_CONNECTION_STRING=${CONNECTION_STRING}?dump_configuration=true" >> "$GITHUB_ENV"
778+
mkdir -p logs
779+
cbdinocluster -v collect-logs ${{ steps.create-cluster.outputs.id }} ./logs
780+
- name: Upload logs
781+
if: failure()
782+
uses: actions/upload-artifact@v4
783+
with:
784+
name: ${{ github.job }}-${{ github.run_attempt }}-${{ matrix.server }}-logs
785+
path: |
786+
logs/*
787+
test/**/*.{log,xml}
788+
retention-days: 5
789+
790+
test_linux_x86_64_cng:
791+
timeout-minutes: 60
792+
needs:
793+
- source
794+
- repackage_linux_x86_64
795+
runs-on: ubuntu-22.04
796+
strategy:
797+
fail-fast: false
798+
matrix:
799+
server:
800+
- 8.0.0
801+
steps:
802+
- uses: actions/checkout@v4
803+
- name: Create Couchbase cluster
804+
id: create-cluster
805+
uses: ./.github/actions/create-cluster
806+
with:
807+
version: ${{ matrix.server }}
808+
- name: Start CNG
809+
id: start-cng
810+
uses: ./.github/actions/start-cng
811+
with:
812+
couchbase-hostname: ${{ steps.create-cluster.outputs.ip }}
763813
- uses: actions/download-artifact@v4
764814
with:
765815
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-linux
@@ -790,14 +840,15 @@ jobs:
790840
bundle exec ruby -r bundler/setup -r couchbase -r couchbase/opentelemetry -e 'pp Couchbase::VERSION, Couchbase::BUILD_INFO, {otel: Couchbase::OpenTelemetry::VERSION}'
791841
- name: Test
792842
env:
843+
TEST_CONNECTION_STRING: ${{ steps.start-cng.outputs.cng-connection-string }}?trust_certificate=${{ steps.start-cng.outputs.ca-cert-path }}
793844
TEST_SERVER_VERSION: ${{ matrix.server }}
794845
run: |
795846
bundle exec rake test
796847
- name: Publish Test Report
797848
uses: mikepenz/action-junit-report@v4.1.0
798849
if: always()
799850
with:
800-
check_name: 🐧server, ee-${{ matrix.server }}
851+
check_name: 🐧cng, ee-${{ matrix.server }}
801852
report_paths: test/reports/*.xml
802853
require_tests: true
803854
annotate_only: true
@@ -806,7 +857,7 @@ jobs:
806857
if: failure()
807858
run: |
808859
mkdir -p logs
809-
cbdinocluster -v collect-logs $CLUSTER_ID ./logs
860+
cbdinocluster -v collect-logs ${{ steps.create-cluster.outputs.id }} ./logs
810861
- name: Upload logs
811862
if: failure()
812863
uses: actions/upload-artifact@v4

lib/couchbase/datastructures/couchbase_list.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseList.new)
3838
@options = options
3939
@cas = 0
4040
@observability = @collection.instance_variable_get(:@observability)
41+
@observability = Observability::Wrapper.new if @observability.nil?
4142
end
4243

4344
# Calls the given block once for each element in the list, passing that element as a parameter.

lib/couchbase/datastructures/couchbase_map.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseMap.new)
3838
@options = options
3939
@cas = 0
4040
@observability = collection.instance_variable_get(:@observability)
41+
@observability = Observability::Wrapper.new if @observability.nil?
4142
end
4243

4344
# Calls the given block once for each element in the map, passing that element as a parameter.

lib/couchbase/datastructures/couchbase_queue.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseQueue.new)
3838
@options = options
3939
@cas = 0
4040
@observability = @collection.instance_variable_get(:@observability)
41+
@observability = Observability::Wrapper.new if @observability.nil?
4142
end
4243

4344
# Calls the given block once for each element in the queue, passing that element as a parameter.

lib/couchbase/datastructures/couchbase_set.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def initialize(id, collection, options = Options::CouchbaseSet.new)
3838
@options = options
3939
@cas = 0
4040
@observability = @collection.instance_variable_get(:@observability)
41+
@observability = Observability::Wrapper.new if @observability.nil?
4142
end
4243

4344
# Calls the given block once for each element in the set, passing that element as a parameter.

lib/couchbase/errors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def context=(context)
4444
end
4545

4646
def to_s
47-
result = super
47+
result = +super
4848
result << ", context=#{JSON.generate(@context)}" if @context
4949
result << ", cause=#{@cause}" if @cause
5050
result

lib/couchbase/protostellar/client.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
require_relative "error_handling"
1818

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

3938
@stubs = {
40-
routing: Generated::Routing::V1::RoutingService::Stub.new(host, credentials, channel_override: @channel),
4139
kv: Generated::KV::V1::KvService::Stub.new(host, credentials, channel_override: @channel),
4240
query: Generated::Query::V1::QueryService::Stub.new(host, credentials, channel_override: @channel),
4341
search: Generated::Search::V1::SearchService::Stub.new(host, credentials, channel_override: @channel),

0 commit comments

Comments
 (0)