You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use enrollTestNode in the six integration specs and remove their duplicated CSR and enrollment code. Add ready: false for setups that previously enrolled without a heartbeat.
Why
Keeps fleet infrastructure imports inside the shared test helper while preserving node facts, tenant ownership and readiness.
How it was tested
The six specs pass on both unchanged main and this branch: 16 tests each, against disposable PostgreSQL 17.
pnpm lint, pnpm test, pnpm proto:lint and Prettier checks pass with Node 22.
Full pnpm test:integration: 348 passed, one password-authentication test failed because the disposable server used trust. After switching it to SCRAM authentication, all 20 tests in provision-runtime.integration.spec.ts passed. The full suite was not rerun after that environment correction.
Go unit tests and browser acceptance were not run for this test-only refactor.
Security considerations
Test setup only. Enrollment still uses real join tokens, CSRs and application services. No production code or contracts changed.
Summary by CodeRabbit
Tests
Standardized node setup across integration tests for application domains, confirmations, agent actions, deployment pipelines, and allocation observations.
Added coverage for nodes that have enrolled but have not yet sent an initial heartbeat, including deployment placement scenarios.
No actionable comments were generated in the recent review.
Walkthrough
Six API integration tests now use the shared enrollTestNode helper instead of creating certificate signing requests and enrolling nodes locally. The helper accepts an optional ready value and skips its first heartbeat when that value is false.
shipkeepdev/shipkeep#318: Its placement-concurrency integration test uses the shared enrollTestNode helper introduced here.
Merge Risk: Minimal · up to 828dc
This is a test-only refactor with no production behavior change. The remaining risk is small: the full integration suite was not rerun after the environment fix.
Security architecture risk: Minimal · up to 828dc
This is a test-setup refactor. Enrollment keeps the same organization scope, join-token authority, and certificate requests. Tests that previously sent a heartbeat still do; those that did not explicitly skip it.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "test(api): reuse node enrollment helper" matches the main change. The PR replaces duplicated CSR creation and node-enrollment setup in six API integration specs with the shared enrollTestNo…
Linked Issues check
[#295] Requirement: add a shared helper in apps/api/src/testing/ that issues a join token, builds the CSR, enrolls the node, and returns its ID; use it in the six listed specs and remove their direct …
Out of Scope Changes check
The PR summary lists changes only in apps/api/src/testing/enroll-test-node.ts and the six named integration specs. The helper change adds an optional ready flag and documents the skipped heartbeat. Th…
Full details: Title check
Explanation
The title "test(api): reuse node enrollment helper" matches the main change. The PR replaces duplicated CSR creation and node-enrollment setup in six API integration specs with the shared enrollTestNode helper. The helper gains an optional ready flag, which the title does not mention, but that detail is secondary. The title is short, specific, and follows the conventional-commit style.
Full details: Linked Issues check
Explanation
[#295] Requirement: add a shared helper in apps/api/src/testing/ that issues a join token, builds the CSR, enrolls the node, and returns its ID; use it in the six listed specs and remove their direct fleet/infrastructure imports. Evidence at head: apps/api/src/testing/enroll-test-node.ts exists and performs IssueJoinToken, agentCsr() and EnrollNode, then returns nodeId. The helper's fleet/infrastructure/ca/x509 import is in src/testing/, which the issue allows. deployment-pipeline.integration.spec.ts and pipeline-store.integration.spec.ts at head import enrollTestNode from ../../testing/enroll-test-node and no longer import fleet/infrastructure. The PR summary reports the same for the other four specs; I did not read those four files. The ready flag preserves the old no-heartbeat setups (pipeline-store uses ready: false; the helper skips the heartbeat when ready is false). Unresolved: the acceptance criterion 'pnpm test:integration passes with the same number of tests' is supported only by author-reported results. The full suite was not rerun after the environment correction (SCRAM authentication). The one failure was attributed to the disposable server's trust authentication, not to this change.
Full details: Out of Scope Changes check
Explanation
The PR summary lists changes only in apps/api/src/testing/enroll-test-node.ts and the six named integration specs. The helper change adds an optional ready flag and documents the skipped heartbeat. This supports the issue's requirement for the shared helper and the ready: false setups. No production code, contracts, or fleet tests are reported as changed. I could not run a whole-PR diff (the diff operation failed because changed blobs were unavailable), so the file list relies on the supplied summary. The file contents I read at head are consistent with that list.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint install timed out. The project may have too many dependencies for the sandbox.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Hi @iyuzhang, welcome to Shipkeep, and thank you for this contribution.
The change does what #295 asked for: the six specs no longer import fleet/infrastructure, behavior is preserved, and the affected specs pass on this branch. Thank you as well for stating clearly in the description what was run and what was not.
The CI and security workflows are now running. I will merge once they are green.
Feel free to pick up any other issue that interests you. The ones labelled good first issue are a good place to continue, and you are welcome to comment on any issue you would like to take.
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
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.
Task
Closes #295.
What changed
Use
enrollTestNodein the six integration specs and remove their duplicated CSR and enrollment code. Addready: falsefor setups that previously enrolled without a heartbeat.Why
Keeps fleet infrastructure imports inside the shared test helper while preserving node facts, tenant ownership and readiness.
How it was tested
pnpm lint,pnpm test,pnpm proto:lintand Prettier checks pass with Node 22.pnpm test:integration: 348 passed, one password-authentication test failed because the disposable server usedtrust. After switching it to SCRAM authentication, all 20 tests inprovision-runtime.integration.spec.tspassed. The full suite was not rerun after that environment correction.Security considerations
Test setup only. Enrollment still uses real join tokens, CSRs and application services. No production code or contracts changed.
Summary by CodeRabbit