Download this file
| 1 | package activator |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | // Settings spec rev 11 §4.3a: a landing move carries the build state with |
| 9 | // the replica. The legacy round mirrors the whole hibernate prefix to |
| 10 | // moves/<host>/, and promoteStagedReplica copies every staged object over |
| 11 | // the own prefix, build-state.json included. This pins today's behaviour: |
| 12 | // a keep filter added to the promotion later must not drop it. |
| 13 | func TestALandingMovePromotesTheBuildState(t *testing.T) { |
| 14 | b := testExecBackend(t) |
| 15 | m := newFakeMirrorStore() |
| 16 | b.Mirror = m |
| 17 | host := "moved.example.com" |
| 18 | m.put(b.Cfg.Bucket, MovesPrefix(host)+"generations/0000/a.ltx", "e1") |
| 19 | m.put(b.Cfg.Bucket, MovesPrefix(host)+"build-state.json", "e2") |
| 20 | if _, err := b.promoteStagedReplica(context.Background(), host); err != nil { |
| 21 | t.Fatal(err) |
| 22 | } |
| 23 | got, ok := m.buckets[b.Cfg.Bucket][b.Cfg.hibernatePrefix(host)+"/build-state.json"] |
| 24 | if !ok || got.ETag != "e2" { |
| 25 | t.Fatalf("the landing did not carry build-state.json beside the replica: %+v %v", got, ok) |
| 26 | } |
| 27 | if _, ok := m.buckets[b.Cfg.Bucket][b.Cfg.hibernatePrefix(host)+"/generations/0000/a.ltx"]; !ok { |
| 28 | t.Fatal("the landing did not carry the replica") |
| 29 | } |
| 30 | } |
| 31 | |