mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-25 01:14:50 +00: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>
74 lines
2.2 KiB
Go
74 lines
2.2 KiB
Go
package blockvol
|
|
|
|
import (
|
|
"net"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCanonicalizeAddr_WildcardIPv4_UsesAdvertised(t *testing.T) {
|
|
addr := &net.TCPAddr{IP: net.IPv4zero, Port: 5099}
|
|
result := canonicalizeListenerAddr(addr, "192.168.1.184")
|
|
if result != "192.168.1.184:5099" {
|
|
t.Fatalf("expected 192.168.1.184:5099, got %q", result)
|
|
}
|
|
}
|
|
|
|
func TestCanonicalizeAddr_WildcardIPv6_UsesAdvertised(t *testing.T) {
|
|
addr := &net.TCPAddr{IP: net.IPv6zero, Port: 5099}
|
|
result := canonicalizeListenerAddr(addr, "10.0.0.3")
|
|
if result != "10.0.0.3:5099" {
|
|
t.Fatalf("expected 10.0.0.3:5099, got %q", result)
|
|
}
|
|
}
|
|
|
|
func TestCanonicalizeAddr_NilIP_UsesAdvertised(t *testing.T) {
|
|
addr := &net.TCPAddr{IP: nil, Port: 5099}
|
|
result := canonicalizeListenerAddr(addr, "192.168.1.184")
|
|
if result != "192.168.1.184:5099" {
|
|
t.Fatalf("expected 192.168.1.184:5099, got %q", result)
|
|
}
|
|
}
|
|
|
|
func TestCanonicalizeAddr_AlreadyCanonical_Unchanged(t *testing.T) {
|
|
addr := &net.TCPAddr{IP: net.ParseIP("192.168.1.5"), Port: 5099}
|
|
result := canonicalizeListenerAddr(addr, "10.0.0.1")
|
|
if result != "192.168.1.5:5099" {
|
|
t.Fatalf("expected 192.168.1.5:5099 (unchanged), got %q", result)
|
|
}
|
|
}
|
|
|
|
func TestCanonicalizeAddr_Loopback_Unchanged(t *testing.T) {
|
|
addr := &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 3260}
|
|
result := canonicalizeListenerAddr(addr, "192.168.1.184")
|
|
if result != "127.0.0.1:3260" {
|
|
t.Fatalf("expected 127.0.0.1:3260 (loopback intentional), got %q", result)
|
|
}
|
|
}
|
|
|
|
func TestCanonicalizeAddr_NoAdvertised_FallsBackToOutbound(t *testing.T) {
|
|
addr := &net.TCPAddr{IP: net.IPv4zero, Port: 5099}
|
|
result := canonicalizeListenerAddr(addr, "")
|
|
// Should not be wildcard.
|
|
if strings.HasPrefix(result, "0.0.0.0:") || strings.HasPrefix(result, "[::]:") || strings.HasPrefix(result, ":") {
|
|
t.Fatalf("fallback should produce routable addr, got %q", result)
|
|
}
|
|
if !strings.Contains(result, ":5099") {
|
|
t.Fatalf("port should be preserved, got %q", result)
|
|
}
|
|
}
|
|
|
|
func TestPreferredOutboundIP_NotEmpty(t *testing.T) {
|
|
ip := PreferredOutboundIP()
|
|
if ip == "" {
|
|
t.Skip("no network interface available")
|
|
}
|
|
parsed := net.ParseIP(ip)
|
|
if parsed == nil {
|
|
t.Fatalf("not a valid IP: %q", ip)
|
|
}
|
|
if parsed.IsUnspecified() {
|
|
t.Fatalf("returned unspecified IP: %q", ip)
|
|
}
|
|
}
|