mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-24 01:26:39 +00:00
ipn/ipnlocal: use an in-memory TKA store if FS is unavailable
This requires making the internals of LocalBackend a bit more generic, and implementing the `tka.CompactableChonk` interface for `tka.Mem`. Signed-off-by: Alex Chan <alexc@tailscale.com> Updates https://github.com/tailscale/corp/issues/33599
This commit is contained in:
@@ -127,6 +127,43 @@ func TestTailchonkFS_IgnoreTempFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// If we use a non-existent directory with filesystem Chonk storage,
|
||||
// it's automatically created.
|
||||
func TestTailchonkFS_CreateChonkDir(t *testing.T) {
|
||||
base := filepath.Join(t.TempDir(), "a", "b", "c")
|
||||
|
||||
chonk, err := ChonkDir(base)
|
||||
if err != nil {
|
||||
t.Fatalf("ChonkDir: %v", err)
|
||||
}
|
||||
|
||||
aum := AUM{MessageKind: AUMNoOp}
|
||||
must.Do(chonk.CommitVerifiedAUMs([]AUM{aum}))
|
||||
|
||||
got, err := chonk.AUM(aum.Hash())
|
||||
if err != nil {
|
||||
t.Errorf("Chonk.AUM: %v", err)
|
||||
}
|
||||
if diff := cmp.Diff(got, aum); diff != "" {
|
||||
t.Errorf("wrong AUM; (-got+want):%v", diff)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(base); err != nil {
|
||||
t.Errorf("os.Stat: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// You can't use a file as the root of your filesystem Chonk storage.
|
||||
func TestTailchonkFS_CannotUseFile(t *testing.T) {
|
||||
base := filepath.Join(t.TempDir(), "tka_storage.txt")
|
||||
must.Do(os.WriteFile(base, []byte("this won't work"), 0644))
|
||||
|
||||
_, err := ChonkDir(base)
|
||||
if err == nil {
|
||||
t.Fatal("ChonkDir succeeded; expected an error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkActiveChain(t *testing.T) {
|
||||
type aumTemplate struct {
|
||||
AUM AUM
|
||||
|
||||
Reference in New Issue
Block a user