mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
all: close fake userspace engines when tests complete
We were leaking FDs. In a few places, switch from defer to t.Cleanup. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
008f36986e
commit
7693d36aed
@ -443,6 +443,7 @@ func TestLazyMachineKeyGeneration(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NewFakeUserspaceEngine: %v", err)
|
t.Fatalf("NewFakeUserspaceEngine: %v", err)
|
||||||
}
|
}
|
||||||
|
t.Cleanup(eng.Close)
|
||||||
lb, err := NewLocalBackend(logf, "logid", store, eng)
|
lb, err := NewLocalBackend(logf, "logid", store, eng)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NewLocalBackend: %v", err)
|
t.Fatalf("NewLocalBackend: %v", err)
|
||||||
|
@ -52,6 +52,7 @@ func TestLocalLogLines(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
t.Cleanup(e.Close)
|
||||||
|
|
||||||
lb, err := NewLocalBackend(logf, idA.String(), store, e)
|
lb, err := NewLocalBackend(logf, idA.String(), store, e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -284,6 +284,7 @@ func TestStateMachine(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NewFakeUserspaceEngine: %v", err)
|
t.Fatalf("NewFakeUserspaceEngine: %v", err)
|
||||||
}
|
}
|
||||||
|
t.Cleanup(e.Close)
|
||||||
|
|
||||||
cc := newMockControl()
|
cc := newMockControl()
|
||||||
b, err := NewLocalBackend(logf, "logid", store, e)
|
b, err := NewLocalBackend(logf, "logid", store, e)
|
||||||
|
@ -60,7 +60,7 @@ func TestRunMultipleAccepts(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer eng.Close()
|
t.Cleanup(eng.Close)
|
||||||
|
|
||||||
opts := ipnserver.Options{
|
opts := ipnserver.Options{
|
||||||
SocketPath: socketPath,
|
SocketPath: socketPath,
|
||||||
|
@ -89,7 +89,7 @@ func TestUserspaceEngineReconfig(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer e.Close()
|
t.Cleanup(e.Close)
|
||||||
ue := e.(*userspaceEngine)
|
ue := e.(*userspaceEngine)
|
||||||
|
|
||||||
routerCfg := &router.Config{}
|
routerCfg := &router.Config{}
|
||||||
@ -158,7 +158,7 @@ func TestUserspaceEnginePortReconfig(t *testing.T) {
|
|||||||
if ue == nil {
|
if ue == nil {
|
||||||
t.Fatal("could not create a wgengine with a specific port")
|
t.Fatal("could not create a wgengine with a specific port")
|
||||||
}
|
}
|
||||||
defer ue.Close()
|
t.Cleanup(ue.Close)
|
||||||
|
|
||||||
startingPort := ue.magicConn.LocalPort()
|
startingPort := ue.magicConn.LocalPort()
|
||||||
nodeKey := nkFromHex("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
nodeKey := nkFromHex("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||||
|
@ -48,6 +48,7 @@ func TestWatchdog(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
t.Cleanup(e.Close)
|
||||||
usEngine := e.(*userspaceEngine)
|
usEngine := e.(*userspaceEngine)
|
||||||
e = NewWatchdog(e)
|
e = NewWatchdog(e)
|
||||||
wdEngine := e.(*watchdogEngine)
|
wdEngine := e.(*watchdogEngine)
|
||||||
|
Loading…
Reference in New Issue
Block a user