Skip to content

Conversation

@joshua-adams-1
Copy link
Contributor

Adds serialization tests for MetricStatsTests and TierBalanceStatsTests

Related to #131025

Adds serialization tests for `ClusterBalanceStats.MetricStats` and
`ClusterBalanceStats.TierBalanceStats`
@joshua-adams-1 joshua-adams-1 requested a review from ywangd August 18, 2025 11:16
@joshua-adams-1 joshua-adams-1 added >non-issue :Distributed Coordination/Distributed A catch all label for anything in the Distributed Coordination area. Please avoid if you can. labels Aug 18, 2025
@joshua-adams-1 joshua-adams-1 marked this pull request as ready for review August 18, 2025 11:16
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination Meta label for Distributed Coordination team label Aug 18, 2025
@joshua-adams-1
Copy link
Contributor Author

I added these tests during #131025 but didn't commit them to avoid bloating the PR. Adding them now as they're useful

Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 47 to 52
double total = randomDouble();
double min = randomDouble();
double max = randomDouble();
double average = randomDouble();
double stdDev = randomDouble();
ClusterBalanceStats.MetricStats stats = new ClusterBalanceStats.MetricStats(total, min, max, average, stdDev);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think these can be replaced by calling createRandomMetricStats() and the later assertions can compare with stats.total() etc?

Comment on lines 55 to 66
ClusterBalanceStats.MetricStats shardCount = createRandomMetricStats();
ClusterBalanceStats.MetricStats undesiredShardAllocations = createRandomMetricStats();
ClusterBalanceStats.MetricStats forecastWriteLoad = createRandomMetricStats();
ClusterBalanceStats.MetricStats forecastDiskUsage = createRandomMetricStats();
ClusterBalanceStats.MetricStats actualDiskUsage = createRandomMetricStats();
ClusterBalanceStats.TierBalanceStats tierBalanceStats = new ClusterBalanceStats.TierBalanceStats(
shardCount,
undesiredShardAllocations,
forecastWriteLoad,
forecastDiskUsage,
actualDiskUsage
);
Copy link
Member

Choose a reason for hiding this comment

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

Similar nit: this can be replaced by createRandomTierBalanceStats()?

@joshua-adams-1 joshua-adams-1 merged commit e308abb into elastic:main Aug 22, 2025
33 checks passed
@joshua-adams-1 joshua-adams-1 deleted the cluster-balance-stats-tests branch August 22, 2025 09:17
pabloem pushed a commit to pabloem/elasticsearch that referenced this pull request Aug 22, 2025
Adds serialization tests for `ClusterBalanceStats.MetricStats` and
`ClusterBalanceStats.TierBalanceStats`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Distributed A catch all label for anything in the Distributed Coordination area. Please avoid if you can. >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants