mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
tstest/integration: change return type of AwaitIP from string to netaddr.IP
Signed-off-by: Simeng He <simeng@tailscale.com>
This commit is contained in:
parent
46896a9311
commit
3d049a9d71
@ -23,12 +23,14 @@
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go4.org/mem"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
"tailscale.com/safesocket"
|
||||
"tailscale.com/tailcfg"
|
||||
@ -528,22 +530,40 @@ func (n *testNode) AwaitListening(t testing.TB) {
|
||||
}
|
||||
}
|
||||
|
||||
func (n *testNode) AwaitIP(t testing.TB) (ips string) {
|
||||
func (n *testNode) AwaitIPs(t testing.TB) []netaddr.IP {
|
||||
t.Helper()
|
||||
var addrs []netaddr.IP
|
||||
if err := tstest.WaitFor(20*time.Second, func() error {
|
||||
out, err := n.Tailscale("ip").Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ips = string(out)
|
||||
ips := string(out)
|
||||
ipslice := strings.Fields(ips)
|
||||
addrs = make([]netaddr.IP, len(ipslice))
|
||||
|
||||
for i, ip := range ipslice {
|
||||
netIP, err := netaddr.ParseIP(ip)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
addrs[i] = netIP
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
t.Fatalf("awaiting an IP address: %v", err)
|
||||
}
|
||||
if ips == "" {
|
||||
if len(addrs) == 0 {
|
||||
t.Fatalf("returned IP address was blank")
|
||||
}
|
||||
return ips
|
||||
return addrs
|
||||
}
|
||||
|
||||
// AwaitIP returns the IP address of n.
|
||||
func (n *testNode) AwaitIP(t testing.TB) netaddr.IP {
|
||||
t.Helper()
|
||||
ips := n.AwaitIPs(t)
|
||||
return ips[0]
|
||||
}
|
||||
|
||||
func (n *testNode) AwaitRunning(t testing.TB) {
|
||||
|
Loading…
Reference in New Issue
Block a user