Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7eeacbd35 |
@@ -16,12 +16,10 @@
|
|||||||
// operations are in flight at once in one test binary.
|
// operations are in flight at once in one test binary.
|
||||||
//
|
//
|
||||||
// 2. Retry with exponential backoff. Each live operation gets several
|
// 2. Retry with exponential backoff. Each live operation gets several
|
||||||
// attempts with its own timeout. An attempt is retried when it
|
// attempts with its own timeout. The retry condition is strictly
|
||||||
// obtained nothing to check, never because of what the test
|
// transport-level — "did a nameserver answer at all" — never the
|
||||||
// asserts about the result, so a wrong result still fails on the
|
// assertion the test is making. Code that answers incorrectly
|
||||||
// first attempt. A fault in the code under test that leaves
|
// still fails on the first attempt.
|
||||||
// nothing to check looks the same as live DNS not answering, and
|
|
||||||
// fails only after the last attempt.
|
|
||||||
package livedns
|
package livedns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -115,7 +113,7 @@ func Retry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.Fatalf(
|
t.Fatalf(
|
||||||
"%s: all %d live attempts failed: %v",
|
"%s: no answer after %d live attempts: %v",
|
||||||
what, attempts, last,
|
what, attempts, last,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,11 +171,11 @@ func defaultTestConfig(t *testing.T) *config.Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkOnce runs the watcher's checks once and returns an error when a
|
// checkOnce runs the watcher's checks once and returns
|
||||||
// configured name has no hostname state saved by this check, or that
|
// livedns.ErrNoAnswer when live DNS did not answer for a configured
|
||||||
// state holds no address. The watcher saves a name's hostname state
|
// name. The watcher saves a name's hostname state only when all of the
|
||||||
// only when all of the name's lookups succeed, so this means either
|
// name's lookups succeed, so live DNS answered for a name when this
|
||||||
// live DNS did not answer or the watcher did not save what it got.
|
// check saved its hostname state and that state holds an address.
|
||||||
func checkOnce(
|
func checkOnce(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
w *watcher.Watcher,
|
w *watcher.Watcher,
|
||||||
@@ -191,11 +191,7 @@ func checkOnce(
|
|||||||
hs, ok := deps.state.GetHostnameState(name)
|
hs, ok := deps.state.GetHostnameState(name)
|
||||||
if !ok || hs.LastChecked.Before(started) ||
|
if !ok || hs.LastChecked.Before(started) ||
|
||||||
len(addresses(hs)) == 0 {
|
len(addresses(hs)) == 0 {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf("%w: %s", livedns.ErrNoAnswer, name)
|
||||||
"%s: %w, or the watcher saved no fresh "+
|
|
||||||
"result for it",
|
|
||||||
name, livedns.ErrNoAnswer,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user