mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-06 07:23:10 +00:00
Remove DebugCodexNodes
- Codex nodes will log to file by default, so this parameter could be removed. - Add NoCodexLogFilters define, that unsets chronicles' topic filters when logging codex nodes chronicles logs to file
This commit is contained in:
parent
6057d5ac45
commit
338ee181d3
4
Makefile
4
Makefile
@ -143,10 +143,8 @@ testContracts: | build deps
|
||||
TEST_PARAMS :=
|
||||
ifdef DEBUG
|
||||
TEST_PARAMS := $(TEST_PARAMS) -d:DebugTestHarness=$(DEBUG)
|
||||
TEST_PARAMS := $(TEST_PARAMS) -d:DebugCodexNodes=$(DEBUG)
|
||||
TEST_PARAMS := $(TEST_PARAMS) -d:NoCodexLogFilters=$(DEBUG)
|
||||
TEST_PARAMS := $(TEST_PARAMS) -d:ShowContinuousStatusUpdates=$(DEBUG)
|
||||
endif
|
||||
ifdef DEBUG_HARDHAT
|
||||
TEST_PARAMS := $(TEST_PARAMS) -d:DebugHardhat=$(DEBUG_HARDHAT)
|
||||
endif
|
||||
ifdef TEST_TIMEOUT
|
||||
|
||||
@ -12,8 +12,9 @@ import ../../examples
|
||||
const HardhatPort {.intdefine.}: int = 8545
|
||||
const CodexApiPort {.intdefine.}: int = 8080
|
||||
const CodexDiscPort {.intdefine.}: int = 8090
|
||||
const DebugCodexNodes {.booldefine.}: bool = false
|
||||
const LogsDir {.strdefine.}: string = ""
|
||||
const CodexLogToFile {.booldefine.}: bool = false
|
||||
const CodexLogLevel {.strdefine.}: string = ""
|
||||
const CodexLogsDir {.strdefine.}: string = ""
|
||||
|
||||
asyncchecksuite "Command line interface":
|
||||
let startTime = now().format("yyyy-MM-dd'_'HH:mm:ss")
|
||||
@ -30,21 +31,23 @@ asyncchecksuite "Command line interface":
|
||||
tbody
|
||||
|
||||
proc addLogFile(args: seq[string]): seq[string] =
|
||||
when DebugCodexNodes:
|
||||
return args.concat @[
|
||||
var args = args
|
||||
when CodexLogToFile:
|
||||
args.add(
|
||||
"--log-file=" &
|
||||
getLogFile(
|
||||
LogsDir,
|
||||
CodexLogsDir,
|
||||
startTime,
|
||||
"Command line interface",
|
||||
currentTestName,
|
||||
"Client",
|
||||
some nodeCount mod testCount,
|
||||
),
|
||||
"--log-level=" & $LogLevel.TRACE,
|
||||
]
|
||||
else:
|
||||
return args
|
||||
)
|
||||
)
|
||||
when CodexLogLevel != "":
|
||||
args.add "--log-level=" & CodexLogLevel
|
||||
|
||||
return args
|
||||
|
||||
proc startCodex(arguments: seq[string]): Future[CodexProcess] {.async.} =
|
||||
inc nodeCount
|
||||
@ -56,7 +59,7 @@ asyncchecksuite "Command line interface":
|
||||
"--disc-port=" & $(await nextFreePort(CodexDiscPort + nodeCount)),
|
||||
]
|
||||
),
|
||||
debug = DebugCodexNodes,
|
||||
debug = false,
|
||||
"cli-test-node",
|
||||
)
|
||||
|
||||
|
||||
@ -46,8 +46,9 @@ const HardhatPort {.intdefine.}: int = 8545
|
||||
const CodexApiPort {.intdefine.}: int = 8080
|
||||
const CodexDiscPort {.intdefine.}: int = 8090
|
||||
const TestId {.strdefine.}: string = "TestId"
|
||||
const DebugCodexNodes {.booldefine.}: bool = false
|
||||
const LogsDir {.strdefine.}: string = ""
|
||||
const CodexLogToFile {.booldefine.}: bool = false
|
||||
const CodexLogLevel {.strdefine.}: string = ""
|
||||
const CodexLogsDir {.strdefine.}: string = ""
|
||||
|
||||
proc raiseMultiNodeSuiteError(
|
||||
msg: string, parent: ref CatchableError = nil
|
||||
@ -122,7 +123,7 @@ template multinodesuite*(name: string, body: untyped) =
|
||||
if config.logFile:
|
||||
try:
|
||||
let updatedLogFile =
|
||||
getLogFile(LogsDir, starttime, name, currentTestName, $role, none int)
|
||||
getLogFile(CodexLogsDir, starttime, name, currentTestName, $role, none int)
|
||||
args.add "--log-file=" & updatedLogFile
|
||||
except IOError as e:
|
||||
raiseMultiNodeSuiteError(
|
||||
@ -166,10 +167,11 @@ template multinodesuite*(name: string, body: untyped) =
|
||||
sanitize($starttime) / sanitize($role & "_" & $roleIdx)
|
||||
|
||||
try:
|
||||
if config.logFile.isSome or DebugCodexNodes:
|
||||
if config.logFile.isSome or CodexLogToFile:
|
||||
try:
|
||||
let updatedLogFile =
|
||||
getLogFile(LogsDir, starttime, name, currentTestName, $role, some roleIdx)
|
||||
let updatedLogFile = getLogFile(
|
||||
CodexLogsDir, starttime, name, currentTestName, $role, some roleIdx
|
||||
)
|
||||
config.withLogFile(updatedLogFile)
|
||||
except IOError as e:
|
||||
raiseMultiNodeSuiteError(
|
||||
@ -183,9 +185,9 @@ template multinodesuite*(name: string, body: untyped) =
|
||||
" because logfile path could not be obtained: " & e.msg,
|
||||
e,
|
||||
)
|
||||
|
||||
if DebugCodexNodes:
|
||||
config.addCliOption("--log-level", $LogLevel.TRACE)
|
||||
# TODO: uncomment once HttpClient has been asyncified
|
||||
# when CodexLogLevel != "":
|
||||
# config.addCliOption("--log-level", CodexLogLevel)
|
||||
|
||||
var apiPort, discPort: int
|
||||
withLock(codexPortLock):
|
||||
@ -281,9 +283,9 @@ template multinodesuite*(name: string, body: untyped) =
|
||||
)
|
||||
|
||||
return await newCodexProcess(providerIdx, config, Role.Provider)
|
||||
except CodexConfigError as e:
|
||||
except CodexConfigError as exc:
|
||||
raiseMultiNodeSuiteError "Failed to start codex node, error adding cli options: " &
|
||||
e.msg, e
|
||||
exc.msg, exc
|
||||
|
||||
proc startValidatorNode(
|
||||
conf: CodexConfig
|
||||
@ -362,9 +364,9 @@ template multinodesuite*(name: string, body: untyped) =
|
||||
# When this file is run with `-d:chronicles_sinks=textlines[file]`, we
|
||||
# need to set the log file path at runtime, otherwise chronicles didn't seem to
|
||||
# create a log file even when using an absolute path
|
||||
when defaultChroniclesStream.outputs is (FileOutput,) and LogsDir.len > 0:
|
||||
when defaultChroniclesStream.outputs is (FileOutput,) and CodexLogsDir.len > 0:
|
||||
let logFile =
|
||||
LogsDir / sanitize(getAppFilename().extractFilename & ".chronicles.log")
|
||||
CodexLogsDir / sanitize(getAppFilename().extractFilename & ".chronicles.log")
|
||||
let success = defaultChroniclesStream.outputs[0].open(logFile, fmAppend)
|
||||
doAssert success, "Failed to open log file: " & logFile
|
||||
|
||||
|
||||
@ -23,10 +23,9 @@ type
|
||||
|
||||
TestManagerConfig* = object # Echoes stdout from Hardhat process
|
||||
debugHardhat*: bool
|
||||
# Echoes stdout from the integration test file process. Codex process logs
|
||||
# can also be output if a test uses a multinodesuite, requires
|
||||
# CodexConfig.debug to be enabled
|
||||
debugCodexNodes*: bool
|
||||
# Shows all log topics at TRACE log level by disabling codex node output log
|
||||
# topic filters, eg libp2p, websock, JSON RPC
|
||||
noCodexLogFilters*: bool
|
||||
# Shows test status updates at regular time intervals. Useful for running
|
||||
# locally while attended. Set to false for unattended runs, eg CI.
|
||||
showContinuousStatusUpdates*: bool
|
||||
@ -339,6 +338,12 @@ proc buildCommand(
|
||||
let discPort = await nextFreePort(test.manager.lastCodexDiscPort + 1000)
|
||||
test.manager.lastCodexDiscPort = discPort
|
||||
|
||||
let codexLogLevel =
|
||||
if test.manager.config.noCodexLogFilters:
|
||||
"TRACE"
|
||||
else:
|
||||
"TRACE;disabled:libp2p,websock,JSONRPC-HTTP-CLIENT,JSONRPC-WS-CLIENT,discv5"
|
||||
|
||||
withLock(test.manager.hardhatPortLock):
|
||||
try:
|
||||
return
|
||||
@ -346,15 +351,14 @@ proc buildCommand(
|
||||
"nim c " &
|
||||
&"-d:CodexApiPort={apiPort} " &
|
||||
&"-d:CodexDiscPort={discPort} " &
|
||||
&"-d:DebugCodexNodes={test.manager.config.debugCodexNodes} " &
|
||||
&"-d:DebugHardhat={test.manager.config.debugHardhat} " &
|
||||
&"-d:LogsDir={test.logsDir} " &
|
||||
&"-d:CodexLogsDir={test.logsDir} " &
|
||||
&"-d:CodexLogLevel=\"{codexLogLevel}\" " &
|
||||
&"-d:CodexLogToFile=true " &
|
||||
(hhPort |? "") & " " &
|
||||
&"-d:TestId={test.testId} " &
|
||||
# Log multinodes chronicles logs to file. If DebugCodexNodes is also
|
||||
# enabled, the chronicles output will also get logged to stdout.
|
||||
# Log multinodes chronicles logs settings (log to file with no
|
||||
# colours, and loglevel = TRACE).
|
||||
"-d:chronicles_log_level=TRACE " &
|
||||
"-d:chronicles_disabled_topics=websock,JSONRPC-HTTP-CLIENT,JSONRPC-WS-CLIENT " &
|
||||
"-d:chronicles_sinks=textlines[nocolors,file] " &
|
||||
"--verbosity:0 " &
|
||||
"--hints:off " &
|
||||
|
||||
@ -32,10 +32,7 @@ const TestConfigs =
|
||||
|
||||
# Echoes stdout from Hardhat process
|
||||
const DebugHardhat {.booldefine.} = false
|
||||
# Echoes stdout from the integration test file process. Codex process logs can
|
||||
# also be output if a test uses a multinodesuite, requires CodexConfig.debug
|
||||
# to be enabled
|
||||
const DebugCodexNodes {.booldefine.} = false
|
||||
const NoCodexLogFilters {.booldefine.} = false
|
||||
# Shows test status updates at time intervals. Useful for running locally with
|
||||
# active terminal interaction. Set to false for unattended runs, eg CI.
|
||||
const ShowContinuousStatusUpdates {.booldefine.} = false
|
||||
@ -82,7 +79,7 @@ proc run(): Future[bool] {.async: (raises: []).} =
|
||||
let manager = TestManager.new(
|
||||
config = TestManagerConfig(
|
||||
debugHardhat: DebugHardhat,
|
||||
debugCodexNodes: DebugCodexNodes,
|
||||
noCodexLogFilters: NoCodexLogFilters,
|
||||
showContinuousStatusUpdates: ShowContinuousStatusUpdates,
|
||||
logsDir: logsDir,
|
||||
testTimeout: TestTimeout.minutes,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user