Skip to content

Commit 28addb5

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

55 files changed

Lines changed: 822 additions & 404 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: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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: |
47+
go generate ./...
48+
go build -o stellar-gateway ./cmd/gateway
49+
50+
- name: Start Stellar Gateway
51+
shell: bash
52+
working-directory: stellar-gateway
53+
run: |
54+
./stellar-gateway \
55+
--cb-host "${{ inputs.couchbase-hostname }}" \
56+
--data-port 18098 \
57+
--cert cert.pem \
58+
--key key.pem &

.github/workflows/tests.yml

Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -724,42 +724,93 @@ 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+
- uses: actions/checkout@v4
728+
- name: Create Couchbase cluster
729+
id: create-cluster
730+
uses: ./.github/actions/create-cluster
731+
with:
732+
version: ${{ matrix.server }}
733+
- uses: actions/download-artifact@v4
734+
with:
735+
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-linux
736+
- uses: actions/download-artifact@v4
737+
with:
738+
name: couchbase-opentelemetry-${{ needs.source.outputs.otel_gem_version }}
739+
- uses: actions/download-artifact@v4
740+
with:
741+
name: scripts-${{ needs.source.outputs.gem_version }}
742+
- uses: actions/download-artifact@v4
743+
with:
744+
name: tests-${{ needs.source.outputs.gem_version }}
745+
- uses: ruby/setup-ruby@v1
746+
with:
747+
ruby-version: 3.3
748+
- name: Install
734749
run: |
735-
cbdinocluster -v init --auto
736-
- name: Start couchbase cluster
750+
COUCHBASE_GEM_PATH=$(realpath couchbase-${{ needs.source.outputs.gem_version }}-*.gem)
751+
COUCHBASE_OPENTELEMETRY_GEM_PATH=$(realpath couchbase-opentelemetry-${{ needs.source.outputs.otel_gem_version }}.gem)
752+
mkdir -p local-gem-repo/gems
753+
mv ${COUCHBASE_GEM_PATH} local-gem-repo/gems
754+
mv ${COUCHBASE_OPENTELEMETRY_GEM_PATH} local-gem-repo/gems
755+
GEM_REPO_PATH=$(realpath local-gem-repo)
756+
gem generate_index --directory local-gem-repo
757+
ruby -i.bak -pe "gsub(/gemspec$/, 'gem \"couchbase\", source: \"file://${GEM_REPO_PATH}\"')" Gemfile
758+
ruby -i.bak -pe "gsub(/gemspec path: \"couchbase-opentelemetry\"$/, 'gem \"couchbase-opentelemetry\", source: \"file://${GEM_REPO_PATH}\"')" Gemfile
759+
bundle install
760+
bundle exec ruby -r bundler/setup -r couchbase -r couchbase/opentelemetry -e 'pp Couchbase::VERSION, Couchbase::BUILD_INFO, {otel: Couchbase::OpenTelemetry::VERSION}'
761+
- name: Test
737762
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
763+
TEST_CONNECTION_STRING: ${{ steps.create-cluster.outputs.connstr }}?dump_configuration=true
764+
TEST_SERVER_VERSION: ${{ matrix.server }}
756765
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"
766+
bundle exec rake test
767+
- name: Publish Test Report
768+
uses: mikepenz/action-junit-report@v4.1.0
769+
if: always()
770+
with:
771+
check_name: 🐧server, ee-${{ matrix.server }}
772+
report_paths: test/reports/*.xml
773+
require_tests: true
774+
annotate_only: true
775+
- name: Collect server logs
776+
timeout-minutes: 15
777+
if: failure()
778+
run: |
779+
mkdir -p logs
780+
cbdinocluster -v collect-logs ${{ steps.create-cluster.outputs.id }} ./logs
781+
- name: Upload logs
782+
if: failure()
783+
uses: actions/upload-artifact@v4
784+
with:
785+
name: ${{ github.job }}-${{ github.run_attempt }}-${{ matrix.server }}-logs
786+
path: |
787+
logs/*
788+
test/**/*.{log,xml}
789+
retention-days: 5
790+
791+
test_cng_linux_x86_64:
792+
timeout-minutes: 60
793+
needs:
794+
- source
795+
- repackage_linux_x86_64
796+
runs-on: ubuntu-22.04
797+
strategy:
798+
fail-fast: false
799+
matrix:
800+
server:
801+
- 8.0.0
802+
steps:
803+
- uses: actions/checkout@v4
804+
- name: Create Couchbase cluster
805+
id: create-cluster
806+
uses: ./.github/actions/create-cluster
807+
with:
808+
version: ${{ matrix.server }}
809+
- name: Start CNG
810+
id: start-cng
811+
uses: ./.github/actions/start-cng
812+
with:
813+
couchbase-hostname: ${{ steps.create-cluster.outputs.ip }}
763814
- uses: actions/download-artifact@v4
764815
with:
765816
name: couchbase-${{ needs.source.outputs.gem_version }}-x86_64-linux
@@ -790,14 +841,15 @@ jobs:
790841
bundle exec ruby -r bundler/setup -r couchbase -r couchbase/opentelemetry -e 'pp Couchbase::VERSION, Couchbase::BUILD_INFO, {otel: Couchbase::OpenTelemetry::VERSION}'
791842
- name: Test
792843
env:
844+
TEST_CONNECTION_STRING: ${{ steps.start-cng.outputs.cng-connection-string }}?trust_certificate=${{ steps.start-cng.outputs.ca-cert-path }}
793845
TEST_SERVER_VERSION: ${{ matrix.server }}
794846
run: |
795847
bundle exec rake test
796848
- name: Publish Test Report
797849
uses: mikepenz/action-junit-report@v4.1.0
798850
if: always()
799851
with:
800-
check_name: 🐧server, ee-${{ matrix.server }}
852+
check_name: 🐧cng, ee-${{ matrix.server }}
801853
report_paths: test/reports/*.xml
802854
require_tests: true
803855
annotate_only: true
@@ -806,7 +858,7 @@ jobs:
806858
if: failure()
807859
run: |
808860
mkdir -p logs
809-
cbdinocluster -v collect-logs $CLUSTER_ID ./logs
861+
cbdinocluster -v collect-logs ${{ steps.create-cluster.outputs.id }} ./logs
810862
- name: Upload logs
811863
if: failure()
812864
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)