Skip to content

Commit b0455bf

Browse files
committed
minor fix for configureFailPoint
1 parent 5ab8f15 commit b0455bf

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

mongo/integration/cmd_monitoring_helpers_test.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,24 @@ func compareValues(mt *mtest.T, key string, expected, actual bson.RawValue) erro
8282
if typeVal, err := e.LookupErr("$$type"); err == nil {
8383
// $$type represents a type assertion
8484
// for example {field: {$$type: "binData"}} should assert that "field" is an element with a binary value
85-
return checkValueType(mt, key, actual.Type, typeVal.StringValue())
85+
switch t := typeVal.Type; t {
86+
case bson.TypeString:
87+
return checkValueType(mt, key, actual.Type, typeVal.StringValue())
88+
case bson.TypeArray:
89+
array := typeVal.Array()
90+
elems, err := array.Values()
91+
if err != nil {
92+
return err
93+
}
94+
for _, elem := range elems {
95+
if checkValueType(mt, key, actual.Type, elem.StringValue()) == nil {
96+
return nil
97+
}
98+
}
99+
return fmt.Errorf("BSON type mismatch for key %s; expected %s, got %s", key, array.String(), actual)
100+
default:
101+
return fmt.Errorf("unsupported $$type: %s", t.String())
102+
}
86103
}
87104

88105
a := actual.Document()

mongo/integration/mtest/mongotest.go

+5
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,11 @@ func (t *T) TrackFailPoint(fpName string) {
586586

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

0 commit comments

Comments
 (0)