Skip to content

Commit cbb85d7

Browse files
committed
Fix TempDir cleanup race causing macOS CI failures
Remove cfg.IdentityPath = t.TempDir() overrides from test files. Go's LIFO cleanup order removes TempDir before env.Close() stops daemons, causing "directory not empty" errors on macOS. AddDaemon already sets identity path in the env's managed tmpDir.
1 parent 810769e commit cbb85d7

5 files changed

Lines changed: 16 additions & 45 deletions

File tree

tests/commands_test.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package tests
33
import (
44
"encoding/base64"
55
"fmt"
6-
"path/filepath"
76
"testing"
87
"time"
98

@@ -286,7 +285,7 @@ func TestCmdRotateKey(t *testing.T) {
286285
t.Parallel()
287286
env := NewTestEnv(t)
288287
a := env.AddDaemon(func(cfg *daemon.Config) {
289-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
288+
290289
})
291290

292291
rc, err := registry.Dial(env.RegistryAddr)
@@ -330,7 +329,7 @@ func TestCmdRotateKeyBadSignature(t *testing.T) {
330329
t.Parallel()
331330
env := NewTestEnv(t)
332331
a := env.AddDaemon(func(cfg *daemon.Config) {
333-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
332+
334333
})
335334

336335
rc, err := registry.Dial(env.RegistryAddr)
@@ -515,15 +514,15 @@ func TestCmdHandshakePendingApproveReject(t *testing.T) {
515514

516515
a := env.AddDaemon(func(cfg *daemon.Config) {
517516
cfg.Encrypt = true
518-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
517+
519518
})
520519
b := env.AddDaemon(func(cfg *daemon.Config) {
521520
cfg.Encrypt = true
522-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
521+
523522
})
524523
c := env.AddDaemon(func(cfg *daemon.Config) {
525524
cfg.Encrypt = true
526-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
525+
527526
})
528527

529528
// B sends handshake to A
@@ -630,11 +629,11 @@ func TestCmdUntrust(t *testing.T) {
630629

631630
a := env.AddDaemon(func(cfg *daemon.Config) {
632631
cfg.Encrypt = true
633-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
632+
634633
})
635634
b := env.AddDaemon(func(cfg *daemon.Config) {
636635
cfg.Encrypt = true
637-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
636+
638637
})
639638

640639
// Mutual handshake: both sides request
@@ -692,10 +691,10 @@ func TestCmdHandshakeRelayUnsigned(t *testing.T) {
692691
env := NewTestEnv(t)
693692

694693
a := env.AddDaemon(func(cfg *daemon.Config) {
695-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
694+
696695
})
697696
b := env.AddDaemon(func(cfg *daemon.Config) {
698-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
697+
699698
})
700699

701700
rc, err := registry.Dial(env.RegistryAddr)
@@ -724,10 +723,10 @@ func TestCmdHandshakeRelaySignedOK(t *testing.T) {
724723
env := NewTestEnv(t)
725724

726725
a := env.AddDaemon(func(cfg *daemon.Config) {
727-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
726+
728727
})
729728
b := env.AddDaemon(func(cfg *daemon.Config) {
730-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
729+
731730
})
732731

733732
rc, err := registry.Dial(env.RegistryAddr)
@@ -764,10 +763,10 @@ func TestCmdRespondHandshakeUnsigned(t *testing.T) {
764763
env := NewTestEnv(t)
765764

766765
a := env.AddDaemon(func(cfg *daemon.Config) {
767-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
766+
768767
})
769768
b := env.AddDaemon(func(cfg *daemon.Config) {
770-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
769+
771770
})
772771

773772
rc, err := registry.Dial(env.RegistryAddr)
@@ -835,10 +834,7 @@ func TestCmdIdentityConsistency(t *testing.T) {
835834
t.Parallel()
836835
env := NewTestEnv(t)
837836

838-
idPath := filepath.Join(t.TempDir(), "identity.json")
839-
a := env.AddDaemon(func(cfg *daemon.Config) {
840-
cfg.IdentityPath = idPath
841-
})
837+
a := env.AddDaemon()
842838

843839
identity := a.Daemon.Identity()
844840
if identity == nil {

tests/handshake_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ func TestHandshakeMutualAutoApprove(t *testing.T) {
2020

2121
infoA := env.AddDaemon(func(c *daemon.Config) {
2222
c.Encrypt = true
23-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
2423
})
2524
infoB := env.AddDaemon(func(c *daemon.Config) {
2625
c.Encrypt = true
27-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
2826
})
2927

3028
daemonA := infoA.Daemon
@@ -132,15 +130,12 @@ func TestHandshakePendingApproveReject(t *testing.T) {
132130

133131
infoA := env.AddDaemon(func(c *daemon.Config) {
134132
c.Encrypt = true
135-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
136133
})
137134
infoB := env.AddDaemon(func(c *daemon.Config) {
138135
c.Encrypt = true
139-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
140136
})
141137
infoC := env.AddDaemon(func(c *daemon.Config) {
142138
c.Encrypt = true
143-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
144139
})
145140

146141
daemonA := infoA.Daemon
@@ -267,11 +262,9 @@ func TestHandshakeNetworkTrust(t *testing.T) {
267262

268263
infoA := env.AddDaemon(func(c *daemon.Config) {
269264
c.Encrypt = true
270-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
271265
})
272266
infoB := env.AddDaemon(func(c *daemon.Config) {
273267
c.Encrypt = true
274-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
275268
})
276269

277270
daemonA := infoA.Daemon
@@ -368,11 +361,9 @@ func TestHandshakeRevokeTrust(t *testing.T) {
368361

369362
infoA := env.AddDaemon(func(c *daemon.Config) {
370363
c.Encrypt = true
371-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
372364
})
373365
infoB := env.AddDaemon(func(c *daemon.Config) {
374366
c.Encrypt = true
375-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
376367
})
377368

378369
daemonA := infoA.Daemon
@@ -449,7 +440,6 @@ func TestHandshakeTrustPersistence(t *testing.T) {
449440
})
450441
infoB := env.AddDaemon(func(c *daemon.Config) {
451442
c.Encrypt = true
452-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
453443
})
454444

455445
daemonA := infoA.Daemon
@@ -503,11 +493,9 @@ func TestHandshakeRejectReason(t *testing.T) {
503493

504494
infoA := env.AddDaemon(func(c *daemon.Config) {
505495
c.Encrypt = true
506-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
507496
})
508497
infoB := env.AddDaemon(func(c *daemon.Config) {
509498
c.Encrypt = true
510-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
511499
})
512500

513501
daemonA := infoA.Daemon
@@ -580,7 +568,6 @@ func TestHandshakeTrustLoadVerify(t *testing.T) {
580568
})
581569
infoB := env.AddDaemon(func(c *daemon.Config) {
582570
c.Encrypt = true
583-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
584571
})
585572

586573
drvA := infoA.Driver

tests/syn_trust_gate_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package tests
22

33
import (
44
"net"
5-
"path/filepath"
65
"testing"
76
"time"
87

@@ -53,13 +52,13 @@ func TestSYNFromTrustedNodeAccepted(t *testing.T) {
5352
server := env.AddDaemon(func(cfg *daemon.Config) {
5453
cfg.Public = false
5554
cfg.Encrypt = true
56-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
55+
5756
cfg.KeepaliveInterval = 500 * time.Millisecond // fast relay polling
5857
})
5958
client := env.AddDaemon(func(cfg *daemon.Config) {
6059
cfg.Public = false
6160
cfg.Encrypt = true
62-
cfg.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
61+
6362
cfg.KeepaliveInterval = 500 * time.Millisecond // fast relay polling
6463
})
6564

tests/tunnel_encrypt_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,9 @@ func TestEncryptedLargeTransfer(t *testing.T) {
312312

313313
infoA := env.AddDaemon(func(c *daemon.Config) {
314314
c.Encrypt = true
315-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
316315
})
317316
infoB := env.AddDaemon(func(c *daemon.Config) {
318317
c.Encrypt = true
319-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
320318
})
321319

322320
drvA := infoA.Driver

tests/webhook_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io"
77
"net/http"
88
"net/http/httptest"
9-
"path/filepath"
109
"sync"
1110
"testing"
1211
"time"
@@ -415,12 +414,10 @@ func TestWebhook_HandshakeMutualAutoApprove(t *testing.T) {
415414
// Webhook on B to catch received + pending (B receives A's initial request)
416415
infoA := env.AddDaemon(func(c *daemon.Config) {
417416
c.Encrypt = true
418-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
419417
c.WebhookURL = collectorA.URL()
420418
})
421419
infoB := env.AddDaemon(func(c *daemon.Config) {
422420
c.Encrypt = true
423-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
424421
c.WebhookURL = collectorB.URL()
425422
})
426423

@@ -511,11 +508,9 @@ func TestWebhook_HandshakePendingAndApprove(t *testing.T) {
511508

512509
infoA := env.AddDaemon(func(c *daemon.Config) {
513510
c.Encrypt = true
514-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
515511
})
516512
infoB := env.AddDaemon(func(c *daemon.Config) {
517513
c.Encrypt = true
518-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
519514
c.WebhookURL = collectorB.URL()
520515
})
521516

@@ -583,11 +578,9 @@ func TestWebhook_HandshakeReject(t *testing.T) {
583578

584579
infoA := env.AddDaemon(func(c *daemon.Config) {
585580
c.Encrypt = true
586-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
587581
})
588582
infoB := env.AddDaemon(func(c *daemon.Config) {
589583
c.Encrypt = true
590-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
591584
c.WebhookURL = collectorB.URL()
592585
})
593586

@@ -646,12 +639,10 @@ func TestWebhook_TrustRevoke(t *testing.T) {
646639

647640
infoA := env.AddDaemon(func(c *daemon.Config) {
648641
c.Encrypt = true
649-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
650642
c.WebhookURL = collectorA.URL()
651643
})
652644
infoB := env.AddDaemon(func(c *daemon.Config) {
653645
c.Encrypt = true
654-
c.IdentityPath = filepath.Join(t.TempDir(), "identity.json")
655646
c.WebhookURL = collectorB.URL()
656647
})
657648

0 commit comments

Comments
 (0)