Skip to content

Commit

Permalink
Switch visibility related types to internal (cadence-workflow#3770)
Browse files Browse the repository at this point in the history
  • Loading branch information
vytautas-karpavicius authored Nov 19, 2020
1 parent 32b167b commit b0316fa
Show file tree
Hide file tree
Showing 17 changed files with 405 additions and 400 deletions.
123 changes: 62 additions & 61 deletions common/persistence/persistence-tests/visibilityPersistenceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/definition"
p "github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
)

type (
Expand Down Expand Up @@ -71,9 +72,9 @@ func (s *VisibilityPersistenceSuite) TestBasicVisibility() {

testDomainUUID := uuid.New()

workflowExecution := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-workflow-test"),
RunId: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
workflowExecution := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-workflow-test"),
RunID: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
}

startTime := time.Now().Add(time.Second * -5).UnixNano()
Expand Down Expand Up @@ -134,9 +135,9 @@ func (s *VisibilityPersistenceSuite) TestBasicVisibilityTimeSkew() {

testDomainUUID := uuid.New()

workflowExecution := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-workflow-test-time-skew"),
RunId: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
workflowExecution := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-workflow-test-time-skew"),
RunID: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
}

startTime := time.Now().Add(time.Second * -5).UnixNano()
Expand All @@ -156,7 +157,7 @@ func (s *VisibilityPersistenceSuite) TestBasicVisibilityTimeSkew() {
})
s.Nil(err1)
s.Equal(1, len(resp.Executions))
s.Equal(workflowExecution.WorkflowId, resp.Executions[0].Execution.WorkflowId)
s.Equal(workflowExecution.WorkflowID, resp.Executions[0].Execution.WorkflowID)

