mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
Pinner wired to real retention: - NewPinner calls vol.SetV2RetentionFloor(p.MinWALRetentionFloor) - Flusher.RetentionFloorFn() / SetRetentionFloorFn() exposed - SetV2RetentionFloor chains with existing shipper retention floor - Holds actually prevent WAL reclaim (not just tracked state) Executor uses real WAL scan: - BlockVol.ScanWALEntries(fromLSN, callback) wraps wal.ScanFrom with real fd, walOffset, checkpointLSN - Executor.StreamWALEntries uses ScanWALEntries (not stub) - Reads real WAL entries, tracks highest LSN scanned CommittedLSN mapping: - Explicitly documented as interim V1 model (committed = checkpointed) - Will diverge when V2 distributed commit separates from local flush Carry-forward: - TransferSnapshot/TransferFullBase/TruncateWAL: stubs (need extent I/O) - Control intent from confirmed failover: deferred Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
83 lines
2.1 KiB
Go
83 lines
2.1 KiB
Go
package actions
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestExtractHost(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want string
|
|
}{
|
|
{"192.168.1.184:18400", "192.168.1.184"},
|
|
{"10.0.0.3:4420", "10.0.0.3"},
|
|
{":3299", ""},
|
|
{"0.0.0.0:3299", "0.0.0.0"},
|
|
{"[::]:3299", "::"},
|
|
{"localhost:9555", "localhost"},
|
|
{"", ""},
|
|
{"no-port", "no-port"},
|
|
}
|
|
for _, tt := range tests {
|
|
got := extractHost(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("extractHost(%q) = %q, want %q", tt.input, got, tt.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestBenchmarkReportHeader_CrossMachineDetection(t *testing.T) {
|
|
// Cross-machine: different IPs.
|
|
p := extractHost("192.168.1.184:18400")
|
|
r := extractHost("192.168.1.181:18401")
|
|
if p == r {
|
|
t.Fatal("expected different IPs for cross-machine")
|
|
}
|
|
|
|
// Same-host: same IP different port.
|
|
p2 := extractHost("192.168.1.184:18400")
|
|
r2 := extractHost("192.168.1.184:18401")
|
|
if p2 != r2 {
|
|
t.Fatal("expected same IP for same-host")
|
|
}
|
|
}
|
|
|
|
func TestPostcheckPgdataLocalDetection(t *testing.T) {
|
|
// pgdata under mount path — OK.
|
|
mount := "/mnt/bench"
|
|
pgdata := "/mnt/bench/pgdata"
|
|
if !hasPrefix(pgdata, mount) {
|
|
t.Fatal("pgdata under mount should be detected as OK")
|
|
}
|
|
|
|
// pgdata NOT under mount — suspect (local disk).
|
|
pgdata2 := "/tmp/pgdata"
|
|
if hasPrefix(pgdata2, mount) {
|
|
t.Fatal("pgdata on /tmp should be detected as local disk")
|
|
}
|
|
}
|
|
|
|
func hasPrefix(path, prefix string) bool {
|
|
return len(path) >= len(prefix) && path[:len(prefix)] == prefix
|
|
}
|
|
|
|
func TestPreflightAddressCheck(t *testing.T) {
|
|
// These should fail preflight.
|
|
badAddrs := []string{":3299", "0.0.0.0:3299", "[::]:3299"}
|
|
for _, addr := range badAddrs {
|
|
host := extractHost(addr)
|
|
if host != "" && host != "0.0.0.0" && host != "::" {
|
|
t.Errorf("address %q should be detected as non-routable, got host=%q", addr, host)
|
|
}
|
|
}
|
|
|
|
// These should pass.
|
|
goodAddrs := []string{"192.168.1.181:5099", "10.0.0.3:4420"}
|
|
for _, addr := range goodAddrs {
|
|
host := extractHost(addr)
|
|
if host == "" || host == "0.0.0.0" || host == "::" {
|
|
t.Errorf("address %q should be routable, got host=%q", addr, host)
|
|
}
|
|
}
|
|
}
|