501
}
502
503
>
func (s *HistoryEventsSuite) TestAppendForkSelectTrim_LastBranch() {
history_store.go
504
>
treeID := uuid.NewString()
505
>
branchID := uuid.NewString()
506
>
branchToken, err := s.store.GetHistoryBranchUtil().NewHistoryBranch(
507
>
uuid.NewString(),
508
>
uuid.NewString(),
509
>
uuid.NewString(),
510
>
treeID,
511
>
&branchID,
512
>
[]*persistencespb.HistoryBranchRange{},
513
>
time.Duration(0),
514
>
time.Duration(0),
515
>
time.Duration(0),
516
>
)
517
>
s.NoError(err)
518
>
var events []*historypb.HistoryEvent
519
>
520
>
eventsPacket0 := s.newHistoryEvents(
521
>
[]int64{1, 2, 3},
522
>
rand.Int63(),
523
>
0,
524
>
)
525
>
s.appendHistoryEvents(s.ShardID, branchToken, eventsPacket0)
526
>
events = append(events, eventsPacket0.events...)
527
>
528
>
s.appendHistoryEvents(s.ShardID, branchToken, s.newHistoryEvents(
529
>
[]int64{4, 5},
530
>
eventsPacket0.transactionID+1,
531
>
eventsPacket0.transactionID,
532
>
))
533
>
534
>
newBranchToken := s.forkHistoryBranch(s.ShardID, branchToken, 4)
535
>
eventsPacket1 := s.newHistoryEvents(
536
>
[]int64{4, 5},
537
>
eventsPacket0.transactionID+2,
538
>
eventsPacket0.transactionID,
539
>
)
540
>
s.appendHistoryEvents(s.ShardID, newBranchToken, eventsPacket1)
541
>
events = append(events, eventsPacket1.events...)
542
>
543
>
s.appendHistoryEvents(s.ShardID, newBranchToken, s.newHistoryEvents(
544
>
[]int64{4, 5},
545
>
eventsPacket0.transactionID+3,
546
>
eventsPacket0.transactionID,
547
>
))
548
>
549
>
s.trimHistoryBranch(s.ShardID, newBranchToken, eventsPacket1.nodeID, eventsPacket1.transactionID)
550
>
551
>
protorequire.ProtoSliceEqual(s.T(), events, s.listAllHistoryEvents(s.ShardID, newBranchToken))
552
>
}
553
554
func (s *HistoryEventsSuite) TestAppendBatches() {