Fix flaky unittest failures (#7544)
Fix three unit tests which have been flakily failing for the last several weeks: //test/load-generator/acme: TestNew/unreachable_directory_URL Fixed by changing the error checking code to care only about the underlying "connection refused" message, and not the IP address from which it was receieved. //va: TestHTTPDialTimeout Fixed by correcting the error checking code to look for "network is unreachable" instead of "Network unreachable" //va: TestFetchHTTP/Broken_IPv6_only Fixed by making the expected error message more specific -- it was previously looking for "Error getting validation data", which is the message that `detailedError` gives for errors it doesn't recognize. An underlying library has changed to provide an error type that `detailedError` now recognizes as a connection error.
This commit is contained in:
parent
2b5b6239a4
commit
80df797486
|
|
@ -132,7 +132,7 @@ func TestNew(t *testing.T) {
|
|||
{
|
||||
Name: "unreachable directory URL",
|
||||
DirectoryURL: "http://localhost:1987",
|
||||
ExpectedError: "Get \"http://localhost:1987\": dial tcp 127.0.0.1:1987: connect: connection refused",
|
||||
ExpectedError: "connect: connection refused",
|
||||
},
|
||||
{
|
||||
Name: "wrong directory HTTP status code",
|
||||
|
|
@ -179,7 +179,7 @@ func TestNew(t *testing.T) {
|
|||
if err == nil && tc.ExpectedError != "" {
|
||||
t.Errorf("expected error %q got nil", tc.ExpectedError)
|
||||
} else if err != nil {
|
||||
test.AssertEquals(t, err.Error(), tc.ExpectedError)
|
||||
test.AssertContains(t, err.Error(), tc.ExpectedError)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -992,7 +992,7 @@ func TestFetchHTTP(t *testing.T) {
|
|||
Host: "ipv6.localhost",
|
||||
Path: "/ok",
|
||||
ExpectedProblem: probs.Connection(
|
||||
"::1: Fetching http://ipv6.localhost/ok: Error getting validation data"),
|
||||
"::1: Fetching http://ipv6.localhost/ok: Connection refused"),
|
||||
ExpectedRecords: []core.ValidationRecord{
|
||||
{
|
||||
Hostname: "ipv6.localhost",
|
||||
|
|
@ -1098,14 +1098,14 @@ func TestFetchHTTP(t *testing.T) {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
|
||||
defer cancel()
|
||||
body, records, err := va.fetchHTTP(ctx, tc.Host, tc.Path)
|
||||
if err != nil && tc.ExpectedProblem == nil {
|
||||
t.Errorf("expected nil prob, got %#v\n", err)
|
||||
} else if err == nil && tc.ExpectedProblem != nil {
|
||||
t.Errorf("expected %#v prob, got nil", tc.ExpectedProblem)
|
||||
} else if err != nil && tc.ExpectedProblem != nil {
|
||||
if tc.ExpectedProblem == nil {
|
||||
test.AssertNotError(t, err, "expected nil prob")
|
||||
} else {
|
||||
test.AssertError(t, err, "expected non-nil prob")
|
||||
prob := detailedError(err)
|
||||
test.AssertMarshaledEquals(t, prob, tc.ExpectedProblem)
|
||||
} else {
|
||||
}
|
||||
if tc.ExpectedBody != "" {
|
||||
test.AssertEquals(t, string(body), tc.ExpectedBody)
|
||||
}
|
||||
// in all cases we expect validation records to be present and matching expected
|
||||
|
|
@ -1378,7 +1378,7 @@ func TestHTTPDialTimeout(t *testing.T) {
|
|||
var err error
|
||||
for range 20 {
|
||||
_, err = va.validateHTTP01(ctx, dnsi("unroutable.invalid"), expectedToken, expectedKeyAuthorization)
|
||||
if err != nil && strings.Contains(err.Error(), "Network unreachable") {
|
||||
if err != nil && strings.Contains(err.Error(), "network is unreachable") {
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
|
|
|
|||
Loading…
Reference in New Issue