Skip to content

Commit aa3c88d

Browse files
authored
shutdown daemon after test (#11135)
1 parent 1301710 commit aa3c88d

27 files changed

+122
-3
lines changed

test/cli/backup_bootstrap_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ func TestBackupBootstrapPeers(t *testing.T) {
3939

4040
// Start 1 and 2. 2 does not know anyone yet.
4141
nodes[1].StartDaemon()
42+
defer nodes[1].StopDaemon()
4243
nodes[2].StartDaemon()
44+
defer nodes[2].StopDaemon()
4345
assert.Len(t, nodes[1].Peers(), 0)
4446
assert.Len(t, nodes[2].Peers(), 0)
4547

@@ -51,6 +53,7 @@ func TestBackupBootstrapPeers(t *testing.T) {
5153
// Start 0, wait a bit. Should connect to 1, and then discover 2 via the
5254
// backup bootstrap peers.
5355
nodes[0].StartDaemon()
56+
defer nodes[0].StopDaemon()
5457
time.Sleep(time.Millisecond * 500)
5558

5659
// Check if they're all connected.

test/cli/bitswap_config_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ func TestBitswapConfig(t *testing.T) {
2222
t.Parallel()
2323
h := harness.NewT(t)
2424
provider := h.NewNode().Init().StartDaemon()
25+
defer provider.StopDaemon()
2526
requester := h.NewNode().Init().StartDaemon()
27+
defer requester.StopDaemon()
2628

2729
hash := provider.IPFSAddStr(string(testData))
2830
requester.Connect(provider)
@@ -38,8 +40,10 @@ func TestBitswapConfig(t *testing.T) {
3840
provider := h.NewNode().Init()
3941
provider.SetIPFSConfig("Bitswap.ServerEnabled", false)
4042
provider = provider.StartDaemon()
43+
defer provider.StopDaemon()
4144

4245
requester := h.NewNode().Init().StartDaemon()
46+
defer requester.StopDaemon()
4347

4448
hash := provider.IPFSAddStr(string(testData))
4549
requester.Connect(provider)
@@ -70,8 +74,10 @@ func TestBitswapConfig(t *testing.T) {
7074
requester := h.NewNode().Init()
7175
requester.SetIPFSConfig("Bitswap.ServerEnabled", false)
7276
requester.StartDaemon()
77+
defer requester.StopDaemon()
7378

7479
provider := h.NewNode().Init().StartDaemon()
80+
defer provider.StopDaemon()
7581
hash := provider.IPFSAddStr(string(testData))
7682
requester.Connect(provider)
7783

@@ -91,8 +97,10 @@ func TestBitswapConfig(t *testing.T) {
9197
cfg.HTTPRetrieval.Enabled = config.True
9298
})
9399
requester.StartDaemon()
100+
defer requester.StopDaemon()
94101

95102
provider := h.NewNode().Init().StartDaemon()
103+
defer provider.StopDaemon()
96104
hash := provider.IPFSAddStr(string(testData))
97105

98106
requester.Connect(provider)
@@ -126,7 +134,9 @@ func TestBitswapConfig(t *testing.T) {
126134
cfg.HTTPRetrieval.Enabled = config.True
127135
})
128136
provider = provider.StartDaemon()
137+
defer provider.StopDaemon()
129138
requester := h.NewNode().Init().StartDaemon()
139+
defer requester.StopDaemon()
130140
requester.Connect(provider)
131141

132142
// read libp2p identify from remote peer, and print protocols

test/cli/content_blocking_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func TestContentBlocking(t *testing.T) {
7676

7777
// Start daemon, it should pick up denylist from $IPFS_PATH/denylists/test.deny
7878
node.StartDaemon() // we need online mode for GatewayOverLibp2p tests
79+
t.Cleanup(func() { node.StopDaemon() })
7980
client := node.GatewayClient()
8081

8182
// First, confirm gateway works

test/cli/dag_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func TestDag(t *testing.T) {
4747
t.Run("ipfs dag stat --enc=json", func(t *testing.T) {
4848
t.Parallel()
4949
node := harness.NewT(t).NewNode().Init().StartDaemon()
50+
defer node.StopDaemon()
51+
5052
// Import fixture
5153
r, err := os.Open(fixtureFile)
5254
assert.Nil(t, err)
@@ -91,6 +93,7 @@ func TestDag(t *testing.T) {
9193
t.Run("ipfs dag stat", func(t *testing.T) {
9294
t.Parallel()
9395
node := harness.NewT(t).NewNode().Init().StartDaemon()
96+
defer node.StopDaemon()
9497
r, err := os.Open(fixtureFile)
9598
assert.NoError(t, err)
9699
defer r.Close()

test/cli/delegated_routing_v1_http_proxy_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ func TestRoutingV1Proxy(t *testing.T) {
6060
})
6161
nodes[2].StartDaemon()
6262

63+
t.Cleanup(func() {
64+
nodes.StopDaemons()
65+
})
66+
6367
// Connect them.
6468
nodes.Connect()
6569

test/cli/delegated_routing_v1_http_server_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func TestRoutingV1Server(t *testing.T) {
3232
})
3333
})
3434
nodes.StartDaemons().Connect()
35+
t.Cleanup(func() { nodes.StopDaemons() })
3536
return nodes
3637
}
3738

@@ -133,6 +134,7 @@ func TestRoutingV1Server(t *testing.T) {
133134
cfg.Routing.Type = config.NewOptionalString("dht")
134135
})
135136
node.StartDaemon()
137+
defer node.StopDaemon()
136138

137139
// Put IPNS record in lonely node. It should be accepted as it is a valid record.
138140
c, err = client.New(node.GatewayURL())
@@ -196,6 +198,7 @@ func TestRoutingV1Server(t *testing.T) {
196198
}
197199
})
198200
node.StartDaemon()
201+
defer node.StopDaemon()
199202

200203
c, err := client.New(node.GatewayURL())
201204
require.NoError(t, err)
@@ -238,6 +241,7 @@ func TestRoutingV1Server(t *testing.T) {
238241
cfg.Bootstrap = autoconf.FallbackBootstrapPeers
239242
})
240243
node.StartDaemon()
244+
defer node.StopDaemon()
241245

242246
c, err := client.New(node.GatewayURL())
243247
require.NoError(t, err)

test/cli/dht_autoclient_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func TestDHTAutoclient(t *testing.T) {
1616
node.IPFS("config", "Routing.Type", "autoclient")
1717
})
1818
nodes.StartDaemons().Connect()
19+
t.Cleanup(func() { nodes.StopDaemons() })
1920

2021
t.Run("file added on node in client mode is retrievable from node in client mode", func(t *testing.T) {
2122
t.Parallel()

test/cli/dht_opt_prov_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestDHTOptimisticProvide(t *testing.T) {
2222
})
2323

2424
nodes.StartDaemons().Connect()
25+
defer nodes.StopDaemons()
2526

2627
hash := nodes[0].IPFSAddStr(string(random.Bytes(100)))
2728
nodes[0].IPFS("routing", "provide", hash)

test/cli/files_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func TestFilesCp(t *testing.T) {
1919
t.Parallel()
2020

2121
node := harness.NewT(t).NewNode().Init().StartDaemon()
22+
defer node.StopDaemon()
2223

2324
// Create simple text file
2425
data := "testing files cp command"
@@ -36,6 +37,7 @@ func TestFilesCp(t *testing.T) {
3637
t.Run("files cp with unsupported DAG node type fails", func(t *testing.T) {
3738
t.Parallel()
3839
node := harness.NewT(t).NewNode().Init().StartDaemon()
40+
defer node.StopDaemon()
3941

4042
// MFS UnixFS is limited to dag-pb or raw, so we create a dag-cbor node to test this
4143
jsonData := `{"data": "not a UnixFS node"}`
@@ -53,6 +55,7 @@ func TestFilesCp(t *testing.T) {
5355
t.Run("files cp with invalid UnixFS data structure fails", func(t *testing.T) {
5456
t.Parallel()
5557
node := harness.NewT(t).NewNode().Init().StartDaemon()
58+
defer node.StopDaemon()
5659

5760
// Create an invalid proto file
5861
data := []byte{0xDE, 0xAD, 0xBE, 0xEF} // Invalid protobuf data
@@ -75,6 +78,7 @@ func TestFilesCp(t *testing.T) {
7578
t.Run("files cp with raw node succeeds", func(t *testing.T) {
7679
t.Parallel()
7780
node := harness.NewT(t).NewNode().Init().StartDaemon()
81+
defer node.StopDaemon()
7882

7983
// Create a raw node
8084
data := "raw data"
@@ -98,6 +102,7 @@ func TestFilesCp(t *testing.T) {
98102
t.Run("files cp creates intermediate directories with -p", func(t *testing.T) {
99103
t.Parallel()
100104
node := harness.NewT(t).NewNode().Init().StartDaemon()
105+
defer node.StopDaemon()
101106

102107
// Create a simple text file and add it to IPFS
103108
data := "hello parent directories"
@@ -130,6 +135,7 @@ func TestFilesRm(t *testing.T) {
130135
t.Parallel()
131136

132137
node := harness.NewT(t).NewNode().Init().StartDaemon()
138+
defer node.StopDaemon()
133139

134140
// Create a file to remove
135141
node.IPFS("files", "mkdir", "/test-dir")
@@ -149,6 +155,7 @@ func TestFilesRm(t *testing.T) {
149155
t.Parallel()
150156

151157
node := harness.NewT(t).NewNode().Init().StartDaemon()
158+
defer node.StopDaemon()
152159

153160
// Create a file to remove
154161
node.IPFS("files", "mkdir", "/test-dir")
@@ -166,6 +173,7 @@ func TestFilesRm(t *testing.T) {
166173
t.Parallel()
167174

168175
node := harness.NewT(t).NewNode().Init().StartDaemon()
176+
defer node.StopDaemon()
169177

170178
// Create a file to remove
171179
node.IPFS("files", "mkdir", "/test-dir")
@@ -186,6 +194,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
186194
t.Run("reaches default limit of 256 operations", func(t *testing.T) {
187195
t.Parallel()
188196
node := harness.NewT(t).NewNode().Init().StartDaemon()
197+
defer node.StopDaemon()
189198

190199
// Perform 256 operations with --flush=false (should succeed)
191200
for i := 0; i < 256; i++ {
@@ -214,6 +223,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
214223
})
215224

216225
node.StartDaemon()
226+
defer node.StopDaemon()
217227

218228
// Perform 5 operations (should succeed)
219229
for i := 0; i < 5; i++ {
@@ -239,6 +249,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
239249
})
240250

241251
node.StartDaemon()
252+
defer node.StopDaemon()
242253

243254
// Do 2 operations with --flush=false
244255
node.IPFS("files", "mkdir", "--flush=false", "/dir1")
@@ -271,6 +282,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
271282
})
272283

273284
node.StartDaemon()
285+
defer node.StopDaemon()
274286

275287
// Do 2 operations with --flush=false
276288
node.IPFS("files", "mkdir", "--flush=false", "/dir1")
@@ -303,6 +315,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
303315
})
304316

305317
node.StartDaemon()
318+
defer node.StopDaemon()
306319

307320
// Should be able to do many operations without error
308321
for i := 0; i < 300; i++ {
@@ -322,6 +335,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
322335
})
323336

324337
node.StartDaemon()
338+
defer node.StopDaemon()
325339

326340
// Mix of different MFS operations (5 operations to hit the limit)
327341
node.IPFS("files", "mkdir", "--flush=false", "/testdir")

test/cli/gateway_limits_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func TestGatewayLimits(t *testing.T) {
2828
cfg.Gateway.RetrievalTimeout = config.NewOptionalDuration(1 * time.Second)
2929
})
3030
node.StartDaemon()
31+
defer node.StopDaemon()
3132

3233
// Add content that can be retrieved quickly
3334
cid := node.IPFSAddStr("test content")
@@ -69,6 +70,7 @@ func TestGatewayLimits(t *testing.T) {
6970
cfg.Gateway.RetrievalTimeout = config.NewOptionalDuration(2 * time.Second)
7071
})
7172
node.StartDaemon()
73+
defer node.StopDaemon()
7274

7375
// Add some content - use a non-existent CID that will block during retrieval
7476
// to ensure we can control timing

0 commit comments

Comments
 (0)