mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-02 03:33:05 +00:00
Retry magicdns tests
This commit is contained in:
parent
ce53bb0eee
commit
b71a881d0e
1 changed files with 25 additions and 10 deletions
|
@ -683,6 +683,18 @@ func (s *IntegrationTestSuite) TestMagicDNS() {
|
||||||
ips, err := getIPs(scales.tailscales)
|
ips, err := getIPs(scales.tailscales)
|
||||||
assert.Nil(s.T(), err)
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
retry := func(times int, sleepInverval time.Duration, doWork func() (string, error)) (result string, err error) {
|
||||||
|
for attempts := 0; attempts < times; attempts++ {
|
||||||
|
result, err = doWork()
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(sleepInverval)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for hostname, tailscale := range scales.tailscales {
|
for hostname, tailscale := range scales.tailscales {
|
||||||
for _, peername := range hostnames {
|
for _, peername := range hostnames {
|
||||||
if strings.Contains(peername, hostname) {
|
if strings.Contains(peername, hostname) {
|
||||||
|
@ -693,7 +705,7 @@ func (s *IntegrationTestSuite) TestMagicDNS() {
|
||||||
command := []string{
|
command := []string{
|
||||||
"tailscale", "ip", peername,
|
"tailscale", "ip", peername,
|
||||||
}
|
}
|
||||||
|
result, err := retry(10, 1*time.Second, func() (string, error) {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"Resolving name %s from %s\n",
|
"Resolving name %s from %s\n",
|
||||||
peername,
|
peername,
|
||||||
|
@ -704,6 +716,9 @@ func (s *IntegrationTestSuite) TestMagicDNS() {
|
||||||
command,
|
command,
|
||||||
[]string{},
|
[]string{},
|
||||||
)
|
)
|
||||||
|
return result, err
|
||||||
|
})
|
||||||
|
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
log.Printf("Result for %s: %s\n", hostname, result)
|
log.Printf("Result for %s: %s\n", hostname, result)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue