Skip to content

tests: Add Fleet and FleetAutoscaler tests - #27

Merged
lacroixthomas merged 12 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:fix/fleet-autoscaler-tests
Aug 2, 2026
Merged

tests: Add Fleet and FleetAutoscaler tests#27
lacroixthomas merged 12 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:fix/fleet-autoscaler-tests

Conversation

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor

Draft — depends on #25 and #26. Will be marked ready for review after those PRs merge and this branch is rebased.

Type of change

  • 🐛 Bug fix
  • 🚀 New feature / enhancement
  • 📖 Documentation
  • 🧹 Refactoring / cleanup
  • ⚙️ CI / tooling
  • ⚠️ Breaking change

What this PR does

Adds comprehensive unit tests for the Fleet and FleetAutoscaler resource 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.
  • All policy types covered: Buffer, Webhook, Counter, List, Schedule (between + activePeriod), Wasm, Chain.

Did you use AI tools in preparing this PR?:
Y

Test plan

Automated checks

  • npm ci
  • npm run build
  • npm run tsc
  • npm run lint
  • npm run format -- --check
  • npm run test

All 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.go in agones-upstream/pkg/apis/agones/v1/).

Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
@NAME-ASHWANIYADAV
NAME-ASHWANIYADAV marked this pull request as draft June 23, 2026 23:18
@markmandel

Copy link
Copy Markdown
Member

oh fun more conflicts ohno 😄

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

@markmandel I resolved the conflict , will appreciate a re-reviw!!

@NAME-ASHWANIYADAV
NAME-ASHWANIYADAV marked this pull request as ready for review July 16, 2026 21:13
Comment thread src/resources/fleetautoscaler.test.ts Outdated
Comment thread src/resources/fleetautoscaler.test.ts Outdated
@markmandel

Copy link
Copy Markdown
Member

@lacroixthomas you got eyes on this one? I merged a stack of stuff today, but didn't want to step on your reviews.

@lacroixthomas

Copy link
Copy Markdown
Contributor

@lacroixthomas you got eyes on this one? I merged a stack of stuff today, but didn't want to step on your reviews.

LGTM ! 👍🏼

@lacroixthomas
lacroixthomas enabled auto-merge (squash) August 2, 2026 22:30
@markmandel
markmandel requested a review from Copilot August 2, 2026 22:33
@markmandel

Copy link
Copy Markdown
Member

Testing Copilot as a reviewer - I'm curious....

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Fleet unit test suite covering core getters and newer fields (allocationOverflow/priorities/counters/lists).
  • Added a new FleetAutoscaler unit test suite covering core getters plus shape coverage for additional policy variants (Schedule/Wasm/Chain).
  • Updated the AgonesFleetAutoscaler TypeScript interface (notably the Wasm policy schema and the schedule.between shape).

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.

Comment on lines 50 to 80
/**
* 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;
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine - we talked about it above.

@lacroixthomas
lacroixthomas merged commit 435b12f into agones-dev:main Aug 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants