| index b7604c80c..5687b96e1 100644 |
| --- a/internal/release/rollback_test.go |
| +++ b/internal/release/rollback_test.go |
| @@ -85,6 +85,63 @@ func TestNotUpRollsTheWholeGroupBackAndRefusesEveryHost(t *testing.T) { |
| } |
| } |
| |
| +// Final review F4: a same-upstream route following ANOTHER channel is a |
| +// separate promotion. It is neither repointed nor refused with the bound |
| +// route's PromotedAt. |
| +func TestRollbackGroupLeavesAnotherChannelAlone(t *testing.T) { |
| + ctx, reg, s, pub, opt := startUnitFixture(t, "console.example.com") |
| + if err := reg.SetUnit("console.example.com", "console.service"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.SetUpstreams("console.example.com", "127.0.0.1:8090", "", ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.Upsert(registry.Route{Host: "zz-beta.example.com", Kind: "instance", App: "console", |
| + Channel: "beta", Addr: "127.0.0.1:8090"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := StageArtifact(opt, "bab", "new", "console", []byte("bad build")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := PointLive(opt, "zz-beta.example.com", "bab", "new", "console"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := processGroup(reg, mustRoute(t, reg, "console.example.com")); len(got) != 0 { |
| + t.Fatalf("group = %+v, want none: zz-beta follows another channel", got) |
| + } |
| + restart := func(h string) error { |
| + if h == "console.example.com" { |
| + return &UnitNotUpError{Unit: "console.service", Reason: "not ready after 30s"} |
| + } |
| + return nil |
| + } |
| + bake := t.TempDir() |
| + var out bytes.Buffer |
| + withCapturedStdout(t, &out, func() { |
| + if err := Pass(ctx, reg, s, pub, opt, restart, BakeDir(bake), WithRollbackRestart(func(string) error { return nil })); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + }) |
| + if v, _ := LiveVersion(opt, "zz-beta.example.com"); v != "new" { |
| + t.Fatalf("another channel's route was rolled back to %q", v) |
| + } |
| + if r, _ := ReadRefusal(bake, "zz-beta.example.com"); r != nil { |
| + t.Fatalf("another channel's route was refused with the bound route's promotion: %+v", r) |
| + } |
| + if r, _ := ReadRefusal(bake, "console.example.com"); r == nil { |
| + t.Fatal("the bound route has no refusal") |
| + } |
| +} |
| + |
| +func mustRoute(t *testing.T, reg *registry.Registry, host string) registry.Route { |
| + t.Helper() |
| + rt, err := reg.Get(host) |
| + if err != nil || rt == nil { |
| + t.Fatalf("get %s: %+v, %v", host, rt, err) |
| + } |
| + return *rt |
| +} |
| + |
| func TestRollbackGroupLeavesOtherUpstreamAlone(t *testing.T) { |
| ctx, reg, s, pub, opt := startUnitFixture(t, "console.example.com") |
| if err := reg.SetUnit("console.example.com", "console.service"); err != nil { |