Skip to content

Commit d6f7fb3

Browse files
committed
integration: shutdown codex node at end of test
On Windows the codex node did not shut down properly after this test finished.
1 parent 0f152d3 commit d6f7fb3

File tree

2 files changed

+28
-54
lines changed

2 files changed

+28
-54
lines changed

tests/integration/codexclient.nim

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import std/httpclient
21
import std/strutils
32

43
from pkg/libp2p import Cid, `$`, init

tests/integration/testrestapivalidation.nim

+28-53
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,23 @@
1-
import std/httpclient
21
import std/times
32
import pkg/ethers
4-
import pkg/codex/manifest
53
import pkg/codex/conf
64
import pkg/codex/contracts
7-
from pkg/codex/stores/repostore/types import DefaultQuotaBytes
85
import ../asynctest
96
import ../checktest
107
import ../examples
118
import ../codex/examples
129
import ./codexconfig
13-
import ./codexprocess
10+
import ./codexclient
11+
import ./multinodes
1412

15-
from ./multinodes import Role, getTempDirName, jsonRpcProviderUrl, nextFreePort
13+
multinodesuite "Rest API validation":
14+
let config = NodeConfigs(clients: CodexConfigs.init(nodes = 1).some)
15+
var client: CodexClient
1616

17-
# This suite allows to run fast the basic rest api validation.
18-
# It starts only one node for all the checks in order to speed up
19-
# the execution.
20-
asyncchecksuite "Rest API validation":
21-
var node: CodexProcess
22-
var config = CodexConfigs.init(nodes = 1).configs[0]
23-
let starttime = now().format("yyyy-MM-dd'_'HH:mm:ss")
24-
let nodexIdx = 0
25-
let datadir = getTempDirName(starttime, Role.Client, nodexIdx)
17+
setup:
18+
client = clients()[0].client
2619

27-
config.addCliOption("--api-port", $(waitFor nextFreePort(8081)))
28-
config.addCliOption("--data-dir", datadir)
29-
config.addCliOption("--nat", "none")
30-
config.addCliOption("--listen-addrs", "/ip4/127.0.0.1/tcp/0")
31-
config.addCliOption("--disc-port", $(waitFor nextFreePort(8081)))
32-
config.addCliOption(StartUpCmd.persistence, "--eth-provider", jsonRpcProviderUrl)
33-
config.addCliOption(StartUpCmd.persistence, "--eth-account", $EthAddress.example)
34-
35-
node =
36-
waitFor CodexProcess.startNode(config.cliArgs, config.debugEnabled, $Role.Client)
37-
38-
waitFor node.waitUntilStarted()
39-
40-
let client = node.client()
41-
42-
test "should return 422 when attempting delete of non-existing dataset":
20+
test "should return 422 when attempting delete of non-existing dataset", config:
4321
let data = await RandomChunker.example(blocks = 2)
4422
let cid = (await client.upload(data)).get
4523
let duration = 100.uint64
@@ -58,7 +36,7 @@ asyncchecksuite "Rest API validation":
5836
check responseBefore.status == 422
5937
check (await responseBefore.body) == "Tolerance needs to be bigger then zero"
6038

