| index 939808128..cfbf69658 100644 |
| --- a/internal/steering/g3_test.go |
| +++ b/internal/steering/g3_test.go |
| @@ -85,7 +85,7 @@ func TestG3RegionWinner(t *testing.T) { |
| t.Fatalf("winner=%s record=%v", winner, rr) |
| } |
| } |
| - if strings.Count(log.String(), "ERROR steering: dropped duplicate region target") != 2 { |
| + if strings.Count(log.String(), "ERROR steering: dropped duplicate region target") != 1 || !strings.Contains(log.String(), "name_count=2") { |
| t.Fatalf("log=%s", log) |
| } |
| }) |
| @@ -155,7 +155,7 @@ func TestG3RegionWinnerPreservesReplicaHome(t *testing.T) { |
| if !foundHome { |
| t.Fatal("home record was deleted") |
| } |
| - if strings.Count(log.String(), "dropped duplicate region target") != 1 || !strings.Contains(log.String(), "name=edge.example.com.") { |
| + if strings.Count(log.String(), "dropped duplicate region target") != 1 || !strings.Contains(log.String(), "examples=[edge.example.com.]") { |
| t.Fatalf("log=%s", log) |
| } |
| writes := f.writes() |
| @@ -317,3 +317,38 @@ func TestG3UncertainWriteAndCleanupReadFailure(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +func TestG3RegionDropLogSummary(t *testing.T) { |
| + f := newFake() |
| + var routes []registry.Route |
| + for i := range 134 { |
| + routes = append(routes, steeredRoute(fmt.Sprintf("h%03d.example.com", i))) |
| + } |
| + var bodies [][]byte |
| + for _, region := range []string{"us-east-1", "eu-west-1"} { |
| + for i, box := range []string{"a", "b", "c"} { |
| + bodies = append(bodies, []byte(fmt.Sprintf(`{"v":1,"box":%q,"eip":"192.0.2.%d","region":%q,"serves_shared_pool":true}`, box+"-"+region, i+1, region))) |
| + } |
| + } |
| + log := captureLog(t) |
| + for range 2 { |
| + log.Reset() |
| + if err := ConvergeDeployment(t.Context(), f, testZone, routes, bodies, "example.com"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if strings.Count(log.String(), "ERROR steering: dropped duplicate region target") != 4 { |
| + t.Fatalf("want four region/winner/loser summaries, got %s", log) |
| + } |
| + for _, region := range []string{"us-east-1", "eu-west-1"} { |
| + for _, box := range []string{"b", "c"} { |
| + want := fmt.Sprintf("region=%s kept=a-%s dropped=%s-%s name_count=135 examples=\"[edge.example.com. h000.example.com. h001.example.com.]\"", region, region, box, region) |
| + if strings.Count(log.String(), want) != 1 { |
| + t.Fatalf("missing summary %q: %s", want, log) |
| + } |
| + } |
| + } |
| + if len(f.records) != 270 { |
| + t.Fatalf("records=%d, want one per name and region", len(f.records)) |
| + } |
| + } |
| +} |