Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
29 changes: 29 additions & 0 deletions internal/integration/unified/database_operation_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,35 @@ func executeListCollectionNames(ctx context.Context, operation *operation) (*ope
return newValueResult(bson.TypeArray, data, nil), nil
}

func executeModifyCollection(ctx context.Context, operation *operation) (*operationResult, error) {
db, err := entities(ctx).database(operation.Object)
if err != nil {
return nil, err
}

collModCmd := bson.D{}

elems, _ := operation.Arguments.Elements()
for _, elem := range elems {
key := elem.Key()
val := elem.Value()

switch key {
case "collection":
collModCmd = append(collModCmd, bson.E{"collMod", val.StringValue()})
case "changeStreamPreAndPostImages":
collModCmd = append(collModCmd, bson.E{"changeStreamPreAndPostImages", val.Document()})
case "validator":
collModCmd = append(collModCmd, bson.E{"validator", val.Document()})
default:
return nil, fmt.Errorf("unrecognized modifyCollection option %q", key)
}
}

res, err := db.RunCommand(ctx, collModCmd).Raw()
return newDocumentResult(res, err), nil
}

func executeRunCommand(ctx context.Context, operation *operation) (*operationResult, error) {
db, err := entities(ctx).database(operation.Object)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion internal/integration/unified/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ func (op *operation) run(ctx context.Context, loopDone <-chan struct{}) (*operat
return executeListCollections(ctx, op)
case "listCollectionNames":
return executeListCollectionNames(ctx, op)
case "modifyCollection":
return executeModifyCollection(ctx, op)
case "runCommand":
return executeRunCommand(ctx, op)
case "runCursorCommand":
Expand Down Expand Up @@ -268,7 +270,7 @@ func (op *operation) run(ctx context.Context, loopDone <-chan struct{}) (*operat
return executeAddKeyAltName(ctx, op)

// Unsupported operations
case "count", "listIndexNames", "modifyCollection":
case "count", "listIndexNames":
return nil, newSkipTestError(fmt.Sprintf("the %q operation is not supported", op.Name))
default:
return nil, fmt.Errorf("unrecognized entity operation %q", op.Name)
Expand Down
Loading