@@ -367,6 +367,34 @@ func TestScaleUpCausedByShardToNodeRatioExceeded(t *testing.T) {
367367 require .Equal (t , UP , actual .ScalingDirection , actual .Description )
368368}
369369
370+ func TestEnsureMinMaxBoundsAppliedWhenScalingHintNoneAndNothingToDo (t * testing.T ) {
371+ edS := edsTestFixture (4 )
372+ edS .Spec .Scaling .MinReplicas = 6
373+ edS .Spec .Scaling .MaxReplicas = 6
374+ // allow 0 replicas to not trigger index-replica reconciliation
375+ edS .Spec .Scaling .MinIndexReplicas = 0
376+
377+ esNodes := make ([]ESNode , 0 )
378+ esIndices := map [string ]ESIndex {
379+ "ad1" : {Replicas : 0 , Primaries : 4 , Index : "ad1" },
380+ }
381+
382+ scalingHint := NONE
383+
384+ // with the given input:
385+ // - shard-to-node ratio is 4/4=1, which doesn't violate maxShardsPerNode
386+ // - index replicas are within configured bounds
387+ // - no scaling hint
388+ // this would be a noop operation but we still want
389+ // replica bounds (min/max replicas) to be enforced.
390+ as := systemUnderTest (edS , nil , nil )
391+ actual := as .calculateScalingOperation (esIndices , esNodes , scalingHint )
392+
393+ require .NotNil (t , actual .NodeReplicas )
394+ require .Equal (t , int32 (6 ), * actual .NodeReplicas )
395+ require .Equal (t , UP , actual .ScalingDirection )
396+ }
397+
370398func TestScaleUpCausedByShardToNodeRatioLessThanOne (t * testing.T ) {
371399 eds := edsTestFixture (11 )
372400 esNodes := make ([]ESNode , 0 )
0 commit comments