(t *testing.T, duration time.Duration, c *HATracker, user, replicaGroup, replica string, expected time.Time)
| 37 | } |
| 38 | |
| 39 | func checkReplicaTimestamp(t *testing.T, duration time.Duration, c *HATracker, user, replicaGroup, replica string, expected time.Time) { |
| 40 | key := fmt.Sprintf("%s/%s", user, replicaGroup) |
| 41 | |
| 42 | // Round the expected timestamp with milliseconds precision |
| 43 | // to match "received at" precision |
| 44 | expected = expected.Truncate(time.Millisecond) |
| 45 | |
| 46 | test.Poll(t, duration, nil, func() any { |
| 47 | c.electedLock.RLock() |
| 48 | r := c.elected[key] |
| 49 | c.electedLock.RUnlock() |
| 50 | |
| 51 | if r.GetReplica() != replica { |
| 52 | return fmt.Errorf("replicas did not match: %s != %s", r.GetReplica(), replica) |
| 53 | } |
| 54 | if r.GetDeletedAt() > 0 { |
| 55 | return fmt.Errorf("replica is marked for deletion") |
| 56 | } |
| 57 | if !timestamp.Time(r.GetReceivedAt()).Equal(expected) { |
| 58 | return fmt.Errorf("timestamps did not match: %+v != %+v", timestamp.Time(r.GetReceivedAt()), expected) |
| 59 | } |
| 60 | |
| 61 | return nil |
| 62 | }) |
| 63 | } |
| 64 | |
| 65 | func TestHATrackerConfig_Validate(t *testing.T) { |
| 66 | t.Parallel() |
no test coverage detected