Skip to content

Commit

Permalink
Update Makefile.
Browse files Browse the repository at this point in the history
Improve logging on failure.
  • Loading branch information
cheatfate committed Aug 4, 2023
1 parent 4af0d96 commit bbb5a9e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ FORCE_BUILD_ALONE_ALL_TESTS_DEPS :=
endif
force_build_alone_all_tests: | $(FORCE_BUILD_ALONE_ALL_TESTS_DEPS)

all_tests: | build deps nimbus_signing_node force_build_alone_all_tests
all_tests: | build deps nimbus_beacon_node nimbus_signing_node ncli_testnet nimbus_validator_client force_build_alone_all_tests
+ echo -e $(BUILD_MSG) "build/$@" && \
MAKE="$(MAKE)" V="$(V)" $(ENV_SCRIPT) scripts/compile_nim_program.sh \
$@ \
Expand Down
43 changes: 28 additions & 15 deletions tests/test_keymanager_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ proc prepareNetwork() {.async.} =
"--insecure-netkey-password=true",
"--genesis-offset=0"
]
let binaryPath = absolutePath("build/ncli_testnet")

let process =
await startProcess("build/ncli_testnet",
await startProcess(binaryPath,
arguments = arguments,
options = {AsyncProcessOption.StdErrToStdOut},
stdoutHandle = AsyncProcess.Pipe)
Expand All @@ -193,7 +194,9 @@ proc prepareNetwork() {.async.} =
else:
notice "Unable to create testnet", rescode = rescode
let res = await process.stdoutStream.read()
echo "===== [", binaryPath, "] exited with [", rescode, "] ====="
echo bytesToString(res)
echo "====="
finally:
await process.closeWait()

Expand Down Expand Up @@ -354,8 +357,10 @@ proc startBeaconNode(basePort: int): Future[TestProcess] {.async.} =
"--doppelganger-detection=off"
]

let binaryPath = absolutePath("build/nimbus_beacon_node")

let res =
await startProcess("build/nimbus_beacon_node",
await startProcess(binaryPath,
arguments = arguments,
options = {AsyncProcessOption.StdErrToStdOut},
stdoutHandle = AsyncProcess.Pipe)
Expand All @@ -364,7 +369,7 @@ proc startBeaconNode(basePort: int): Future[TestProcess] {.async.} =
)

notice "Beacon node process has been started",
process_id = tp.process.pid()
process_id = tp.process.pid(), binary_path = binaryPath

let
address = initTAddress("127.0.0.1:" &
Expand All @@ -373,12 +378,15 @@ proc startBeaconNode(basePort: int): Future[TestProcess] {.async.} =

if not(flag):
notice "Unable to establish connection with `nimbus_beacon_node` process",
process_id = tp.process.pid()
let exitCode = await killAndWaitForExit(tp.process, 5.seconds)
echo "\n===== `nimbus_beacon_node` [", exitCode, "], logs ====="
let output = await tp.reader
echo bytesToString(output)
process_id = tp.process.pid(), binary_path = binaryPath
let
exitCode = await killAndWaitForExit(tp.process, 5.seconds)
output = await tp.reader

await tp.process.closeWait()
echo "===== [", binaryPath, "] exited with [", exitCode, "] ====="
echo bytesToString(output)
echo "====="
raiseAssert "Unable to continue test"

return tp
Expand All @@ -399,8 +407,10 @@ proc startValidatorClient(basePort: int): Future[TestProcess] {.async.} =
"--keymanager-token-file=" & tokenFilePath
]

let binaryPath = absolutePath("build/nimbus_validator_client")

let res =
await startProcess("build/nimbus_validator_client",
await startProcess(binaryPath,
arguments = arguments,
options = {AsyncProcessOption.StdErrToStdOut},
stdoutHandle = AsyncProcess.Pipe)
Expand All @@ -409,7 +419,7 @@ proc startValidatorClient(basePort: int): Future[TestProcess] {.async.} =
)

notice "Validator client process has been started",
process_id = tp.process.pid()
process_id = tp.process.pid(), binary_path = binaryPath

let
address = initTAddress("127.0.0.1:" &
Expand All @@ -418,12 +428,15 @@ proc startValidatorClient(basePort: int): Future[TestProcess] {.async.} =

if not(flag):
notice "Unable to establish connection with `nimbus_validator_client` " &
"process", process_id = tp.process.pid()
discard await killAndWaitForExit(tp.process, 5.seconds)
echo "\n===== `nimbus_validator_client` logs ====="
let output = await tp.reader
echo bytesToString(output)
"process", process_id = tp.process.pid(), binary_path = binaryPath
let
exitCode = await killAndWaitForExit(tp.process, 5.seconds)
output = await tp.reader

await tp.process.closeWait()
echo "===== [", binaryPath, "] exited with [", exitCode, "] ====="
echo bytesToString(output)
echo "====="
raiseAssert "Unable to continue test"

return tp
Expand Down

0 comments on commit bbb5a9e

Please sign in to comment.