SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
package shell
import (
"reflect"
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
)
func TestVolumeServerAddressesUseRegisteredGrpcPort(t *testing.T) {
dataNodes := []*master_pb.DataNodeInfo{
{Id: "10.0.0.1:8080", Address: "10.0.0.1:8080", GrpcPort: 18080},
{Id: "10.0.0.2:7000", Address: "10.0.0.2:7000", GrpcPort: 7500},
{Id: "10.0.0.3:8081"},
}
tests := []struct {
nodes string
wantGrpc []string
}{
{"", []string{"10.0.0.1:18080", "10.0.0.2:7500", "10.0.0.3:18081"}},
{"10.0.0.2:7000", []string{"10.0.0.2:7500"}},
{" 10.0.0.2:7000 ,,10.0.0.1:8080", []string{"10.0.0.2:7500", "10.0.0.1:18080"}},
{"10.0.0.9:7000.7600", []string{"10.0.0.9:7600"}},
{"10.0.0.2:7000.7600", []string{"10.0.0.2:7600"}},
}
for _, tt := range tests {
var gotGrpc []string
for _, addr := range volumeServerAddresses(dataNodes, tt.nodes) {
gotGrpc = append(gotGrpc, addr.ToGrpcAddress())
}
if !reflect.DeepEqual(gotGrpc, tt.wantGrpc) {
t.Errorf("volumeServerAddresses(%q) dials %v, want %v", tt.nodes, gotGrpc, tt.wantGrpc)
}
}
}
func TestEveryNodeNamesGrpcPort(t *testing.T) {
tests := []struct {
nodes string
want bool
}{
{"10.0.0.9:7000.7600", true},
{" 10.0.0.9:7000.7600 ,,[::1]:8080.18080", true},
{"10.0.0.9:7000.7600,10.0.0.2:7000", false},
{"10.0.0.2:7000", false},
{"volume.example.com", false},
{"volume.example.com:8080", false},
}
for _, tt := range tests {
if got := everyNodeNamesGrpcPort(tt.nodes); got != tt.want {
t.Errorf("everyNodeNamesGrpcPort(%q) = %v, want %v", tt.nodes, got, tt.want)
}
}
}