Skip to content

Commit

Permalink
Change username to userId
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Reid <tyler.reid@grafana.com>
  • Loading branch information
Tyler Reid committed May 27, 2021
1 parent b89016c commit 0da69c8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/distributor/ha_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ func TestHATracker_MetricsCleanup(t *testing.T) {
func TestCheckReplicaCleanup(t *testing.T) {
replica := "r1"
cluster := "c1"
userName := "user"
ctx := user.InjectOrgID(context.Background(), userName)
userId := "user"
ctx := user.InjectOrgID(context.Background(), userId)

reg := prometheus.NewPedanticRegistry()

Expand All @@ -680,32 +680,32 @@ func TestCheckReplicaCleanup(t *testing.T) {

now := time.Now()

err = c.checkReplica(context.Background(), userName, cluster, replica, now)
err = c.checkReplica(context.Background(), userId, cluster, replica, now)
assert.NoError(t, err)
checkReplicaTimestamp(t, time.Second, c, userName, cluster, replica, now)
checkReplicaTimestamp(t, time.Second, c, userId, cluster, replica, now)

// Replica is not marked for deletion yet.
checkReplicaDeletionState(t, time.Second, c, userName, cluster, true, true, false)
checkReplicaDeletionState(t, time.Second, c, userId, cluster, true, true, false)

// This will mark replica for deletion (with time.Now())
c.cleanupOldReplicas(ctx, now.Add(1*time.Second))

// Verify marking for deletion.
checkReplicaDeletionState(t, time.Second, c, userName, cluster, false, true, true)
checkReplicaDeletionState(t, time.Second, c, userId, cluster, false, true, true)

// This will "revive" the replica.
now = time.Now()
err = c.checkReplica(context.Background(), userName, cluster, replica, now)
err = c.checkReplica(context.Background(), userId, cluster, replica, now)
assert.NoError(t, err)
checkReplicaTimestamp(t, time.Second, c, userName, cluster, replica, now) // This also checks that entry is not marked for deletion.
checkReplicaTimestamp(t, time.Second, c, userId, cluster, replica, now) // This also checks that entry is not marked for deletion.

// This will mark replica for deletion again (with new time.Now())
c.cleanupOldReplicas(ctx, now.Add(1*time.Second))
checkReplicaDeletionState(t, time.Second, c, userName, cluster, false, true, true)
checkReplicaDeletionState(t, time.Second, c, userId, cluster, false, true, true)

// Delete entry marked for deletion completely.
c.cleanupOldReplicas(ctx, time.Now().Add(5*time.Second))
checkReplicaDeletionState(t, time.Second, c, userName, cluster, false, false, false)
checkReplicaDeletionState(t, time.Second, c, userId, cluster, false, false, false)

require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
# HELP cortex_ha_tracker_replicas_cleanup_marked_for_deletion_total Number of elected replicas marked for deletion.
Expand Down

0 comments on commit 0da69c8

Please sign in to comment.