61-
test "request storage fails for datasets that are too small":
39+
test "request storage fails for datasets that are too small", config:
6240
let cid = (await client.upload("some file contents")).get
6341
let response = (
6442
await client.requestStorageRaw(
@@ -77,7 +55,7 @@ asyncchecksuite "Rest API validation":
7755
"Dataset too small for erasure parameters, need at least " &
7856
$(2 * DefaultBlockSize.int) & " bytes"
7957

80-
test "request storage fails if nodes and tolerance aren't correct":
58+
test "request storage fails if nodes and tolerance aren't correct", config:
8159
let data = await RandomChunker.example(blocks = 2)
8260
let cid = (await client.upload(data)).get
8361
let duration = 100.uint64
@@ -101,7 +79,7 @@ asyncchecksuite "Rest API validation":
10179
check (await responseBefore.body) ==
10280
"Invalid parameters: parameters must satify `1 < (nodes - tolerance) ≥ tolerance`"
10381

104-
test "request storage fails if tolerance > nodes (underflow protection)":
82+
test "request storage fails if tolerance > nodes (underflow protection)", config:
10583
let data = await RandomChunker.example(blocks = 2)
10684
let cid = (await client.upload(data)).get
10785
let duration = 100.uint64
@@ -122,21 +100,21 @@ asyncchecksuite "Rest API validation":
122100
check responseBefore.status == 422
123101
check (await responseBefore.body) == "Tolerance needs to be bigger then zero"
124102

125-
test "upload fails if content disposition contains bad filename":
103+
test "upload fails if content disposition contains bad filename", config:
126104
let headers = @[("Content-Disposition", "attachment; filename=\"exam*ple.txt\"")]
127105
let response = await client.uploadRaw("some file contents", headers)
128106

129107
check response.status == 422
130108
check (await response.body) == "The filename is not valid."
131109

132-
test "upload fails if content type is invalid":
110+
test "upload fails if content type is invalid", config:
133111
let headers = @[("Content-Type", "hello/world")]
134112
let response = await client.uploadRaw("some file contents", headers)
135113

136114
check response.status == 422
137115
check (await response.body) == "The MIME type 'hello/world' is not valid."
138116

139-
test "updating non-existing availability":
117+
test "updating non-existing availability", config:
140118
let nonExistingResponse = await client.patchAvailabilityRaw(
141119
AvailabilityId.example,
142120
duration = 100.uint64.some,
@@ -145,7 +123,7 @@ asyncchecksuite "Rest API validation":
145123
)
146124
check nonExistingResponse.status == 404
147125

148-
test "updating availability - freeSize is not allowed to be changed":
126+
test "updating availability - freeSize is not allowed to be changed", config:
149127
let availability = (
150128
await client.postAvailability(
151129
totalSize = 140000.uint64,
@@ -159,7 +137,7 @@ asyncchecksuite "Rest API validation":
159137
check freeSizeResponse.status == 422
160138
check "not allowed" in (await freeSizeResponse.body)
161139

162-
test "creating availability above the node quota returns 422":
140+
test "creating availability above the node quota returns 422", config:
163141
let response = await client.postAvailabilityRaw(
164142
totalSize = 24000000000.uint64,
165143
duration = 200.uint64,
@@ -170,7 +148,7 @@ asyncchecksuite "Rest API validation":
170148
check response.status == 422
171149
check (await response.body) == "Not enough storage quota"
172150

173-
test "updating availability above the node quota returns 422":
151+
test "updating availability above the node quota returns 422", config:
174152
let availability = (
175153
await client.postAvailability(
176154
totalSize = 140000.uint64,
@@ -186,7 +164,7 @@ asyncchecksuite "Rest API validation":
186164
check response.status == 422
187165
check (await response.body) == "Not enough storage quota"
188166

189-
test "creating availability when total size is zero returns 422":
167+
test "creating availability when total size is zero returns 422", config:
190168
let response = await client.postAvailabilityRaw(
191169
totalSize = 0.uint64,
192170
duration = 200.uint64,
@@ -197,7 +175,7 @@ asyncchecksuite "Rest API validation":
197175
check response.status == 422
198176
check (await response.body) == "Total size must be larger then zero"
199177

200-
test "updating availability when total size is zero returns 422":
178+
test "updating availability when total size is zero returns 422", config:
201179
let availability = (
202180
await client.postAvailability(
203181
totalSize = 140000.uint64,
@@ -212,7 +190,7 @@ asyncchecksuite "Rest API validation":
212190
check response.status == 422
213191
check (await response.body) == "Total size must be larger then zero"
214192

215-
test "creating availability when total size is negative returns 422":
193+
test "creating availability when total size is negative returns 422", config:
216194
let json =
217195
%*{
218196
"totalSize": "-1",
@@ -225,7 +203,7 @@ asyncchecksuite "Rest API validation":
225203
check response.status == 400
226204
check (await response.body) == "Parsed integer outside of valid range"
227205

228-
test "updating availability when total size is negative returns 422":
206+
test "updating availability when total size is negative returns 422", config:
229207
let availability = (
230208
await client.postAvailability(
231209
totalSize = 140000.uint64,
@@ -243,7 +221,7 @@ asyncchecksuite "Rest API validation":
243221
check response.status == 400
244222
check (await response.body) == "Parsed integer outside of valid range"
245223

246-
test "request storage fails if tolerance is zero":
224+
test "request storage fails if tolerance is zero", config:
247225
let data = await RandomChunker.example(blocks = 2)
248226
let cid = (await client.upload(data)).get
249227
let duration = 100.uint64
@@ -264,7 +242,7 @@ asyncchecksuite "Rest API validation":
264242
check responseBefore.status == 422
265243
check (await responseBefore.body) == "Tolerance needs to be bigger then zero"
266244

267-
test "request storage fails if duration exceeds limit":
245+
test "request storage fails if duration exceeds limit", config:
268246
let data = await RandomChunker.example(blocks = 2)
269247
let cid = (await client.upload(data)).get
270248
let duration = (31 * 24 * 60 * 60).uint64
@@ -286,7 +264,7 @@ asyncchecksuite "Rest API validation":
286264
check responseBefore.status == 422
287265
check "Duration exceeds limit of" in (await responseBefore.body)
288266

289-
test "request storage fails if expiry is zero":
267+
test "request storage fails if expiry is zero", config:
290268
let data = await RandomChunker.example(blocks = 2)
291269
let cid = (await client.upload(data)).get
292270
let duration = 100.uint64
@@ -306,7 +284,7 @@ asyncchecksuite "Rest API validation":
306284
check (await responseBefore.body) ==
307285
"Expiry must be greater than zero and less than the request's duration"
308286

309-
test "request storage fails if proof probability is zero":
287+
test "request storage fails if proof probability is zero", config:
310288
let data = await RandomChunker.example(blocks = 2)
311289
let cid = (await client.upload(data)).get
312290
let duration = 100.uint64
@@ -325,7 +303,7 @@ asyncchecksuite "Rest API validation":
325303
check responseBefore.status == 422
326304
check (await responseBefore.body) == "Proof probability must be greater than zero"
327305

328-
test "request storage fails if price per byte per second is zero":
306+
test "request storage fails if price per byte per second is zero", config:
329307
let data = await RandomChunker.example(blocks = 2)
330308
let cid = (await client.upload(data)).get
331309
let duration = 100.uint64
@@ -345,7 +323,7 @@ asyncchecksuite "Rest API validation":
345323
check (await responseBefore.body) ==
346324
"Price per byte per second must be greater than zero"
347325

348-
test "request storage fails if collareral per byte is zero":
326+
test "request storage fails if collareral per byte is zero", config:
349327
let data = await RandomChunker.example(blocks = 2)
350328
let cid = (await client.upload(data)).get
351329
let duration = 100.uint64
@@ -364,7 +342,7 @@ asyncchecksuite "Rest API validation":
364342
check responseBefore.status == 422
365343
check (await responseBefore.body) == "Collateral per byte must be greater than zero"
366344

367-
test "creating availability fails when until is negative":
345+
test "creating availability fails when until is negative", config:
368346
let totalSize = 12.uint64
369347
let minPricePerBytePerSecond = 1.u256
370348
let totalCollateral = totalSize.u256 * minPricePerBytePerSecond
@@ -379,6 +357,3 @@ asyncchecksuite "Rest API validation":
379357
check:
380358
response.status == 422
381359
(await response.body) == "Cannot set until to a negative value"
382-
383-
waitFor node.stop()
384-
node.removeDataDir()

0 commit comments

Comments
 (0)