| new file mode 100644 |
| index 000000000..811cda748 |
| --- /dev/null |
| +++ b/internal/console/hatransfers_test.go |
| @@ -0,0 +1,482 @@ |
| +package console |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "net/http" |
| + "net/http/httptest" |
| + "reflect" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/moves" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/seeds" |
| +) |
| + |
| +// Fixture edits preserve the record's other fields and its CAS. |
| +func haTransferEdit(t *testing.T, st release.Store, acct, app, host string, edit func(*provision.Record)) { |
| + t.Helper() |
| + rec, err := provision.GetRecord(context.Background(), st, acct, app, host) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + edit(rec) |
| + b, err := json.Marshal(rec) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + offlinePut(t, st, provision.RecordKey(acct, app, host), b) |
| +} |
| + |
| +type haTransferNoopStore struct { |
| + release.Store |
| + t *testing.T |
| + noops map[string]bool |
| +} |
| + |
| +func (s *haTransferNoopStore) Put(ctx context.Context, key string, b []byte, match string) (string, error) { |
| + if s.noops[key] { |
| + s.t.Errorf("placement attempted to rewrite a proven normalized no-op: %s", key) |
| + } |
| + return s.Store.Put(ctx, key, b, match) |
| +} |
| + |
| +func TestHAPlaceRegionsBeforeWrites(t *testing.T) { |
| + type record struct { |
| + region, kind string |
| + ha bool |
| + } |
| + for _, c := range []struct { |
| + name, target, block string |
| + active []string |
| + records []record |
| + }{ |
| + {"legacy active source", "fleet/pi", "ie", []string{"ie"}, []record{{"ie", "", false}}}, |
| + {"immutable switch off", "fleet/pi", "ie", nil, []record{{"", "", true}}}, |
| + {"fleet to HA home", "", "ie", []string{"ie"}, []record{{"fleet/pi", "", false}}}, |
| + {"empty HA home no-op", "", "", []string{"ie"}, []record{{"", "", true}}}, |
| + {"explicit HA home no-op", "", "", []string{"ie"}, []record{{"ie", "", true}}}, |
| + {"legacy explicit home no-op", "", "", []string{"ie"}, []record{{"ie", "", false}}}, |
| + {"same fleet HA no-op", "fleet/pi", "", nil, []record{{"fleet/pi", "", true}}}, |
| + {"HA fleet no-op plus legacy moving", "fleet/pi", "", []string{"ie"}, []record{{"fleet/pi", "", true}, {"uk", "", false}}}, |
| + {"HA home no-op plus legacy moving", "", "ie", []string{"ie"}, []record{{"ie", "", true}, {"uk", "", false}}}, |
| + {"static only out of HA", "fleet/pi", "", []string{"ie"}, []record{{"ie", "static", false}}}, |
| + {"static only into HA", "", "", []string{"ie"}, []record{{"fleet/pi", "static", false}}}, |
| + {"static HA source plus legacy data", "fleet/pi", "", []string{"ie"}, []record{{"ie", "static", false}, {"uk", "", false}}}, |
| + {"static plus blocked data", "fleet/pi", "ie", []string{"ie"}, []record{{"uk", "static", false}, {"ie", "", false}}}, |
| + {"immutable static", "fleet/pi", "ie", nil, []record{{"ie", "static", true}}}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + fx, token := placeSeedFixture(t, "code-ha-place") |
| + fx.srv.cfg.HomeRegion, fx.srv.cfg.HARegions = "ie", c.active |
| + noops := map[string]bool{} |
| + for i, r := range c.records { |
| + host := []string{"a.shop.example.com", "b.shop.example.com"}[i] |
| + rec := provision.Record{Schema: 1, Account: fx.sqid, App: "shop", Host: host, Slug: strings.Split(host, ".")[0], Region: r.region, Kind: r.kind, HA: r.ha, Channel: "stable", CreatedAt: time.Now().UTC()} |
| + if err := provision.CreateRecord(context.Background(), fx.rel, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if fx.srv.homeRegionIn(r.region) == c.target { |
| + noops[provision.RecordKey(fx.sqid, "shop", host)] = true |
| + } |
| + } |
| + before := bucketState(t, fx.rel) |
| + placement, err := fx.st.AppPlacement(OpsAccountID, "shop") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + reg, err := openRegistry(fx.srv.cfg.Registry) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + routes, err := reg.List() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + fx.srv.cfg.Releases = &haTransferNoopStore{Store: fx.rel, t: t, noops: noops} |
| + st := haTransferTrack(fx.srv) |
| + code, _, out := rawReq(t, http.MethodPost, placeURL(fx, "shop"), token, `{"target":"`+c.target+`"}`) |
| + if c.block != "" { |
| + if code != http.StatusConflict || errorText(out) != haMoveSentence(c.block) { |
| + t.Errorf("place = %d %s; want 409 naming %s", code, out, c.block) |
| + } |
| + haTransferUnchanged(t, st, before) |
| + if got, err := fx.st.AppPlacement(OpsAccountID, "shop"); err != nil || got != placement { |
| + t.Errorf("refusal changed placement: %q, %v", got, err) |
| + } |
| + if got, err := reg.List(); err != nil || !reflect.DeepEqual(got, routes) { |
| + t.Error("refusal changed registry routes") |
| + } |
| + return |
| + } |
| + if code != http.StatusOK { |
| + t.Fatalf("place = %d %s", code, out) |
| + } |
| + for i, r := range c.records { |
| + host := []string{"a.shop.example.com", "b.shop.example.com"}[i] |
| + got, err := provision.GetRecord(context.Background(), fx.rel, fx.sqid, "shop", host) |
| + want := c.target |
| + if noops[provision.RecordKey(fx.sqid, "shop", host)] { |
| + want = r.region // explicit home remains deliberately uncanonicalised |
| + } |
| + if err != nil || got.Region != want || got.HA != r.ha { |
| + t.Errorf("record = %+v, %v; want region %q HA %v", got, err, want, r.ha) |
| + } |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestHAPlaceLateHomeHARecordUsesCAS(t *testing.T) { |
| + fx, token := placeSeedFixture(t, "code-ha-place-late-home") |
| + fx.srv.cfg.HomeRegion = "ie" |
| + const known = "known.shop.example.com" |
| + putHARecord(t, fx.rel, fx.sqid, known, "") |
| + fx.srv.cfg.Releases = &createOnSecondListStore{Store: fx.rel, prefix: provision.RecordsPrefix(fx.sqid, "shop"), create: func(st release.Store) { |
| + // Its normalized region is home too, but the strict preflight did |
| + // not see it. Only the known record may bypass SetRecordRegion. |
| + putHARecord(t, st, fx.sqid, seedMoveHost, "ie") |
| + }} |
| + code, _, out := rawReq(t, http.MethodPost, placeURL(fx, "shop"), token, `{"target":""}`) |
| + if code != http.StatusConflict || errorText(out) != haMoveC1 { |
| + t.Fatalf("late HA home = %d %s", code, out) |
| + } |
| + for host, region := range map[string]string{known: "", seedMoveHost: "ie"} { |
| + got, err := provision.GetRecord(context.Background(), fx.rel, fx.sqid, "shop", host) |
| + if err != nil || got.Region != region || !got.HA { |
| + t.Fatalf("HA record changed: %+v, %v", got, err) |
| + } |
| + } |
| +} |
| + |
| +func TestHATransferStaticExemption(t *testing.T) { |
| + t.Run("exact predicate and ordering", func(t *testing.T) { |
| + s := &Server{cfg: Config{HomeRegion: "ie", HARegions: []string{"ie", "uk"}}} |
| + for _, c := range []struct { |
| + name, from, to, kind, want string |
| + ha bool |
| + }{ |
| + {"static source", "ie", "se", "static", "", false}, |
| + {"static destination", "se", "uk", "static", "", false}, |
| + {"static immutable", "", "uk", "static", "ie", true}, |
| + {"immutable before no-op", "ie", "", "static", "ie", true}, |
| + {"empty home equal", "", "ie", "", "", false}, |
| + {"explicit home equal", "ie", "", "", "", false}, |
| + {"active source before destination", "ie", "uk", "", "ie", false}, |
| + {"default kind", "se", "uk", "", "uk", false}, |
| + {"instance kind", "se", "uk", "instance", "uk", false}, |
| + {"sidecar is not static", "se", "uk", "sidecar", "uk", false}, |
| + {"unknown kind is not static", "se", "uk", "unknown", "uk", false}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + if got := s.haTransferRegion(&provision.Record{Region: c.from, Kind: c.kind, HA: c.ha}, c.to); got != c.want { |
| + t.Fatalf("blocked region = %q, want %q", got, c.want) |
| + } |
| + }) |
| + } |
| + }) |
| + for _, door := range []string{"offline start", "offline stage", "legacy", "phase 1"} { |
| + for _, c := range []struct { |
| + name, from, to string |
| + ha bool |
| + seed, runtime bool |
| + }{ |
| + {"static source", "ie", "uk", false, false, false}, |
| + {"static destination", "uk", "ie", false, false, false}, |
| + {"immutable static", "ie", "uk", true, false, false}, |
| + {"seed still refuses", "ie", "uk", false, true, false}, |
| + {"runtime still refuses", "ie", "uk", false, false, true}, |
| + } { |
| + t.Run(door+"/"+c.name, func(t *testing.T) { |
| + w := newOfflineWorldIn(t, "", c.from, oneEach...) |
| + haTransferEdit(t, w.fx.rel, "bab", "shop", offlineHost, func(rec *provision.Record) { |
| + rec.Kind, rec.HA = "static", c.ha |
| + if c.seed { |
| + rec.Kind = "instance" |
| + rec.Seed = &provision.SeedSource{Kind: seeds.KindImport, State: seeds.StateUploaded} |
| + } |
| + if c.runtime { |
| + rec.Kind = "instance" |
| + rec.Runtime = "rootfs-v1" |
| + } |
| + }) |
| + u := haTransferDoor(w, door) |
| + w.fx.srv.cfg.HARegions = []string{"ie"} |
| + code, _, out := rawReq(t, http.MethodPost, u, w.token, `{"region":"`+c.to+`"}`) |
| + switch { |
| + case c.seed: |
| + if code != http.StatusConflict || errorText(out) != provision.SeedMoveSentence(w.record().Seed.MoveBlock()) { |
| + t.Fatalf("seed rail = %d %s", code, out) |
| + } |
| + case c.runtime: |
| + if code != http.StatusConflict || !strings.Contains(errorText(out), "rootfs instance") { |
| + t.Fatalf("runtime rail = %d %s", code, out) |
| + } |
| + default: |
| + // All initiation families retain their existing kind gate. |
| + // The helper above and apps place exercise the exemption. |
| + if code != http.StatusBadRequest || !strings.Contains(errorText(out), "only exec-backed instances move") || !strings.Contains(errorText(out), "kind static") { |
| + t.Fatalf("static shape rail = %d %s", code, out) |
| + } |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +func TestHATransferCleanupStillWorks(t *testing.T) { |
| + t.Run("offline abort", func(t *testing.T) { |
| + w := newOfflineWorld(t, oneEach...) |
| + w.start() |
| + markHA(t, w.fx.rel, "bab", "shop", offlineHost) |
| + w.fx.srv.cfg.HARegions = []string{"ie", "uk"} |
| + w.ok("/abort", "", provision.OfflineReverting) |
| + w.report(moves.OfflineRoleSource, "ie-box", moves.OfflinePhaseReverted, nil) |
| + w.ok("/finish", "", "none") |
| + }) |
| + t.Run("offline seal flip open finish", func(t *testing.T) { |
| + w := newOfflineWorld(t, oneEach...) |
| + w.start() |
| + markHA(t, w.fx.rel, "bab", "shop", offlineHost) |
| + w.fx.srv.cfg.HARegions = []string{"ie", "uk"} |
| + w.stopped(nil, "ie-box") |
| + w.ok("/seal", "", provision.OfflineSealing) |
| + w.sealed("ie-box") |
| + w.stopped(nil, "ie-box") |
| + w.ok("/flip", "", provision.OfflineLanding) |
| + w.landed("uk-box") |
| + w.stopped(nil, "ie-box") |
| + w.sealerFresh("ie-box") |
| + w.ok("/open", "", provision.OfflineOpen) |
| + w.report(moves.OfflineRoleTarget, "uk-box", moves.OfflinePhaseOpened, func(r *moves.OfflineReport) { r.Items = okChecks(moves.OfflineOwnerLanding) }) |
| + w.report(moves.OfflineRoleSource, "ie-box", moves.OfflinePhaseParked, nil) |
| + w.ok("/finish", "", provision.OfflineFinishing) |
| + w.report(moves.OfflineRoleSealer, "ie-box", moves.OfflinePhaseLifted, nil) |
| + w.report(moves.OfflineRoleSource, "ie-box", moves.OfflinePhaseGone, nil) |
| + w.ok("/finish", "", "none") |
| + if rec := w.record(); rec.Move != nil || rec.Region != "uk" || !rec.HA { |
| + t.Fatalf("finished record = %+v", rec) |
| + } |
| + }) |
| + for _, phase1 := range []bool{false, true} { |
| + t.Run(map[bool]string{false: "legacy cut abort", true: "phase1 cut abort resolve"}[phase1], func(t *testing.T) { |
| + boxes := oneEach |
| + if phase1 { |
| + boxes = nil // armMoveFleet publishes the signed Phase 1 fleet |
| + } |
| + w := newOfflineWorld(t, boxes...) |
| + door := "legacy" |
| + if phase1 { |
| + door = "phase 1" |
| + armMoveFleet(t, w.fx, ieBox("ie-box"), ukBox("uk-box")) |
| + offlineClaimFor(t, w.fx, offlineHost, "ie-box", "ie") |
| + } |
| + u := haTransferDoor(w, door) |
| + if code, _, out := rawReq(t, http.MethodPost, u, w.token, `{"region":"uk"}`); code != http.StatusAccepted { |
| + t.Fatalf("start = %d %s", code, out) |
| + } |
| + markHA(t, w.fx.rel, "bab", "shop", offlineHost) |
| + if phase1 { |
| + w.edit(provision.MoveGuardedPromoteReady(moveGuardOf(w.record()), time.Now(), provision.MoveInputs{})) |
| + } else { |
| + w.edit(provision.MovePromoteReady(time.Now())) |
| + } |
| + w.fx.srv.cfg.HARegions = []string{"ie", "uk"} |
| + if code, _, out := rawReq(t, http.MethodPost, u+"/cut", w.token, ""); code != http.StatusAccepted { |
| + t.Fatalf("cut = %d %s", code, out) |
| + } |
| + if !phase1 { |
| + // Legacy abort is legal before cut; retain that refusal order. |
| + w.edit(func(rec *provision.Record) error { rec.Move.State = provision.MovePreparing; return nil }) |
| + } |
| + if code, _, out := rawReq(t, http.MethodDelete, u, w.token, ""); code != http.StatusAccepted { |
| + t.Fatalf("abort = %d %s", code, out) |
| + } |
| + if phase1 { |
| + // Play the worker's later recovery state, then use the real |
| + // stuck transition and operator retry. |
| + w.edit(func(rec *provision.Record) error { |
| + rec.Move.State, rec.Move.Reason = provision.MoveReverting, provision.RevertCutDeadline |
| + return nil |
| + }, provision.MoveMarkStuck(moveGuardOf(w.record()), provision.StuckRevertProbeBudget)) |
| + if code, _, out := rawReq(t, http.MethodPost, u+"/resolve", w.token, resolveRetryBody); code != http.StatusAccepted || !strings.Contains(out, `"state":"reverting"`) { |
| + t.Fatalf("resolve = %d %s", code, out) |
| + } |
| + } |
| + }) |
| + } |
| + for _, verb := range []string{"commit", "abort"} { |
| + t.Run("import "+verb, func(t *testing.T) { |
| + f := newImportFixture(t) |
| + code, out := beginImport(t, f, importHost, importSHA, 10) |
| + f.requireBegun(t, code, out, importHost) |
| + haTransferEdit(t, f.fx.rel, "bab", fromApp, importHost, func(rec *provision.Record) { |
| + rec.HA = true |
| + if verb == "commit" { |
| + rec.Seed.State = seeds.StatePlaced |
| + } |
| + }) |
| + f.fx.srv.cfg.HomeRegion, f.fx.srv.cfg.HARegions = "ie", []string{"ie"} |
| + if code, out := postImport(t, f, importHost, verb); code != http.StatusOK || out["state"] != map[string]string{"commit": seeds.StateCommitted, "abort": seeds.StateAborted}[verb] { |
| + t.Fatalf("%s = %d %v", verb, code, out) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func haTransferTrack(s *Server) *haCreateStore { |
| + st := &haCreateStore{Store: s.cfg.Releases} |
| + s.cfg.Releases = st |
| + return st |
| +} |
| + |
| +func haTransferUnchanged(t *testing.T, st *haCreateStore, before map[string]string) { |
| + t.Helper() |
| + if n, _ := st.counts(); n != 0 { |
| + t.Errorf("refusal attempted %d control mutations (record, stage, stop, hold, env or serial)", n) |
| + } |
| + if after := bucketState(t, st.Store); !reflect.DeepEqual(before, after) { |
| + t.Error("refusal changed the deployment bucket") |
| + } |
| +} |
| + |
| +func haTransferDoor(w *offlineWorld, door string) string { |
| + switch door { |
| + case "offline stage": |
| + return w.base + "/stage" |
| + case "phase 1": |
| + enableMovesPhase1(w.fx) |
| + fallthrough |
| + case "legacy": |
| + return strings.TrimSuffix(w.base, "/offline") |
| + default: |
| + return w.base |
| + } |
| +} |
| + |
| +func TestHAMixedMoveRegionsBeforeWrites(t *testing.T) { |
| + t.Run("staged start rechecks", func(t *testing.T) { |
| + for _, region := range []string{"ie", "uk"} { |
| + t.Run(region, func(t *testing.T) { |
| + w := newOfflineWorld(t, oneEach...) |
| + w.ok("/stage", `{"region":"uk"}`, provision.OfflineStaging) |
| + w.fx.srv.cfg.HARegions = []string{region} |
| + before := bucketState(t, w.fx.rel) |
| + st := haTransferTrack(w.fx.srv) |
| + code, out := w.req(http.MethodPost, "", `{"region":"uk"}`) |
| + if code != http.StatusConflict || errorText(out) != haMoveSentence(region) { |
| + t.Errorf("staged start = %d %s", code, out) |
| + } |
| + haTransferUnchanged(t, st, before) |
| + }) |
| + } |
| + }) |
| + for _, door := range []string{"offline start", "offline stage", "legacy", "phase 1"} { |
| + for _, c := range []struct { |
| + name, home, from, to, block string |
| + active []string |
| + ha bool |
| + }{ |
| + {"HA to legacy", "", "ie", "uk", "ie", []string{"ie"}, true}, |
| + {"legacy to HA", "", "ie", "uk", "uk", []string{"uk"}, false}, |
| + {"HA to HA source wins", "", "ie", "uk", "ie", []string{"ie", "uk"}, false}, |
| + {"legacy in active source", "", "ie", "uk", "ie", []string{"ie"}, false}, |
| + {"empty home source", "ie", "", "uk", "ie", []string{"ie"}, false}, |
| + {"explicit home source", "ie", "ie", "uk", "ie", []string{"ie"}, false}, |
| + {"HA home destination", "uk", "ie", "uk", "uk", []string{"uk"}, false}, |
| + {"immutable switch off", "ie", "", "uk", "ie", nil, true}, |
| + } { |
| + t.Run(door+"/"+c.name, func(t *testing.T) { |
| + w := newOfflineWorldIn(t, c.home, c.from, oneEach...) |
| + haTransferEdit(t, w.fx.rel, "bab", "shop", offlineHost, func(rec *provision.Record) { |
| + rec.Region, rec.HA = c.from, c.ha |
| + }) |
| + u := haTransferDoor(w, door) |
| + w.fx.srv.cfg.HARegions = c.active |
| + before := bucketState(t, w.fx.rel) |
| + st := haTransferTrack(w.fx.srv) |
| + code, _, out := rawReq(t, http.MethodPost, u, w.token, `{"region":"`+c.to+`"}`) |
| + if code != http.StatusConflict || errorText(out) != haMoveSentence(c.block) { |
| + t.Errorf("move = %d %s; want 409 naming %s", code, out, c.block) |
| + } |
| + haTransferUnchanged(t, st, before) |
| + if rec := w.record(); rec.Move != nil { |
| + t.Errorf("refusal wrote a move/stage journal: %+v", rec.Move) |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +func TestHAImportFlagSurvivesSwitchOff(t *testing.T) { |
| + for _, door := range []string{"upload", "stopped"} { |
| + t.Run(door, func(t *testing.T) { |
| + f := newImportFixture(t) |
| + body, sha := sqliteBytes(t) |
| + code, out := beginImport(t, f, importHost, sha, int64(len(body))) |
| + f.requireBegun(t, code, out, importHost) |
| + if door == "stopped" { |
| + f.uploaded(t, importHost, body) |
| + } |
| + markHA(t, f.fx.rel, "bab", fromApp, importHost) |
| + f.fx.srv.cfg.HomeRegion, f.fx.srv.cfg.HARegions = "ie", nil |
| + before := bucketState(t, f.fx.rel) |
| + st := haTransferTrack(f.fx.srv) |
| + if door == "upload" { |
| + code, out = uploadImport(t, f, importHost, []byte("x")) |
| + } else { |
| + code, out = postImport(t, f, importHost, door) |
| + } |
| + if code != http.StatusConflict || str(t, out, "error") != haImportC2 { |
| + t.Errorf("%s = %d %v; want immutable HA refusal", door, code, out) |
| + } |
| + haTransferUnchanged(t, st, before) |
| + if door == "upload" { |
| + f.requireNothingUploaded(t) |
| + } |
| + }) |
| + } |
| + t.Run("begin active region constructs unstamped record", func(t *testing.T) { |
| + f := newImportFixture(t) |
| + f.fx.srv.cfg.HomeRegion, f.fx.srv.cfg.HARegions = "ie", []string{"ie"} |
| + before := bucketState(t, f.fx.rel) |
| + st := haTransferTrack(f.fx.srv) |
| + code, out := beginImport(t, f, importHost, importSHA, 10) |
| + if code != http.StatusConflict || str(t, out, "error") != haImportC2 { |
| + t.Fatalf("begin = %d %v", code, out) |
| + } |
| + haTransferUnchanged(t, st, before) |
| + f.requireNoRecord(t, importHost) |
| + f.requireNothingUploaded(t) |
| + }) |
| + t.Run("begin defensive flag predicate", func(t *testing.T) { |
| + // HTTP begin never loads an existing record. Exercise its defensive |
| + // flag check at beginImport with an explicitly stamped candidate. |
| + f := newImportFixture(t) |
| + f.fx.srv.cfg.HomeRegion, f.fx.srv.cfg.HARegions = "ie", nil |
| + before := bucketState(t, f.fx.rel) |
| + st := haTransferTrack(f.fx.srv) |
| + w := httptest.NewRecorder() |
| + f.fx.srv.beginImport(w, httptest.NewRequest(http.MethodPost, "/", nil), seedCreate{ |
| + acct: &Account{Sqid: "bab"}, app: fromApp, m: &provision.Manifest{}, |
| + rec: provision.Record{Host: importHost, HA: true}, |
| + }, seedImportReq{}) |
| + if w.Code != http.StatusConflict || errorText(w.Body.String()) != haImportC2 { |
| + t.Errorf("defensive begin = %d %s", w.Code, w.Body.String()) |
| + } |
| + haTransferUnchanged(t, st, before) |
| + }) |
| + t.Run("non HA import retains upload and stopped", func(t *testing.T) { |
| + f := newImportFixture(t) |
| + body, sha := sqliteBytes(t) |
| + code, out := beginImport(t, f, importHost, sha, int64(len(body))) |
| + rec, _ := f.requireBegun(t, code, out, importHost) |
| + requireImportState(t, f.uploaded(t, importHost, body), rec.Seed.ID, seeds.StateUploaded, "") |
| + if code, out := postImport(t, f, importHost, "stopped"); code != http.StatusOK || out["state"] != seeds.StateReady { |
| + t.Fatalf("stopped = %d %v", code, out) |
| + } |
| + }) |
| +} |