Example #1
0
func (s *simulationStateManager) startWorkflowExecution() error {
	_, err := s.swfAPI.StartWorkflowExecution(&swf.StartWorkflowExecutionInput{
		Domain:                       sugar.S(config.Viper.GetString("env")),
		WorkflowId:                   sugar.S(uuid.NewV4().String()),
		ExecutionStartToCloseTimeout: sugar.S("120"),
		TaskStartToCloseTimeout:      sugar.S("120"),
		ChildPolicy:                  sugar.S(swf.ChildPolicyTerminate),
		//you will have previously regiestered a WorkflowType that this FSM will work.
		WorkflowType: &swf.WorkflowType{Name: sugar.S(config.Workflow.Name), Version: sugar.S(config.Workflow.Version)},
		Input:        fsm.StartFSMWorkflowInput(s.FSM, &StateData{SimulationResultID: 10, CustomerID: 1, S3SimulationFolder: "folder/test"}),
	})
	if err != nil {
		panic(err)
	}
	return nil
}
Example #2
0
func TestFSMWhenStartingNewWorkflowExpectsPreprocScheduled(t *testing.T) {
	// arrange
	// {"CustomerId": 1, "SimulationResultId": 172, "S3SimulationFolder": "Customer_1/simulation172_2016-01-22"}

	simulationStateManager := &simulationStateManager{}
	simulationStateManager.FSM = simulationStateManager.setupFSM()
	events := []*swf.HistoryEvent{
		&swf.HistoryEvent{EventType: sugar.S("DecisionTaskStarted"), EventId: sugar.I(3)},
		&swf.HistoryEvent{EventType: sugar.S("DecisionTaskScheduled"), EventId: sugar.I(2)},
		sugar.EventFromPayload(1, &swf.WorkflowExecutionStartedEventAttributes{
			Input: fsm.StartFSMWorkflowInput(simulationStateManager.FSM, testData),
		}),
	}
	firstDecisionTask := testDecisionTask(0, events)

	// act
	_, decisions, _, err := simulationStateManager.Tick(firstDecisionTask)

	// assert
	assert.Nil(t, err, "Should be no errors")
	assert.NotNil(t, decisions, "Should have returned some decisions")
	assert.True(t, Find(decisions, scheduleActivityPredicateFunc("preproc")), "Should have scheduled preproc")
}