test: align imageRef selftests with Aipod spec source
This commit is contained in:
@@ -6,12 +6,13 @@ import { MemoryAgentRunStore } from "../../mgr/store.js";
|
|||||||
import { ManagerClient } from "../../mgr/client.js";
|
import { ManagerClient } from "../../mgr/client.js";
|
||||||
import { renderRunnerJobDryRun } from "../../runner/k8s-job.js";
|
import { renderRunnerJobDryRun } from "../../runner/k8s-job.js";
|
||||||
import type { JsonRecord, RunRecord } from "../../common/types.js";
|
import type { JsonRecord, RunRecord } from "../../common/types.js";
|
||||||
import { assertNoSecretLeak, createRunWithCommand, type SelfTestCase } from "../harness.js";
|
import { assertNoSecretLeak, createRunWithCommand, loadArtificerImageRef, type SelfTestCase } from "../harness.js";
|
||||||
|
|
||||||
const selfTest: SelfTestCase = async (context) => {
|
const selfTest: SelfTestCase = async (context) => {
|
||||||
const server = await startManagerServer({ port: 0, host: "127.0.0.1", sourceCommit: "self-test", store: new MemoryAgentRunStore() });
|
const server = await startManagerServer({ port: 0, host: "127.0.0.1", sourceCommit: "self-test", store: new MemoryAgentRunStore() });
|
||||||
try {
|
try {
|
||||||
const client = new ManagerClient(server.baseUrl);
|
const client = new ManagerClient(server.baseUrl);
|
||||||
|
const artificerImageRef = await loadArtificerImageRef(context.root);
|
||||||
const githubToolCredentials = [{
|
const githubToolCredentials = [{
|
||||||
tool: "github",
|
tool: "github",
|
||||||
purpose: "pull-request",
|
purpose: "pull-request",
|
||||||
@@ -188,7 +189,7 @@ process.exit(1);
|
|||||||
imageRef: {
|
imageRef: {
|
||||||
kind: "env-image-dockerfile",
|
kind: "env-image-dockerfile",
|
||||||
repoUrl: "git@github.com:pikasTech/agentrun.git",
|
repoUrl: "git@github.com:pikasTech/agentrun.git",
|
||||||
commitId: "59272f8edb4e23d805b7b9da0050ec40cfc0233d",
|
commitId: artificerImageRef.commitId,
|
||||||
dockerfilePath: "deploy/container/Containerfile",
|
dockerfilePath: "deploy/container/Containerfile",
|
||||||
},
|
},
|
||||||
transientEnv: [
|
transientEnv: [
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { startManagerServer } from "../../mgr/server.js";
|
|||||||
import { MemoryAgentRunStore } from "../../mgr/store.js";
|
import { MemoryAgentRunStore } from "../../mgr/store.js";
|
||||||
import { ManagerClient } from "../../mgr/client.js";
|
import { ManagerClient } from "../../mgr/client.js";
|
||||||
import type { JsonRecord, QueueDispatchResult, QueueTaskRecord } from "../../common/types.js";
|
import type { JsonRecord, QueueDispatchResult, QueueTaskRecord } from "../../common/types.js";
|
||||||
import { assertNoSecretLeak, type SelfTestCase } from "../harness.js";
|
import { assertNoSecretLeak, loadArtificerImageRef, type SelfTestCase } from "../harness.js";
|
||||||
|
|
||||||
const selfTest: SelfTestCase = async (context) => {
|
const selfTest: SelfTestCase = async (context) => {
|
||||||
const fakeKubectl = path.join(context.tmp, "fake-kubectl-queue-q2.js");
|
const fakeKubectl = path.join(context.tmp, "fake-kubectl-queue-q2.js");
|
||||||
@@ -39,10 +39,11 @@ process.exit(1);
|
|||||||
`);
|
`);
|
||||||
await chmod(fakeKubectl, 0o755);
|
await chmod(fakeKubectl, 0o755);
|
||||||
const store = new MemoryAgentRunStore();
|
const store = new MemoryAgentRunStore();
|
||||||
|
const artificerImageRef = await loadArtificerImageRef(context.root);
|
||||||
const aipodImageRef = {
|
const aipodImageRef = {
|
||||||
kind: "env-image-dockerfile",
|
kind: "env-image-dockerfile",
|
||||||
repoUrl: "git@github.com:pikasTech/agentrun.git",
|
repoUrl: "git@github.com:pikasTech/agentrun.git",
|
||||||
commitId: "59272f8edb4e23d805b7b9da0050ec40cfc0233d",
|
commitId: artificerImageRef.commitId,
|
||||||
dockerfilePath: "deploy/container/Containerfile",
|
dockerfilePath: "deploy/container/Containerfile",
|
||||||
};
|
};
|
||||||
const server = await startManagerServer({
|
const server = await startManagerServer({
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ import { startManagerServer } from "../../mgr/server.js";
|
|||||||
import { MemoryAgentRunStore } from "../../mgr/store.js";
|
import { MemoryAgentRunStore } from "../../mgr/store.js";
|
||||||
import type { JsonRecord } from "../../common/types.js";
|
import type { JsonRecord } from "../../common/types.js";
|
||||||
import { resolveGitBundleFetchSource } from "../../runner/resource-bundle.js";
|
import { resolveGitBundleFetchSource } from "../../runner/resource-bundle.js";
|
||||||
import { assertNoSecretLeak, type SelfTestCase } from "../harness.js";
|
import { assertNoSecretLeak, loadArtificerImageRef, type SelfTestCase } from "../harness.js";
|
||||||
|
|
||||||
const selfTest: SelfTestCase = async (context) => {
|
const selfTest: SelfTestCase = async (context) => {
|
||||||
const server = await startManagerServer({ port: 0, host: "127.0.0.1", sourceCommit: "self-test", store: new MemoryAgentRunStore(), aipodSpecDir: path.join(context.root, "config", "aipods") });
|
const server = await startManagerServer({ port: 0, host: "127.0.0.1", sourceCommit: "self-test", store: new MemoryAgentRunStore(), aipodSpecDir: path.join(context.root, "config", "aipods") });
|
||||||
try {
|
try {
|
||||||
const client = new ManagerClient(server.baseUrl);
|
const client = new ManagerClient(server.baseUrl);
|
||||||
|
const artificerImageRef = await loadArtificerImageRef(context.root);
|
||||||
const parsedWithoutBunGlobal = await runNodeParserCompat(context);
|
const parsedWithoutBunGlobal = await runNodeParserCompat(context);
|
||||||
assert.equal(parsedWithoutBunGlobal.name, "Artificer");
|
assert.equal(parsedWithoutBunGlobal.name, "Artificer");
|
||||||
assert.equal(parsedWithoutBunGlobal.hasBunGlobal, false);
|
assert.equal(parsedWithoutBunGlobal.hasBunGlobal, false);
|
||||||
@@ -27,7 +28,7 @@ const selfTest: SelfTestCase = async (context) => {
|
|||||||
const shownImageRef = shownItem.imageRef as JsonRecord;
|
const shownImageRef = shownItem.imageRef as JsonRecord;
|
||||||
assert.equal(shownImageRef.kind, "env-image-dockerfile");
|
assert.equal(shownImageRef.kind, "env-image-dockerfile");
|
||||||
assert.equal(shownImageRef.repoUrl, "git@github.com:pikasTech/agentrun.git");
|
assert.equal(shownImageRef.repoUrl, "git@github.com:pikasTech/agentrun.git");
|
||||||
assert.equal(shownImageRef.commitId, "59272f8edb4e23d805b7b9da0050ec40cfc0233d");
|
assert.equal(shownImageRef.commitId, artificerImageRef.commitId);
|
||||||
assert.equal(shownImageRef.dockerfilePath, "deploy/container/Containerfile");
|
assert.equal(shownImageRef.dockerfilePath, "deploy/container/Containerfile");
|
||||||
assert.equal(((shownItem.resourceBundleRef as JsonRecord).gitMirror as JsonRecord).enabled, false);
|
assert.equal(((shownItem.resourceBundleRef as JsonRecord).gitMirror as JsonRecord).enabled, false);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
|||||||
import type { SelfTestCase } from "../harness.js";
|
import type { SelfTestCase } from "../harness.js";
|
||||||
import { imageRefSourceIdentity, imageRefSourceSummary, isDigestPinnedImage, validateAipodImageRef } from "../../common/env-image-ref.js";
|
import { imageRefSourceIdentity, imageRefSourceSummary, isDigestPinnedImage, validateAipodImageRef } from "../../common/env-image-ref.js";
|
||||||
import { smokeBundledWorkReadyCapabilities, smokeImageWorkReadyCapabilities, staticWorkReadyCapabilitySummary } from "../../common/work-ready.js";
|
import { smokeBundledWorkReadyCapabilities, smokeImageWorkReadyCapabilities, staticWorkReadyCapabilitySummary } from "../../common/work-ready.js";
|
||||||
|
import { loadArtificerImageRef } from "../harness.js";
|
||||||
|
|
||||||
const requiredRunnerPackages = Object.freeze(["ca-certificates", "curl", "git", "github-cli", "kubectl", "nodejs", "npm", "openssh-client", "ripgrep"]);
|
const requiredRunnerPackages = Object.freeze(["ca-certificates", "curl", "git", "github-cli", "kubectl", "nodejs", "npm", "openssh-client", "ripgrep"]);
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
@@ -54,7 +55,8 @@ const selfTest: SelfTestCase = async (context) => {
|
|||||||
assert.equal(((bundleSmoke.smoke as { ok?: unknown }).ok), true);
|
assert.equal(((bundleSmoke.smoke as { ok?: unknown }).ok), true);
|
||||||
assert.equal(bundleSmoke.valuesPrinted, false);
|
assert.equal(bundleSmoke.valuesPrinted, false);
|
||||||
assert.equal(JSON.stringify({ imageSmoke, bundleSmoke }).includes("GH_TOKEN"), false);
|
assert.equal(JSON.stringify({ imageSmoke, bundleSmoke }).includes("GH_TOKEN"), false);
|
||||||
const imageRef = validateAipodImageRef({ kind: "env-image-dockerfile", repoUrl: "git@github.com:pikasTech/agentrun.git", commitId: "59272f8edb4e23d805b7b9da0050ec40cfc0233d", dockerfilePath: "deploy/container/Containerfile" });
|
const artificerImageRef = await loadArtificerImageRef(context.root);
|
||||||
|
const imageRef = validateAipodImageRef({ kind: "env-image-dockerfile", repoUrl: "git@github.com:pikasTech/agentrun.git", commitId: artificerImageRef.commitId, dockerfilePath: "deploy/container/Containerfile" });
|
||||||
assert.equal(imageRefSourceIdentity(imageRef).length, 20);
|
assert.equal(imageRefSourceIdentity(imageRef).length, 20);
|
||||||
assert.equal((imageRefSourceSummary(imageRef).valuesPrinted), false);
|
assert.equal((imageRefSourceSummary(imageRef).valuesPrinted), false);
|
||||||
assert.equal(isDigestPinnedImage("127.0.0.1:5000/agentrun/agentrun-mgr@sha256:1111111111111111111111111111111111111111111111111111111111111111"), true);
|
assert.equal(isDigestPinnedImage("127.0.0.1:5000/agentrun/agentrun-mgr@sha256:1111111111111111111111111111111111111111111111111111111111111111"), true);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { chmod, mkdtemp, mkdir, writeFile, rm } from "node:fs/promises";
|
import { chmod, mkdtemp, mkdir, readFile, writeFile, rm } from "node:fs/promises";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { ManagerClient } from "../mgr/client.js";
|
import { ManagerClient } from "../mgr/client.js";
|
||||||
import type { BackendProfile, JsonRecord } from "../common/types.js";
|
import type { AipodImageRef, BackendProfile, JsonRecord } from "../common/types.js";
|
||||||
import { backendProfileSpec } from "../common/backend-profiles.js";
|
import { backendProfileSpec } from "../common/backend-profiles.js";
|
||||||
|
import { parseAipodSpecYaml } from "../common/aipod-specs.js";
|
||||||
import { dsflashGoModelCatalogJson } from "../common/model-catalogs.js";
|
import { dsflashGoModelCatalogJson } from "../common/model-catalogs.js";
|
||||||
|
|
||||||
export interface SelfTestContext {
|
export interface SelfTestContext {
|
||||||
@@ -133,6 +134,12 @@ export function profileSecretHome(context: Pick<SelfTestContext, "codexHome"> &
|
|||||||
return context.codexHome;
|
return context.codexHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function loadArtificerImageRef(root: string): Promise<AipodImageRef> {
|
||||||
|
const text = await readFile(path.join(root, "config", "aipods", "artificer.yaml"), "utf8");
|
||||||
|
const spec = parseAipodSpecYaml(text, "selftest-artificer-image-ref");
|
||||||
|
return spec.spec.imageRef;
|
||||||
|
}
|
||||||
|
|
||||||
function defaultFakeCommand(): string {
|
function defaultFakeCommand(): string {
|
||||||
return process.versions.bun ? process.execPath : "npx";
|
return process.versions.bun ? process.execPath : "npx";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user