Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
486 lines
18 KiB
Go
486 lines
18 KiB
Go
package topology
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
"google.golang.org/protobuf/reflect/protoreflect"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/stats"
|
|
"github.com/seaweedfs/seaweedfs/weed/storage"
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
)
|
|
|
|
func digestTestNode(t *testing.T) (*Topology, *DataNode) {
|
|
t.Helper()
|
|
topo := NewTopology("digest", nil, 32*1024*1024*1024, 5, false)
|
|
dn := topo.GetOrCreateDataCenter("dc1").GetOrCreateRack("rack1").
|
|
GetOrCreateDataNode("127.0.0.1", 8080, 18080, "", "", map[string]uint32{"": 1000})
|
|
return topo, dn
|
|
}
|
|
|
|
func digestTestVolume(id uint32) *master_pb.VolumeInformationMessage {
|
|
return &master_pb.VolumeInformationMessage{
|
|
Id: id,
|
|
Size: 1024 * 1024,
|
|
Collection: "c",
|
|
FileCount: 10,
|
|
DeleteCount: 1,
|
|
DeletedByteCount: 128,
|
|
ReplicaPlacement: 0,
|
|
Version: 3,
|
|
CompactRevision: 1,
|
|
ModifiedAtSecond: 1700000000,
|
|
}
|
|
}
|
|
|
|
func TestVolumeDigestIsStableAcrossRepeatedHeartbeats(t *testing.T) {
|
|
topo, dn := digestTestNode(t)
|
|
volumes := []*master_pb.VolumeInformationMessage{digestTestVolume(1), digestTestVolume(2), digestTestVolume(3)}
|
|
|
|
topo.SyncDataNodeRegistration(volumes, dn)
|
|
first := dn.VolumeDigest()
|
|
if first == 0 {
|
|
t.Fatal("expected a non-zero digest for a node holding volumes")
|
|
}
|
|
for i := 0; i < 3; i++ {
|
|
topo.SyncDataNodeRegistration(volumes, dn)
|
|
if got := dn.VolumeDigest(); got != first {
|
|
t.Fatalf("heartbeat %d changed the digest with no change to report: %d != %d", i, got, first)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestVolumeDigestIsIndependentOfReportOrder(t *testing.T) {
|
|
topoA, dnA := digestTestNode(t)
|
|
topoA.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{
|
|
digestTestVolume(1), digestTestVolume(2), digestTestVolume(3),
|
|
}, dnA)
|
|
|
|
topoB, dnB := digestTestNode(t)
|
|
topoB.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{
|
|
digestTestVolume(3), digestTestVolume(1), digestTestVolume(2),
|
|
}, dnB)
|
|
|
|
if dnA.VolumeDigest() != dnB.VolumeDigest() {
|
|
t.Errorf("digest depends on report order: %d != %d", dnA.VolumeDigest(), dnB.VolumeDigest())
|
|
}
|
|
}
|
|
|
|
// Every field of VolumeInformationMessage has to reach the digest: one the hash
|
|
// skips is a change the master would never be told about. Enumerated from the
|
|
// message rather than listed here, so a field added later cannot quietly fall
|
|
// outside the digest while this still passes.
|
|
// Fields a server reports that the master deliberately does not keep, so a
|
|
// change to one alters nothing it holds and the digest is right not to move.
|
|
var notRetainedByTheMaster = map[string]string{
|
|
"remote_storage_key": "unique per volume, and the master decides nothing from it",
|
|
}
|
|
|
|
func TestVolumeDigestTracksEveryReportedField(t *testing.T) {
|
|
base := digestTestVolume(1)
|
|
baseInfo, err := storage.NewVolumeInfo(base)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
fields := base.ProtoReflect().Descriptor().Fields()
|
|
for i := 0; i < fields.Len(); i++ {
|
|
fd := fields.Get(i)
|
|
t.Run(string(fd.Name()), func(t *testing.T) {
|
|
why, skipped := notRetainedByTheMaster[string(fd.Name())]
|
|
candidates := distinctValuesFor(t, fd, base.ProtoReflect().Get(fd))
|
|
for _, candidate := range candidates {
|
|
changed := proto.Clone(base).(*master_pb.VolumeInformationMessage)
|
|
changed.ProtoReflect().Set(fd, candidate)
|
|
changedInfo, err := storage.NewVolumeInfo(changed)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if baseInfo.ReportHash() != changedInfo.ReportHash() {
|
|
if skipped {
|
|
t.Errorf("%s moves the digest, but is listed as not retained by the master (%s)", fd.Name(), why)
|
|
}
|
|
return
|
|
}
|
|
}
|
|
if skipped {
|
|
return
|
|
}
|
|
t.Errorf("no change to %s moves the digest, so the master would never be told about one", fd.Name())
|
|
})
|
|
}
|
|
}
|
|
|
|
// distinctValuesFor offers values that differ from current. Several, because
|
|
// some fields are narrowed or normalised on the way into VolumeInfo and the
|
|
// smallest change to the wire value can land back on the stored one.
|
|
func distinctValuesFor(t *testing.T, fd protoreflect.FieldDescriptor, current protoreflect.Value) []protoreflect.Value {
|
|
t.Helper()
|
|
switch fd.Kind() {
|
|
case protoreflect.BoolKind:
|
|
return []protoreflect.Value{protoreflect.ValueOfBool(!current.Bool())}
|
|
case protoreflect.Uint32Kind:
|
|
return []protoreflect.Value{
|
|
protoreflect.ValueOfUint32(uint32(current.Uint()) + 1),
|
|
protoreflect.ValueOfUint32(uint32(current.Uint()) + 1<<8),
|
|
protoreflect.ValueOfUint32(uint32(current.Uint()) + 1<<16),
|
|
}
|
|
case protoreflect.Uint64Kind:
|
|
return []protoreflect.Value{protoreflect.ValueOfUint64(current.Uint() + 1)}
|
|
case protoreflect.Int64Kind:
|
|
return []protoreflect.Value{protoreflect.ValueOfInt64(current.Int() + 1)}
|
|
case protoreflect.StringKind:
|
|
return []protoreflect.Value{protoreflect.ValueOfString(current.String() + "x")}
|
|
}
|
|
t.Fatalf("field %s has kind %s, which this test does not know how to vary", fd.Name(), fd.Kind())
|
|
return nil
|
|
}
|
|
|
|
func TestVolumeDigestFollowsVolumeChanges(t *testing.T) {
|
|
topo, dn := digestTestNode(t)
|
|
volumes := []*master_pb.VolumeInformationMessage{digestTestVolume(1), digestTestVolume(2)}
|
|
topo.SyncDataNodeRegistration(volumes, dn)
|
|
original := dn.VolumeDigest()
|
|
|
|
grown := []*master_pb.VolumeInformationMessage{digestTestVolume(1), digestTestVolume(2)}
|
|
grown[1].Size += 4096
|
|
topo.SyncDataNodeRegistration(grown, dn)
|
|
if dn.VolumeDigest() == original {
|
|
t.Error("a volume that grew left the digest unchanged")
|
|
}
|
|
|
|
topo.SyncDataNodeRegistration(volumes, dn)
|
|
if dn.VolumeDigest() != original {
|
|
t.Error("reverting a volume did not restore the digest")
|
|
}
|
|
|
|
topo.SyncDataNodeRegistration(volumes[:1], dn)
|
|
if dn.VolumeDigest() == original {
|
|
t.Error("dropping a volume left the digest unchanged")
|
|
}
|
|
|
|
topo.SyncDataNodeRegistration(volumes, dn)
|
|
if dn.VolumeDigest() != original {
|
|
t.Error("restoring a dropped volume did not restore the digest")
|
|
}
|
|
}
|
|
|
|
func TestVolumeDigestEmptiesWithTheNode(t *testing.T) {
|
|
topo, dn := digestTestNode(t)
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{
|
|
digestTestVolume(1), digestTestVolume(2),
|
|
}, dn)
|
|
|
|
topo.SyncDataNodeRegistration(nil, dn)
|
|
if got := dn.VolumeDigest(); got != 0 {
|
|
t.Errorf("expected an empty node to digest to 0, got %d", got)
|
|
}
|
|
}
|
|
|
|
func TestVolumeDigestFollowsDeltaRegistration(t *testing.T) {
|
|
topo, dn := digestTestNode(t)
|
|
full := []*master_pb.VolumeInformationMessage{digestTestVolume(1), digestTestVolume(2)}
|
|
topo.SyncDataNodeRegistration(full, dn)
|
|
both := dn.VolumeDigest()
|
|
|
|
topo.IncrementalSyncDataNodeRegistration(nil, []*master_pb.VolumeShortInformationMessage{{Id: 2}}, dn)
|
|
if dn.VolumeDigest() == both {
|
|
t.Error("unmounting a volume left the digest unchanged")
|
|
}
|
|
|
|
topo.SyncDataNodeRegistration(full, dn)
|
|
if dn.VolumeDigest() != both {
|
|
t.Error("a full heartbeat did not restore the digest after an unmount")
|
|
}
|
|
}
|
|
|
|
// The point of the digest is not to detect that volumes changed -- in any live
|
|
// cluster some always have. It is to confirm that after applying the changes a
|
|
// heartbeat did carry, the master holds what the volume server holds. So a
|
|
// heartbeat reporting only the volumes that moved must still reconcile.
|
|
func TestVolumeDigestMatchesAfterApplyingOnlyChangedVolumes(t *testing.T) {
|
|
const total = 50
|
|
full := make([]*master_pb.VolumeInformationMessage, 0, total)
|
|
for i := 1; i <= total; i++ {
|
|
v := digestTestVolume(uint32(i))
|
|
v.ReadOnly = i > 5 // only the first few are writable, as in a tiered cluster
|
|
full = append(full, v)
|
|
}
|
|
|
|
topo, dn := digestTestNode(t)
|
|
topo.SyncDataNodeRegistration(full, dn)
|
|
|
|
// Three writable volumes take writes between two heartbeats.
|
|
changed := make([]storage.VolumeInfo, 0, 3)
|
|
for _, v := range full[:3] {
|
|
v.Size += 4096
|
|
v.FileCount++
|
|
v.ModifiedAtSecond += 5
|
|
vi, err := storage.NewVolumeInfo(v)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
changed = append(changed, vi)
|
|
}
|
|
|
|
// What the volume server would now report for its whole set.
|
|
reference, referenceNode := digestTestNode(t)
|
|
reference.SyncDataNodeRegistration(full, referenceNode)
|
|
want := referenceNode.VolumeDigest()
|
|
|
|
if dn.VolumeDigest() == want {
|
|
t.Fatal("expected the master to be behind before the changes are applied")
|
|
}
|
|
|
|
// The heartbeat carries three volumes, not fifty.
|
|
dn.DeltaUpdateVolumes(changed, nil)
|
|
|
|
if got := dn.VolumeDigest(); got != want {
|
|
t.Errorf("digest still disagrees after applying the reported changes: %d != %d", got, want)
|
|
}
|
|
}
|
|
|
|
// A volume that disappears without a delta is exactly what the full list exists
|
|
// to catch, and is the case the digest has to keep catching.
|
|
func TestVolumeDigestCatchesASilentlyLostVolume(t *testing.T) {
|
|
full := []*master_pb.VolumeInformationMessage{
|
|
digestTestVolume(1), digestTestVolume(2), digestTestVolume(3),
|
|
}
|
|
|
|
topo, dn := digestTestNode(t)
|
|
topo.SyncDataNodeRegistration(full, dn)
|
|
|
|
// The volume server no longer has volume 2 and never got to say so.
|
|
reference, referenceNode := digestTestNode(t)
|
|
reference.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{full[0], full[2]}, referenceNode)
|
|
|
|
if dn.VolumeDigest() == referenceNode.VolumeDigest() {
|
|
t.Error("a volume lost without a delta went undetected, which is what the full list is for")
|
|
}
|
|
}
|
|
|
|
// The disk map and the lookup index are maintained separately, and a disconnect
|
|
// racing a reconnect has been seen to drop a volume from the lookup index while
|
|
// leaving it on the node. The volume server's report is identical either way, so
|
|
// the heartbeat digest cannot see it and the master has to notice on its own.
|
|
func TestVolumeIndexDigestSeesLookupDivergence(t *testing.T) {
|
|
topo, dn := digestTestNode(t)
|
|
v := digestTestVolume(1)
|
|
v.Collection = "drr"
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{v}, dn)
|
|
|
|
if !dn.HasConsistentVolumeIndex() {
|
|
t.Fatal("a freshly registered node should have a consistent index")
|
|
}
|
|
reported := dn.VolumeDigest()
|
|
|
|
rp, _ := super_block.NewReplicaPlacementFromString("000")
|
|
vl := topo.GetVolumeLayout("drr", rp, needle.EMPTY_TTL, types.HardDriveType)
|
|
vl.SetVolumeUnavailable(dn, needle.VolumeId(1))
|
|
|
|
if got := topo.Lookup("drr", needle.VolumeId(1)); got != nil {
|
|
t.Fatalf("expected the volume to have become unservable, got %v", got)
|
|
}
|
|
if _, err := dn.GetVolumesById(needle.VolumeId(1)); err != nil {
|
|
t.Fatalf("the volume should still be on the node: %v", err)
|
|
}
|
|
if dn.VolumeDigest() != reported {
|
|
t.Error("the reported digest should not move: the volume server sees no change")
|
|
}
|
|
if dn.HasConsistentVolumeIndex() {
|
|
t.Error("a volume held but not servable left the index digests agreeing, so nothing would repair it")
|
|
}
|
|
|
|
// The full heartbeat self-heal puts it back.
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{v}, dn)
|
|
if !dn.HasConsistentVolumeIndex() {
|
|
t.Error("the self-heal did not restore index consistency")
|
|
}
|
|
}
|
|
|
|
func TestVolumeIndexDigestFollowsNodeLifecycle(t *testing.T) {
|
|
topo, dn := digestTestNode(t)
|
|
full := []*master_pb.VolumeInformationMessage{digestTestVolume(1), digestTestVolume(2), digestTestVolume(3)}
|
|
topo.SyncDataNodeRegistration(full, dn)
|
|
if !dn.HasConsistentVolumeIndex() {
|
|
t.Fatal("registration left the indexes disagreeing")
|
|
}
|
|
|
|
topo.SyncDataNodeRegistration(full[:2], dn)
|
|
if !dn.HasConsistentVolumeIndex() {
|
|
t.Error("dropping a volume left the indexes disagreeing")
|
|
}
|
|
|
|
topo.IncrementalSyncDataNodeRegistration(
|
|
[]*master_pb.VolumeShortInformationMessage{{Id: 9}}, nil, dn)
|
|
if !dn.HasConsistentVolumeIndex() {
|
|
t.Error("a mount delta left the indexes disagreeing")
|
|
}
|
|
|
|
topo.IncrementalSyncDataNodeRegistration(
|
|
nil, []*master_pb.VolumeShortInformationMessage{{Id: 9}}, dn)
|
|
if !dn.HasConsistentVolumeIndex() {
|
|
t.Error("an unmount delta left the indexes disagreeing")
|
|
}
|
|
|
|
topo.UnRegisterDataNode(dn)
|
|
held, servable := dn.VolumeIndexDigests()
|
|
if held != 0 || servable != 0 {
|
|
t.Errorf("an unregistered node should hold nothing: held=%d servable=%d", held, servable)
|
|
}
|
|
}
|
|
|
|
// A volume id mounted on two disks of one server is reported twice with
|
|
// different disk ids, but the master keys volumes by id alone, so it keeps only
|
|
// one copy and its digest can never equal the server's. Resending the full list
|
|
// cannot fix that, so the node has to be excluded from digest comparison
|
|
// entirely rather than resend forever.
|
|
func TestVolumeDigestRefusesDuplicateVolumeIds(t *testing.T) {
|
|
topo, dn := digestTestNode(t)
|
|
|
|
first := digestTestVolume(1)
|
|
second := digestTestVolume(1)
|
|
second.DiskId = 1
|
|
second.Size = first.Size * 2
|
|
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{first, second}, dn)
|
|
if !dn.HasDuplicateVolumeIds() {
|
|
t.Fatal("a volume id reported twice went unnoticed, so the digest would be trusted and never reconcile")
|
|
}
|
|
|
|
firstInfo, err := storage.NewVolumeInfo(first)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
secondInfo, err := storage.NewVolumeInfo(second)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if dn.VolumeDigest() == firstInfo.ReportHash()^secondInfo.ReportHash() {
|
|
t.Error("expected the master to be unable to represent both copies; if it now can, the guard is no longer needed")
|
|
}
|
|
|
|
// Once the stale twin is gone the node is comparable again.
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{first}, dn)
|
|
if dn.HasDuplicateVolumeIds() {
|
|
t.Error("the node stayed marked as duplicated after reporting a clean list")
|
|
}
|
|
if dn.VolumeDigest() != firstInfo.ReportHash() {
|
|
t.Error("digest did not settle on the surviving copy")
|
|
}
|
|
}
|
|
|
|
// Two volume servers can hold one address. GetOrCreateDataNode keys on the id a
|
|
// server reports and deliberately refuses to merge a new id onto an address an
|
|
// older node still claims, while the lookup list keys on address alone -- so
|
|
// registering the second server displaces the first from the lookup entry
|
|
// without either node being told. The digest has to follow the entry, not the
|
|
// node that was passed in.
|
|
func addressSharingNodes(t *testing.T) (*Topology, *DataNode, *DataNode) {
|
|
t.Helper()
|
|
topo := NewTopology("digest", nil, 32*1024*1024*1024, 5, false)
|
|
rack := topo.GetOrCreateDataCenter("dc1").GetOrCreateRack("rack1")
|
|
counts := map[string]uint32{"": 1000}
|
|
old := rack.GetOrCreateDataNode("10.1.2.3", 8080, 18080, "", "n1", counts)
|
|
fresh := rack.GetOrCreateDataNode("10.1.2.3", 8080, 18080, "", "n2", counts)
|
|
if old == fresh {
|
|
t.Skip("address reuse no longer produces two nodes")
|
|
}
|
|
return topo, old, fresh
|
|
}
|
|
|
|
func TestVolumeIndexDigestFollowsDisplacedLookupEntry(t *testing.T) {
|
|
topo, old, fresh := addressSharingNodes(t)
|
|
v := digestTestVolume(1)
|
|
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{v}, old)
|
|
if !old.HasConsistentVolumeIndex() {
|
|
t.Fatal("the first node should be consistent before it is displaced")
|
|
}
|
|
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{v}, fresh)
|
|
|
|
servable := map[*DataNode]bool{}
|
|
for _, dn := range topo.Lookup("", needle.VolumeId(1)) {
|
|
servable[dn] = true
|
|
}
|
|
if servable[old] || !servable[fresh] {
|
|
t.Fatalf("expected the lookup entry to move to the new node, got old=%v fresh=%v",
|
|
servable[old], servable[fresh])
|
|
}
|
|
|
|
if old.HasConsistentVolumeIndex() {
|
|
t.Error("the displaced node still holds the volume and can no longer serve it, so its index must read as inconsistent")
|
|
}
|
|
if !fresh.HasConsistentVolumeIndex() {
|
|
t.Error("the node the lookup entry now names reads as inconsistent")
|
|
}
|
|
}
|
|
|
|
func TestVolumeIndexDigestFollowsRemovedLookupEntry(t *testing.T) {
|
|
topo, old, fresh := addressSharingNodes(t)
|
|
v := digestTestVolume(1)
|
|
topo.SyncDataNodeRegistration([]*master_pb.VolumeInformationMessage{v}, old)
|
|
|
|
// fresh shares old's address, so unregistering through it removes old's
|
|
// lookup entry. The digest must come off the node that was actually removed.
|
|
rp, _ := super_block.NewReplicaPlacementFromString("000")
|
|
vl := topo.GetVolumeLayout("c", rp, needle.EMPTY_TTL, types.HardDriveType)
|
|
vl.SetVolumeUnavailable(fresh, needle.VolumeId(1))
|
|
|
|
if got := topo.Lookup("c", needle.VolumeId(1)); got != nil {
|
|
t.Fatalf("expected the lookup entry to be gone, got %v", got)
|
|
}
|
|
if old.HasConsistentVolumeIndex() {
|
|
t.Error("the removed node still holds the volume and cannot serve it, so its index must read as inconsistent")
|
|
}
|
|
if _, servable := fresh.VolumeIndexDigests(); servable != 0 {
|
|
t.Error("the node that was merely passed in should never have gained the entry")
|
|
}
|
|
}
|
|
|
|
// The two ends must agree on real heartbeat data, not just on hand-built
|
|
// messages: the volume server hashes what it is about to send, the master
|
|
// hashes what it stored from it.
|
|
func TestMasterDigestMatchesWhatAVolumeServerReports(t *testing.T) {
|
|
dir := t.TempDir()
|
|
loc := storage.NewDiskLocation(dir, 100, util.MinFreeSpace{}, "", types.HardDriveType, nil,
|
|
stats.DefaultDiskIOProbeConfig())
|
|
for _, vid := range []needle.VolumeId{1, 2, 3} {
|
|
v, err := storage.NewVolume(loc.Directory, loc.IdxDirectory, "", vid, storage.NeedleMapInMemory,
|
|
&super_block.ReplicaPlacement{}, &needle.TTL{}, 0, needle.GetCurrentVersion(), 0, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
loc.SetVolume(vid, v)
|
|
}
|
|
|
|
reported := make([]*master_pb.VolumeInformationMessage, 0, 3)
|
|
var serverDigest uint64
|
|
for _, vid := range []needle.VolumeId{1, 2, 3} {
|
|
v, _ := loc.FindVolume(vid)
|
|
_, m := v.ToVolumeInformationMessage(nil)
|
|
if m == nil {
|
|
t.Fatalf("volume %d reported nothing", vid)
|
|
}
|
|
vi, err := storage.NewVolumeInfo(m)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
serverDigest ^= vi.ReportHash()
|
|
reported = append(reported, m)
|
|
}
|
|
|
|
topo, dn := digestTestNode(t)
|
|
topo.SyncDataNodeRegistration(reported, dn)
|
|
|
|
if got := dn.VolumeDigest(); got != serverDigest {
|
|
t.Errorf("master digest %d does not match the reporting server's %d", got, serverDigest)
|
|
}
|
|
}
|