Skip to content

maybe fix test? #6812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions common/persistence/persistence-tests/historyV2PersistenceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/backoff"
"github.com/uber/cadence/common/codec"
"github.com/uber/cadence/common/persistence"
p "github.com/uber/cadence/common/persistence"
persistenceutils "github.com/uber/cadence/common/persistence/persistence-utils"
"github.com/uber/cadence/common/types"
Expand Down Expand Up @@ -87,6 +88,32 @@ func (s *HistoryV2PersistenceSuite) SetupSuite() {
}
}

func (s *HistoryV2PersistenceSuite) AfterTest(_, _ string) {
// ensure there's no leftover trees in the database
// between tests
if os.Getenv("SKIP_SCAN_HISTORY") != "" {
s.T().Skipf("GetAllHistoryTreeBranches not supported in %v", s.TaskMgr.GetName())
}
ctx, cancel := context.WithTimeout(context.Background(), largeTestContextTimeout)
defer cancel()

resp, err := s.HistoryV2Mgr.GetAllHistoryTreeBranches(ctx, &p.GetAllHistoryTreeBranchesRequest{
PageSize: 1,
})
s.Nil(err)
for _, br := range resp.Branches {
branchToken, err := persistence.NewHistoryBranchTokenByBranchID(br.TreeID, br.BranchID)
s.Nil(err)

s.HistoryV2Mgr.DeleteHistoryBranch(ctx, &p.DeleteHistoryBranchRequest{
BranchToken: branchToken,
ShardID: common.IntPtr(0),
})
s.Nil(err)
}
s.Equal(0, len(resp.Branches), "some trees were leaked in other tests")
}

// SetupTest implementation
func (s *HistoryV2PersistenceSuite) SetupTest() {
// Have to define our overridden assertions in the test setup. If we did it earlier, s.T() will return nil
Expand Down Expand Up @@ -122,18 +149,9 @@ func (s *HistoryV2PersistenceSuite) TestGenUUIDs() {

// TestScanAllTrees test
func (s *HistoryV2PersistenceSuite) TestScanAllTrees() {
if os.Getenv("SKIP_SCAN_HISTORY") != "" {
s.T().Skipf("GetAllHistoryTreeBranches not supported in %v", s.TaskMgr.GetName())
}
ctx, cancel := context.WithTimeout(context.Background(), largeTestContextTimeout)
ctx, cancel := context.WithTimeout(context.Background(), testContextTimeout)
defer cancel()

resp, err := s.HistoryV2Mgr.GetAllHistoryTreeBranches(ctx, &p.GetAllHistoryTreeBranchesRequest{
PageSize: 1,
})
s.Nil(err)
s.Equal(0, len(resp.Branches), "some trees were leaked in other tests")

trees := map[string]bool{}
totalTrees := 1002
pgSize := 100
Expand Down
Loading