From 4b810a7f25fd7a16377b744714290e4a104a87e2 Mon Sep 17 00:00:00 2001 From: Igor Kryvenko Date: Sat, 8 Sep 2018 16:35:49 +0300 Subject: [PATCH 1/3] GODRIVER-523: Support new readConcern level "available" --- core/readconcern/readconcern.go | 6 ++++++ .../connection-string/read-concern.json | 9 +++++++++ .../connection-string/read-concern.yml | 6 ++++++ data/read-write-concern/document/read-concern.json | 11 +++++++++++ data/read-write-concern/document/read-concern.yml | 6 ++++++ 5 files changed, 38 insertions(+) diff --git a/core/readconcern/readconcern.go b/core/readconcern/readconcern.go index 1b4862fb85..65c18fab33 100644 --- a/core/readconcern/readconcern.go +++ b/core/readconcern/readconcern.go @@ -40,6 +40,12 @@ func Linearizable() *ReadConcern { return New(Level("linearizable")) } +// Available specifies that the query should return data from the instance with no guarantee +// that the data has been written to a majority of the replica set members (i.e. may be rolled back). +func Available() *ReadConcern { + return New(Level("available")) +} + // New constructs a new read concern from the given string. func New(options ...Option) *ReadConcern { concern := &ReadConcern{} diff --git a/data/read-write-concern/connection-string/read-concern.json b/data/read-write-concern/connection-string/read-concern.json index dd2b792b29..0cdd6a1dea 100644 --- a/data/read-write-concern/connection-string/read-concern.json +++ b/data/read-write-concern/connection-string/read-concern.json @@ -24,6 +24,15 @@ "readConcern": { "level": "majority" } + }, + { + "description": "available specified", + "uri": "mongodb://localhost/?readConcernLevel=available", + "valid": true, + "warning": false, + "readConcern": { + "level": "available" + } } ] } diff --git a/data/read-write-concern/connection-string/read-concern.yml b/data/read-write-concern/connection-string/read-concern.yml index 1560763d43..1f4e548e60 100644 --- a/data/read-write-concern/connection-string/read-concern.yml +++ b/data/read-write-concern/connection-string/read-concern.yml @@ -17,3 +17,9 @@ tests: valid: true warning: false readConcern: { level: "majority" } + - + description: "available specified" + uri: "mongodb://localhost?readConcernLevel=available" + valid: true + warning: false + readConcern: { level: "available" } diff --git a/data/read-write-concern/document/read-concern.json b/data/read-write-concern/document/read-concern.json index ef2bafdf55..c7750f665d 100644 --- a/data/read-write-concern/document/read-concern.json +++ b/data/read-write-concern/document/read-concern.json @@ -28,6 +28,17 @@ "level": "local" }, "isServerDefault": false + }, + { + "description": "Available", + "valid": true, + "readConcern": { + "level": "available" + }, + "readConcernDocument": { + "level": "available" + }, + "isServerDefault": false } ] } diff --git a/data/read-write-concern/document/read-concern.yml b/data/read-write-concern/document/read-concern.yml index e20a2d24ec..0fd96ef1db 100644 --- a/data/read-write-concern/document/read-concern.yml +++ b/data/read-write-concern/document/read-concern.yml @@ -16,4 +16,10 @@ tests: valid: true readConcern: { level: "local" } readConcernDocument: { level: "local" } + isServerDefault: false + - + description: "Available" + valid: true + readConcern: { level: "available" } + readConcernDocument: { level: "available" } isServerDefault: false \ No newline at end of file From 323e3896da8bd63bc97c15a4227cd69d2f89ade1 Mon Sep 17 00:00:00 2001 From: Igor Kryvenko Date: Wed, 12 Sep 2018 23:17:37 +0300 Subject: [PATCH 2/3] GODRIVER-547: Resync read write concern tests to add new read concern levels --- core/readconcern/readconcern.go | 5 +++++ .../connection-string/read-concern.json | 18 +++++++++++++++ .../connection-string/read-concern.yml | 12 ++++++++++ .../document/read-concern.json | 22 +++++++++++++++++++ .../document/read-concern.yml | 12 ++++++++++ 5 files changed, 69 insertions(+) diff --git a/core/readconcern/readconcern.go b/core/readconcern/readconcern.go index 65c18fab33..79ec17a0e2 100644 --- a/core/readconcern/readconcern.go +++ b/core/readconcern/readconcern.go @@ -46,6 +46,11 @@ func Available() *ReadConcern { return New(Level("available")) } +// Only available for operations within multi-document transactions. +func Snapshot() *ReadConcern { + return New(Level("snapshot")) +} + // New constructs a new read concern from the given string. func New(options ...Option) *ReadConcern { concern := &ReadConcern{} diff --git a/data/read-write-concern/connection-string/read-concern.json b/data/read-write-concern/connection-string/read-concern.json index 0cdd6a1dea..960b47f51d 100644 --- a/data/read-write-concern/connection-string/read-concern.json +++ b/data/read-write-concern/connection-string/read-concern.json @@ -33,6 +33,24 @@ "readConcern": { "level": "available" } + }, + { + "description": "snapshot specified", + "uri": "mongodb://localhost/?readConcernLevel=snapshot", + "valid": true, + "warning": false, + "readConcern": { + "level": "snapshot" + } + }, + { + "description": "linearizable specified", + "uri": "mongodb://localhost/?readConcernLevel=linearizable", + "valid": true, + "warning": false, + "readConcern": { + "level": "linearizable" + } } ] } diff --git a/data/read-write-concern/connection-string/read-concern.yml b/data/read-write-concern/connection-string/read-concern.yml index 1f4e548e60..65de3243ff 100644 --- a/data/read-write-concern/connection-string/read-concern.yml +++ b/data/read-write-concern/connection-string/read-concern.yml @@ -23,3 +23,15 @@ tests: valid: true warning: false readConcern: { level: "available" } + - + description: "snapshot specified" + uri: "mongodb://localhost?readConcernLevel=snapshot" + valid: true + warning: false + readConcern: { level: "snapshot" } + - + description: "linearizable specified" + uri: "mongodb://localhost?readConcernLevel=linearizable" + valid: true + warning: false + readConcern: { level: "linearizable" } \ No newline at end of file diff --git a/data/read-write-concern/document/read-concern.json b/data/read-write-concern/document/read-concern.json index c7750f665d..950954e0d7 100644 --- a/data/read-write-concern/document/read-concern.json +++ b/data/read-write-concern/document/read-concern.json @@ -39,6 +39,28 @@ "level": "available" }, "isServerDefault": false + }, + { + "description": "Snapshot", + "valid": true, + "readConcern": { + "level": "snapshot" + }, + "readConcernDocument": { + "level": "snapshot" + }, + "isServerDefault": false + }, + { + "description": "Linearizable", + "valid": true, + "readConcern": { + "level": "linearizable" + }, + "readConcernDocument": { + "level": "linearizable" + }, + "isServerDefault": false } ] } diff --git a/data/read-write-concern/document/read-concern.yml b/data/read-write-concern/document/read-concern.yml index 0fd96ef1db..70679151c0 100644 --- a/data/read-write-concern/document/read-concern.yml +++ b/data/read-write-concern/document/read-concern.yml @@ -22,4 +22,16 @@ tests: valid: true readConcern: { level: "available" } readConcernDocument: { level: "available" } + isServerDefault: false + - + description: "Snapshot" + valid: true + readConcern: { level: "snapshot" } + readConcernDocument: { level: "snapshot" } + isServerDefault: false + - + description: "Linearizable" + valid: true + readConcern: { level: "linearizable" } + readConcernDocument: { level: "linearizable" } isServerDefault: false \ No newline at end of file From 58426f88e3d55a5abb96d970169135a7e2afa229 Mon Sep 17 00:00:00 2001 From: Igor Kryvenko Date: Mon, 17 Sep 2018 18:38:58 +0300 Subject: [PATCH 3/3] GODRIVER-547: Resync read write concern tests to add new read concern levels --- core/readconcern/readconcern.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/readconcern/readconcern.go b/core/readconcern/readconcern.go index 79ec17a0e2..aa8d01a3fe 100644 --- a/core/readconcern/readconcern.go +++ b/core/readconcern/readconcern.go @@ -46,7 +46,7 @@ func Available() *ReadConcern { return New(Level("available")) } -// Only available for operations within multi-document transactions. +// Snapshot is only available for operations within multi-document transactions. func Snapshot() *ReadConcern { return New(Level("snapshot")) }