-
Notifications
You must be signed in to change notification settings - Fork 89
Feat/test improvements #1579
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
base: main
Are you sure you want to change the base?
Feat/test improvements #1579
Conversation
- Use Turbo's --filter='...[origin/main]' to only run checks on packages that have changed since origin/main - Add fallback to run full check if origin/main doesn't exist (fresh clone) - Add documentation comments explaining the affected-only behavior This significantly speeds up pre-push validation when only a few packages are modified, targeting < 30 seconds with cache. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Document the setup command: npx turbo login && npx turbo link - Document expected behavior: FULL TURBO and cache hits - Document how to verify caching: pnpm turbo run build --summarize - Include CI/CD configuration for TURBO_TOKEN and TURBO_TEAM Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…asks - Add test:fast task with dependsOn=['build'], cache=true for fast unit tests - Add test:slow task with dependsOn=['build'], cache=true for database-backed tests - Add test:integration task with dependsOn=['build'], cache=false for integration tests This enables the test pyramid optimization by separating tests into tiers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add test:fast script: turbo test:fast - Add test:slow script: turbo test:slow - Add test:integration script: turbo test:integration Enables running different test tiers from root with pnpm test:fast/slow/integration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create agents-api/vitest.fast.config.ts based on existing config - Set include to ['**/*.test.ts', '**/*.test.tsx'] - Set exclude to include *.slow.test.ts and *.integration.test.ts - Set testTimeout to 5000ms (5 seconds) - Enable fileParallelism for parallel test execution - Add test:fast script to agents-api/package.json Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create agents-api/vitest.slow.config.ts for database-backed tests - Set include to ['**/*.slow.test.ts'] - Set testTimeout to 60000ms (60 seconds) - Keep setup files that initialize PGlite from original config - Add test:slow script to agents-api/package.json Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create packages/agents-core/vitest.fast.config.ts - Set include to ['**/*.test.ts', '**/*.test.tsx'] - Set exclude for *.slow.test.ts, *.integration.test.ts, and integration/ - Set testTimeout to 5000ms (5 seconds) - Add test:fast script to packages/agents-core/package.json Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create packages/agents-core/vitest.slow.config.ts - Set include to ['**/*.slow.test.ts'] - Set testTimeout to 60000ms (60 seconds) - Add test:slow script to packages/agents-core/package.json Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Modify check:prepush task to depend on test:fast instead of test - This makes pre-push checks faster by running only fast unit tests - Slow and integration tests still run in CI for full coverage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create SLOW_TESTS_TO_RENAME.md listing 35 test files that use database - Tests identified by searching for createTestClient and PGlite imports - Document reason for classification (PGlite setup, migrations, timeouts) - Include renaming instructions using git mv Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename 5 test files from *.test.ts to *.slow.test.ts: - agent.test.ts -> agent.slow.test.ts - agentFull.test.ts -> agentFull.slow.test.ts - apiKeys.test.ts -> apiKeys.slow.test.ts - artifactComponents.test.ts -> artifactComponents.slow.test.ts - contextConfigs.test.ts -> contextConfigs.slow.test.ts These tests use database operations and are now excluded from test:fast. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename 30 additional test files from *.test.ts to *.slow.test.ts: - CRUD route tests (credentialReferences, credentialStores, dataComponents, etc.) - Evaluation CRUD tests (datasets, evaluators, etc.) - Data layer tests (agentFull, artifactComponents, conversations, etc.) - Run domain tests (dataChat, delegationTaskCreation) Delete SLOW_TESTS_TO_RENAME.md as all tests are now renamed. Total: 35 tests moved to slow tier, significantly reducing test:fast time. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename 4 test files that use database operations to *.slow.test.ts: - cascading-delete.test.ts -> cascading-delete.slow.test.ts - projectLifecycle.test.ts -> projectLifecycle.slow.test.ts - projectMetadata.test.ts -> projectMetadata.slow.test.ts - client.test.ts -> client.slow.test.ts These tests use PGlite/createTestClient and are now categorized properly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add scripts/generate-test-db-snapshot.ts that creates pre-compiled PGlite
database snapshots with all migrations applied. This enables tests to skip
migration execution for faster initialization.
The script:
- Creates PGlite instances for both manage and runtime databases
- Applies all Drizzle migrations from packages/agents-core/drizzle/
- Exports database state using PGlite's dumpDataDir('gzip') method
- Saves snapshots to test-fixtures/ directory
Added `pnpm test:generate-snapshot` command to root package.json.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Modify test database client functions to automatically load pre-compiled snapshots when available, significantly speeding up test initialization. - Add snapshot loading support to createTestManageDatabaseClient - Add snapshot loading support to createTestRuntimeDatabaseClient - Add snapshot loading support to *NoMigrations variants - Update agents-api setup.ts to skip migrations when snapshots exist - Update agents-core setup.ts with improved logging - Add test-fixtures/ to .gitignore Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add step to generate PGlite database snapshots before running tests. This pre-compiles database migrations so tests don't need to run them individually, speeding up test initialization. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Document analysis of why agents-cli tests run sequentially: - Identified sequential execution settings in vitest.config.ts and vitest.config.ci.ts - Analyzed 38 test files to understand parallelization blockers - Identified key blockers: global mock pollution, file system race conditions, process state modifications, and child process execution - Documented which tests need sequential execution (command tests with heavy mocking) - Documented which tests could safely run in parallel (generator tests, pure utilities) - Provided recommendations for potential parallelization strategy Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Mark US-017 as complete with notes about findings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Created vitest.parallel.config.ts for agents-cli that enables parallel execution for tests identified as safe in US-017 analysis: - Generator tests (13 files) - pure code generation functions - Pure utility tests (package-manager, url, json-comparator, templates, ci-environment) - Component parser test Config enables fileParallelism=true, singleThread=false, maxConcurrency=8 for up to ~6x speedup on generator tests while keeping existing sequential config for tests with global mocks, file system operations, or process spawning. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ared setup - Parallelize entity creation in createMultipleAgents helpers using Promise.all - agent.slow.test.ts: Two-phase parallel creation (agents, then sub-agents) - subAgents.slow.test.ts: Direct parallel sub-agent creation - Add shared tenant/project setup using beforeAll in tools.slow.test.ts - Convert 3 "not found" tests to use shared tenant infrastructure - Add OPTIMIZATION comments documenting the changes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add conditional logic to run affected-only checks on pull_request events - Use Turbo's --filter='...[origin/main]' to detect affected packages - Full check suite still runs on push to main/master for complete validation - Fetch main branch for comparison when running affected-only checks - Add comments explaining the affected-only testing strategy Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Configure Vitest to output JUnit XML test reports with per-test timing data for identifying slow tests and tracking performance trends. - Add JUnit reporter to vitest.config.ci.ts with output to test-results/ - Add CI step to upload test-results directory as GitHub Actions artifact - Document how to access and analyze timing reports in AGENTS.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @amikofalvy's task —— View job TypeScript Staff Engineer & System Architect ReviewReviewing this comprehensive test infrastructure overhaul. This PR introduces significant changes to testing strategy, CI/CD, and build processes. Todo List:
Executive SummaryThis PR implements a sophisticated testing infrastructure overhaul with three key innovations:
While the technical execution is solid, there are several architectural concerns and potential risks that warrant attention before merging. 🔥 Critical Issues1. Database Snapshot Management & Race ConditionsLocation: Issue: The snapshot loading strategy has multiple concerning patterns: if (snapshotPath) {
const snapshotData = readFileSync(snapshotPath); // Synchronous file I/O
const blob = new Blob([snapshotData], { type: 'application/gzip' });
client = new PGlite({ loadDataDir: blob });
} else {
client = new PGlite();
// Falls back to migration
}Problems:
Recommendation: Implement snapshot versioning with checksums and async loading: // Add version checking
const snapshotVersion = await getSnapshotVersion(snapshotPath);
const currentSchemaVersion = await getCurrentSchemaVersion();
if (snapshotVersion !== currentSchemaVersion) {
// Regenerate or fall back to migrations
}2. Parallel Test Resource ManagementLocation: Issue: Both fast and slow configs use identical threading parameters: poolOptions: {
threads: {
maxThreads: 10,
minThreads: 4,
},
}Problems:
Recommendation: Differentiate resource allocation by test type: // Fast tests - CPU bound, low memory
maxThreads: 8, minThreads: 2
// Slow tests - I/O bound, higher memory
maxThreads: 4, minThreads: 1
|
No description provided.