gokv
gokv copied to clipboard
Add couchbase govk
This PR add supports for couchbase using gocb api version 2
To be possible run the tests you have two options
- starts couchbase and set the following env vars:
-
COUCHBASE_SERVER
must contains the connection string examplecouchbase://localhost
-
COUCHBASE_BUCKET
must contains the name of the bucket to test -
COUCHBASE_USERNAME
&COUCHBASE_PASSWORD
must contains the user and pass needed to access the couchbase
This can be done following this procedure using docker
- by running the tests with a bigger timeout (most of the time) and using the integration tag like in the example below. This integration tests starts a local container using
github.com/testcontainers/testcontainers-go
(you can check here and here how it works.
$ go test -v -timeout=600s -tags=integration ./...
2024/05/29 14:34:30 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 26.1.3
API Version: 1.44
Operating System: Ubuntu 24.04 LTS
Total Memory: 15806 MB
Resolved Docker Host: unix:///var/run/docker.sock
Resolved Docker Socket Path: /var/run/docker.sock
Test SessionID: 272a8f169a1a0cac2aa669bf15c7affb5f0c82e8c53b6e656244dcda14340428
Test ProcessID: 1a1ef910-978e-44d5-8557-2c6a73ac2160
2024/05/29 14:34:30 🐳 Creating container for image testcontainers/ryuk:0.7.0
2024/05/29 14:34:30 ✅ Container created: 84ddc12dec3d
2024/05/29 14:34:30 🐳 Starting container: 84ddc12dec3d
2024/05/29 14:34:30 ✅ Container started: 84ddc12dec3d
2024/05/29 14:34:30 🚧 Waiting for container id 84ddc12dec3d image: testcontainers/ryuk:0.7.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/05/29 14:34:30 🔔 Container is ready: 84ddc12dec3d
2024/05/29 14:34:30 🐳 Creating container for image couchbase:community-7.1.1
2024/05/29 14:34:30 ✅ Container created: 54dda7abeb27
2024/05/29 14:34:30 🐳 Starting container: 54dda7abeb27
2024/05/29 14:34:31 ✅ Container started: 54dda7abeb27
2024/05/29 14:34:31 🔔 Container is ready: 54dda7abeb27
=== RUN TestClient
couchbase_test.go:20: checking for couchbase connection string on env var "COUCHBASE_SERVER"
=== RUN TestClient/Test_client_with_codec_JSON
=== RUN TestClient/Test_client_with_codec_Gob
--- PASS: TestClient (0.02s)
--- PASS: TestClient/Test_client_with_codec_JSON (0.01s)
--- PASS: TestClient/Test_client_with_codec_Gob (0.01s)
PASS
2024/05/29 14:34:57 🐳 Terminating container: 54dda7abeb27
2024/05/29 14:34:57 🚫 Container terminated: 54dda7abeb27
ok github.com/philippgille/gokv/couchbase 27.600s
if there is no env var COUCHBASE_SERVER
set, the tests will be skipped.