test: wait for box isolation readiness in the pool witness
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
5 files changed,
+256
−29
internal/host/region_ha_g2_isolation_test.go+120 −0internal/host/region_ha_g2_pool_root_linux_test.go+9 −9internal/host/region_ha_g2_root_fixture_test.go+112 −20scripts/region-ha-g2-pool-witness.py+9 −0scripts/region_ha_g2_pool_witness_test.py+6 −0
Intent
Human
<task-notification> <task-id>bdiw9baz0</task-id> <tool-use-id>toolu_019FhthBgVaRA2jLd9nh7E6d</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/5555438b-7fa2-408d-b2c4-9fa87ea89332/tasks/bdiw9baz0.output</output-file> <status>completed</status> <summary>Background command "Run F-B witness live, run 5" completed (exit code 0)</summary> </task-notification>
diff --git a/internal/host/region_ha_g2_isolation_test.go b/internal/host/region_ha_g2_isolation_test.go| new file mode 100644 |
| index 000000000..c29c5f921 |
| --- /dev/null |
| +++ b/internal/host/region_ha_g2_isolation_test.go |
| @@ -0,0 +1,120 @@ |
| +//go:build linux && rootrunner |
| + |
| +package host |
| + |
| +import ( |
| + "bufio" |
| + "context" |
| + "fmt" |
| + "net" |
| + "net/http" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/controlsock" |
| + "github.com/carlosframework/platform/internal/instancectl" |
| +) |
| + |
| +func TestG2PoolIsolationReadiness(t *testing.T) { |
| + client := instancectl.NewClient(controlsock.Path) |
| + calls := 0 |
| + client.Dial = func(ctx context.Context, path string) (net.Conn, error) { |
| + if path != controlsock.Path { |
| + t.Fatalf("unexpected control socket: %s", path) |
| + } |
| + calls++ |
| + attempt := calls |
| + local, remote := net.Pipe() |
| + go func() { |
| + defer remote.Close() |
| + req, err := http.ReadRequest(bufio.NewReader(remote)) |
| + if err != nil { |
| + t.Error(err) |
| + return |
| + } |
| + defer req.Body.Close() |
| + if req.Method != "GET" || req.URL.Path != "/ready" { |
| + t.Errorf("unexpected probe request: %s %s", req.Method, req.URL.Path) |
| + } |
| + if attempt == 1 { |
| + body := `{"ready":false,"lines":[{"check":"cgroup-ro","verdict":"fail","detail":"edge not loaded"},{"check":"imds-v6","verdict":"unverified","detail":"deny not exercised"}]}` |
| + fmt.Fprintf(remote, "HTTP/1.1 503 Service Unavailable\r\nContent-Length: %d\r\n\r\n%s", len(body), body) |
| + } else { |
| + fmt.Fprintf(remote, "HTTP/1.1 204 No Content\r\n%s: %s\r\n\r\n", instancectl.BuildHeader, client.Build) |
| + } |
| + }() |
| + return local, nil |
| + } |
| + ctx, cancel := context.WithTimeout(context.Background(), time.Second) |
| + defer cancel() |
| + evidence, err := g2WaitIsolation(ctx, time.Millisecond, func(ctx context.Context) error { |
| + if _, ok := ctx.Deadline(); !ok { |
| + t.Fatal("probe request lacks gate deadline") |
| + } |
| + return client.Ready(ctx) |
| + }) |
| + if err != nil || !evidence.Ready || calls != 2 || len(evidence.History) != 2 { |
| + t.Fatalf("calls=%d evidence=%+v err=%v", calls, evidence, err) |
| + } |
| + first := evidence.History[0] |
| + if first.Report == nil || len(first.Report.Lines) != 2 || !strings.Contains(first.Error, "edge not loaded") { |
| + t.Fatalf("lost probe report: %+v", first) |
| + } |
| + if evidence.Elapsed <= 0 || evidence.StartedAt.IsZero() || evidence.History[1].Error != "" { |
| + t.Fatalf("lost time-to-ready or final verdict: %+v", evidence) |
| + } |
| +} |
| + |
| +func TestG2PoolIsolationReadinessTimeout(t *testing.T) { |
| + for _, mode := range []string{"not-ready", "transport", "stale-build", "blocked", "late-success"} { |
| + t.Run(mode, func(t *testing.T) { |
| + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Millisecond) |
| + defer cancel() |
| + calls := 0 |
| + evidence, err := g2WaitIsolation(ctx, time.Millisecond, func(ctx context.Context) error { |
| + calls++ |
| + switch mode { |
| + case "transport": |
| + return fmt.Errorf("control socket unavailable") |
| + case "stale-build": |
| + return &instancectl.StaleBuildError{Running: "old", Want: "new"} |
| + case "blocked", "late-success": |
| + <-ctx.Done() |
| + if mode == "late-success" { |
| + return nil |
| + } |
| + return ctx.Err() |
| + default: |
| + return &instancectl.NotReadyError{Report: instancectl.ProbeReport{Lines: []instancectl.VerdictLine{{Check: "probe", Verdict: "fail", Detail: "not yet run"}}}} |
| + } |
| + }) |
| + if err == nil || !strings.Contains(err.Error(), "G2_ENVIRONMENT_NOT_READY") || evidence.Ready || calls == 0 { |
| + t.Fatalf("calls=%d evidence=%+v err=%v", calls, evidence, err) |
| + } |
| + if len(evidence.History) != calls || evidence.Elapsed < 15*time.Millisecond || evidence.Elapsed > time.Second { |
| + t.Fatalf("unbounded wait or lost history: %+v", evidence) |
| + } |
| + if !strings.Contains(err.Error(), "history") || !strings.Contains(err.Error(), evidence.History[0].Error) { |
| + t.Fatalf("failure lacks probe history: %v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestG2PoolIsolationReadinessImmediate(t *testing.T) { |
| + ctx, cancel := context.WithTimeout(context.Background(), time.Second) |
| + defer cancel() |
| + evidence, err := g2WaitIsolation(ctx, time.Hour, func(context.Context) error { return nil }) |
| + if err != nil || !evidence.Ready || len(evidence.History) != 1 { |
| + t.Fatalf("ready box waited: %+v %v", evidence, err) |
| + } |
| + cancel() |
| + evidence, err = g2WaitIsolation(ctx, time.Hour, func(context.Context) error { |
| + t.Fatal("queried after deadline") |
| + return nil |
| + }) |
| + if err == nil || evidence.Ready { |
| + t.Fatalf("expired gate passed: %+v %v", evidence, err) |
| + } |
| +} |
diff --git a/internal/host/region_ha_g2_pool_root_linux_test.go b/internal/host/region_ha_g2_pool_root_linux_test.go| index 99303d3df..d97519354 100644 |
| --- a/internal/host/region_ha_g2_pool_root_linux_test.go |
| +++ b/internal/host/region_ha_g2_pool_root_linux_test.go |
| @@ -363,7 +363,7 @@ func TestRootG2PoolIngress(t *testing.T) { |
| } |
| client := g2Client(t, config.CA) |
| b = g2Peer(t, g2RPC{Action: "start"}) |
| - a.start() |
| + g2Must(t, a.start()) |
| g2Serial(t, storage.deploy) |
| g2WaitPeer(t, storage.deploy, b.Ref, []string{"ha"}) |
| // Any changed guard is observed at the first ineligible local service, |
| @@ -427,7 +427,7 @@ func TestRootG2PoolIngress(t *testing.T) { |
| } |
| // Restart A through its supported startup path to clear holder-cache |
| // history. Its pool remains 'other' and no membership seam is used. |
| - a.pools("other") |
| + g2Must(t, a.pools("other")) |
| served(projection+"/"+kind, g2Host, b.Ref) |
| g2NoLocal(t, a, storage, start) |
| t.Logf("CASE %s/%s PASS", projection, kind) |
| @@ -438,7 +438,7 @@ func TestRootG2PoolIngress(t *testing.T) { |
| if projection == "row-absent" { |
| fresh = g2AbsentRowHost |
| } |
| - a.pools("other") |
| + g2Must(t, a.pools("other")) |
| if projection == "row-absent" { |
| g2Must(t, a.reg.Delete(fresh)) |
| g2Serial(t, storage.deploy) |
| @@ -466,7 +466,7 @@ func TestRootG2PoolIngress(t *testing.T) { |
| journalCursor := g2Peer(t, g2RPC{Action: "journal-cursor"}).AgentJournal |
| g2Must(t, storage.data.Delete(t.Context(), "instances/"+fresh+"/lock.json")) |
| g2Must(t, g2AbsentPrefix(t.Context(), storage.data, fresh, true)) |
| - a.pools("other") |
| + g2Must(t, a.pools("other")) |
| if projection == "row-absent" { |
| g2Must(t, a.reg.Delete(fresh)) |
| } |
| @@ -542,7 +542,7 @@ func TestRootG2PoolIngress(t *testing.T) { |
| g2Stopped(t, g2Peer(t, g2RPC{Action: "state"}), g2Host) |
| start = len(storage.snapshot()) |
| g2PeerEvidence(t, storage, b.Ref, true, false) |
| - a.pools("other") |
| + g2Must(t, a.pools("other")) |
| served("eligible-low-headroom", g2Host, b.Ref) |
| g2NoLocal(t, a, storage, start) |
| storage.holdPeer("") |
| @@ -556,14 +556,14 @@ func TestRootG2PoolIngress(t *testing.T) { |
| t.Fatal("no-eligible-peer needs a released ordinary host") |
| } |
| start = len(storage.snapshot()) |
| - a.pools("other") |
| + g2Must(t, a.pools("other")) |
| g2Refused(t, client, "no-eligible-peer", g2Host, "") |
| g2NoLocal(t, a, storage, start) |
| t.Log("CASE no-eligible-peer PASS") |
| g2Stopped(t, g2Peer(t, g2RPC{Action: "state"}), g2Host) |
| start = len(storage.snapshot()) |
| g2PeerEvidence(t, storage, b.Ref, false, true) |
| - a.pools("other") |
| + g2Must(t, a.pools("other")) |
| g2Refused(t, client, "host-advertised-wrong-pool", g2Host, "") |
| g2NoLocal(t, a, storage, start) |
| storage.holdPeer("") |
| @@ -577,7 +577,7 @@ func TestRootG2PoolIngress(t *testing.T) { |
| t.Fatal("withdrawal needs a released ordinary host") |
| } |
| start = len(storage.snapshot()) |
| - a.pools("ha") |
| + g2Must(t, a.pools("ha")) |
| g2Serial(t, storage.deploy) |
| g2Wait(t, "A reminted eligible row", 60*time.Second, func() bool { row, err := a.reg.Get(g2Host); return err == nil && row != nil }) |
| aRef := a.state().Ref |
| @@ -593,7 +593,7 @@ func TestRootG2PoolIngress(t *testing.T) { |
| storage.block(true) |
| } |
| boundary := len(storage.snapshot()) |
| - a.pools("other") |
| + g2Must(t, a.pools("other")) |
| g2Serial(t, storage.deploy) |
| g2Refused(t, client, "withdrawal/"+fault+"/fenced", g2Host, "") |
| if fault != "clean" { |
diff --git a/internal/host/region_ha_g2_root_fixture_test.go b/internal/host/region_ha_g2_root_fixture_test.go| index e6f4c2b38..83bfdffab 100644 |
| --- a/internal/host/region_ha_g2_root_fixture_test.go |
| +++ b/internal/host/region_ha_g2_root_fixture_test.go |
| @@ -19,6 +19,7 @@ import ( |
| "encoding/pem" |
| "errors" |
| "flag" |
| + "fmt" |
| "io" |
| "math/big" |
| "net" |
| @@ -41,6 +42,7 @@ import ( |
| "github.com/aws/aws-sdk-go-v2/aws" |
| "github.com/aws/aws-sdk-go-v2/credentials" |
| "github.com/aws/aws-sdk-go-v2/service/s3" |
| + "github.com/carlosframework/platform/internal/controlsock" |
| "github.com/carlosframework/platform/internal/hafresh" |
| "github.com/carlosframework/platform/internal/instancectl" |
| "github.com/carlosframework/platform/internal/provision" |
| @@ -49,20 +51,23 @@ import ( |
| ) |
| const ( |
| - g2Root = "/var/lib/g2fix" |
| - g2Host = "pool.g2fix.test" |
| - g2AbsentOldHost = "fresh-old.g2fix.test" |
| - g2AbsentRowHost = "fresh-row.g2fix.test" |
| - g2Alias = "alias.g2fix.test" |
| - g2Regional = "pool.ie.g2fix.test" |
| - g2Account = "bab" |
| - g2App = "g2witness" |
| - g2Version = "a0123456" |
| - g2Deploy = "g2fix-deployment" |
| - g2Data = "g2fix-data" |
| - g2Access = "g2fix-access" |
| - g2Secret = "g2fix-secret-only-disposable-minio" |
| - g2PoolViolation = "G2_POOL_VIOLATION" |
| + g2Root = "/var/lib/g2fix" |
| + g2Host = "pool.g2fix.test" |
| + g2AbsentOldHost = "fresh-old.g2fix.test" |
| + g2AbsentRowHost = "fresh-row.g2fix.test" |
| + g2Alias = "alias.g2fix.test" |
| + g2Regional = "pool.ie.g2fix.test" |
| + g2Account = "bab" |
| + g2App = "g2witness" |
| + g2Version = "a0123456" |
| + g2Deploy = "g2fix-deployment" |
| + g2Data = "g2fix-data" |
| + g2Access = "g2fix-access" |
| + g2Secret = "g2fix-secret-only-disposable-minio" |
| + g2PoolViolation = "G2_POOL_VIOLATION" |
| + g2EnvironmentNotReady = "G2_ENVIRONMENT_NOT_READY" |
| + g2IsolationTimeout = 180 * time.Second |
| + g2PeerTimeout = g2IsolationTimeout + 180*time.Second |
| ) |
| type g2Config struct { |
| @@ -77,6 +82,57 @@ type g2State struct { |
| TenantCgroups map[string]string |
| Owed []string |
| AgentJournal string |
| + Isolation []g2IsolationEvidence |
| + IsolationError string |
| +} |
| + |
| +type g2ProbeSample struct { |
| + Elapsed time.Duration `json:"elapsed_ns"` |
| + Error string `json:"error,omitempty"` |
| + Report *instancectl.ProbeReport `json:"report,omitempty"` |
| +} |
| + |
| +type g2IsolationEvidence struct { |
| + Role, IID, Action string |
| + StartedAt time.Time `json:"started_at"` |
| + Elapsed time.Duration `json:"elapsed_ns"` |
| + Ready bool `json:"ready"` |
| + History []g2ProbeSample `json:"history"` |
| +} |
| + |
| +func g2WaitIsolation(ctx context.Context, interval time.Duration, ready func(context.Context) error) (g2IsolationEvidence, error) { |
| + started := time.Now() |
| + evidence := g2IsolationEvidence{StartedAt: started} |
| + for ctx.Err() == nil { |
| + err := ready(ctx) |
| + if err == nil { |
| + err = ctx.Err() |
| + } |
| + sample := g2ProbeSample{Elapsed: time.Since(started)} |
| + if err != nil { |
| + sample.Error = err.Error() |
| + var refused *instancectl.NotReadyError |
| + if errors.As(err, &refused) { |
| + report := refused.Report |
| + sample.Report = &report |
| + } |
| + } |
| + evidence.History = append(evidence.History, sample) |
| + if err == nil { |
| + evidence.Ready = true |
| + evidence.Elapsed = time.Since(started) |
| + return evidence, nil |
| + } |
| + timer := time.NewTimer(interval) |
| + select { |
| + case <-ctx.Done(): |
| + timer.Stop() |
| + case <-timer.C: |
| + } |
| + } |
| + evidence.Elapsed = time.Since(started) |
| + raw, _ := json.Marshal(evidence) |
| + return evidence, fmt.Errorf("%s: %v; %s", g2EnvironmentNotReady, ctx.Err(), raw) |
| } |
| type g2Box struct { |
| @@ -88,6 +144,7 @@ type g2Box struct { |
| uid, gid int |
| env map[string]string |
| units []string |
| + isolation []g2IsolationEvidence |
| } |
| func g2Must(t *testing.T, err error) { |
| @@ -350,24 +407,48 @@ func (b *g2Box) listening() { |
| return true |
| }) |
| } |
| -func (b *g2Box) start() { |
| +func (b *g2Box) isolationReady(action string) error { |
| + ctx, cancel := context.WithTimeout(context.Background(), g2IsolationTimeout) |
| + defer cancel() |
| + // This is the same /ready verdict used by the activator's NestedOK gate. |
| + evidence, err := g2WaitIsolation(ctx, time.Second, instancectl.NewClient(controlsock.Path).Ready) |
| + evidence.Role, evidence.IID, evidence.Action = b.role, b.iid, action |
| + b.isolation = append(b.isolation, evidence) |
| + b.t.Logf("ISOLATION_READINESS %s", g2JSON(b.t, evidence)) |
| + if err != nil { |
| + return fmt.Errorf("%s box=%s iid=%s action=%s: %w", g2EnvironmentNotReady, b.role, b.iid, action, err) |
| + } |
| + return nil |
| +} |
| + |
| +func (b *g2Box) start() error { |
| g2Command(b.t, "systemctl", "start", "carlos-edge.service") |
| + if err := b.isolationReady("start"); err != nil { |
| + return err |
| + } |
| b.listening() |
| + return nil |
| } |
| -func (b *g2Box) pools(value string) { |
| +func (b *g2Box) pools(value string) error { |
| if value != "ha" && value != "other" { |
| b.t.Fatal("invalid fixture pool") |
| } |
| b.env["CARLOS_POOLS"] = value |
| b.writeEnv() |
| g2Command(b.t, "systemctl", "restart", "carlos-edge.service") |
| + if b.role == "B" { |
| + if err := b.isolationReady("restart/pools=" + value); err != nil { |
| + return err |
| + } |
| + } |
| b.listening() |
| + return nil |
| } |
| func (b *g2Box) state() g2State { |
| t := b.t |
| rows, err := b.reg.List() |
| g2Must(t, err) |
| - state := g2State{IID: b.iid, Ref: metricsBoxLabel(func(k string) string { return b.env[k] }, readMachineID()), Pools: b.env["CARLOS_POOLS"], Rows: rows, TenantPIDs: map[string]string{}, TenantCgroups: map[string]string{}} |
| + state := g2State{IID: b.iid, Ref: metricsBoxLabel(func(k string) string { return b.env[k] }, readMachineID()), Pools: b.env["CARLOS_POOLS"], Rows: rows, TenantPIDs: map[string]string{}, TenantCgroups: map[string]string{}, Isolation: slices.Clone(b.isolation)} |
| state.AgentPID = g2Command(t, "systemctl", "show", "carlos-edge.service", "-p", "MainPID", "--value") |
| state.AgentCgroup = g2Command(t, "systemctl", "show", "carlos-edge.service", "-p", "ControlGroup", "--value") |
| for _, rec := range b.config.Records { |
| @@ -495,11 +576,12 @@ func TestRootG2Peer(t *testing.T) { |
| if box == nil { |
| t.Fatal("configure first") |
| } |
| + var isolationErr error |
| switch call.request.Action { |
| case "start": |
| - box.start() |
| + isolationErr = box.start() |
| case "pools": |
| - box.pools(call.request.Value) |
| + isolationErr = box.pools(call.request.Value) |
| case "freeze": |
| g2Command(t, "systemctl", "kill", "--kill-whom=main", "--signal=STOP", "carlos-edge.service") |
| case "thaw": |
| @@ -525,6 +607,10 @@ func TestRootG2Peer(t *testing.T) { |
| default: |
| t.Fatal("invalid fixture action", call.request.Action) |
| } |
| + if isolationErr != nil { |
| + call.result <- g2State{IID: box.iid, Isolation: slices.Clone(box.isolation), IsolationError: isolationErr.Error()} |
| + continue |
| + } |
| call.result <- box.state() |
| } |
| } |
| @@ -532,7 +618,7 @@ func TestRootG2Peer(t *testing.T) { |
| } |
| func g2Peer(t *testing.T, req g2RPC) g2State { |
| t.Helper() |
| - client := &http.Client{Timeout: 100 * time.Second} |
| + client := &http.Client{Timeout: g2PeerTimeout} |
| request, err := http.NewRequest("POST", "http://"+os.Getenv("G2_B_IP")+":9444/", bytes.NewReader(g2JSON(t, req))) |
| g2Must(t, err) |
| request.Header.Set("Authorization", "Bearer "+os.Getenv("G2_TOKEN")) |
| @@ -544,6 +630,12 @@ func g2Peer(t *testing.T, req g2RPC) g2State { |
| } |
| var state g2State |
| g2Must(t, json.NewDecoder(response.Body).Decode(&state)) |
| + if req.Action == "start" || req.Action == "pools" { |
| + t.Logf("peer ISOLATION_READINESS %s", g2JSON(t, state.Isolation)) |
| + } |
| + if state.IsolationError != "" { |
| + t.Fatal(state.IsolationError) |
| + } |
| return state |
| } |
diff --git a/scripts/region-ha-g2-pool-witness.py b/scripts/region-ha-g2-pool-witness.py| index 196ffd3be..048fcd36e 100644 |
| --- a/scripts/region-ha-g2-pool-witness.py |
| +++ b/scripts/region-ha-g2-pool-witness.py |
| @@ -26,6 +26,7 @@ MINIO_URL = ("https://github.com/minio/minio/releases/download/RELEASE.2025-09-0 |
| "minio.linux-arm64.RELEASE.2025-09-07T16-13-09Z") |
| MINIO_SHA = "5c83cd2cf151717ba0243f73e1c7802ff36e272b67144bdd7f1f7d684fd6f03d" |
| PASS = "PASS TestRootG2PoolIngress" |
| +ENVIRONMENT_NOT_READY = "G2_ENVIRONMENT_NOT_READY" |
| REQUIRED_CASES = (["signed-hop-ineligible", "concurrent-posts", "eligible-low-headroom", |
| "no-eligible-peer", "host-advertised-wrong-pool"] + |
| [f"{projection}/{shape}" for projection in ("old-row-startup", "row-absent") |
| @@ -60,7 +61,14 @@ def validate_tip(worktree, expected): |
| raise ValueError("worktree must be clean") |
| +def verify_environment(log): |
| + failures = [line for line in log.splitlines() if ENVIRONMENT_NOT_READY in line] |
| + if failures: |
| + raise RuntimeError("\n".join(failures)) |
| + |
| + |
| def verify_result(result, log, phase): |
| + verify_environment(log) |
| if phase == "mutant": |
| if result["Status"] == "Success" or "G2_POOL_VIOLATION" not in log: |
| raise RuntimeError("mutation must fail the pool assertion, not an infrastructure prerequisite") |
| @@ -466,6 +474,7 @@ class Run: |
| print(f"ASSERT {phase}: " + ("nonzero exit AND G2_POOL_VIOLATION" if phase == "mutant" else "Success, exact test PASS, all case evidence, no SKIP")) |
| else: |
| # SSM truncates inline output. Read the complete, automatically uploaded log. |
| + verify_environment(log + "\n" + peer_log) |
| if "--- PASS: TestRootG2Peer " not in peer_log or "--- FAIL:" in peer_log or "--- SKIP:" in peer_log: |
| raise RuntimeError(f"{phase}: peer fixture or its cleanup failed") |
| verify_result(result, log, phase) |
diff --git a/scripts/region_ha_g2_pool_witness_test.py b/scripts/region_ha_g2_pool_witness_test.py| index f0d94c1db..6bd833271 100644 |
| --- a/scripts/region_ha_g2_pool_witness_test.py |
| +++ b/scripts/region_ha_g2_pool_witness_test.py |
| @@ -111,6 +111,12 @@ class DriverOfflineTest(unittest.TestCase): |
| driver.verify_result({"Status": status}, log, "mutant") |
| driver.verify_result({"Status": "Failed"}, "G2_POOL_VIOLATION", "mutant") |
| + def test_environment_not_ready_is_distinct_from_product_failure(self): |
| + history = 'G2_ENVIRONMENT_NOT_READY box=B history=[probe fail not yet run]' |
| + for phase in ("baseline", "mutant", "restored"): |
| + with self.subTest(phase=phase), self.assertRaisesRegex(RuntimeError, history.replace('[', r'\[').replace(']', r'\]')): |
| + driver.verify_result({"Status": "Failed"}, history + "\nG2_POOL_VIOLATION", phase) |
| + |
| def test_mutation_does_not_edit_source(self): |
| with tempfile.TemporaryDirectory(dir=os.environ["TMPDIR"]) as directory: |
| root = Path(directory) |