Skip to content

Commit 693bd8d

Browse files
committed
ING-1088: Add tests for durability err cases
ING-1088: Add durability impossible tests ING-1088: Run tests that change the cluster in paralell ING-1088: Run syncWriteAmbiguous test cases in paralell
1 parent fe2fa6a commit 693bd8d

File tree

14 files changed

+1173
-35
lines changed

14 files changed

+1173
-35
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Install cbdinocluster
2+
3+
inputs:
4+
github-token:
5+
required: true
6+
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Install cbdinocluster
11+
shell: bash
12+
run: |
13+
mkdir -p "$HOME/bin"
14+
wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.86/cbdinocluster-linux-amd64
15+
chmod +x $HOME/bin/cbdinocluster
16+
echo "$HOME/bin" >> $GITHUB_PATH
17+
- name: Initialize cbdinocluster
18+
shell: bash
19+
env:
20+
GITHUB_TOKEN: ${{ inputs.github-token }}
21+
run: |
22+
cbdinocluster -v init --auto
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Start Couchbase Cluster
2+
3+
outputs:
4+
dino-id:
5+
description: "Dinocluster ID of the Couchbase Cluster"
6+
value: ${{ steps.start-couchbase-cluster.outputs.dino-id }}
7+
node-ip:
8+
description: "Ip address of a node"
9+
value: ${{ steps.start-couchbase-cluster.outputs.node-ip }}
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Start Couchbase Cluster
15+
id: start-couchbase-cluster
16+
shell: bash
17+
env:
18+
CLUSTERCONFIG: |
19+
nodes:
20+
- count: 3
21+
version: ${{ matrix.server }}
22+
services: [kv, n1ql, index, fts, cbas]
23+
docker:
24+
kv-memory: 2048
25+
index-memory: 1024
26+
fts-memory: 1024
27+
run: |
28+
CBDC_ID=$(cbdinocluster -v alloc --def="${CLUSTERCONFIG}")
29+
cbdinocluster -v buckets add ${CBDC_ID} default --ram-quota-mb=100 --flush-enabled=true --num-replicas=2
30+
cbdinocluster -v collections add ${CBDC_ID} default _default test
31+
cbdinocluster -v query ${CBDC_ID} "CREATE PRIMARY INDEX ON default"
32+
CBDC_IP=$(cbdinocluster -v ip $CBDC_ID)
33+
echo "dino-id=$(echo $CBDC_ID)" >> $GITHUB_OUTPUT
34+
echo "node-ip=$(echo $CBDC_IP)" >> $GITHUB_OUTPUT
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run Data API Durability Impossible Tests
2+
permissions:
3+
contents: read
4+
packages: read
5+
6+
on:
7+
push:
8+
tags:
9+
- v*
10+
branches:
11+
- master
12+
pull_request:
13+
jobs:
14+
test:
15+
name: Test
16+
strategy:
17+
matrix:
18+
server:
19+
- 8.0.0-3534
20+
- 7.6.5
21+
- 7.2.2
22+
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
- name: Install cbdinocluster
29+
uses: ./.github/actions/install-cbdinocluster
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Start couchbase cluster
33+
id: start-cluster
34+
uses: ./.github/actions/start-couchbase-cluster
35+
- uses: actions/setup-go@v5
36+
with:
37+
go-version: 1.24
38+
- uses: arduino/setup-protoc@v3
39+
with:
40+
version: 31.1
41+
repo-token: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Install Tools
43+
run: |
44+
go install google.golang.org/protobuf/cmd/[email protected]
45+
go install google.golang.org/grpc/cmd/[email protected]
46+
go install github.com/matryer/[email protected]
47+
- name: Install Dependencies
48+
run: go get ./...
49+
- name: Generate Files
50+
run: |
51+
go generate ./...
52+
- name: Run Test
53+
env:
54+
SGTEST_CBCONNSTR: ${{ steps.start-cluster.outputs.node-ip }}
55+
SGTEST_DINOID: ${{ steps.start-cluster.outputs.dino-id }}
56+
run: go test ./gateway/test -run TestGatewayOps -v -testify.m TestDapiDurabilityImpossible
57+
58+
- name: Collect couchbase logs
59+
timeout-minutes: 10
60+
if: failure()
61+
run: |
62+
mkdir -p ./dapi-durability-impossible-logs
63+
cbdinocluster -v collect-logs ${{ steps.start-cluster.outputs.dino-id }} ./dapi-durability-impossible-logs
64+
- name: Upload couchbase logs
65+
if: failure()
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: cbcollect-logs-${{ matrix.server }}
69+
path: ./dapi-durability-impossible-logs/*
70+
retention-days: 5
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run GRPC Durability Impossible Tests
2+
permissions:
3+
contents: read
4+
packages: read
5+
6+
on:
7+
push:
8+
tags:
9+
- v*
10+
branches:
11+
- master
12+
pull_request:
13+
jobs:
14+
test:
15+
name: Test
16+
strategy:
17+
matrix:
18+
server:
19+
- 8.0.0-3534
20+
- 7.6.5
21+
- 7.2.2
22+
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
- name: Install cbdinocluster
29+
uses: ./.github/actions/install-cbdinocluster
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Start couchbase cluster
33+
id: start-cluster
34+
uses: ./.github/actions/start-couchbase-cluster
35+
- uses: actions/setup-go@v5
36+
with:
37+
go-version: 1.24
38+
- uses: arduino/setup-protoc@v3
39+
with:
40+
version: 31.1
41+
repo-token: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Install Tools
43+
run: |
44+
go install google.golang.org/protobuf/cmd/[email protected]
45+
go install google.golang.org/grpc/cmd/[email protected]
46+
go install github.com/matryer/[email protected]
47+
- name: Install Dependencies
48+
run: go get ./...
49+
- name: Generate Files
50+
run: |
51+
go generate ./...
52+
- name: Run Test
53+
env:
54+
SGTEST_CBCONNSTR: ${{ steps.start-cluster.outputs.node-ip }}
55+
SGTEST_DINOID: ${{ steps.start-cluster.outputs.dino-id }}
56+
run: go test ./gateway/test -run TestGatewayOps -v -testify.m TestDurabilityImpossible
57+
58+
- name: Collect couchbase logs
59+
timeout-minutes: 10
60+
if: failure()
61+
run: |
62+
mkdir -p ./durability-impossible-logs
63+
cbdinocluster -v collect-logs ${{ steps.start-cluster.outputs.dino-id }} ./durability-impossible-logs
64+
- name: Upload couchbase logs
65+
if: failure()
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: cbcollect-logs-${{ matrix.server }}
69+
path: ./durability-impossible-logs/*
70+
retention-days: 5
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Run SyncWriteAmbiguous Tests
2+
permissions:
3+
contents: read
4+
packages: read
5+
6+
on:
7+
push:
8+
tags:
9+
- v*
10+
branches:
11+
- master
12+
pull_request:
13+
jobs:
14+
test:
15+
name: Test
16+
strategy:
17+
matrix:
18+
server:
19+
- 8.0.0-3534
20+
- 7.6.5
21+
- 7.2.2
22+
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
- name: Install cbdinocluster
29+
uses: ./.github/actions/install-cbdinocluster
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Start couchbase cluster
33+
id: start-cluster
34+
uses: ./.github/actions/start-couchbase-cluster
35+
36+
- uses: actions/setup-go@v5
37+
with:
38+
go-version: 1.24
39+
- uses: arduino/setup-protoc@v3
40+
with:
41+
version: 31.1
42+
repo-token: ${{ secrets.GITHUB_TOKEN }}
43+
- name: Install Tools
44+
run: |
45+
go install google.golang.org/protobuf/cmd/[email protected]
46+
go install google.golang.org/grpc/cmd/[email protected]
47+
go install github.com/matryer/[email protected]
48+
- name: Install Dependencies
49+
run: go get ./...
50+
- name: Generate Files
51+
run: |
52+
go generate ./...
53+
- name: Run Test
54+
env:
55+
SGTEST_CBCONNSTR: ${{ steps.start-cluster.outputs.node-ip }}
56+
SGTEST_DINOID: ${{ steps.start-cluster.outputs.dino-id }}
57+
run: go test ./gateway/test -run TestGatewayOps -v -testify.m TestSyncWriteAmbiguous
58+
59+
- name: Collect couchbase logs
60+
timeout-minutes: 10
61+
if: failure()
62+
run: |
63+
mkdir -p ./sync-write-ambiguous-logs
64+
cbdinocluster -v collect-logs ${{ steps.start-cluster.outputs.dino-id }} ./sync-write-ambiguous-logs
65+
- name: Upload couchbase logs
66+
if: failure()
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: cbcollect-logs-${{ matrix.server }}
70+
path: ./sync-write-ambiguous-logs/*
71+
retention-days: 5

.github/workflows/test.yml

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Tests
1+
name: Run Integration Tests
22
permissions:
33
contents: read
44
packages: read
@@ -12,7 +12,7 @@ on:
1212
pull_request:
1313
jobs:
1414
test:
15-
name: Integration Test
15+
name: Test
1616
strategy:
1717
matrix:
1818
server:
@@ -22,40 +22,16 @@ jobs:
2222

2323
runs-on: ubuntu-latest
2424
steps:
25-
- name: Install cbdinocluster
26-
run: |
27-
mkdir -p "$HOME/bin"
28-
wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.84/cbdinocluster-linux-amd64
29-
chmod +x $HOME/bin/cbdinocluster
30-
echo "$HOME/bin" >> $GITHUB_PATH
31-
- name: Initialize cbdinocluster
32-
run: |
33-
cbdinocluster -v init --auto
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
- name: Start couchbase cluster
37-
env:
38-
CLUSTERCONFIG: |
39-
nodes:
40-
- count: 3
41-
version: ${{ matrix.server }}
42-
services: [kv, n1ql, index, fts, cbas]
43-
docker:
44-
kv-memory: 2048
45-
index-memory: 1024
46-
fts-memory: 1024
47-
run: |
48-
CBDC_ID=$(cbdinocluster -v alloc --def="${CLUSTERCONFIG}")
49-
cbdinocluster -v buckets add ${CBDC_ID} default --ram-quota-mb=100 --flush-enabled=true --num-replicas=2
50-
cbdinocluster -v collections add ${CBDC_ID} default _default test
51-
cbdinocluster -v query ${CBDC_ID} "CREATE PRIMARY INDEX ON default"
52-
CBDC_IP=$(cbdinocluster -v ip $CBDC_ID)
53-
echo "CBDC_ID=$CBDC_ID" >> "$GITHUB_ENV"
54-
echo "CBDC_IP=$CBDC_IP" >> "$GITHUB_ENV"
55-
5625
- uses: actions/checkout@v4
5726
with:
5827
submodules: recursive
28+
- name: Install cbdinocluster
29+
uses: ./.github/actions/install-cbdinocluster
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Start couchbase cluster
33+
id: start-cluster
34+
uses: ./.github/actions/start-couchbase-cluster
5935
- uses: actions/setup-go@v5
6036
with:
6137
go-version: 1.24
@@ -76,15 +52,15 @@ jobs:
7652
- name: Run Tests
7753
timeout-minutes: 10
7854
env:
79-
SGTEST_CBCONNSTR: ${{ env.CBDC_IP }}
55+
SGTEST_CBCONNSTR: ${{ steps.start-cluster.outputs.node-ip }}
8056
run: go test -v $(go list ./... | grep -v /contrib/)
8157

8258
- name: Collect couchbase logs
8359
timeout-minutes: 10
8460
if: failure()
8561
run: |
8662
mkdir -p ./logs
87-
cbdinocluster -v collect-logs $CBDC_ID ./logs
63+
cbdinocluster -v collect-logs ${{ steps.start-cluster.outputs.dino-id }} ./logs
8864
- name: Upload couchbase logs
8965
if: failure()
9066
uses: actions/upload-artifact@v4

gateway/dapiimpl/server_v1/dataapi_crud.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ func (s *DataApiServer) UpdateDocument(
392392
return nil, s.errorHandler.NewCollectionNoWriteAccessStatus(err, in.BucketName, in.ScopeName, in.CollectionName).Err()
393393
} else if errors.Is(err, memdx.ErrValueTooLarge) {
394394
return nil, s.errorHandler.NewValueTooLargeStatus(err, in.BucketName, in.ScopeName, in.CollectionName, in.DocumentKey, false).Err()
395+
} else if errors.Is(err, memdx.ErrDurabilityImpossible) {
396+
return nil, s.errorHandler.NewDurabilityImpossibleStatus(err, in.BucketName).Err()
395397
} else if errors.Is(err, memdx.ErrInvalidArgument) {
396398
errType := memdx.ParseInvalidArgsError(err)
397399
if errType == memdx.InvalidArgsErrorCannotInflate {

gateway/dapiimpl/server_v1/dataapi_subdoc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ func (s *DataApiServer) MutateInDocument(
261261
return nil, s.errorHandler.NewSdBadCombo(err).Err()
262262
} else if errors.Is(err, memdx.ErrDocExists) {
263263
return nil, s.errorHandler.NewDocExistsStatus(err, in.BucketName, in.ScopeName, in.CollectionName, in.DocumentKey).Err()
264+
} else if errors.Is(err, memdx.ErrDurabilityImpossible) {
265+
return nil, s.errorHandler.NewDurabilityImpossibleStatus(err, in.BucketName).Err()
264266
} else {
265267
var subdocErr *memdx.SubDocError
266268
if errors.As(err, &subdocErr) {

0 commit comments

Comments
 (0)