@@ -796,7 +796,8 @@ func TestStoreGateway_syncStoresShouldWaitRingStability(t *testing.T) {
796
796
}))
797
797
798
798
syncCtx , cancelCtx := context .WithTimeout (ctx , 3 * time .Second )
799
- g .syncStores (syncCtx , "test" , true )
799
+ ringState , _ := g .ring .GetAllHealthy (BlocksOwnerSync )
800
+ g .syncStores (syncCtx , ringState , "test" )
800
801
cancelCtx ()
801
802
802
803
// No blocks should be synced
@@ -806,63 +807,6 @@ func TestStoreGateway_syncStoresShouldWaitRingStability(t *testing.T) {
806
807
assert .Equal (t , float64 (0 ), metrics .GetSumOfGauges ("cortex_bucket_store_blocks_loaded" ))
807
808
}
808
809
809
- func TestStoreGateway_PeriodicSyncShouldNotUpdateUserList (t * testing.T ) {
810
- registeredAt := time .Now ()
811
- bucketClient , storageDir := cortex_testutil .PrepareFilesystemBucket (t )
812
-
813
- // This tests uses real TSDB blocks. 24h time range, 2h block range period
814
- now := time .Now ()
815
- mockTSDB (t , path .Join (storageDir , "user-1" ), 1 , 12 , now .Add (- 24 * time .Hour ).Unix ()* 1000 , now .Unix ()* 1000 )
816
-
817
- ctx := context .Background ()
818
- gatewayCfg := mockGatewayConfig ()
819
- gatewayCfg .ShardingEnabled = true
820
- gatewayCfg .ShardingRing .RingCheckPeriod = time .Hour // Do not trigger the ring change sync in this test.
821
-
822
- storageCfg := mockStorageConfig (t )
823
- storageCfg .BucketStore .SyncInterval = 100 * time .Millisecond
824
-
825
- reg := prometheus .NewPedanticRegistry ()
826
- ringStore , closer := consul .NewInMemoryClient (ring .GetCodec (), log .NewNopLogger (), nil )
827
- t .Cleanup (func () { assert .NoError (t , closer .Close ()) })
828
-
829
- g , err := newStoreGateway (gatewayCfg , storageCfg , bucketClient , ringStore , defaultLimitsOverrides (t ), mockLoggingLevel (), log .NewNopLogger (), reg )
830
- require .NoError (t , err )
831
-
832
- require .NoError (t , ringStore .CAS (ctx , RingKey , func (in interface {}) (interface {}, bool , error ) {
833
- ringDesc := ring .GetOrCreateRingDesc (in )
834
- ringDesc .AddIngester ("instance-1" , "127.0.0.1" , "" , ring.Tokens {1 , 2 , 3 }, ring .ACTIVE , registeredAt )
835
- return ringDesc , true , nil
836
- }))
837
-
838
- require .NoError (t , services .StartAndAwaitRunning (ctx , g ))
839
- defer services .StopAndAwaitTerminated (ctx , g ) //nolint:errcheck
840
-
841
- // Assert on the initial state.
842
- regs := util .NewUserRegistries ()
843
- regs .AddUserRegistry ("test" , reg )
844
- metrics := regs .BuildMetricFamiliesPerUser ()
845
- assert .Equal (t , float64 (12 ), metrics .GetSumOfGauges ("cortex_bucket_store_blocks_loaded" ))
846
-
847
- // Add more blocks, and extra user
848
- mockTSDB (t , path .Join (storageDir , "user-1" ), 1 , 3 , now .Unix ()* 1000 , now .Add (6 * time .Hour ).Unix ()* 1000 )
849
- mockTSDB (t , path .Join (storageDir , "user-2" ), 1 , 3 , now .Unix ()* 1000 , now .Add (6 * time .Hour ).Unix ()* 1000 )
850
-
851
- // Verify only user-1 blocks are synced
852
- time .Sleep (time .Second )
853
- metrics = regs .BuildMetricFamiliesPerUser ()
854
- assert .Equal (t , float64 (12 + 3 ), metrics .GetSumOfGauges ("cortex_bucket_store_blocks_loaded" ))
855
-
856
- // Force update user list
857
- g .syncStores (ctx , "test" , true )
858
- g .waitRingStability (ctx , "test" )
859
-
860
- // Verify user-2 blocks are also synced
861
- time .Sleep (time .Second )
862
- metrics = regs .BuildMetricFamiliesPerUser ()
863
- assert .Equal (t , float64 (12 + 3 + 3 ), metrics .GetSumOfGauges ("cortex_bucket_store_blocks_loaded" ))
864
- }
865
-
866
810
func TestStoreGateway_RingLifecyclerShouldAutoForgetUnhealthyInstances (t * testing.T ) {
867
811
const unhealthyInstanceID = "unhealthy-id"
868
812
const heartbeatTimeout = time .Minute
0 commit comments