tests: Add Fleet and FleetAutoscaler tests - #27
Conversation
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
|
oh fun more conflicts ohno 😄 |
|
@markmandel I resolved the conflict , will appreciate a re-reviw!! |
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
…ASHWANIYADAV/headlamp-plugin into fix/fleet-autoscaler-tests
|
@lacroixthomas you got eyes on this one? I merged a stack of stuff today, but didn't want to step on your reviews. |
LGTM ! 👍🏼 |
|
Testing Copilot as a reviewer - I'm curious.... |
There was a problem hiding this comment.
Pull request overview
This PR adds Vitest unit coverage for the Agones Fleet and FleetAutoscaler resource models in the Headlamp plugin, expanding the existing resource-model test suite.
Changes:
- Added a new
Fleetunit test suite covering core getters and newer fields (allocationOverflow/priorities/counters/lists). - Added a new
FleetAutoscalerunit test suite covering core getters plus shape coverage for additional policy variants (Schedule/Wasm/Chain). - Updated the
AgonesFleetAutoscalerTypeScript interface (notably the Wasm policy schema and theschedule.betweenshape).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/resources/fleetautoscaler.ts |
Updates the FleetAutoscaler interface shape (Wasm policy and schedule typing) to support additional fields referenced by tests/upstream. |
src/resources/fleetautoscaler.test.ts |
Introduces a FleetAutoscaler unit test suite validating static fields and key getters, plus policy shape coverage. |
src/resources/fleet.test.ts |
Introduces a Fleet unit test suite validating static fields and key getters, including newer scheduling/allocation-related fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * WebAssembly-based autoscaling policy. | ||
| * | ||
| * @see {@link https://agones.dev/site/docs/advanced/scheduling-and-autoscaling/#custom-autoscaler-with-wasm | Wasm Autoscaler} | ||
| * @see {@link https://agones.dev/site/docs/reference/fleetautoscaler/#wasm-autoscaling | Wasm Autoscaler} | ||
| */ | ||
| wasm?: { | ||
| url: string; | ||
| requestsPerSecond?: number; | ||
| /** Exported function to call in the wasm module, defaults to 'scale'. */ | ||
| function?: string; | ||
| /** Config values to pass to the wasm program on startup. */ | ||
| config?: Record<string, string>; | ||
| /** Source of the Wasm module. */ | ||
| from: { | ||
| url?: { | ||
| url?: string; | ||
| service?: { | ||
| name: string; | ||
| namespace: string; | ||
| path?: string; | ||
| port?: number; | ||
| }; | ||
| caBundle?: string; | ||
| }; | ||
| }; | ||
| /** Hex-encoded SHA-256 hash for integrity verification. */ | ||
| hash?: string; | ||
| }; | ||
| schedule?: { | ||
| between?: { | ||
| start: string; | ||
| end: string; | ||
| minReplicas: number; | ||
| maxReplicas: number; | ||
| }; |
There was a problem hiding this comment.
This seems fine - we talked about it above.
Type of change
What this PR does
Adds comprehensive unit tests for the
FleetandFleetAutoscalerresource models using the Vitest infrastructure introduced in #26.Fleet tests (30 tests):
scheduling,desiredReplicas,currentReplicas,allocatedReplicas,readyReplicas,reservedReplicas,strategy,maxSurge,maxUnavailable,allocationOverflow,priorities,counters,lists.FleetAutoscaler tests (34 tests):
fleetName,policyType,bufferSize,minReplicas,maxReplicas,currentReplicas,desiredReplicas,ableToScale,scalingLimited,lastScaleTime,lastAppliedPolicy,syncInterval.Did you use AI tools in preparing this PR?:
Y
Test plan
Automated checks
npm cinpm run buildnpm run tscnpm run lintnpm run format -- --checknpm run testAll 121 tests pass across 5 test files (GameServer 29, Fleet 30, FleetAutoscaler 34, StateChip 13, buildAllocationBody 15).
Manual verification
N/A - unit tests only.
Notes for reviewers
All test data structures are verified against the upstream Agones Go structs (
fleet.go,fleetautoscaler.goinagones-upstream/pkg/apis/agones/v1/).