You've already forked tribes-supertest
fix: log roundtrip through app logger
RPC evaluation runs with a remote group leader, which the runtime logger filters from the console handler. Temporarily route the RPC process to the running node user group leader so the scenario exercises the real Tribes logger, service log, syslog-ng importer, and admin API path.
This commit is contained in:
+16
-1
@@ -1428,7 +1428,7 @@ export class ScenarioExecution {
|
||||
await this.callNodeRpc(
|
||||
server.id,
|
||||
"tribes-log-roundtrip-emit",
|
||||
`require Logger; Logger.info(${elixirStringLiteral(message)}); Logger.flush(); :ok`
|
||||
buildTribesLogRoundTripRpcExpression(message)
|
||||
)
|
||||
|
||||
const entry = await this.waitForLogEntry(
|
||||
@@ -3210,6 +3210,21 @@ function isTransientHetznerCapacityError(error: unknown): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
export function buildTribesLogRoundTripRpcExpression(message: string): string {
|
||||
return [
|
||||
"require Logger",
|
||||
"old_group_leader = Process.group_leader()",
|
||||
"Process.group_leader(self(), Process.whereis(:user))",
|
||||
"try do",
|
||||
` Logger.info(${elixirStringLiteral(message)})`,
|
||||
" Logger.flush()",
|
||||
" :ok",
|
||||
"after",
|
||||
" Process.group_leader(self(), old_group_leader)",
|
||||
"end"
|
||||
].join("; ")
|
||||
}
|
||||
|
||||
export function buildLocalBootKeyStateScript(): string {
|
||||
return `
|
||||
local_boot_key_file=
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
buildLocalBootKeyStateScript,
|
||||
buildNodeCreateArgs,
|
||||
buildSshAccessCommand,
|
||||
buildTribesLogRoundTripRpcExpression,
|
||||
buildVictoriaMetricsLatestSnapshotScript,
|
||||
extractGuixBuildLogPaths,
|
||||
extractGuixBuildLogPathsFromText,
|
||||
@@ -68,6 +69,15 @@ test("buildVictoriaMetricsLatestSnapshotScript queries latest samples for all me
|
||||
assert.match(script, /curl -fsS/)
|
||||
})
|
||||
|
||||
test("buildTribesLogRoundTripRpcExpression logs through the running node group leader", () => {
|
||||
const expression = buildTribesLogRoundTripRpcExpression("[source=core] hello")
|
||||
|
||||
assert.match(expression, /old_group_leader = Process\.group_leader\(\)/)
|
||||
assert.match(expression, /Process\.group_leader\(self\(\), Process\.whereis\(:user\)\)/)
|
||||
assert.match(expression, /Logger\.info\("\[source=core\] hello"\)/)
|
||||
assert.match(expression, /Process\.group_leader\(self\(\), old_group_leader\)/)
|
||||
})
|
||||
|
||||
test("buildLocalBootKeyStateScript follows deployed system facts", () => {
|
||||
const script = buildLocalBootKeyStateScript()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user