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 "context"
5 "os"
6 "testing"
7
8 "github.com/carlosframework/platform/internal/hostbox"
9 execlease "github.com/carlosframework/platform/internal/hostexec"
10)
11
12func TestPlan14RemoteUnlaunchedCleanup(t *testing.T) {
13 for _, fault := range []string{"none", "legacy", "read-error", "local-inventory"} {
14 t.Run(fault, func(t *testing.T) {
15 f := newRecoveryFixture(t)
16 launches, inventory := hostbox.RemoteJournals(func(ctx context.Context, q hostbox.JournalRequest) (hostbox.JournalResponse, error) {
17 if q.Op != "has-host" {
18 t.Fatalf("unexpected root operation %s", q.Op)
19 }
20 if fault == "read-error" {
21 return hostbox.JournalResponse{}, os.ErrPermission
22 }
23 return hostbox.JournalResponse{V: 1, ID: q.ID}, nil
24 })
25 if fault == "local-inventory" {
26 inventory = nil
27 }
28 p := &productionClaimLocal{legacyParticipation: fault == "legacy", assembly: &ClaimAssembly{Wake: &ClaimWakeAssembly{}, Launches: launches, Reconcile: &hostbox.ReconcileAdapter{Inventory: inventory, Census: &hostbox.EmptyInstallationCensus{}}}}
29 err := p.cleanup(t.Context(), f.read(), execlease.Binding{})
30 if (err == nil) != (fault == "none") {
31 t.Fatal(fault, err)
32 }
33 })
34 }
35}
36