Skip to content

Commit

Permalink
Add more data base test for create workflow execution (cadence-workfl…
Browse files Browse the repository at this point in the history
  • Loading branch information
wxing1292 authored Apr 10, 2019
1 parent 3eb8ab5 commit 0f70455
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 8 deletions.
47 changes: 45 additions & 2 deletions common/persistence/persistence-tests/executionManagerTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func (s *ExecutionManagerSuite) TestCreateWorkflowExecutionRunIDReuseWithReplica
WorkflowId: workflowExecution.WorkflowId,
RunId: common.StringPtr(uuid.New()),
}

// try to create a workflow while the current workflow is still running
_, err := s.ExecutionManager.CreateWorkflowExecution(&p.CreateWorkflowExecutionRequest{
RequestID: uuid.New(),
DomainID: domainID,
Expand All @@ -154,7 +156,7 @@ func (s *ExecutionManagerSuite) TestCreateWorkflowExecutionRunIDReuseWithReplica
RangeID: s.ShardInfo.RangeID,
CreateWorkflowMode: p.CreateWorkflowModeWorkflowIDReuse,
PreviousRunID: workflowExecution.GetRunId(),
PreviousLastWriteVersion: common.EmptyVersion,
PreviousLastWriteVersion: version,
ReplicationState: replicationState,
})
s.NotNil(err)
Expand Down Expand Up @@ -191,6 +193,47 @@ func (s *ExecutionManagerSuite) TestCreateWorkflowExecutionRunIDReuseWithReplica
})
s.NoError(err)

// try to create a workflow while the current workflow is complete but run ID is wrong
_, err = s.ExecutionManager.CreateWorkflowExecution(&p.CreateWorkflowExecutionRequest{
RequestID: uuid.New(),
DomainID: domainID,
Execution: newExecution,
TaskList: tasklist,
WorkflowTypeName: workflowType,
WorkflowTimeout: workflowTimeout,
DecisionTimeoutValue: decisionTimeout,
NextEventID: nextEventID,
LastProcessedEvent: lastProcessedEventID,
RangeID: s.ShardInfo.RangeID,
CreateWorkflowMode: p.CreateWorkflowModeWorkflowIDReuse,
PreviousRunID: uuid.New(),
PreviousLastWriteVersion: version,
ReplicationState: replicationState,
})
s.NotNil(err)
s.IsType(&p.CurrentWorkflowConditionFailedError{}, err, err.Error())

// try to create a workflow while the current workflow is complete but version is wrong
_, err = s.ExecutionManager.CreateWorkflowExecution(&p.CreateWorkflowExecutionRequest{
RequestID: uuid.New(),
DomainID: domainID,
Execution: newExecution,
TaskList: tasklist,
WorkflowTypeName: workflowType,
WorkflowTimeout: workflowTimeout,
DecisionTimeoutValue: decisionTimeout,
NextEventID: nextEventID,
LastProcessedEvent: lastProcessedEventID,
RangeID: s.ShardInfo.RangeID,
CreateWorkflowMode: p.CreateWorkflowModeWorkflowIDReuse,
PreviousRunID: workflowExecution.GetRunId(),
PreviousLastWriteVersion: version - 1,
ReplicationState: replicationState,
})
s.NotNil(err)
s.IsType(&p.CurrentWorkflowConditionFailedError{}, err, err.Error())

// try to create a workflow while the current workflow is complete with run ID & version correct
_, err = s.ExecutionManager.CreateWorkflowExecution(&p.CreateWorkflowExecutionRequest{
RequestID: uuid.New(),
DomainID: domainID,
Expand All @@ -207,7 +250,7 @@ func (s *ExecutionManagerSuite) TestCreateWorkflowExecutionRunIDReuseWithReplica
PreviousLastWriteVersion: version,
ReplicationState: replicationState,
})
s.NoError(err)
s.Nil(err)
}

// TestCreateWorkflowExecutionRunIDReuseWithoutReplication test
Expand Down
22 changes: 16 additions & 6 deletions environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@ import (
)

const (
// Localhost default localhost
Localhost = "127.0.0.1"

CassandraSeeds = "CASSANDRA_SEEDS"
CassandraPort = "CASSANDRA_PORT"
// CassandraSeeds env
CassandraSeeds = "CASSANDRA_SEEDS"
// CassandraPort env
CassandraPort = "CASSANDRA_PORT"
// CassandraDefaultPort Cassandra default port
CassandraDefaultPort = "9042"

MySQLSeeds = "MYSQL_SEEDS"
MySQLPort = "MYSQL_PORT"
// MySQLSeeds env
MySQLSeeds = "MYSQL_SEEDS"
// MySQLPort env
MySQLPort = "MYSQL_PORT"
// MySQLDefaultPort MySQL default port
MySQLDefaultPort = "3306"

KafkaSeeds = "KAFKA_SEEDS"
KafkaPort = "KAFKA_PORT"
// KafkaSeeds env
KafkaSeeds = "KAFKA_SEEDS"
// KafkaPort env
KafkaPort = "KAFKA_PORT"
// KafkaDefaultPort Kafka default port
KafkaDefaultPort = "9092"
)

Expand Down

0 comments on commit 0f70455

Please sign in to comment.