carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package hostops
2
3import (
4 "context"
5 "errors"
6 "testing"
7)
8
9type sqlCommittedProof struct{ sqlProof }
10
11func (p *sqlCommittedProof) FenceSQLOutcome(ctx context.Context, s SQLReceiptScope) (bool, error) {
12 return true, p.FenceSQL(ctx, s)
13}
14
15// M13: recovery that finds the original commit records sql-committed, not
16// sql-fenced; a plain FenceSQL adapter keeps sql-fenced.
17func TestPlan9Fix1RecoveryRecordsCommittedReceipt(t *testing.T) {
18 for _, tc := range []struct {
19 proof SQLRecovery
20 want string
21 }{{&sqlCommittedProof{}, "sql-committed"}, {&sqlProof{}, "sql-fenced"}} {
22 w, raw, _ := testWriter(t)
23 ctx := t.Context()
24 seedAdmission(t, raw, "bab", "demo", openAdmission("app"))
25 h, err := w.RegisterIngest(ctx, "bab", "demo", "app", "ingest", testOwner)
26 if err != nil {
27 t.Fatal(err)
28 }
29 _, settle, err := h.start.Runner(w.now).Issue(ctx, Effect{ID: "ingest", Resource: "app-sql:ingest", Action: sqlIngestAction, Inputs: map[string]string{"sql_database": "original"}})
30 if err != nil {
31 t.Fatal(err)
32 }
33 _ = settle("", errors.New("console vanished"))
34 if err = w.RecoverIngest(ctx, "bab", "demo", "app", "ingest", tc.proof); err != nil {
35 t.Fatal(err)
36 }
37 a, _ := ReadAdmission(ctx, raw, "bab", "demo", "app")
38 if got := a.Value.Effects["ingest"].ResultReference; got != tc.want {
39 t.Fatalf("result %q, want %q", got, tc.want)
40 }
41 }
42}
43