mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-16 12:23:07 +00:00
debugging windows integration tests
- Use rest api check to determine when node started - Use poInteractive and poStdErrToStdOut process start options in the hopes it may help with the small windows buffers
This commit is contained in:
parent
93c1b30a98
commit
a7f33bf15f
@ -24,6 +24,15 @@ proc info*(client: CodexClient): JsonNode =
|
||||
let url = client.baseurl & "/debug/info"
|
||||
client.http.getContent(url).parseJson()
|
||||
|
||||
proc isAvailable*(client: CodexClient): bool =
|
||||
try:
|
||||
discard client.info
|
||||
return true
|
||||
except OSError as e:
|
||||
if e.msg == "Connection refused":
|
||||
return false
|
||||
raise e
|
||||
|
||||
proc setLogLevel*(client: CodexClient, level: string) =
|
||||
let url = client.baseurl & "/debug/chronicles/loglevel?level=" & level
|
||||
let headers = newHttpHeaders({"Content-Type": "text/plain"})
|
||||
|
||||
@ -90,30 +90,16 @@ template marketplacesuite*(name: string, body: untyped) =
|
||||
discard
|
||||
|
||||
setup:
|
||||
echo ">>> [marketplacesuite.setup] setup start"
|
||||
marketplace = Marketplace.new(Marketplace.address, ethProvider.getSigner())
|
||||
echo ">>> [marketplacesuite.setup] setup 1"
|
||||
let tokenAddress = await marketplace.token()
|
||||
echo ">>> [marketplacesuite.setup] setup 2"
|
||||
token = Erc20Token.new(tokenAddress, ethProvider.getSigner())
|
||||
echo ">>> [marketplacesuite.setup] setup 3"
|
||||
let config = await mp.config(marketplace)
|
||||
echo ">>> [marketplacesuite.setup] setup 4"
|
||||
period = config.proofs.period.truncate(uint64)
|
||||
echo ">>> [marketplacesuite.setup] setup 5"
|
||||
periodicity = Periodicity(seconds: period.u256)
|
||||
echo ">>> [marketplacesuite.setup] setup 6"
|
||||
|
||||
when defined(windows):
|
||||
let millis = chronos.millis(500)
|
||||
else:
|
||||
let millis = chronos.millis(1000)
|
||||
continuousMineFut = continuouslyAdvanceEvery(millis)
|
||||
echo ">>> [marketplacesuite.setup] setup 7"
|
||||
continuousMineFut = continuouslyAdvanceEvery(chronos.millis(500))
|
||||
|
||||
teardown:
|
||||
echo ">>> [marketplacesuite.teardown] teardown start"
|
||||
await continuousMineFut.cancelAndWait()
|
||||
echo ">>> [marketplacesuite.teardown] teardown end"
|
||||
|
||||
body
|
||||
|
||||
@ -40,7 +40,8 @@ proc start(node: NodeProcess) =
|
||||
node.process = osproc.startProcess(
|
||||
executable,
|
||||
workingDir,
|
||||
node.arguments
|
||||
node.arguments,
|
||||
options={poStdErrToStdOut, poInteractive}
|
||||
)
|
||||
|
||||
proc waitUntilOutput*(node: NodeProcess, output: string) =
|
||||
@ -52,12 +53,6 @@ proc waitUntilOutput*(node: NodeProcess, output: string) =
|
||||
return
|
||||
raiseAssert "node did not output '" & output & "'"
|
||||
|
||||
proc waitUntilStarted*(node: NodeProcess) =
|
||||
if node.debug or defined(windows):
|
||||
sleep(5_000)
|
||||
else:
|
||||
node.waitUntilOutput("Started codex node")
|
||||
|
||||
proc startNode*(args: openArray[string], debug: string | bool = false): NodeProcess =
|
||||
## Starts a Codex Node with the specified arguments.
|
||||
## Set debug to 'true' to see output of the node.
|
||||
@ -84,6 +79,12 @@ proc client*(node: NodeProcess): CodexClient =
|
||||
node.client = some client
|
||||
client
|
||||
|
||||
proc waitUntilStarted*(node: NodeProcess) =
|
||||
while true:
|
||||
if client(node).isAvailable:
|
||||
break
|
||||
sleep(1)
|
||||
|
||||
method stop*(node: NodeProcess) {.base.} =
|
||||
if node.process != nil:
|
||||
node.process.terminate()
|
||||
|
||||
@ -22,14 +22,14 @@ marketplacesuite "Hosts submit regular proofs":
|
||||
clients:
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("node"),
|
||||
|
||||
providers:
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("marketplace", "sales", "reservations", "node"),
|
||||
):
|
||||
@ -71,7 +71,7 @@ marketplacesuite "Simulate invalid proofs":
|
||||
clients:
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("node"),
|
||||
|
||||
@ -79,7 +79,7 @@ marketplacesuite "Simulate invalid proofs":
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.simulateProofFailuresFor(providerIdx=0, failEveryNProofs=1)
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("marketplace", "sales", "reservations", "node"),
|
||||
|
||||
@ -87,7 +87,7 @@ marketplacesuite "Simulate invalid proofs":
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogTopics("validator", "onchain", "ethers")
|
||||
):
|
||||
let client0 = clients()[0].node.client
|
||||
@ -123,7 +123,7 @@ marketplacesuite "Simulate invalid proofs":
|
||||
clients:
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("node"),
|
||||
|
||||
@ -131,14 +131,14 @@ marketplacesuite "Simulate invalid proofs":
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.simulateProofFailuresFor(providerIdx=0, failEveryNProofs=3)
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("marketplace", "sales", "reservations", "node"),
|
||||
|
||||
validators:
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.debug()
|
||||
# .debug()
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("validator", "onchain", "ethers")
|
||||
):
|
||||
@ -176,7 +176,7 @@ marketplacesuite "Simulate invalid proofs":
|
||||
clients:
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.debug() # uncomment to enable console log output.debug()
|
||||
# .debug() # uncomment to enable console log output.debug()
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("node", "erasure", "clock", "purchases"),
|
||||
|
||||
@ -184,14 +184,14 @@ marketplacesuite "Simulate invalid proofs":
|
||||
NodeConfig()
|
||||
.nodes(2)
|
||||
.simulateProofFailuresFor(providerIdx=0, failEveryNProofs=2)
|
||||
.debug() # uncomment to enable console log output
|
||||
# .debug() # uncomment to enable console log output
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("marketplace", "sales", "reservations", "node"),
|
||||
|
||||
validators:
|
||||
NodeConfig()
|
||||
.nodes(1)
|
||||
.debug()
|
||||
# .debug()
|
||||
.withLogFile() # uncomment to output log file to tests/integration/logs/<start_datetime> <suite_name>/<test_name>/<node_role>_<node_idx>.log
|
||||
.withLogTopics("validator")
|
||||
):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user