Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(e2e): r4-m5 restore both upload policy inputs exactly
Josué546cc8ef123a
diff --git a/tests/e2e/gfsUploadV2Runtime.read.test.ts b/tests/e2e/gfsUploadV2Runtime.read.test.tsindex 1e73bfae6..fa4ca15c5 100644--- a/tests/e2e/gfsUploadV2Runtime.read.test.ts+++ b/tests/e2e/gfsUploadV2Runtime.read.test.ts@@ -1,15 +1,17 @@import { beforeEach, describe, expect, it, vi } from 'vitest'-import { readGfsUploadProductMaxBytes } from './gfsUploadV2Runtime'+import { readGfsUploadProductMaxBytes, recoverGfsUploadProductMaxBytes } from './gfsUploadV2Runtime'-const { execFileMock, execFileSyncMock, kubectlContextMock } = vi.hoisted(() => ({+const { execFileMock, execFileSyncMock, kubectlContextMock, spawnMock } = vi.hoisted(() => ({execFileMock: vi.fn(),execFileSyncMock: vi.fn(),kubectlContextMock: vi.fn(() => 'clerum-test'),+ spawnMock: vi.fn(),}))vi.mock('node:child_process', () => ({execFile: execFileMock,execFileSync: execFileSyncMock,+ spawn: spawnMock,}))vi.mock('./gfsFixtureCore', async importOriginal => ({@@ -21,14 +23,18 @@ describe('readGfsUploadProductMaxBytes', () => {beforeEach(() => {execFileMock.mockReset()execFileSyncMock.mockReset()+ spawnMock.mockReset()kubectlContextMock.mockClear()execFileMock.mockImplementation((_file: unknown, args: unknown[], _options: unknown, callback: Function) => {const isJson = args.includes('-o') && args[args.indexOf('-o') + 1] === 'json'+ const isRecoveryMarker = args.includes('configmap/gfs-upload-product-limit-recovery')callback(null, {- stdout: isJson- ? JSON.stringify({ spec: { template: { spec: { containers: [{ env: [] }] } } } })- : '',+ stdout: isRecoveryMarker+ ? ''+ : isJson+ ? JSON.stringify({ spec: { template: { spec: { containers: [{ env: [] }] } } } })+ : '',stderr: '',})}@@ -44,4 +50,35 @@ describe('readGfsUploadProductMaxBytes', () => {expect.any(Function))})++ it('reports no interrupted transaction when the durable marker is absent', async () => {+ await expect(+ recoverGfsUploadProductMaxBytes({ uid: 'expected-uid', holder: 'expected-holder' })+ ).resolves.toBe(false)+ expect(execFileMock).toHaveBeenCalledWith(+ 'kubectl',+ expect.arrayContaining(['configmap/gfs-upload-product-limit-recovery', '--ignore-not-found']),+ expect.anything(),+ expect.any(Function)+ )+ })++ it('fails closed when the cluster recovery marker is not immutable', async () => {+ execFileMock.mockImplementationOnce(+ (_file: unknown, _args: unknown[], _options: unknown, callback: Function) => {+ callback(null, {+ stdout: JSON.stringify({+ metadata: { uid: 'marker-uid' },+ immutable: false,+ data: { 'transaction.json': '{}' },+ }),+ stderr: '',+ })+ }+ )++ await expect(+ recoverGfsUploadProductMaxBytes({ uid: 'expected-uid', holder: 'expected-holder' })+ ).rejects.toThrow('invalid GFS Upload v2 product-limit recovery ConfigMap shape')+ })})diff --git a/tests/e2e/gfsUploadV2Runtime.test.ts b/tests/e2e/gfsUploadV2Runtime.test.tsindex ae51dd237..70ffdf439 100644--- a/tests/e2e/gfsUploadV2Runtime.test.ts+++ b/tests/e2e/gfsUploadV2Runtime.test.ts@@ -1,6 +1,9 @@import { describe, expect, it } from 'vitest'import {+ buildGfsUploadProductMarkerDeleteRequest,buildGfsUploadProductMaxEnvArgs,+ buildGfsUploadProductMaxInputEnvArgs,+ parseGfsUploadProductMaxInputs,parseGfsUploadProductMaxState,parseRenderedGfsUploadProductMax,} from './gfsUploadV2Runtime'@@ -12,6 +15,101 @@ function renderedDeployment(env: unknown[]): string {}describe('GFS Upload v2 runtime product-limit helper', () => {+ it('deletes only the UID-bound recovery marker through the Kubernetes API', () => {+ const request = buildGfsUploadProductMarkerDeleteRequest('marker-uid')++ expect(request.args).toEqual([+ '-n',+ 'control-plane',+ 'delete',+ '--raw',+ '/api/v1/namespaces/control-plane/configmaps/gfs-upload-product-limit-recovery',+ '-f',+ '-',+ '--wait=true',+ ])+ expect(JSON.parse(request.input)).toEqual({+ apiVersion: 'v1',+ kind: 'DeleteOptions',+ preconditions: { uid: 'marker-uid' },+ })+ expect(() => buildGfsUploadProductMarkerDeleteRequest('')).toThrow('without a UID')+ })++ it('snapshots and restores canonical and alias inputs independently', () => {+ expect(parseGfsUploadProductMaxInputs(renderedDeployment([]))).toEqual({+ canonical: { kind: 'absent' },+ alias: { kind: 'absent' },+ })++ const canonicalOnly = parseGfsUploadProductMaxInputs(+ renderedDeployment([+ {+ name: 'CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES',+ value: '104857600',+ },+ ])+ )+ expect(canonicalOnly).toEqual({+ canonical: { kind: 'explicit', value: 104857600 },+ alias: { kind: 'absent' },+ })+ expect(buildGfsUploadProductMaxInputEnvArgs(canonicalOnly)).toEqual([+ 'CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES=104857600',+ 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES-',+ ])++ const aliasOnly = parseGfsUploadProductMaxInputs(+ renderedDeployment([+ { name: 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES', value: '104857600' },+ ])+ )+ expect(buildGfsUploadProductMaxInputEnvArgs(aliasOnly)).toEqual([+ 'CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES-',+ 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES=104857600',+ ])++ const matching = parseGfsUploadProductMaxInputs(+ renderedDeployment([+ {+ name: 'CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES',+ value: '104857600',+ },+ { name: 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES', value: '104857600' },+ ])+ )+ expect(buildGfsUploadProductMaxInputEnvArgs(matching)).toEqual([+ 'CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES=104857600',+ 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES=104857600',+ ])+ })++ it('fails before mutation for malformed, duplicated, or conflicting HCC inputs', () => {+ expect(() =>+ parseGfsUploadProductMaxInputs(+ renderedDeployment([+ { name: 'CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES', valueFrom: {} },+ ])+ )+ ).toThrow('invalid CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES')+ expect(() =>+ parseGfsUploadProductMaxInputs(+ renderedDeployment([+ { name: 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES', value: '100' },+ { name: 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES', value: '100' },+ ])+ )+ ).toThrow('duplicate authority')+ expect(() =>+ parseGfsUploadProductMaxInputs(+ renderedDeployment([+ { name: 'CONTEXT_MAPPER_GFSC_UPLOAD_PRODUCT_MAX_FILE_BYTES', value: '100' },+ { name: 'CONTEXT_MAPPER_GFSC_UPLOAD_MAX_FILE_BYTES', value: '300' },+ ])+ )+ ).toThrow('conflicting canonical and deprecated')+ })+it('round-trips an explicit baseline through set and restore command construction', () => {const baseline = parseGfsUploadProductMaxState(renderedDeployment([{ name: 'GFS_UPLOAD_PRODUCT_MAX_FILE_BYTES', value: '104857600' }])