@@ -440,54 +440,6 @@ func TestScaleToZero_Start(t *testing.T) {
440440
441441 wantErr : nil ,
442442 },
443- {
444- name : "cluster with scale to zero enabled and inactive cluster, hibernation error replica instance stops the process" ,
445- client : func (done chan struct {}) * mockClusterClient {
446- return & mockClusterClient {
447- getClusterFunc : func (ctx context.Context , forceUpdate bool ) (* cnpgv1.Cluster , error ) {
448- return & cnpgv1.Cluster {
449- Status : cnpgv1.ClusterStatus {
450- Phase : healthyClusterStatus ,
451- CurrentPrimary : "test-pod-1" ,
452- },
453- ObjectMeta : metav1.ObjectMeta {
454- Annotations : map [string ]string {
455- scaleToZeroEnabledAnnotation : "true" ,
456- inactivityMinutesAnnotation : "5" ,
457- },
458- },
459- }, nil
460- },
461- updateClusterFunc : func (ctx context.Context , cluster * cnpgv1.Cluster ) error {
462- defer func () { done <- struct {}{} }()
463- require .NotNil (t , cluster )
464- require .Equal (t , "on" , cluster .Annotations [hibernationAnnotation ])
465- return errReplicaInstance
466- },
467- getClusterScheduledBackupFunc : func (ctx context.Context ) (* cnpgv1.ScheduledBackup , error ) {
468- return nil , fmt .Errorf ("scheduledbackups.postgresql.cnpg.io \" test-cluster\" not found" )
469- },
470- }
471- },
472- querier : func (_ chan struct {}) * mockQuerier {
473- return & mockQuerier {
474- queryFunc : func (ctx context.Context , query string , args ... any ) (postgres.Row , error ) {
475- return & mockRow {
476- scanFn : func (dest ... any ) error {
477- require .Len (t , dest , 1 )
478- count , ok := dest [0 ].(* int )
479- require .True (t , ok )
480- * count = 0 // Simulate an inactive cluster
481- return nil
482- },
483- }, nil
484- },
485- }
486- },
487- lastActive : time .Now ().Add (- time .Minute * 10 ), // Simulate inactivity
488-
489- wantErr : nil ,
490- },
491443 {
492444 name : "cluster with scale to zero enabled, unable to check activity, error ignored" ,
493445 client : func (done chan struct {}) * mockClusterClient {
@@ -941,25 +893,6 @@ func Test_hibernate(t *testing.T) {
941893 },
942894 wantErr : errTest ,
943895 },
944- {
945- name : "updateCluster returns errReplicaInstance" ,
946- client : & mockClusterClient {
947- getClusterFunc : func (ctx context.Context , forceUpdate bool ) (* cnpgv1.Cluster , error ) {
948- return & cnpgv1.Cluster {
949- Status : cnpgv1.ClusterStatus {
950- Phase : healthyClusterStatus ,
951- },
952- ObjectMeta : metav1.ObjectMeta {
953- Annotations : map [string ]string {},
954- },
955- }, nil
956- },
957- updateClusterFunc : func (ctx context.Context , cluster * cnpgv1.Cluster ) error {
958- return errReplicaInstance
959- },
960- },
961- wantErr : errReplicaInstance ,
962- },
963896 }
964897
965898 for _ , tc := range tests {
0 commit comments