Skip to content

Commit

Permalink
minor fix for configureFailPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Jun 1, 2024
1 parent 5ab8f15 commit b0455bf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 18 additions & 1 deletion mongo/integration/cmd_monitoring_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,24 @@ func compareValues(mt *mtest.T, key string, expected, actual bson.RawValue) erro
if typeVal, err := e.LookupErr("$$type"); err == nil {
// $$type represents a type assertion
// for example {field: {$$type: "binData"}} should assert that "field" is an element with a binary value
return checkValueType(mt, key, actual.Type, typeVal.StringValue())
switch t := typeVal.Type; t {
case bson.TypeString:
return checkValueType(mt, key, actual.Type, typeVal.StringValue())
case bson.TypeArray:
array := typeVal.Array()
elems, err := array.Values()
if err != nil {
return err
}
for _, elem := range elems {
if checkValueType(mt, key, actual.Type, elem.StringValue()) == nil {
return nil
}
}
return fmt.Errorf("BSON type mismatch for key %s; expected %s, got %s", key, array.String(), actual)
default:
return fmt.Errorf("unsupported $$type: %s", t.String())
}
}

a := actual.Document()
Expand Down
5 changes: 5 additions & 0 deletions mongo/integration/mtest/mongotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ func (t *T) TrackFailPoint(fpName string) {

// ClearFailPoints disables all previously set failpoints for this test.
func (t *T) ClearFailPoints() {
if t.clientOpts != nil && t.clientOpts.AutoEncryptionOptions != nil && len(t.failPointNames) > 0 {
t.Logf("configureFailPoint is not supported for auto encryption, skipping ClearFailPoints()")
t.failPointNames = t.failPointNames[:0]
return
}
db := t.Client.Database("admin")
for _, fp := range t.failPointNames {
cmd := bson.D{
Expand Down

0 comments on commit b0455bf

Please sign in to comment.