From 19857693ba5450a3589bd3f5f8a2aeecbdda85a7 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Sat, 8 Feb 2025 18:46:58 +0100 Subject: [PATCH] add comments Signed-off-by: Tim Vaillancourt --- go/vt/vtorc/logic/tablet_discovery_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/go/vt/vtorc/logic/tablet_discovery_test.go b/go/vt/vtorc/logic/tablet_discovery_test.go index d17662cf26a..13374b54627 100644 --- a/go/vt/vtorc/logic/tablet_discovery_test.go +++ b/go/vt/vtorc/logic/tablet_discovery_test.go @@ -821,35 +821,39 @@ func TestSetReplicationSource(t *testing.T) { } func TestGetAllTablets(t *testing.T) { - factory := faketopo.NewFakeTopoFactory() - tablet := &topodatapb.Tablet{ Hostname: t.Name(), } tabletProto, _ := tablet.MarshalVT() + factory := faketopo.NewFakeTopoFactory() + + // zone1 (success) goodCell1 := faketopo.NewFakeConnection() goodCell1.AddListResult("tablets", []topo.KVInfo{ { - Key: []byte("hello"), + Key: []byte("zone1-00000001"), Value: tabletProto, }, }) factory.SetCell("zone1", goodCell1) + // zone2 (success) goodCell2 := faketopo.NewFakeConnection() goodCell2.AddListResult("tablets", []topo.KVInfo{ { - Key: []byte("hello"), + Key: []byte("zone2-00000002"), Value: tabletProto, }, }) factory.SetCell("zone2", goodCell2) + // zone3 (fail) badCell1 := faketopo.NewFakeConnection() badCell1.AddListError(true) factory.SetCell("zone3", badCell1) + // zone4 (fail) badCell2 := faketopo.NewFakeConnection() badCell2.AddListError(true) factory.SetCell("zone4", badCell2) @@ -861,10 +865,10 @@ func TestGetAllTablets(t *testing.T) { ctx := context.Background() ts = faketopo.NewFakeTopoServer(ctx, factory) + // confirm zone1 + zone2 succeeded and zone3 + zone4 failed tabletsByCell, failedCells := getAllTablets(ctx, []string{"zone1", "zone2", "zone3", "zone4"}) require.Len(t, tabletsByCell, 2) require.Equal(t, []string{"zone3", "zone4"}, failedCells) - for _, tablets := range tabletsByCell { require.Len(t, tablets, 1) for _, tablet := range tablets {