-
Notifications
You must be signed in to change notification settings - Fork 2.9k
test(e2e): migrate Telegram injection to Vitest #5576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+795
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
98ccb03
test(e2e): migrate Telegram injection to Vitest
cv 7a1acdf
test(e2e): keep Telegram injection test linear
cv 57f25d3
Merge branch 'main' into e2e-phase6-telegram-injection
cv d45654f
test(e2e): address Telegram injection review feedback
cv d5d1d2f
Merge remote-tracking branch 'origin/e2e-phase6-telegram-injection' i…
cv c493191
test(e2e): cover telegram SSH path
jyaunches File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import path from "node:path"; | ||
|
|
||
| import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts"; | ||
| import type { HostCliClient } from "../fixtures/clients/host.ts"; | ||
| import { | ||
| type SandboxClient, | ||
| sandboxAccessEnv, | ||
| trustedSandboxShellScript, | ||
| validateSandboxName, | ||
| } from "../fixtures/clients/sandbox.ts"; | ||
| import { expect } from "../fixtures/e2e-test.ts"; | ||
| import type { ShellProbeResult } from "../fixtures/shell-probe.ts"; | ||
| import { isNvidiaEndpointRateLimitFailure } from "./messaging-providers-helpers.ts"; | ||
|
|
||
| export const REPO_ROOT = path.resolve(import.meta.dirname, "../../.."); | ||
| export const CLI = process.env.NEMOCLAW_CLI_BIN ?? path.join(REPO_ROOT, "bin", "nemoclaw.js"); | ||
|
|
||
| export const INSTALL_TIMEOUT_MS = 45 * 60_000; | ||
| export const COMMAND_TIMEOUT_MS = 120_000; | ||
|
|
||
| export type AgentKind = "openclaw" | "hermes"; | ||
|
|
||
| export function stripAnsi(value: string): string { | ||
| return value.replace(/\u001b\[[0-9;]*m/g, ""); | ||
| } | ||
|
|
||
| export function resultText(result: Pick<ShellProbeResult, "stdout" | "stderr">): string { | ||
| return [result.stdout, result.stderr].filter(Boolean).join("\n"); | ||
| } | ||
|
|
||
| export function shellQuote(value: string): string { | ||
| return `'${value.replace(/'/g, `'\\''`)}'`; | ||
| } | ||
|
|
||
| export function base64(value: string): string { | ||
| return Buffer.from(value, "utf8").toString("base64"); | ||
| } | ||
|
|
||
| export function phase6Env(options: { | ||
| sandboxName: string; | ||
| agent?: AgentKind; | ||
| apiKey?: string; | ||
| extra?: NodeJS.ProcessEnv; | ||
| }): NodeJS.ProcessEnv { | ||
| validateSandboxName(options.sandboxName); | ||
| return { | ||
| ...buildAvailabilityProbeEnv(), | ||
| NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1", | ||
| NEMOCLAW_NON_INTERACTIVE: "1", | ||
| NEMOCLAW_RECREATE_SANDBOX: "1", | ||
| NEMOCLAW_FRESH: "1", | ||
| NEMOCLAW_POLICY_TIER: process.env.NEMOCLAW_POLICY_TIER ?? "open", | ||
| NEMOCLAW_SANDBOX_NAME: options.sandboxName, | ||
| OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY ?? "nemoclaw", | ||
| ...(options.agent ? { NEMOCLAW_AGENT: options.agent } : {}), | ||
| ...(options.apiKey | ||
| ? { NVIDIA_INFERENCE_API_KEY: options.apiKey, NVIDIA_API_KEY: options.apiKey } | ||
| : {}), | ||
| ...options.extra, | ||
| }; | ||
| } | ||
|
|
||
| export function redactionValues(apiKey: string | undefined): string[] { | ||
| return [apiKey].filter((value): value is string => typeof value === "string" && value.length > 0); | ||
| } | ||
|
|
||
| export async function bestEffort(run: () => Promise<unknown>): Promise<void> { | ||
| try { | ||
| await run(); | ||
| } catch { | ||
| // Cleanup and diagnostics must not hide primary test failures. | ||
| } | ||
| } | ||
|
|
||
| export function expectExitZero(result: ShellProbeResult, label: string): void { | ||
| expect(result.exitCode, `${label}\n${resultText(result)}`).toBe(0); | ||
| } | ||
|
|
||
| export async function precleanSandbox( | ||
| host: HostCliClient, | ||
| sandboxName: string, | ||
| env: NodeJS.ProcessEnv, | ||
| redactions: string[], | ||
| prefix: string, | ||
| ): Promise<void> { | ||
| await bestEffort(() => | ||
| host.command("node", [CLI, sandboxName, "destroy", "--yes"], { | ||
| artifactName: `${prefix}-nemoclaw-destroy`, | ||
| env, | ||
| redactionValues: redactions, | ||
| timeoutMs: 15 * 60_000, | ||
| }), | ||
| ); | ||
| await bestEffort(() => | ||
| host.command("openshell", ["sandbox", "delete", sandboxName], { | ||
| artifactName: `${prefix}-openshell-sandbox-delete`, | ||
| env, | ||
| redactionValues: redactions, | ||
| timeoutMs: 120_000, | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| export async function cleanupSandbox( | ||
| host: HostCliClient, | ||
| sandboxName: string, | ||
| env: NodeJS.ProcessEnv, | ||
| redactions: string[], | ||
| prefix: string, | ||
| ): Promise<void> { | ||
| await precleanSandbox(host, sandboxName, env, redactions, prefix); | ||
| } | ||
|
|
||
| export async function installSandbox( | ||
| host: HostCliClient, | ||
| env: NodeJS.ProcessEnv, | ||
| redactions: string[], | ||
| artifactName: string, | ||
| ): Promise<ShellProbeResult> { | ||
| const result = await host.command("bash", ["install.sh", "--non-interactive"], { | ||
| artifactName, | ||
| cwd: REPO_ROOT, | ||
| env, | ||
| redactionValues: redactions, | ||
| timeoutMs: INSTALL_TIMEOUT_MS, | ||
| }); | ||
| if (result.exitCode !== 0 && isNvidiaEndpointRateLimitFailure(resultText(result))) { | ||
| throw new Error(`NVIDIA_ENDPOINT_RATE_LIMIT:${artifactName}`); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| export async function installSandboxOrSkipOnRateLimit( | ||
| host: HostCliClient, | ||
| env: NodeJS.ProcessEnv, | ||
| redactions: string[], | ||
| artifactName: string, | ||
| skip: (note?: string) => never, | ||
| skipMessage: string, | ||
| ): Promise<ShellProbeResult> { | ||
| try { | ||
| return await installSandbox(host, env, redactions, artifactName); | ||
| } catch (error) { | ||
| if (String(error).includes("NVIDIA_ENDPOINT_RATE_LIMIT")) { | ||
| skip(skipMessage); | ||
| } | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| export async function expectSandboxReady( | ||
| host: HostCliClient, | ||
| sandboxName: string, | ||
| env: NodeJS.ProcessEnv, | ||
| redactions: string[], | ||
| artifactName: string, | ||
| ): Promise<void> { | ||
| const list = await host.command("openshell", ["sandbox", "list"], { | ||
| artifactName, | ||
| env, | ||
| redactionValues: redactions, | ||
| timeoutMs: 60_000, | ||
| }); | ||
| expectExitZero(list, "openshell sandbox list"); | ||
| const row = stripAnsi(list.stdout) | ||
| .split(/\r?\n/) | ||
| .find((line) => line.includes(sandboxName)); | ||
| expect(row, resultText(list)).toMatch(/\bReady\b/i); | ||
| } | ||
|
|
||
| export async function sandboxSh( | ||
| sandbox: SandboxClient, | ||
| sandboxName: string, | ||
| script: string, | ||
| options: { | ||
| artifactName: string; | ||
| redactionValues?: string[]; | ||
| timeoutMs?: number; | ||
| }, | ||
| ): Promise<ShellProbeResult> { | ||
| return sandbox.execShell(sandboxName, trustedSandboxShellScript(script), { | ||
| artifactName: options.artifactName, | ||
| env: sandboxAccessEnv(), | ||
| redactionValues: options.redactionValues ?? [], | ||
| timeoutMs: options.timeoutMs ?? COMMAND_TIMEOUT_MS, | ||
| }); | ||
| } | ||
|
|
||
| export async function dockerInfo( | ||
| host: HostCliClient, | ||
| env: NodeJS.ProcessEnv, | ||
| ): Promise<ShellProbeResult> { | ||
| return host.command("docker", ["info"], { | ||
| artifactName: "phase6-docker-info", | ||
| env, | ||
| timeoutMs: 30_000, | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.