Skip to content

Commit 5c12a39

Browse files
GODRIVER-2736 Deprecate currentOp/collStats commands (#1280)
Co-authored-by: Kevin Albertson <[email protected]>
1 parent 71edba3 commit 5c12a39

File tree

7 files changed

+84
-127
lines changed

7 files changed

+84
-127
lines changed

examples/documentation_examples/examples.go

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,7 @@ func CausalConsistencyExamples(client *mongo.Client) error {
26252625
}
26262626

26272627
// RunCommandExamples contains examples of RunCommand operations.
2628-
// Appears at https://www.mongodb.com/docs/manual/reference/command/collStats/.
2628+
// Appears at https://www.mongodb.com/docs/manual/reference/command/buildInfo/.
26292629
func RunCommandExamples(t *testing.T, db *mongo.Database) {
26302630
ctx := context.Background()
26312631

@@ -2634,61 +2634,12 @@ func RunCommandExamples(t *testing.T, db *mongo.Database) {
26342634
err := coll.Drop(ctx)
26352635
require.NoError(t, err)
26362636

2637-
restaurants := []interface{}{
2638-
bson.D{
2639-
{"name", "Chez Panisse"},
2640-
{"city", "Oakland"},
2641-
{"state", "California"},
2642-
{"country", "United States"},
2643-
{"rating", 4.4},
2644-
},
2645-
bson.D{
2646-
{"name", "Central"},
2647-
{"city", "Lima"},
2648-
{"country", "Peru"},
2649-
{"rating", 4.8},
2650-
},
2651-
bson.D{
2652-
{"name", "Eleven Madison Park"},
2653-
{"city", "New York City"},
2654-
{"state", "New York"},
2655-
{"country", "United States"},
2656-
{"rating", 4.6},
2657-
},
2658-
bson.D{
2659-
{"name", "Gaggan"},
2660-
{"city", "Bangkok"},
2661-
{"country", "Thailand"},
2662-
{"rating", 4.3},
2663-
},
2664-
bson.D{
2665-
{"name", "Dad's Grill"},
2666-
{"city", "Oklahoma City"},
2667-
{"state", "Oklahoma"},
2668-
{"country", "United States"},
2669-
{"rating", 2.1},
2670-
},
2671-
}
2672-
2673-
result, err := coll.InsertMany(ctx, restaurants)
2674-
require.NoError(t, err)
2675-
require.Len(t, result.InsertedIDs, 5)
2676-
26772637
{
26782638
// Start RunCommand Example 1
26792639
res := db.RunCommand(ctx, bson.D{{"buildInfo", 1}})
26802640

26812641
// End RunCommand Example 1
26822642

2683-
err := res.Err()
2684-
require.NoError(t, err)
2685-
}
2686-
{
2687-
// Start RunCommand Example 2
2688-
res := db.RunCommand(ctx, bson.D{{"collStats", "restaurants"}})
2689-
2690-
// End RunCommand Example 2
2691-
26922643
err := res.Err()
26932644
require.NoError(t, err)
26942645
}

mongo/integration/unified/collection_data.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
)
2121

2222
type collectionData struct {
23-
DatabaseName string `bson:"databaseName"`
24-
CollectionName string `bson:"collectionName"`
25-
Documents []bson.Raw `bson:"documents"`
26-
Options *collectionDataOptions `bson:"collectionOptions"`
23+
DatabaseName string `bson:"databaseName"`
24+
CollectionName string `bson:"collectionName"`
25+
Documents []bson.Raw `bson:"documents"`
26+
Options *createOptions `bson:"createOptions"`
2727
}
2828

29-
type collectionDataOptions struct {
29+
type createOptions struct {
3030
Capped *bool `bson:"capped"`
3131
SizeInBytes *int64 `bson:"size"`
3232
}

testdata/client-side-encryption/legacy/bypassedCommand.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
]
7979
},
8080
{
81-
"description": "current op is not bypassed",
81+
"description": "kill op is not bypassed",
8282
"clientOptions": {
8383
"autoEncryptOpts": {
8484
"kmsProviders": {
@@ -90,14 +90,15 @@
9090
{
9191
"name": "runCommand",
9292
"object": "database",
93-
"command_name": "currentOp",
93+
"command_name": "killOp",
9494
"arguments": {
9595
"command": {
96-
"currentOp": 1
96+
"killOp": 1,
97+
"op": 1234
9798
}
9899
},
99100
"result": {
100-
"errorContains": "command not supported for auto encryption: currentOp"
101+
"errorContains": "command not supported for auto encryption: killOp"
101102
}
102103
}
103104
]

testdata/client-side-encryption/legacy/bypassedCommand.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ tests:
2626
command:
2727
ping: 1
2828
command_name: ping
29-
- description: "current op is not bypassed"
29+
- description: "kill op is not bypassed"
3030
clientOptions:
3131
autoEncryptOpts:
3232
kmsProviders:
3333
aws: {} # Credentials filled in from environment.
3434
operations:
3535
- name: runCommand
3636
object: database
37-
command_name: currentOp
37+
command_name: killOp
3838
arguments:
3939
command:
40-
currentOp: 1
40+
killOp: 1
41+
op: 1234
4142
result:
42-
errorContains: "command not supported for auto encryption: currentOp"
43+
errorContains: "command not supported for auto encryption: killOp"

testdata/unified-test-format/valid-pass/initialCollectionData-collectionOptions.json renamed to testdata/unified-test-format/valid-pass/collectionData-createOptions.json

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
2-
"description": "initialCollectionData-collectionOptions",
3-
"schemaVersion": "1.5",
2+
"description": "collectionData-createOptions",
3+
"schemaVersion": "1.9",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "3.6",
7+
"serverless": "forbid"
8+
}
9+
],
410
"createEntities": [
511
{
612
"client": {
@@ -26,9 +32,9 @@
2632
{
2733
"collectionName": "coll0",
2834
"databaseName": "database0",
29-
"collectionOptions": {
35+
"createOptions": {
3036
"capped": true,
31-
"size": 512
37+
"size": 4096
3238
},
3339
"documents": [
3440
{
@@ -41,27 +47,31 @@
4147
"tests": [
4248
{
4349
"description": "collection is created with the correct options",
44-
"runOnRequirements": [
45-
{
46-
"minServerVersion": "3.6",
47-
"serverless": "forbid"
48-
}
49-
],
5050
"operations": [
5151
{
52-
"name": "runCommand",
53-
"object": "database0",
52+
"object": "collection0",
53+
"name": "aggregate",
5454
"arguments": {
55-
"commandName": "collStats",
56-
"command": {
57-
"collStats": "coll0",
58-
"scale": 1
59-
}
55+
"pipeline": [
56+
{
57+
"$collStats": {
58+
"storageStats": {}
59+
}
60+
},
61+
{
62+
"$project": {
63+
"capped": "$storageStats.capped",
64+
"maxSize": "$storageStats.maxSize"
65+
}
66+
}
67+
]
6068
},
61-
"expectResult": {
62-
"capped": true,
63-
"maxSize": 512
64-
}
69+
"expectResult": [
70+
{
71+
"capped": true,
72+
"maxSize": 4096
73+
}
74+
]
6575
}
6676
]
6777
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
description: collectionData-createOptions
2+
schemaVersion: "1.9"
3+
runOnRequirements:
4+
- minServerVersion: "3.6"
5+
# Capped collections cannot be created on serverless instances.
6+
serverless: forbid
7+
createEntities:
8+
- client:
9+
id: &client0 client0
10+
- database:
11+
id: &database0 database0
12+
client: *client0
13+
databaseName: &database0Name database0
14+
- collection:
15+
id: &collection0 collection0
16+
database: *database0
17+
collectionName: &collection0Name coll0
18+
initialData:
19+
- collectionName: *collection0Name
20+
databaseName: *database0Name
21+
createOptions:
22+
capped: true
23+
# With MMAPv1, the size field cannot be less than 4096.
24+
size: &cappedSize 4096
25+
documents:
26+
- { _id: 1, x: 11 }
27+
tests:
28+
- description: collection is created with the correct options
29+
operations:
30+
- object: *collection0
31+
name: aggregate
32+
arguments:
33+
pipeline:
34+
- $collStats: { storageStats: {} }
35+
- $project: { capped: '$storageStats.capped', maxSize: '$storageStats.maxSize'}
36+
expectResult:
37+
- { capped: true, maxSize: *cappedSize }

testdata/unified-test-format/valid-pass/initialCollectionData-collectionOptions.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)