refactor: move remote screenshots into web-probe
This commit is contained in:
@@ -27,6 +27,7 @@ import { hwlabNodeHelp, hwlabNodeObservabilityHelp, hwlabNodeWebProbeHelp } from
|
||||
import { compactWebProbeResult, compactWebProbeScriptResult } from "../hwlab-node-web-probe-summary";
|
||||
import { nodeObservabilityRecordingRuleExpression, nodeObservabilityRecordingRuleSummaries, nodeObservabilityWarningAlertExpression, nodeObservabilityWarningAlertSummaries } from "../hwlab-node-observability-promql";
|
||||
import { runDelegatedHwlabNodeCommand, type DelegatedNodeDomain } from "../hwlab-node-transport";
|
||||
import { runWebProbeRemoteArtifactJob } from "../web-probe-remote-artifact";
|
||||
import type { RenderedCliResult } from "../output";
|
||||
|
||||
import type { BootstrapAdminPasswordMaterial, NodeWebProbeObserveCommandType, NodeWebProbeObserveOptions, NodeWebProbeOptions, NodeWebProbeRunOptions, NodeWebProbeScreenshotOptions, NodeWebProbeSentinelOptions, RuntimeSecretSpec, WebObserveIndexEntry, WebProbeBrowserProxyMode } from "./entry";
|
||||
@@ -619,19 +620,17 @@ export function runNodeWebProbe(options: NodeWebProbeOptions): Record<string, un
|
||||
export function runNodeWebProbeScreenshot(options: NodeWebProbeScreenshotOptions, spec: HwlabRuntimeLaneSpec): Record<string, unknown> {
|
||||
const route = `${options.node}:${spec.workspace}`;
|
||||
const script = webProbeScreenshotRemoteScript(options);
|
||||
const result = runCommand([
|
||||
transPath(),
|
||||
const job = runWebProbeRemoteArtifactJob({
|
||||
route,
|
||||
"playwright",
|
||||
"--local-dir",
|
||||
options.localDir,
|
||||
"--wait-timeout-ms",
|
||||
String(options.waitTimeoutMs),
|
||||
"--inactivity-timeout-ms",
|
||||
"30000",
|
||||
...(options.keepRemote ? ["--keep-remote"] : []),
|
||||
], repoRoot, { input: script, timeoutMs: options.commandTimeoutSeconds * 1000 });
|
||||
const transport = record(parseJsonObject(result.stdout));
|
||||
localDir: options.localDir,
|
||||
waitTimeoutMs: options.waitTimeoutMs,
|
||||
commandTimeoutMs: options.commandTimeoutSeconds * 1000,
|
||||
inactivityTimeoutMs: 30000,
|
||||
keepRemote: options.keepRemote,
|
||||
runIdPrefix: `web-probe-screenshot-${options.node.toLowerCase()}-${options.lane}`,
|
||||
}, script);
|
||||
const result = job.result;
|
||||
const transport = record(job.transport);
|
||||
const transportParsed = Object.keys(transport).length > 0;
|
||||
const artifacts = Array.isArray(transport.artifacts) ? transport.artifacts.map(record) : [];
|
||||
const screenshot = artifacts.find((artifact) => {
|
||||
@@ -749,7 +748,7 @@ function webProbeScreenshotRemoteScript(options: NodeWebProbeScreenshotOptions):
|
||||
return [
|
||||
"set -eu",
|
||||
`export UNIDESK_WEB_PROBE_SCREENSHOT_URL=${shellQuote(options.url)}`,
|
||||
`export UNIDESK_WEB_PROBE_SCREENSHOT_PATH="$UNIDESK_PLAYWRIGHT_REMOTE_DIR"/${shellQuote(options.name)}`,
|
||||
`export UNIDESK_WEB_PROBE_SCREENSHOT_PATH="$UNIDESK_WEB_PROBE_ARTIFACT_REMOTE_DIR"/${shellQuote(options.name)}`,
|
||||
`export UNIDESK_WEB_PROBE_SCREENSHOT_WIDTH=${shellQuote(widthRaw ?? "1440")}`,
|
||||
`export UNIDESK_WEB_PROBE_SCREENSHOT_HEIGHT=${shellQuote(heightRaw ?? "900")}`,
|
||||
`export UNIDESK_WEB_PROBE_SCREENSHOT_TIMEOUT_MS=${shellQuote(String(options.timeoutMs))}`,
|
||||
@@ -765,10 +764,10 @@ function webProbeScreenshotRemoteScript(options: NodeWebProbeScreenshotOptions):
|
||||
"else",
|
||||
" export UNIDESK_WEB_PROBE_SCREENSHOT_EXECUTABLE_PATH=",
|
||||
"fi",
|
||||
"cat > \"$UNIDESK_PLAYWRIGHT_REMOTE_DIR/web-probe-screenshot.mjs\" <<'WEB_PROBE_SCREENSHOT_JS'",
|
||||
"cat > \"$UNIDESK_WEB_PROBE_ARTIFACT_REMOTE_DIR/web-probe-screenshot.mjs\" <<'WEB_PROBE_SCREENSHOT_JS'",
|
||||
webProbeScreenshotRemoteModule(),
|
||||
"WEB_PROBE_SCREENSHOT_JS",
|
||||
"bun \"$UNIDESK_PLAYWRIGHT_REMOTE_DIR/web-probe-screenshot.mjs\"",
|
||||
"bun \"$UNIDESK_WEB_PROBE_ARTIFACT_REMOTE_DIR/web-probe-screenshot.mjs\"",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user