Skip to content

GODRIVER-2736 Deprecate currentOp/collStats commands #1280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 1 addition & 50 deletions examples/documentation_examples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2625,7 +2625,7 @@ func CausalConsistencyExamples(client *mongo.Client) error {
}

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

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

restaurants := []interface{}{
bson.D{
{"name", "Chez Panisse"},
{"city", "Oakland"},
{"state", "California"},
{"country", "United States"},
{"rating", 4.4},
},
bson.D{
{"name", "Central"},
{"city", "Lima"},
{"country", "Peru"},
{"rating", 4.8},
},
bson.D{
{"name", "Eleven Madison Park"},
{"city", "New York City"},
{"state", "New York"},
{"country", "United States"},
{"rating", 4.6},
},
bson.D{
{"name", "Gaggan"},
{"city", "Bangkok"},
{"country", "Thailand"},
{"rating", 4.3},
},
bson.D{
{"name", "Dad's Grill"},
{"city", "Oklahoma City"},
{"state", "Oklahoma"},
{"country", "United States"},
{"rating", 2.1},
},
}

result, err := coll.InsertMany(ctx, restaurants)
require.NoError(t, err)
require.Len(t, result.InsertedIDs, 5)

{
// Start RunCommand Example 1
res := db.RunCommand(ctx, bson.D{{"buildInfo", 1}})

// End RunCommand Example 1

err := res.Err()
require.NoError(t, err)
}
{
// Start RunCommand Example 2
res := db.RunCommand(ctx, bson.D{{"collStats", "restaurants"}})

// End RunCommand Example 2

err := res.Err()
require.NoError(t, err)
}
Expand Down
10 changes: 5 additions & 5 deletions mongo/integration/unified/collection_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
)

type collectionData struct {
DatabaseName string `bson:"databaseName"`
CollectionName string `bson:"collectionName"`
Documents []bson.Raw `bson:"documents"`
Options *collectionDataOptions `bson:"collectionOptions"`
DatabaseName string `bson:"databaseName"`
CollectionName string `bson:"collectionName"`
Documents []bson.Raw `bson:"documents"`
Options *createOptions `bson:"createOptions"`
}

type collectionDataOptions struct {
type createOptions struct {
Capped *bool `bson:"capped"`
SizeInBytes *int64 `bson:"size"`
}
Expand Down
9 changes: 5 additions & 4 deletions testdata/client-side-encryption/legacy/bypassedCommand.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
]
},
{
"description": "current op is not bypassed",
"description": "kill op is not bypassed",
"clientOptions": {
"autoEncryptOpts": {
"kmsProviders": {
Expand All @@ -90,14 +90,15 @@
{
"name": "runCommand",
"object": "database",
"command_name": "currentOp",
"command_name": "killOp",
"arguments": {
"command": {
"currentOp": 1
"killOp": 1,
"op": 1234
}
},
"result": {
"errorContains": "command not supported for auto encryption: currentOp"
"errorContains": "command not supported for auto encryption: killOp"
}
}
]
Expand Down
9 changes: 5 additions & 4 deletions testdata/client-side-encryption/legacy/bypassedCommand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ tests:
command:
ping: 1
command_name: ping
- description: "current op is not bypassed"
- description: "kill op is not bypassed"
clientOptions:
autoEncryptOpts:
kmsProviders:
aws: {} # Credentials filled in from environment.
operations:
- name: runCommand
object: database
command_name: currentOp
command_name: killOp
arguments:
command:
currentOp: 1
killOp: 1
op: 1234
result:
errorContains: "command not supported for auto encryption: currentOp"
errorContains: "command not supported for auto encryption: killOp"
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"description": "initialCollectionData-collectionOptions",
"schemaVersion": "1.5",
"description": "collectionData-createOptions",
"schemaVersion": "1.9",
"runOnRequirements": [
{
"minServerVersion": "3.6",
"serverless": "forbid"
}
],
"createEntities": [
{
"client": {
Expand All @@ -26,9 +32,9 @@
{
"collectionName": "coll0",
"databaseName": "database0",
"collectionOptions": {
"createOptions": {
"capped": true,
"size": 512
"size": 4096
},
"documents": [
{
Expand All @@ -41,27 +47,31 @@
"tests": [
{
"description": "collection is created with the correct options",
"runOnRequirements": [
{
"minServerVersion": "3.6",
"serverless": "forbid"
}
],
"operations": [
{
"name": "runCommand",
"object": "database0",
"object": "collection0",
"name": "aggregate",
"arguments": {
"commandName": "collStats",
"command": {
"collStats": "coll0",
"scale": 1
}
"pipeline": [
{
"$collStats": {
"storageStats": {}
}
},
{
"$project": {
"capped": "$storageStats.capped",
"maxSize": "$storageStats.maxSize"
}
}
]
},
"expectResult": {
"capped": true,
"maxSize": 512
}
"expectResult": [
{
"capped": true,
"maxSize": 4096
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
description: collectionData-createOptions
schemaVersion: "1.9"
runOnRequirements:
- minServerVersion: "3.6"
# Capped collections cannot be created on serverless instances.
serverless: forbid
createEntities:
- client:
id: &client0 client0
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name database0
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0
initialData:
- collectionName: *collection0Name
databaseName: *database0Name
createOptions:
capped: true
# With MMAPv1, the size field cannot be less than 4096.
size: &cappedSize 4096
documents:
- { _id: 1, x: 11 }
tests:
- description: collection is created with the correct options
operations:
- object: *collection0
name: aggregate
arguments:
pipeline:
- $collStats: { storageStats: {} }
- $project: { capped: '$storageStats.capped', maxSize: '$storageStats.maxSize'}
expectResult:
- { capped: true, maxSize: *cappedSize }

This file was deleted.