mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
test: reproduce recorded revocation ACK refusal after deadline
This commit is contained in:
1 parent
4b958e03f2
commit
06d6c4441b
1 file changed
+53
@@ -0,0 +1,53 @@
|
||||
package authority
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A successful write whose answer was lost is not a new ACK admission.
|
||||
// Expiring the granted lease must not turn that retry into an exit-75 cycle.
|
||||
func TestRecordedRevocationAckRetryAfterDeadline(t *testing.T) {
|
||||
clock := newTestClock()
|
||||
store := &failingStore{}
|
||||
p := newLeasePublisher(t, store, time.Second, clock)
|
||||
bindAndGrant(t, p, "v", "r")
|
||||
ctx := context.Background()
|
||||
if err := p.BeginWorkspaceRevocation(ctx, "v", "r", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ack := WorkspaceRevokeAck{ReplicaID: "r", Epoch: 1, HeadGen: 7, Holder: "host/r", RemoteLSN: 42}
|
||||
head := WorkspaceHead{Gen: 7, Detached: true, Epoch: 1, Holder: "host/r", RemoteLSN: 42}
|
||||
if err := p.AckWorkspaceRevocation(ctx, "v", ack, head); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recorded := p.WorkspaceState("v")
|
||||
clock.at(100) // the caller lost the answer and repeats after both deadlines
|
||||
if p.WorkspaceLeaseValidity(*recorded.Lease) != 0 {
|
||||
t.Fatal("fixture lease still valid")
|
||||
}
|
||||
if err := p.AckWorkspaceRevocation(ctx, "v", ack, head); err != nil {
|
||||
t.Fatalf("recorded ACK retry after deadline: %v", err)
|
||||
}
|
||||
// Replaying the witness must not persist or renew anything.
|
||||
if !reflect.DeepEqual(recorded, p.WorkspaceState("v")) {
|
||||
t.Fatal("retry changed the recorded state")
|
||||
}
|
||||
for _, mutate := range []func(*WorkspaceRevokeAck, *WorkspaceHead){
|
||||
func(a *WorkspaceRevokeAck, h *WorkspaceHead) { a.ReplicaID = "other" },
|
||||
func(a *WorkspaceRevokeAck, h *WorkspaceHead) { a.Epoch++; h.Epoch++ },
|
||||
func(a *WorkspaceRevokeAck, h *WorkspaceHead) { a.Holder = "other/r"; h.Holder = a.Holder },
|
||||
func(a *WorkspaceRevokeAck, h *WorkspaceHead) { h.RemoteLSN++ },
|
||||
} {
|
||||
a, h := ack, head
|
||||
mutate(&a, &h)
|
||||
if err := p.AckWorkspaceRevocation(ctx, "v", a, h); err == nil {
|
||||
t.Fatalf("changed stop accepted: %+v %+v", a, h)
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(recorded, p.WorkspaceState("v")) {
|
||||
t.Fatal("changed retry modified the recorded state")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user