diff --git a/go/vt/discovery/healthcheck_test.go b/go/vt/discovery/healthcheck_test.go index fd8f9910fcd..4e636f895b6 100644 --- a/go/vt/discovery/healthcheck_test.go +++ b/go/vt/discovery/healthcheck_test.go @@ -64,13 +64,11 @@ func init() { } func TestHealthCheckRace(t *testing.T) { - ctx := utils.LeakCheckContext(t) - // reset error counters hcErrorCounters.ResetAll() - ts := memorytopo.NewServer(ctx, "cell") + ts := memorytopo.NewServer("cell") defer ts.Close() - hc := createTestHc(ctx, ts) + hc := createTestHc(ts) // close healthcheck defer hc.Close() tablet := createTestTablet(0, "cell", "a") @@ -82,14 +80,17 @@ func TestHealthCheckRace(t *testing.T) { Target: target, Serving: true, - PrimaryTermStartTimestamp: 0, - RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 1, CpuUsage: 0.5}, + TabletExternallyReparentedTimestamp: 0, + RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 1, CpuUsage: 0.5}, } input := make(chan *querypb.StreamHealthResponse) fc := createFakeConn(tablet, input) fc.errCh = make(chan error) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go func() { ticker := time.NewTicker(10 * time.Millisecond) defer ticker.Stop() @@ -120,7 +121,7 @@ func TestHealthCheckRace(t *testing.T) { case <-ctx.Done(): return case <-ticker.C: - conn, err := hc.TabletConnection(context.Background(), tablet.Alias, target) + conn, err := hc.TabletConnection(tablet.Alias, target) assert.NoError(t, err) assert.NotNil(t, conn) @@ -858,13 +859,11 @@ func TestRemoveTablet(t *testing.T) { // During this time, operations like `RemoveTablet` should not lead // to multiple tablets becoming valid targets for `PRIMARY`. func TestRemoveTabletDuringExternalReparenting(t *testing.T) { - ctx := utils.LeakCheckContext(t) - // reset error counters hcErrorCounters.ResetAll() - ts := memorytopo.NewServer(ctx, "cell") + ts := memorytopo.NewServer("cell") defer ts.Close() - hc := createTestHc(ctx, ts) + hc := createTestHc(ts) // close healthcheck defer hc.Close() @@ -905,8 +904,8 @@ func TestRemoveTabletDuringExternalReparenting(t *testing.T) { Target: &querypb.Target{Keyspace: "k", Shard: "s", TabletType: topodatapb.TabletType_PRIMARY}, Serving: true, - PrimaryTermStartTimestamp: firstTabletPrimaryTermStartTimestamp, - RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 0, CpuUsage: 0.5}, + TabletExternallyReparentedTimestamp: firstTabletPrimaryTermStartTimestamp, + RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 0, CpuUsage: 0.5}, } secondTabletHealthStream <- &querypb.StreamHealthResponse{ @@ -914,8 +913,8 @@ func TestRemoveTabletDuringExternalReparenting(t *testing.T) { Target: &querypb.Target{Keyspace: "k", Shard: "s", TabletType: topodatapb.TabletType_REPLICA}, Serving: true, - PrimaryTermStartTimestamp: 0, - RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 1, CpuUsage: 0.5}, + TabletExternallyReparentedTimestamp: 0, + RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 1, CpuUsage: 0.5}, } thirdTabletHealthStream <- &querypb.StreamHealthResponse{ @@ -923,8 +922,8 @@ func TestRemoveTabletDuringExternalReparenting(t *testing.T) { Target: &querypb.Target{Keyspace: "k", Shard: "s", TabletType: topodatapb.TabletType_REPLICA}, Serving: true, - PrimaryTermStartTimestamp: 0, - RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 1, CpuUsage: 0.5}, + TabletExternallyReparentedTimestamp: 0, + RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 1, CpuUsage: 0.5}, } <-resultChan @@ -939,8 +938,8 @@ func TestRemoveTabletDuringExternalReparenting(t *testing.T) { Target: &querypb.Target{Keyspace: "k", Shard: "s", TabletType: topodatapb.TabletType_PRIMARY}, Serving: true, - PrimaryTermStartTimestamp: firstTabletPrimaryTermStartTimestamp, - RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 0, CpuUsage: 0.5}, + TabletExternallyReparentedTimestamp: firstTabletPrimaryTermStartTimestamp, + RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 0, CpuUsage: 0.5}, } secondTabletHealthStream <- &querypb.StreamHealthResponse{ @@ -948,8 +947,8 @@ func TestRemoveTabletDuringExternalReparenting(t *testing.T) { Target: &querypb.Target{Keyspace: "k", Shard: "s", TabletType: topodatapb.TabletType_PRIMARY}, Serving: true, - PrimaryTermStartTimestamp: secondTabletPrimaryTermStartTimestamp, - RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 0, CpuUsage: 0.5}, + TabletExternallyReparentedTimestamp: secondTabletPrimaryTermStartTimestamp, + RealtimeStats: &querypb.RealtimeStats{ReplicationLagSeconds: 0, CpuUsage: 0.5}, } <-resultChan