@@ -24,6 +24,7 @@ import (
2424
2525 agonesv1 "agones.dev/agones/pkg/apis/agones/v1"
2626 autoscalingv1 "agones.dev/agones/pkg/apis/autoscaling/v1"
27+ "agones.dev/agones/pkg/util/runtime"
2728 e2e "agones.dev/agones/test/e2e/framework"
2829"github.com/pkg/errors"
2930"github.com/sirupsen/logrus"
@@ -60,7 +61,8 @@ func TestAutoscalerBasicFunctions(t *testing.T){
6061framework .AssertFleetCondition (t , flt , e2e .FleetReadyCount (flt .Spec .Replicas ))
6162
6263fleetautoscalers := framework .AgonesClient .AutoscalingV1 ().FleetAutoscalers (framework .Namespace )
63- fas , err := fleetautoscalers .Create (ctx , defaultFleetAutoscaler (flt , framework .Namespace ), metav1.CreateOptions {})
64+ defaultFas := defaultFleetAutoscaler (flt , framework .Namespace )
65+ fas , err := fleetautoscalers .Create (ctx , defaultFas , metav1.CreateOptions {})
6466if assert .Nil (t , err ){
6567defer fleetautoscalers .Delete (ctx , fas .ObjectMeta .Name , metav1.DeleteOptions {}) // nolint:errcheck
6668 } else {
@@ -69,6 +71,11 @@ func TestAutoscalerBasicFunctions(t *testing.T){
6971return
7072 }
7173
74+ // If the CustomFasSyncInterval feature flag is enabled, the value of fas.spec.sync are equal
75+ if runtime .FeatureEnabled (runtime .FeatureCustomFasSyncInterval ){
76+ assert .Equal (t , defaultFas .Spec .Sync .FixedInterval .Seconds , fas .Spec .Sync .FixedInterval .Seconds )
77+ }
78+
7279// the fleet autoscaler should scale the fleet up now up to BufferSize
7380bufferSize := int32 (fas .Spec .Policy .Buffer .BufferSize .IntValue ())
7481framework .AssertFleetCondition (t , flt , e2e .FleetReadyCount (bufferSize ))
@@ -132,6 +139,54 @@ func TestAutoscalerBasicFunctions(t *testing.T){
132139 })
133140}
134141
142+ func TestFleetAutoscalerDefaultSyncInterval (t * testing.T ){
143+ t .Parallel ()
144+ ctx := context .Background ()
145+
146+ stable := framework .AgonesClient .AgonesV1 ()
147+ fleets := stable .Fleets (framework .Namespace )
148+ flt , err := fleets .Create (ctx , defaultFleet (framework .Namespace ), metav1.CreateOptions {})
149+ if assert .Nil (t , err ){
150+ defer fleets .Delete (ctx , flt .ObjectMeta .Name , metav1.DeleteOptions {}) // nolint:errcheck
151+ }
152+
153+ framework .AssertFleetCondition (t , flt , e2e .FleetReadyCount (flt .Spec .Replicas ))
154+
155+ fleetautoscalers := framework .AgonesClient .AutoscalingV1 ().FleetAutoscalers (framework .Namespace )
156+ dummyFleetName := "dummy-fleet"
157+ defaultFas := & autoscalingv1.FleetAutoscaler {
158+ ObjectMeta : metav1.ObjectMeta {
159+ Name : dummyFleetName + "-autoscaler" ,
160+ Namespace : framework .Namespace ,
161+ },
162+ Spec : autoscalingv1.FleetAutoscalerSpec {
163+ FleetName : dummyFleetName ,
164+ Policy : autoscalingv1.FleetAutoscalerPolicy {
165+ Type : autoscalingv1 .BufferPolicyType ,
166+ Buffer : & autoscalingv1.BufferPolicy {
167+ BufferSize : intstr .FromInt (3 ),
168+ MaxReplicas : 10 ,
169+ },
170+ },
171+ },
172+ }
173+ fas , err := fleetautoscalers .Create (ctx , defaultFas , metav1.CreateOptions {})
174+ if assert .Nil (t , err ){
175+ defer fleetautoscalers .Delete (ctx , fas .ObjectMeta .Name , metav1.DeleteOptions {}) // nolint:errcheck
176+ } else {
177+ // if we could not create the autoscaler, their is no point going further
178+ logrus .Error ("Failed creating autoscaler, aborting TestFleetAutoscalerDefaultSyncInterval" )
179+ return
180+ }
181+
182+ // If the CustomFasSyncInterval feature flag is enabled, fas.spec.sync should be set to its default value
183+ if runtime .FeatureEnabled (runtime .FeatureCustomFasSyncInterval ){
184+ defaultSyncIntervalFas := & autoscalingv1.FleetAutoscaler {}
185+ defaultSyncIntervalFas .ApplyDefaults ()
186+ assert .Equal (t , defaultSyncIntervalFas .Spec .Sync .FixedInterval .Seconds , fas .Spec .Sync .FixedInterval .Seconds )
187+ }
188+ }
189+
135190// TestFleetAutoScalerRollingUpdate - test fleet with RollingUpdate strategy work with
136191// FleetAutoscaler, verify that number of GameServers does not goes down below RollingUpdate strategy
137192// defined level on Fleet updates.
0 commit comments