mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-04 17:01:58 +01:00
Previously a TKA compaction would only run when a node starts, which means a long-running node could use unbounded storage as it accumulates ever-increasing amounts of TKA state. This patch changes TKA so it runs a compaction after every sync. Updates https://github.com/tailscale/corp/issues/33537 Change-Id: I91df887ea0c5a5b00cb6caced85aeffa2a4b24ee Signed-off-by: Alex Chan <alexc@tailscale.com>
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package chonktest
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"tailscale.com/tka"
|
|
"tailscale.com/util/must"
|
|
)
|
|
|
|
func TestImplementsChonk(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
name string
|
|
newChonk func(t *testing.T) tka.Chonk
|
|
}{
|
|
{
|
|
name: "Mem",
|
|
newChonk: func(t *testing.T) tka.Chonk {
|
|
return tka.ChonkMem()
|
|
},
|
|
},
|
|
{
|
|
name: "FS",
|
|
newChonk: func(t *testing.T) tka.Chonk {
|
|
return must.Get(tka.ChonkDir(t.TempDir()))
|
|
},
|
|
},
|
|
} {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
RunChonkTests(t, tt.newChonk)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestImplementsCompactableChonk(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
name string
|
|
newChonk func(t *testing.T) tka.CompactableChonk
|
|
}{
|
|
{
|
|
name: "Mem",
|
|
newChonk: func(t *testing.T) tka.CompactableChonk {
|
|
return tka.ChonkMem()
|
|
},
|
|
},
|
|
{
|
|
name: "FS",
|
|
newChonk: func(t *testing.T) tka.CompactableChonk {
|
|
return must.Get(tka.ChonkDir(t.TempDir()))
|
|
},
|
|
},
|
|
} {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
RunCompactableChonkTests(t, tt.newChonk)
|
|
})
|
|
}
|
|
}
|