carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1//go:build linux && rootrunner
2
3package host
4
5import (
6 "github.com/carlosframework/platform/internal/rootstate"
7 "os"
8 "path/filepath"
9 "testing"
10)
11
12func TestPlan14RootMigrationTimerAdoptionRootRunner(t *testing.T) {
13 testRootMigrationTimerAdoption(t, func(t *testing.T) rootstate.Store {
14 state, err := rootstate.Open(filepath.Join(generationRootRunnerDir(t), "authority"), true, false)
15 if err != nil {
16 t.Fatal(err)
17 }
18 return state
19 }, func(t *testing.T, r *ClaimRuntimeResources) {
20 uid, gid := generationRunnerRegistryUser(t)
21 path := r.Registry.Path()
22 if err := r.Registry.Close(); err != nil {
23 t.Fatal(err)
24 }
25 for dir := filepath.Dir(path); dir != "/tmp" && dir != "/var/lib" && dir != "/"; dir = filepath.Dir(dir) {
26 if err := os.Chmod(dir, 0755); err != nil {
27 t.Fatal(err)
28 }
29 }
30 if err := os.Chown(filepath.Dir(path), uid, gid); err != nil {
31 t.Fatal(err)
32 }
33 for _, suffix := range []string{"", "-wal", "-shm"} {
34 if err := os.Chown(path+suffix, uid, gid); err != nil && !os.IsNotExist(err) {
35 t.Fatal(err)
36 }
37 }
38 reg, err := openRegistryChild(path, uid, gid)
39 if err != nil {
40 t.Fatal(err)
41 }
42 r.Registry = reg
43 t.Cleanup(func() { reg.Close() })
44 })
45}
46