err2 := s.VisibilityMgr.RecordWorkflowExecutionClosed(ctx, &p.RecordWorkflowExecutionClosedRequest{
DomainUUID: testDomainUUID,
Expand Down Expand Up @@ -195,9 +196,9 @@ func (s *VisibilityPersistenceSuite) TestVisibilityPagination() {

// Create 2 executions
startTime1 := time.Now()
workflowExecution1 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-pagination-test1"),
RunId: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
workflowExecution1 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-pagination-test1"),
RunID: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
}

startReq1 := &p.RecordWorkflowExecutionStartedRequest{
Expand All @@ -211,9 +212,9 @@ func (s *VisibilityPersistenceSuite) TestVisibilityPagination() {
s.Nil(err0)

startTime2 := startTime1.Add(time.Second)
workflowExecution2 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-pagination-test2"),
RunId: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
workflowExecution2 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-pagination-test2"),
RunID: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
}

startReq2 := &p.RecordWorkflowExecutionStartedRequest{
Expand Down Expand Up @@ -272,9 +273,9 @@ func (s *VisibilityPersistenceSuite) TestFilteringByType() {
startTime := time.Now().UnixNano()

// Create 2 executions
workflowExecution1 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-filtering-test1"),
RunId: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
workflowExecution1 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-filtering-test1"),
RunID: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
}
err0 := s.VisibilityMgr.RecordWorkflowExecutionStarted(ctx, &p.RecordWorkflowExecutionStartedRequest{
DomainUUID: testDomainUUID,
Expand All @@ -284,9 +285,9 @@ func (s *VisibilityPersistenceSuite) TestFilteringByType() {
})
s.Nil(err0)

workflowExecution2 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-filtering-test2"),
RunId: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
workflowExecution2 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-filtering-test2"),
RunID: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
}
err1 := s.VisibilityMgr.RecordWorkflowExecutionStarted(ctx, &p.RecordWorkflowExecutionStartedRequest{
DomainUUID: testDomainUUID,
Expand All @@ -308,7 +309,7 @@ func (s *VisibilityPersistenceSuite) TestFilteringByType() {
})
s.Nil(err2)
s.Equal(1, len(resp.Executions))
s.Equal(workflowExecution1.WorkflowId, resp.Executions[0].Execution.WorkflowId)
s.Equal(workflowExecution1.WorkflowID, resp.Executions[0].Execution.WorkflowID)

// Close both executions
err3 := s.VisibilityMgr.RecordWorkflowExecutionClosed(ctx, &p.RecordWorkflowExecutionClosedRequest{
Expand Down Expand Up @@ -355,9 +356,9 @@ func (s *VisibilityPersistenceSuite) TestFilteringByWorkflowID() {
startTime := time.Now().UnixNano()

// Create 2 executions
workflowExecution1 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-filtering-test1"),
RunId: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
workflowExecution1 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-filtering-test1"),
RunID: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
}
err0 := s.VisibilityMgr.RecordWorkflowExecutionStarted(ctx, &p.RecordWorkflowExecutionStartedRequest{
DomainUUID: testDomainUUID,
Expand All @@ -367,9 +368,9 @@ func (s *VisibilityPersistenceSuite) TestFilteringByWorkflowID() {
})
s.Nil(err0)

workflowExecution2 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-filtering-test2"),
RunId: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
workflowExecution2 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-filtering-test2"),
RunID: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
}
err1 := s.VisibilityMgr.RecordWorkflowExecutionStarted(ctx, &p.RecordWorkflowExecutionStartedRequest{
DomainUUID: testDomainUUID,
Expand All @@ -391,7 +392,7 @@ func (s *VisibilityPersistenceSuite) TestFilteringByWorkflowID() {
})
s.Nil(err2)
s.Equal(1, len(resp.Executions))
s.Equal(workflowExecution1.WorkflowId, resp.Executions[0].Execution.WorkflowId)
s.Equal(workflowExecution1.WorkflowID, resp.Executions[0].Execution.WorkflowID)

// Close both executions
err3 := s.VisibilityMgr.RecordWorkflowExecutionClosed(ctx, &p.RecordWorkflowExecutionClosedRequest{
Expand Down Expand Up @@ -438,9 +439,9 @@ func (s *VisibilityPersistenceSuite) TestFilteringByCloseStatus() {
startTime := time.Now().UnixNano()

// Create 2 executions
workflowExecution1 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-filtering-test1"),
RunId: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
workflowExecution1 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-filtering-test1"),
RunID: common.StringPtr("fb15e4b5-356f-466d-8c6d-a29223e5c536"),
}
err0 := s.VisibilityMgr.RecordWorkflowExecutionStarted(ctx, &p.RecordWorkflowExecutionStartedRequest{
DomainUUID: testDomainUUID,
Expand All @@ -450,9 +451,9 @@ func (s *VisibilityPersistenceSuite) TestFilteringByCloseStatus() {
})
s.Nil(err0)

workflowExecution2 := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-filtering-test2"),
RunId: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
workflowExecution2 := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-filtering-test2"),
RunID: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
}
err1 := s.VisibilityMgr.RecordWorkflowExecutionStarted(ctx, &p.RecordWorkflowExecutionStartedRequest{
DomainUUID: testDomainUUID,
Expand All @@ -469,7 +470,7 @@ func (s *VisibilityPersistenceSuite) TestFilteringByCloseStatus() {
WorkflowTypeName: "visibility-workflow",
StartTimestamp: startTime,
CloseTimestamp: time.Now().UnixNano(),
Status: gen.WorkflowExecutionCloseStatusCompleted,
Status: types.WorkflowExecutionCloseStatusCompleted,
})
s.Nil(err2)

Expand All @@ -478,7 +479,7 @@ func (s *VisibilityPersistenceSuite) TestFilteringByCloseStatus() {
Execution: workflowExecution2,
WorkflowTypeName: "visibility-workflow",
StartTimestamp: startTime,
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
CloseTimestamp: time.Now().UnixNano(),
HistoryLength: 3,
}
Expand All @@ -493,7 +494,7 @@ func (s *VisibilityPersistenceSuite) TestFilteringByCloseStatus() {
EarliestTime: startTime,
LatestTime: startTime,
},
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
})
s.Nil(err4)
s.Equal(1, len(resp.Executions))
Expand All @@ -507,9 +508,9 @@ func (s *VisibilityPersistenceSuite) TestGetClosedExecution() {

testDomainUUID := uuid.New()

workflowExecution := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-workflow-test"),
RunId: common.StringPtr("a3dbc7bf-deb1-4946-b57c-cf0615ea553f"),
workflowExecution := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-workflow-test"),
RunID: common.StringPtr("a3dbc7bf-deb1-4946-b57c-cf0615ea553f"),
}

startTime := time.Now().Add(time.Second * -5).UnixNano()
Expand All @@ -535,7 +536,7 @@ func (s *VisibilityPersistenceSuite) TestGetClosedExecution() {
Execution: workflowExecution,
WorkflowTypeName: "visibility-workflow",
StartTimestamp: startTime,
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
CloseTimestamp: time.Now().UnixNano(),
HistoryLength: 3,
}
Expand All @@ -556,9 +557,9 @@ func (s *VisibilityPersistenceSuite) TestClosedWithoutStarted() {
defer cancel()

testDomainUUID := uuid.New()
workflowExecution := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-workflow-test"),
RunId: common.StringPtr("1bdb0122-e8c9-4b35-b6f8-d692ab259b09"),
workflowExecution := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-workflow-test"),
RunID: common.StringPtr("1bdb0122-e8c9-4b35-b6f8-d692ab259b09"),
}

closedResp, err0 := s.VisibilityMgr.GetClosedWorkflowExecution(ctx, &p.GetClosedWorkflowExecutionRequest{
Expand All @@ -575,7 +576,7 @@ func (s *VisibilityPersistenceSuite) TestClosedWithoutStarted() {
Execution: workflowExecution,
WorkflowTypeName: "visibility-workflow",
StartTimestamp: time.Now().Add(time.Second * -5).UnixNano(),
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
CloseTimestamp: time.Now().UnixNano(),
HistoryLength: 3,
}
Expand All @@ -597,9 +598,9 @@ func (s *VisibilityPersistenceSuite) TestMultipleUpserts() {

testDomainUUID := uuid.New()

workflowExecution := gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-workflow-test"),
RunId: common.StringPtr("a3dbc7bf-deb1-4946-b57c-cf0615ea553f"),
workflowExecution := types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-workflow-test"),
RunID: common.StringPtr("a3dbc7bf-deb1-4946-b57c-cf0615ea553f"),
}

startTime := time.Now().Add(time.Second * -5).UnixNano()
Expand All @@ -608,7 +609,7 @@ func (s *VisibilityPersistenceSuite) TestMultipleUpserts() {
Execution: workflowExecution,
WorkflowTypeName: "visibility-workflow",
StartTimestamp: startTime,
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
CloseTimestamp: time.Now().UnixNano(),
HistoryLength: 3,
}
Expand Down Expand Up @@ -650,9 +651,9 @@ func (s *VisibilityPersistenceSuite) TestDelete() {
testDomainUUID := uuid.New()
startTime := time.Now().Add(time.Second * -5).UnixNano()
for i := 0; i < nRows; i++ {
workflowExecution := gen.WorkflowExecution{
WorkflowId: common.StringPtr(uuid.New()),
RunId: common.StringPtr(uuid.New()),
workflowExecution := types.WorkflowExecution{
WorkflowID: common.StringPtr(uuid.New()),
RunID: common.StringPtr(uuid.New()),
}
err0 := s.VisibilityMgr.RecordWorkflowExecutionStarted(ctx, &p.RecordWorkflowExecutionStartedRequest{
DomainUUID: testDomainUUID,
Expand All @@ -666,7 +667,7 @@ func (s *VisibilityPersistenceSuite) TestDelete() {
Execution: workflowExecution,
WorkflowTypeName: "visibility-workflow",
StartTimestamp: startTime,
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
CloseTimestamp: time.Now().UnixNano(),
HistoryLength: 3,
}
Expand All @@ -687,7 +688,7 @@ func (s *VisibilityPersistenceSuite) TestDelete() {
for _, row := range resp.Executions {
err4 := s.VisibilityMgr.DeleteWorkflowExecution(ctx, &p.VisibilityDeleteWorkflowExecutionRequest{
DomainID: testDomainUUID,
RunID: row.GetExecution().GetRunId(),
RunID: row.GetExecution().GetRunID(),
})
s.Nil(err4)
remaining--
Expand Down Expand Up @@ -715,7 +716,7 @@ func (s *VisibilityPersistenceSuite) TestUpsertWorkflowExecution() {
request: &p.UpsertWorkflowExecutionRequest{
DomainUUID: "",
Domain: "",
Execution: gen.WorkflowExecution{},
Execution: types.WorkflowExecution{},
WorkflowTypeName: "",
StartTimestamp: 0,
ExecutionTimestamp: 0,
Expand All @@ -732,7 +733,7 @@ func (s *VisibilityPersistenceSuite) TestUpsertWorkflowExecution() {
request: &p.UpsertWorkflowExecutionRequest{
DomainUUID: "",
Domain: "",
Execution: gen.WorkflowExecution{},
Execution: types.WorkflowExecution{},
WorkflowTypeName: "",
StartTimestamp: 0,
ExecutionTimestamp: 0,
Expand All @@ -751,9 +752,9 @@ func (s *VisibilityPersistenceSuite) TestUpsertWorkflowExecution() {
}

func (s *VisibilityPersistenceSuite) assertClosedExecutionEquals(
req *p.RecordWorkflowExecutionClosedRequest, resp *gen.WorkflowExecutionInfo) {
s.Equal(req.Execution.RunId, resp.Execution.RunId)
s.Equal(req.Execution.WorkflowId, resp.Execution.WorkflowId)
req *p.RecordWorkflowExecutionClosedRequest, resp *types.WorkflowExecutionInfo) {
s.Equal(req.Execution.RunID, resp.Execution.RunID)
s.Equal(req.Execution.WorkflowID, resp.Execution.WorkflowID)
s.Equal(req.WorkflowTypeName, resp.GetType().GetName())
s.Equal(s.nanosToMillis(req.StartTimestamp), s.nanosToMillis(resp.GetStartTime()))
s.Equal(s.nanosToMillis(req.CloseTimestamp), s.nanosToMillis(resp.GetCloseTime()))
Expand All @@ -762,9 +763,9 @@ func (s *VisibilityPersistenceSuite) assertClosedExecutionEquals(
}

func (s *VisibilityPersistenceSuite) assertOpenExecutionEquals(
req *p.RecordWorkflowExecutionStartedRequest, resp *gen.WorkflowExecutionInfo) {
s.Equal(req.Execution.GetRunId(), resp.Execution.GetRunId())
s.Equal(req.Execution.WorkflowId, resp.Execution.WorkflowId)
req *p.RecordWorkflowExecutionStartedRequest, resp *types.WorkflowExecutionInfo) {
s.Equal(req.Execution.GetRunID(), resp.Execution.GetRunID())
s.Equal(req.Execution.WorkflowID, resp.Execution.WorkflowID)
s.Equal(req.WorkflowTypeName, resp.GetType().GetName())
s.Equal(s.nanosToMillis(req.StartTimestamp), s.nanosToMillis(resp.GetStartTime()))
s.Nil(resp.CloseTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
p "github.com/uber/cadence/common/persistence"
c "github.com/uber/cadence/common/service/config"
"github.com/uber/cadence/common/service/dynamicconfig"
"github.com/uber/cadence/common/types"
)

type VisibilitySamplingSuite struct {
Expand All @@ -51,9 +52,9 @@ type VisibilitySamplingSuite struct {
var (
testDomainUUID = "fb15e4b5-356f-466d-8c6d-a29223e5c536"
testDomain = "test-domain-name"
testWorkflowExecution = gen.WorkflowExecution{
WorkflowId: common.StringPtr("visibility-workflow-test"),
RunId: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
testWorkflowExecution = types.WorkflowExecution{
WorkflowID: common.StringPtr("visibility-workflow-test"),
RunID: common.StringPtr("843f6fc7-102a-4c63-a2d4-7c653b01bf52"),
}
testWorkflowTypeName = "visibility-workflow"

Expand Down Expand Up @@ -110,14 +111,14 @@ func (s *VisibilitySamplingSuite) TestRecordWorkflowExecutionClosed() {
Domain: testDomain,
Execution: testWorkflowExecution,
WorkflowTypeName: testWorkflowTypeName,
Status: gen.WorkflowExecutionCloseStatusCompleted,
Status: types.WorkflowExecutionCloseStatusCompleted,
}
request2 := &p.RecordWorkflowExecutionClosedRequest{
DomainUUID: testDomainUUID,
Domain: testDomain,
Execution: testWorkflowExecution,
WorkflowTypeName: testWorkflowTypeName,
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
}

s.persistence.On("RecordWorkflowExecutionClosed", mock.Anything, request).Return(nil).Once()
Expand Down Expand Up @@ -230,7 +231,7 @@ func (s *VisibilitySamplingSuite) TestListOpenWorkflowExecutionsByWorkflowID() {
}
request := &p.ListWorkflowExecutionsByWorkflowIDRequest{
ListWorkflowExecutionsRequest: req,
WorkflowID: testWorkflowExecution.GetWorkflowId(),
WorkflowID: testWorkflowExecution.GetWorkflowID(),
}
s.persistence.On("ListOpenWorkflowExecutionsByWorkflowID", mock.Anything, request).Return(nil, nil).Once()
_, err := s.client.ListOpenWorkflowExecutionsByWorkflowID(ctx, request)
Expand All @@ -254,7 +255,7 @@ func (s *VisibilitySamplingSuite) TestListClosedWorkflowExecutionsByWorkflowID()
}
request := &p.ListWorkflowExecutionsByWorkflowIDRequest{
ListWorkflowExecutionsRequest: req,
WorkflowID: testWorkflowExecution.GetWorkflowId(),
WorkflowID: testWorkflowExecution.GetWorkflowID(),
}
s.persistence.On("ListClosedWorkflowExecutionsByWorkflowID", mock.Anything, request).Return(nil, nil).Once()
_, err := s.client.ListClosedWorkflowExecutionsByWorkflowID(ctx, request)
Expand All @@ -278,7 +279,7 @@ func (s *VisibilitySamplingSuite) TestListClosedWorkflowExecutionsByStatus() {
}
request := &p.ListClosedWorkflowExecutionsByStatusRequest{
ListWorkflowExecutionsRequest: req,
Status: gen.WorkflowExecutionCloseStatusFailed,
Status: types.WorkflowExecutionCloseStatusFailed,
}
s.persistence.On("ListClosedWorkflowExecutionsByStatus", mock.Anything, request).Return(nil, nil).Once()
_, err := s.client.ListClosedWorkflowExecutionsByStatus(ctx, request)
Expand Down
Loading

0 comments on commit b0316fa

Please sign in to comment.