661
}
662
663
>
func (s *HistoryEventsSuite) TestForkDeleteBranch_DeleteForkedBranchFirst() {
history_store.go
664
>
treeID := uuid.NewString()
665
>
branchID := uuid.NewString()
666
>
br1Token, err := s.store.GetHistoryBranchUtil().NewHistoryBranch(
667
>
uuid.NewString(),
668
>
uuid.NewString(),
669
>
uuid.NewString(),
670
>
treeID,
671
>
&branchID,
672
>
[]*persistencespb.HistoryBranchRange{},
673
>
time.Duration(0),
674
>
time.Duration(0),
675
>
time.Duration(0),
676
>
)
677
>
s.NoError(err)
678
>
679
>
transactionID := rand.Int63()
680
>
eventsPacket0 := s.newHistoryEvents(
681
>
[]int64{1, 2, 3},
682
>
transactionID,
683
>
0,
684
>
)
685
>
s.appendHistoryEvents(s.ShardID, br1Token, eventsPacket0)
686
>
eventsPacket1 := s.newHistoryEvents(
687
>
[]int64{4, 5},
688
>
transactionID+1,
689
>
transactionID,
690
>
)
691
>
s.appendHistoryEvents(s.ShardID, br1Token, eventsPacket1)
692
>
693
>
br2Token := s.forkHistoryBranch(s.ShardID, br1Token, 4)
694
>
s.appendHistoryEvents(s.ShardID, br2Token, s.newHistoryEvents(
695
>
[]int64{4, 5},
696
>
transactionID+2,
697
>
transactionID,
698
>
))
699
>
700
>
// delete branch2, should only delete branch2:[4,5], keep branch1:[1,2,3] [4,5] as it is by branch1
701
>
s.deleteHistoryBranch(s.ShardID, br2Token)
702
>
// verify branch1 is not affected
703
>
protorequire.ProtoSliceEqual(s.T(), append(eventsPacket0.events, eventsPacket1.events...), s.listAllHistoryEvents(s.ShardID, br1Token))
704
>
705
>
// branch2:[4,5] should be deleted
706
>
_, err = s.store.ReadHistoryBranch(s.Ctx, &p.ReadHistoryBranchRequest{
707
>
ShardID: s.ShardID,
708
>
BranchToken: br2Token,
709
>
MinEventID: 4,
710
>
MaxEventID: common.LastEventID,
711
>
PageSize: 1,
712
>
})
713
>
s.Error(err, "Workflow execution history not found.")
714
>
715
>
// delete branch1, should delete branch1:[1,2,3] [4,5]
716
>
s.deleteHistoryBranch(s.ShardID, br1Token)
717
>
718
>
// branch1 should be deleted
719
>
_, err = s.store.ReadHistoryBranch(s.Ctx, &p.ReadHistoryBranchRequest{
720
>
ShardID: s.ShardID,
721
>
BranchToken: br1Token,
722
>
MinEventID: common.FirstEventID,
723
>
MaxEventID: common.LastEventID,
724
>
PageSize: 1,
725
>
})
726
>
s.Error(err, "Workflow execution history not found.")
727
>
}
728
729
func (s *HistoryEventsSuite) appendHistoryEvents(