Update MongoDB tests to not fail in Go 1.16#11533
Merged
Conversation
Valarissa
reviewed
May 4, 2021
| t.Helper() | ||
|
|
||
| if diff := cmp.Diff(a, b, cmpClientOptionsOpts); diff != "" { | ||
| t.Fatalf("assertion failed: values are not equal\n--- expected\n+++ actual\n%v", diff) |
There was a problem hiding this comment.
Could we see an output of this error message? Is it expecting no differences and then lists out the differences?
Contributor
Author
There was a problem hiding this comment.
Note: I flipped the assertion so it has the expected value on the left and the actual on the right.
Here's a failure if I change the expectedOpts in the TestGetTLSAuth/good_ca test to not include the provided cert.Pem:
Updated test case:
"good ca": {
tlsCAData: cert.Pem,
expectOpts: options.Client().
SetTLSConfig(
&tls.Config{
RootCAs: x509.NewCertPool(), // <-- Note the missing CA
},
),
expectErr: false,
},
Test output:
$ go test -v -run TestGetTLSAuth/good_ca
=== RUN TestGetTLSAuth
=== RUN TestGetTLSAuth/good_ca
mongodb_test.go:353: assertion failed: values are not equal
--- expected
+++ actual
&options.ClientOptions{
... // 22 identical fields
ServerSelectionTimeout: nil,
SocketTimeout: nil,
TLSConfig: &tls.Config{
... // 7 identical fields
VerifyPeerCertificate: ⟪0x00⟫,
VerifyConnection: ⟪0x00⟫,
- RootCAs: nil,
+ RootCAs: &x509.CertPool{
+ byName: map[string][]int{"0\x141\x120\x10\x06\x03U\x04\x03\x13\ttest cert": {0}},
+ lazyCerts: []x509.lazyCert{{rawSubject: []uint8{...}, getCert: ⟪0x0124c580⟫}},
+ haveSum: map[x509.sum224]bool{
+ {0xbd, 0x0c, 0xeb, 0xa8, 0xfe, 0xaa, 0xe8, 0xaf, 0x6d, 0xdf, 0xb9, 0x82, 0x58, 0xff, 0x0c, 0x27, 0x3a, 0xbd, 0xd4, 0xba, 0x24, 0x8b, 0x47, 0xef, 0xbc, 0xbc, 0x78, 0xf0}: true,
+ },
+ },
NextProtos: nil,
ServerName: "",
... // 1 ignored and 16 identical fields
},
WriteConcern: nil,
ZlibLevel: nil,
... // 6 identical fields
}
--- FAIL: TestGetTLSAuth (0.44s)
--- FAIL: TestGetTLSAuth/good_ca (0.00s)
FAIL
exit status 1
FAIL github.com/hashicorp/vault/plugins/database/mongodb 0.881s
Same thing, but messing with the good key test:
"good key": {
username: "unittest",
tlsKeyData: cert.CombinedPEM(),
expectOpts: options.Client().
SetTLSConfig(
&tls.Config{}, // <-- Note the missing cert
).
SetAuth(options.Credential{
AuthMechanism: "MONGODB-X509",
Username: "unittest",
}),
expectErr: false,
},
Test Output:
$ go test -v -run TestGetTLSAuth/good_key
=== RUN TestGetTLSAuth
=== RUN TestGetTLSAuth/good_key
mongodb_test.go:353: assertion failed: values are not equal
--- expected
+++ actual
&options.ClientOptions{
... // 22 identical fields
ServerSelectionTimeout: nil,
SocketTimeout: nil,
TLSConfig: &tls.Config{
Rand: nil,
Time: ⟪0x00⟫,
- Certificates: nil,
+ Certificates: []tls.Certificate{
+ {
+ Certificate: [][]uint8{{...}},
+ PrivateKey: &rsa.PrivateKey{
+ PublicKey: rsa.PublicKey{...},
+ D: s"99111349761763075119885005748638"...,
+ Primes: []*big.Int{...},
+ Precomputed: rsa.PrecomputedValues{...},
+ },
+ },
+ },
NameToCertificate: nil,
GetCertificate: ⟪0x00⟫,
... // 1 ignored and 23 identical fields
},
WriteConcern: nil,
ZlibLevel: nil,
... // 6 identical fields
}
--- FAIL: TestGetTLSAuth (0.30s)
--- FAIL: TestGetTLSAuth/good_key (0.00s)
FAIL
exit status 1
FAIL github.com/hashicorp/vault/plugins/database/mongodb 0.730s
Valarissa
approved these changes
May 4, 2021
Valarissa
left a comment
There was a problem hiding this comment.
Looks good to me, but I'd love to see an example of the error message output!
|
Thanks for that update! Looks great! |
calvn
approved these changes
May 5, 2021
|
|
||
| "github.com/google/go-cmp/cmp" | ||
| "github.com/google/go-cmp/cmp/cmpopts" | ||
|
|
Contributor
There was a problem hiding this comment.
Can you remove the extra newline here?
austingebauer
approved these changes
May 5, 2021
ncabatoff
pushed a commit
that referenced
this pull request
Dec 14, 2021
# Conflicts: # .circleci/config.yml # .circleci/config/commands/go_test.yml
pull bot
pushed a commit
to Zezo-Ai/vault
that referenced
this pull request
Dec 22, 2025
…#11508) (hashicorp#11533) Update the base images for all scenarios: - RHEL: upgrade base image for 10 to 10.1 - RHEL: upgrade base image for 9 to 9.7 - SLES: upgrade base image for 15 to 15.7 - SLES: add SLES 16.0 to the matrix - OpenSUSE: remove OpenSUSE Leap from the matrix I ended up removing OpenSUSE because the images that we were on were rarely updated and that resulted in very slow scenarios because of package upgrades. Also, despite the latest release being in October I didn't find any public cloud images produced for the new version of Leap. We can consider adding it back later but I'm comfortable just leaving SLES 15 and 16 in there for that test coverage. I also ended up fixing a bug in our integration host setup where we'd provision three nodes instead of one. That ought to result in many fewer instance provisions per scenario. I also had to make a few small tweaks in how we detected whether or not SELinux is enabled, as the prior implementation did not work for SLES 16. Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go 1.16 introduced changes to the
x509.CertPooltype that make it incompatible withreflect.DeepEqual(golang/go#45891). This caused some of our tests to start failing in MongoDB. This PR changes the comparison to use github.com/google/go-cmp for the equality check which allows us to ignore certain fields and types.