carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "github.com/carlosframework/platform/internal/activator"
5 "github.com/carlosframework/platform/internal/hostclaim"
6 "github.com/carlosframework/platform/internal/registry"
7 "strings"
8 "testing"
9)
10
11func TestPlan13LandingInvalidSourceWithoutHistory(t *testing.T) {
12 for _, from := range []string{"@home", "IE"} {
13 f := newPOFixture(t)
14 c := f.poFlipClaim()
15 c.Holder.Admissions = nil
16 f.rec.Move.From = from
17 o := hostclaim.Observed{Host: poHost, Claim: c}
18 if _, err := f.owners.landing(t.Context(), o); err == nil {
19 t.Fatal("invalid source accepted", from)
20 }
21 if got, err := predecessorRegion(c.Holder, from); err == nil || got != "" {
22 t.Fatal("invalid predecessor accepted", got, err)
23 }
24 }
25}
26
27func TestPlan13NamedAdmissionReadsHomeStorageWithC8Gate(t *testing.T) {
28 f := plan9D5Fixture(t)
29 f.owners.HomeRegion = "ie"
30 f.owners.Region = "@home"
31 f.file(t, "old", 9, 1, 5)
32 f.marker(t, "old")
33 o := hostclaim.Observed{Host: recoveryHost, Claim: &hostclaim.Claim{Holder: &hostclaim.Holder{Incarnation: "inc", Location: "instances/" + recoveryHost, Generation: "new", Admissions: []hostclaim.AdmissionRecord{{Generation: "new", Predecessor: "old", Region: "ie", PredecessorRegion: "ie", Mode: "cold"}}}}}
34 plan, err := f.owners.baseline(t.Context(), o)
35 if err != nil || plan == nil || plan.MaxTXID != 5 {
36 t.Fatal(plan, err)
37 }
38 if o.Claim.Holder.Admissions[0].Region != "ie" {
39 t.Fatal("rewrote history")
40 }
41 f.owners.Sources.Files = nil
42 o.Claim.Op = hostclaim.Op{Kind: hostclaim.KindServing, Exec: f.owners.Box}
43 if _, err := f.owners.Select(t.Context(), registry.Route{}, o, activator.StartPolicy{}); err == nil || !strings.Contains(err.Error(), "C8") {
44 t.Fatal("C8 provider gate removed", err)
45 }
46}
47