How to use run method of execution Package

Best Gauge code snippet using execution.run

history_execution_child_workflow_test.go

Source:history_execution_child_workflow_test.go Github

copy

Full Screen

...65func (s *historyExecutionChildWorkflowSuite) TestReplace_Single() {66 shardID := rand.Int31()67 namespaceID := primitives.NewUUID()68 workflowID := shuffle.String(testHistoryExecutionWorkflowID)69 runID := primitives.NewUUID()70 initiatedID := rand.Int63()71 childWorkflow := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, initiatedID)72 result, err := s.store.ReplaceIntoChildExecutionInfoMaps(newExecutionContext(), []sqlplugin.ChildExecutionInfoMapsRow{childWorkflow})73 s.NoError(err)74 rowsAffected, err := result.RowsAffected()75 s.NoError(err)76 s.Equal(1, int(rowsAffected))77}78func (s *historyExecutionChildWorkflowSuite) TestReplace_Multiple() {79 shardID := rand.Int31()80 namespaceID := primitives.NewUUID()81 workflowID := shuffle.String(testHistoryExecutionWorkflowID)82 runID := primitives.NewUUID()83 childWorkflow1 := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, rand.Int63())84 childWorkflow2 := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, rand.Int63())85 result, err := s.store.ReplaceIntoChildExecutionInfoMaps(newExecutionContext(), []sqlplugin.ChildExecutionInfoMapsRow{childWorkflow1, childWorkflow2})86 s.NoError(err)87 rowsAffected, err := result.RowsAffected()88 s.NoError(err)89 s.Equal(2, int(rowsAffected))90}91func (s *historyExecutionChildWorkflowSuite) TestReplaceSelect_Single() {92 shardID := rand.Int31()93 namespaceID := primitives.NewUUID()94 workflowID := shuffle.String(testHistoryExecutionWorkflowID)95 runID := primitives.NewUUID()96 initiatedID := rand.Int63()97 childWorkflow := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, initiatedID)98 result, err := s.store.ReplaceIntoChildExecutionInfoMaps(newExecutionContext(), []sqlplugin.ChildExecutionInfoMapsRow{childWorkflow})99 s.NoError(err)100 rowsAffected, err := result.RowsAffected()101 s.NoError(err)102 s.Equal(1, int(rowsAffected))103 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{104 ShardID: shardID,105 NamespaceID: namespaceID,106 WorkflowID: workflowID,107 RunID: runID,108 }109 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)110 s.NoError(err)111 rowMap := map[int64]sqlplugin.ChildExecutionInfoMapsRow{}112 for _, childWorkflow := range rows {113 rowMap[childWorkflow.InitiatedID] = childWorkflow114 }115 s.Equal(map[int64]sqlplugin.ChildExecutionInfoMapsRow{116 childWorkflow.InitiatedID: childWorkflow,117 }, rowMap)118}119func (s *historyExecutionChildWorkflowSuite) TestReplaceSelect_Multiple() {120 numChildWorkflows := 20121 shardID := rand.Int31()122 namespaceID := primitives.NewUUID()123 workflowID := shuffle.String(testHistoryExecutionWorkflowID)124 runID := primitives.NewUUID()125 var childWorkflows []sqlplugin.ChildExecutionInfoMapsRow126 for i := 0; i < numChildWorkflows; i++ {127 childWorkflow := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, rand.Int63())128 childWorkflows = append(childWorkflows, childWorkflow)129 }130 result, err := s.store.ReplaceIntoChildExecutionInfoMaps(newExecutionContext(), childWorkflows)131 s.NoError(err)132 rowsAffected, err := result.RowsAffected()133 s.NoError(err)134 s.Equal(numChildWorkflows, int(rowsAffected))135 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{136 ShardID: shardID,137 NamespaceID: namespaceID,138 WorkflowID: workflowID,139 RunID: runID,140 }141 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)142 s.NoError(err)143 childWorkflowMap := map[int64]sqlplugin.ChildExecutionInfoMapsRow{}144 for _, childWorkflow := range childWorkflows {145 childWorkflowMap[childWorkflow.InitiatedID] = childWorkflow146 }147 rowMap := map[int64]sqlplugin.ChildExecutionInfoMapsRow{}148 for _, childWorkflow := range rows {149 rowMap[childWorkflow.InitiatedID] = childWorkflow150 }151 s.Equal(childWorkflowMap, rowMap)152}153func (s *historyExecutionChildWorkflowSuite) TestDeleteSelect_Single() {154 shardID := rand.Int31()155 namespaceID := primitives.NewUUID()156 workflowID := shuffle.String(testHistoryExecutionWorkflowID)157 runID := primitives.NewUUID()158 initiatedID := rand.Int63()159 deleteFilter := sqlplugin.ChildExecutionInfoMapsFilter{160 ShardID: shardID,161 NamespaceID: namespaceID,162 WorkflowID: workflowID,163 RunID: runID,164 InitiatedIDs: []int64{initiatedID},165 }166 result, err := s.store.DeleteFromChildExecutionInfoMaps(newExecutionContext(), deleteFilter)167 s.NoError(err)168 rowsAffected, err := result.RowsAffected()169 s.NoError(err)170 s.Equal(0, int(rowsAffected))171 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{172 ShardID: shardID,173 NamespaceID: namespaceID,174 WorkflowID: workflowID,175 RunID: runID,176 }177 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)178 s.NoError(err)179 s.Equal([]sqlplugin.ChildExecutionInfoMapsRow(nil), rows)180}181func (s *historyExecutionChildWorkflowSuite) TestDeleteSelect_Multiple() {182 shardID := rand.Int31()183 namespaceID := primitives.NewUUID()184 workflowID := shuffle.String(testHistoryExecutionWorkflowID)185 runID := primitives.NewUUID()186 deleteFilter := sqlplugin.ChildExecutionInfoMapsFilter{187 ShardID: shardID,188 NamespaceID: namespaceID,189 WorkflowID: workflowID,190 RunID: runID,191 InitiatedIDs: []int64{rand.Int63(), rand.Int63()},192 }193 result, err := s.store.DeleteFromChildExecutionInfoMaps(newExecutionContext(), deleteFilter)194 s.NoError(err)195 rowsAffected, err := result.RowsAffected()196 s.NoError(err)197 s.Equal(0, int(rowsAffected))198 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{199 ShardID: shardID,200 NamespaceID: namespaceID,201 WorkflowID: workflowID,202 RunID: runID,203 }204 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)205 s.NoError(err)206 s.Equal([]sqlplugin.ChildExecutionInfoMapsRow(nil), rows)207}208func (s *historyExecutionChildWorkflowSuite) TestDeleteSelect_All() {209 shardID := rand.Int31()210 namespaceID := primitives.NewUUID()211 workflowID := shuffle.String(testHistoryExecutionWorkflowID)212 runID := primitives.NewUUID()213 deleteFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{214 ShardID: shardID,215 NamespaceID: namespaceID,216 WorkflowID: workflowID,217 RunID: runID,218 }219 result, err := s.store.DeleteAllFromChildExecutionInfoMaps(newExecutionContext(), deleteFilter)220 s.NoError(err)221 rowsAffected, err := result.RowsAffected()222 s.NoError(err)223 s.Equal(0, int(rowsAffected))224 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{225 ShardID: shardID,226 NamespaceID: namespaceID,227 WorkflowID: workflowID,228 RunID: runID,229 }230 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)231 s.NoError(err)232 s.Equal([]sqlplugin.ChildExecutionInfoMapsRow(nil), rows)233}234func (s *historyExecutionChildWorkflowSuite) TestReplaceDeleteSelect_Single() {235 shardID := rand.Int31()236 namespaceID := primitives.NewUUID()237 workflowID := shuffle.String(testHistoryExecutionWorkflowID)238 runID := primitives.NewUUID()239 initiatedID := rand.Int63()240 childWorkflow := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, initiatedID)241 result, err := s.store.ReplaceIntoChildExecutionInfoMaps(newExecutionContext(), []sqlplugin.ChildExecutionInfoMapsRow{childWorkflow})242 s.NoError(err)243 rowsAffected, err := result.RowsAffected()244 s.NoError(err)245 s.Equal(1, int(rowsAffected))246 deleteFilter := sqlplugin.ChildExecutionInfoMapsFilter{247 ShardID: shardID,248 NamespaceID: namespaceID,249 WorkflowID: workflowID,250 RunID: runID,251 InitiatedIDs: []int64{initiatedID},252 }253 result, err = s.store.DeleteFromChildExecutionInfoMaps(newExecutionContext(), deleteFilter)254 s.NoError(err)255 rowsAffected, err = result.RowsAffected()256 s.NoError(err)257 s.Equal(1, int(rowsAffected))258 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{259 ShardID: shardID,260 NamespaceID: namespaceID,261 WorkflowID: workflowID,262 RunID: runID,263 }264 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)265 s.NoError(err)266 s.Equal([]sqlplugin.ChildExecutionInfoMapsRow(nil), rows)267}268func (s *historyExecutionChildWorkflowSuite) TestReplaceDeleteSelect_Multiple() {269 numChildWorkflows := 20270 shardID := rand.Int31()271 namespaceID := primitives.NewUUID()272 workflowID := shuffle.String(testHistoryExecutionWorkflowID)273 runID := primitives.NewUUID()274 var childWorkflows []sqlplugin.ChildExecutionInfoMapsRow275 var childWorkflowInitiatedIDs []int64276 for i := 0; i < numChildWorkflows; i++ {277 childWorkflowInitiatedID := rand.Int63()278 childWorkflow := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, childWorkflowInitiatedID)279 childWorkflowInitiatedIDs = append(childWorkflowInitiatedIDs, childWorkflowInitiatedID)280 childWorkflows = append(childWorkflows, childWorkflow)281 }282 result, err := s.store.ReplaceIntoChildExecutionInfoMaps(newExecutionContext(), childWorkflows)283 s.NoError(err)284 rowsAffected, err := result.RowsAffected()285 s.NoError(err)286 s.Equal(numChildWorkflows, int(rowsAffected))287 deleteFilter := sqlplugin.ChildExecutionInfoMapsFilter{288 ShardID: shardID,289 NamespaceID: namespaceID,290 WorkflowID: workflowID,291 RunID: runID,292 InitiatedIDs: childWorkflowInitiatedIDs,293 }294 result, err = s.store.DeleteFromChildExecutionInfoMaps(newExecutionContext(), deleteFilter)295 s.NoError(err)296 rowsAffected, err = result.RowsAffected()297 s.NoError(err)298 s.Equal(numChildWorkflows, int(rowsAffected))299 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{300 ShardID: shardID,301 NamespaceID: namespaceID,302 WorkflowID: workflowID,303 RunID: runID,304 }305 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)306 s.NoError(err)307 s.Equal([]sqlplugin.ChildExecutionInfoMapsRow(nil), rows)308}309func (s *historyExecutionChildWorkflowSuite) TestReplaceDeleteSelect_All() {310 numChildWorkflows := 20311 shardID := rand.Int31()312 namespaceID := primitives.NewUUID()313 workflowID := shuffle.String(testHistoryExecutionWorkflowID)314 runID := primitives.NewUUID()315 var childWorkflows []sqlplugin.ChildExecutionInfoMapsRow316 for i := 0; i < numChildWorkflows; i++ {317 childWorkflow := s.newRandomExecutionChildWorkflowRow(shardID, namespaceID, workflowID, runID, rand.Int63())318 childWorkflows = append(childWorkflows, childWorkflow)319 }320 result, err := s.store.ReplaceIntoChildExecutionInfoMaps(newExecutionContext(), childWorkflows)321 s.NoError(err)322 rowsAffected, err := result.RowsAffected()323 s.NoError(err)324 s.Equal(numChildWorkflows, int(rowsAffected))325 deleteFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{326 ShardID: shardID,327 NamespaceID: namespaceID,328 WorkflowID: workflowID,329 RunID: runID,330 }331 result, err = s.store.DeleteAllFromChildExecutionInfoMaps(newExecutionContext(), deleteFilter)332 s.NoError(err)333 rowsAffected, err = result.RowsAffected()334 s.NoError(err)335 s.Equal(numChildWorkflows, int(rowsAffected))336 selectFilter := sqlplugin.ChildExecutionInfoMapsAllFilter{337 ShardID: shardID,338 NamespaceID: namespaceID,339 WorkflowID: workflowID,340 RunID: runID,341 }342 rows, err := s.store.SelectAllFromChildExecutionInfoMaps(newExecutionContext(), selectFilter)343 s.NoError(err)344 s.Equal([]sqlplugin.ChildExecutionInfoMapsRow(nil), rows)345}346func (s *historyExecutionChildWorkflowSuite) newRandomExecutionChildWorkflowRow(347 shardID int32,348 namespaceID primitives.UUID,349 workflowID string,350 runID primitives.UUID,351 initiatedID int64,352) sqlplugin.ChildExecutionInfoMapsRow {353 return sqlplugin.ChildExecutionInfoMapsRow{354 ShardID: shardID,355 NamespaceID: namespaceID,356 WorkflowID: workflowID,357 RunID: runID,358 InitiatedID: initiatedID,359 Data: shuffle.Bytes(testHistoryExecutionChildWorkflowData),360 DataEncoding: testHistoryExecutionChildWorkflowEncoding,361 }362}...

Full Screen

Full Screen

history_current_execution_test.go

Source:history_current_execution_test.go Github

copy

Full Screen

...82func (s *historyCurrentExecutionSuite) TestInsert_Success() {83 shardID := rand.Int31()84 namespaceID := primitives.NewUUID()85 workflowID := shuffle.String(testHistoryExecutionWorkflowID)86 runID := primitives.NewUUID()87 requestID := primitives.NewUUID().String()88 lastWriteVersion := rand.Int63()89 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)90 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)91 s.NoError(err)92 rowsAffected, err := result.RowsAffected()93 s.NoError(err)94 s.Equal(1, int(rowsAffected))95}96func (s *historyCurrentExecutionSuite) TestInsert_Fail_Duplicate() {97 shardID := rand.Int31()98 namespaceID := primitives.NewUUID()99 workflowID := shuffle.String(testHistoryExecutionWorkflowID)100 runID := primitives.NewUUID()101 requestID := primitives.NewUUID().String()102 lastWriteVersion := rand.Int63()103 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)104 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)105 s.NoError(err)106 rowsAffected, err := result.RowsAffected()107 s.NoError(err)108 s.Equal(1, int(rowsAffected))109 currentExecution = s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)110 _, err = s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)111 s.Error(err) // TODO persistence layer should do proper error translation112}113func (s *historyCurrentExecutionSuite) TestInsertSelect() {114 shardID := rand.Int31()115 namespaceID := primitives.NewUUID()116 workflowID := shuffle.String(testHistoryExecutionWorkflowID)117 runID := primitives.NewUUID()118 requestID := primitives.NewUUID().String()119 lastWriteVersion := rand.Int63()120 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)121 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)122 s.NoError(err)123 rowsAffected, err := result.RowsAffected()124 s.NoError(err)125 s.Equal(1, int(rowsAffected))126 filter := sqlplugin.CurrentExecutionsFilter{127 ShardID: shardID,128 NamespaceID: namespaceID,129 WorkflowID: workflowID,130 RunID: nil,131 }132 row, err := s.store.SelectFromCurrentExecutions(newExecutionContext(), filter)133 s.NoError(err)134 s.Equal(&currentExecution, row)135}136func (s *historyCurrentExecutionSuite) TestInsertUpdate_Success() {137 shardID := rand.Int31()138 namespaceID := primitives.NewUUID()139 workflowID := shuffle.String(testHistoryExecutionWorkflowID)140 runID := primitives.NewUUID()141 requestID := primitives.NewUUID().String()142 lastWriteVersion := rand.Int63()143 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)144 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)145 s.NoError(err)146 rowsAffected, err := result.RowsAffected()147 s.NoError(err)148 s.Equal(1, int(rowsAffected))149 currentExecution = s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, primitives.NewUUID().String(), rand.Int63())150 result, err = s.store.UpdateCurrentExecutions(newExecutionContext(), &currentExecution)151 s.NoError(err)152 rowsAffected, err = result.RowsAffected()153 s.NoError(err)154 s.Equal(1, int(rowsAffected))155}156func (s *historyCurrentExecutionSuite) TestUpdate_Fail() {157 shardID := rand.Int31()158 namespaceID := primitives.NewUUID()159 workflowID := shuffle.String(testHistoryExecutionWorkflowID)160 runID := primitives.NewUUID()161 requestID := primitives.NewUUID().String()162 lastWriteVersion := rand.Int63()163 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)164 result, err := s.store.UpdateCurrentExecutions(newExecutionContext(), &currentExecution)165 s.NoError(err)166 rowsAffected, err := result.RowsAffected()167 s.NoError(err)168 s.Equal(0, int(rowsAffected))169}170func (s *historyCurrentExecutionSuite) TestInsertUpdateSelect() {171 shardID := rand.Int31()172 namespaceID := primitives.NewUUID()173 workflowID := shuffle.String(testHistoryExecutionWorkflowID)174 runID := primitives.NewUUID()175 requestID := primitives.NewUUID().String()176 lastWriteVersion := rand.Int63()177 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)178 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)179 s.NoError(err)180 rowsAffected, err := result.RowsAffected()181 s.NoError(err)182 s.Equal(1, int(rowsAffected))183 currentExecution = s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, primitives.NewUUID().String(), rand.Int63())184 result, err = s.store.UpdateCurrentExecutions(newExecutionContext(), &currentExecution)185 s.NoError(err)186 rowsAffected, err = result.RowsAffected()187 s.NoError(err)188 s.Equal(1, int(rowsAffected))189 filter := sqlplugin.CurrentExecutionsFilter{190 ShardID: shardID,191 NamespaceID: namespaceID,192 WorkflowID: workflowID,193 RunID: nil,194 }195 row, err := s.store.SelectFromCurrentExecutions(newExecutionContext(), filter)196 s.NoError(err)197 s.Equal(&currentExecution, row)198}199func (s *historyCurrentExecutionSuite) TestInsertDeleteSelect_Success() {200 shardID := rand.Int31()201 namespaceID := primitives.NewUUID()202 workflowID := shuffle.String(testHistoryExecutionWorkflowID)203 runID := primitives.NewUUID()204 requestID := primitives.NewUUID().String()205 lastWriteVersion := rand.Int63()206 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)207 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)208 s.NoError(err)209 rowsAffected, err := result.RowsAffected()210 s.NoError(err)211 s.Equal(1, int(rowsAffected))212 filter := sqlplugin.CurrentExecutionsFilter{213 ShardID: shardID,214 NamespaceID: namespaceID,215 WorkflowID: workflowID,216 RunID: runID,217 }218 result, err = s.store.DeleteFromCurrentExecutions(newExecutionContext(), filter)219 s.NoError(err)220 rowsAffected, err = result.RowsAffected()221 s.NoError(err)222 s.Equal(1, int(rowsAffected))223 filter.RunID = nil224 _, err = s.store.SelectFromCurrentExecutions(newExecutionContext(), filter)225 s.Error(err) // TODO persistence layer should do proper error translation226}227func (s *historyCurrentExecutionSuite) TestInsertDeleteSelect_Fail() {228 shardID := rand.Int31()229 namespaceID := primitives.NewUUID()230 workflowID := shuffle.String(testHistoryExecutionWorkflowID)231 runID := primitives.NewUUID()232 requestID := primitives.NewUUID().String()233 lastWriteVersion := rand.Int63()234 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)235 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)236 s.NoError(err)237 rowsAffected, err := result.RowsAffected()238 s.NoError(err)239 s.Equal(1, int(rowsAffected))240 filter := sqlplugin.CurrentExecutionsFilter{241 ShardID: shardID,242 NamespaceID: namespaceID,243 WorkflowID: workflowID,244 RunID: primitives.NewUUID(),245 }246 result, err = s.store.DeleteFromCurrentExecutions(newExecutionContext(), filter)247 s.NoError(err)248 rowsAffected, err = result.RowsAffected()249 s.NoError(err)250 s.Equal(0, int(rowsAffected))251 filter.RunID = nil252 row, err := s.store.SelectFromCurrentExecutions(newExecutionContext(), filter)253 s.NoError(err)254 s.Equal(&currentExecution, row)255}256func (s *historyCurrentExecutionSuite) TestLock() {257 shardID := rand.Int31()258 namespaceID := primitives.NewUUID()259 workflowID := shuffle.String(testHistoryExecutionWorkflowID)260 runID := primitives.NewUUID()261 requestID := primitives.NewUUID().String()262 lastWriteVersion := rand.Int63()263 currentExecution := s.newRandomCurrentExecutionRow(shardID, namespaceID, workflowID, runID, requestID, lastWriteVersion)264 result, err := s.store.InsertIntoCurrentExecutions(newExecutionContext(), &currentExecution)265 s.NoError(err)266 rowsAffected, err := result.RowsAffected()267 s.NoError(err)268 s.Equal(1, int(rowsAffected))269 // NOTE: lock without transaction is equivalent to select270 // this test only test the select functionality271 filter := sqlplugin.CurrentExecutionsFilter{272 ShardID: shardID,273 NamespaceID: namespaceID,274 WorkflowID: workflowID,275 RunID: nil,276 }277 row, err := s.store.LockCurrentExecutions(newExecutionContext(), filter)278 s.NoError(err)279 s.Equal(&currentExecution, row)280}281func (s *historyCurrentExecutionSuite) newRandomCurrentExecutionRow(282 shardID int32,283 namespaceID primitives.UUID,284 workflowID string,285 runID primitives.UUID,286 requestID string,287 lastWriteVersion int64,288) sqlplugin.CurrentExecutionsRow {289 state := testHistoryExecutionStates[rand.Intn(len(testHistoryExecutionStates))]290 status := testHistoryExecutionStatus[state][rand.Intn(len(testHistoryExecutionStatus[state]))]291 return sqlplugin.CurrentExecutionsRow{292 ShardID: shardID,293 NamespaceID: namespaceID,294 WorkflowID: workflowID,295 RunID: runID,296 CreateRequestID: requestID,297 LastWriteVersion: lastWriteVersion,298 State: state,299 Status: status,300 }301}...

Full Screen

Full Screen

history_execution_test.go

Source:history_execution_test.go Github

copy

Full Screen

...68func (s *historyExecutionSuite) TestInsert_Success() {69 shardID := rand.Int31()70 namespaceID := primitives.NewUUID()71 workflowID := shuffle.String(testHistoryExecutionWorkflowID)72 runID := primitives.NewUUID()73 nextEventID := rand.Int63()74 lastWriteVersion := rand.Int63()75 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)76 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)77 s.NoError(err)78 rowsAffected, err := result.RowsAffected()79 s.NoError(err)80 s.Equal(1, int(rowsAffected))81}82func (s *historyExecutionSuite) TestInsert_Fail_Duplicate() {83 shardID := rand.Int31()84 namespaceID := primitives.NewUUID()85 workflowID := shuffle.String(testHistoryExecutionWorkflowID)86 runID := primitives.NewUUID()87 nextEventID := rand.Int63()88 lastWriteVersion := rand.Int63()89 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)90 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)91 s.NoError(err)92 rowsAffected, err := result.RowsAffected()93 s.NoError(err)94 s.Equal(1, int(rowsAffected))95 execution = s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)96 _, err = s.store.InsertIntoExecutions(newExecutionContext(), &execution)97 s.Error(err) // TODO persistence layer should do proper error translation98}99func (s *historyExecutionSuite) TestInsertSelect() {100 shardID := rand.Int31()101 namespaceID := primitives.NewUUID()102 workflowID := shuffle.String(testHistoryExecutionWorkflowID)103 runID := primitives.NewUUID()104 nextEventID := rand.Int63()105 lastWriteVersion := rand.Int63()106 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)107 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)108 s.NoError(err)109 rowsAffected, err := result.RowsAffected()110 s.NoError(err)111 s.Equal(1, int(rowsAffected))112 filter := sqlplugin.ExecutionsFilter{113 ShardID: shardID,114 NamespaceID: namespaceID,115 WorkflowID: workflowID,116 RunID: runID,117 }118 row, err := s.store.SelectFromExecutions(newExecutionContext(), filter)119 s.NoError(err)120 s.Equal(&execution, row)121}122func (s *historyExecutionSuite) TestInsertUpdate_Success() {123 shardID := rand.Int31()124 namespaceID := primitives.NewUUID()125 workflowID := shuffle.String(testHistoryExecutionWorkflowID)126 runID := primitives.NewUUID()127 nextEventID := rand.Int63()128 lastWriteVersion := rand.Int63()129 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)130 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)131 s.NoError(err)132 rowsAffected, err := result.RowsAffected()133 s.NoError(err)134 s.Equal(1, int(rowsAffected))135 execution = s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, rand.Int63(), rand.Int63())136 result, err = s.store.UpdateExecutions(newExecutionContext(), &execution)137 s.NoError(err)138 rowsAffected, err = result.RowsAffected()139 s.NoError(err)140 s.Equal(1, int(rowsAffected))141}142func (s *historyExecutionSuite) TestUpdate_Fail() {143 shardID := rand.Int31()144 namespaceID := primitives.NewUUID()145 workflowID := shuffle.String(testHistoryExecutionWorkflowID)146 runID := primitives.NewUUID()147 nextEventID := rand.Int63()148 lastWriteVersion := rand.Int63()149 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)150 result, err := s.store.UpdateExecutions(newExecutionContext(), &execution)151 s.NoError(err)152 rowsAffected, err := result.RowsAffected()153 s.NoError(err)154 s.Equal(0, int(rowsAffected))155}156func (s *historyExecutionSuite) TestInsertUpdateSelect() {157 shardID := rand.Int31()158 namespaceID := primitives.NewUUID()159 workflowID := shuffle.String(testHistoryExecutionWorkflowID)160 runID := primitives.NewUUID()161 nextEventID := rand.Int63()162 lastWriteVersion := rand.Int63()163 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)164 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)165 s.NoError(err)166 rowsAffected, err := result.RowsAffected()167 s.NoError(err)168 s.Equal(1, int(rowsAffected))169 execution = s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, rand.Int63(), rand.Int63())170 result, err = s.store.UpdateExecutions(newExecutionContext(), &execution)171 s.NoError(err)172 rowsAffected, err = result.RowsAffected()173 s.NoError(err)174 s.Equal(1, int(rowsAffected))175 filter := sqlplugin.ExecutionsFilter{176 ShardID: shardID,177 NamespaceID: namespaceID,178 WorkflowID: workflowID,179 RunID: runID,180 }181 row, err := s.store.SelectFromExecutions(newExecutionContext(), filter)182 s.NoError(err)183 s.Equal(&execution, row)184}185func (s *historyExecutionSuite) TestDeleteSelect() {186 shardID := rand.Int31()187 namespaceID := primitives.NewUUID()188 workflowID := shuffle.String(testHistoryExecutionWorkflowID)189 runID := primitives.NewUUID()190 filter := sqlplugin.ExecutionsFilter{191 ShardID: shardID,192 NamespaceID: namespaceID,193 WorkflowID: workflowID,194 RunID: runID,195 }196 result, err := s.store.DeleteFromExecutions(newExecutionContext(), filter)197 s.NoError(err)198 rowsAffected, err := result.RowsAffected()199 s.NoError(err)200 s.Equal(0, int(rowsAffected))201 _, err = s.store.SelectFromExecutions(newExecutionContext(), filter)202 s.Error(err) // TODO persistence layer should do proper error translation203}204func (s *historyExecutionSuite) TestInsertDeleteSelect() {205 shardID := rand.Int31()206 namespaceID := primitives.NewUUID()207 workflowID := shuffle.String(testHistoryExecutionWorkflowID)208 runID := primitives.NewUUID()209 nextEventID := rand.Int63()210 lastWriteVersion := rand.Int63()211 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)212 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)213 s.NoError(err)214 rowsAffected, err := result.RowsAffected()215 s.NoError(err)216 s.Equal(1, int(rowsAffected))217 filter := sqlplugin.ExecutionsFilter{218 ShardID: shardID,219 NamespaceID: namespaceID,220 WorkflowID: workflowID,221 RunID: runID,222 }223 result, err = s.store.DeleteFromExecutions(newExecutionContext(), filter)224 s.NoError(err)225 rowsAffected, err = result.RowsAffected()226 s.NoError(err)227 s.Equal(1, int(rowsAffected))228 _, err = s.store.SelectFromExecutions(newExecutionContext(), filter)229 s.Error(err) // TODO persistence layer should do proper error translation230}231func (s *historyExecutionSuite) TestReadLock() {232 shardID := rand.Int31()233 namespaceID := primitives.NewUUID()234 workflowID := shuffle.String(testHistoryExecutionWorkflowID)235 runID := primitives.NewUUID()236 nextEventID := rand.Int63()237 lastWriteVersion := rand.Int63()238 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)239 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)240 s.NoError(err)241 rowsAffected, err := result.RowsAffected()242 s.NoError(err)243 s.Equal(1, int(rowsAffected))244 filter := sqlplugin.ExecutionsFilter{245 ShardID: shardID,246 NamespaceID: namespaceID,247 WorkflowID: workflowID,248 RunID: runID,249 }250 rowDBVersion, rowNextEventID, err := s.store.ReadLockExecutions(newExecutionContext(), filter)251 s.NoError(err)252 s.Equal(execution.DBRecordVersion, rowDBVersion)253 s.Equal(execution.NextEventID, rowNextEventID)254}255func (s *historyExecutionSuite) TestWriteLock() {256 shardID := rand.Int31()257 namespaceID := primitives.NewUUID()258 workflowID := shuffle.String(testHistoryExecutionWorkflowID)259 runID := primitives.NewUUID()260 nextEventID := rand.Int63()261 lastWriteVersion := rand.Int63()262 execution := s.newRandomExecutionRow(shardID, namespaceID, workflowID, runID, nextEventID, lastWriteVersion)263 result, err := s.store.InsertIntoExecutions(newExecutionContext(), &execution)264 s.NoError(err)265 rowsAffected, err := result.RowsAffected()266 s.NoError(err)267 s.Equal(1, int(rowsAffected))268 filter := sqlplugin.ExecutionsFilter{269 ShardID: shardID,270 NamespaceID: namespaceID,271 WorkflowID: workflowID,272 RunID: runID,273 }274 rowDBVersion, rowNextEventID, err := s.store.WriteLockExecutions(newExecutionContext(), filter)275 s.NoError(err)276 s.Equal(execution.DBRecordVersion, rowDBVersion)277 s.Equal(execution.NextEventID, rowNextEventID)278}279func (s *historyExecutionSuite) newRandomExecutionRow(280 shardID int32,281 namespaceID primitives.UUID,282 workflowID string,283 runID primitives.UUID,284 nextEventID int64,285 lastWriteVersion int64,286) sqlplugin.ExecutionsRow {287 return sqlplugin.ExecutionsRow{288 ShardID: shardID,289 NamespaceID: namespaceID,290 WorkflowID: workflowID,291 RunID: runID,292 NextEventID: nextEventID,293 LastWriteVersion: lastWriteVersion,294 Data: shuffle.Bytes(testHistoryExecutionData),295 DataEncoding: testHistoryExecutionEncoding,296 State: shuffle.Bytes(testHistoryExecutionStateData),297 StateEncoding: testHistoryExecutionStateEncoding,298 }299}...

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 binary, lookErr := exec.LookPath("ls")4 if lookErr != nil {5 panic(lookErr)6 }7 args := []string{"ls", "-a", "-l", "-h"}8 env := os.Environ()9 execErr := syscall.Exec(binary, args, env)10 if execErr != nil {11 panic(execErr)12 }13}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("hello world")4}5import "fmt"6func main() {7 fmt.Println("hello world")8}9import "fmt"10func main() {11 fmt.Println("hello world")12}13import "fmt"14func main() {15 fmt.Println("hello world")16}17import "fmt"18func main() {19 fmt.Println("hello world")20}21import "fmt"22func main() {23 fmt.Println("hello world")24}25import "fmt"26func main() {27 fmt.Println("hello world")28}29import "fmt"30func main() {31 fmt.Println("hello world")32}33import "fmt"34func main() {35 fmt.Println("hello world")36}37import "fmt"38func main() {39 fmt.Println("hello world")40}41import "fmt"42func main() {43 fmt.Println("hello world")44}45import "fmt"46func main() {47 fmt.Println("hello world")48}49import "fmt"50func main() {51 fmt.Println("hello world")52}53import "fmt"54func main() {55 fmt.Println("hello world")56}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Starting the application...")4 go longRunning()5 go shortRunning()6 time.Sleep(10 * time.Second)7 fmt.Println("Terminating the application...")8}9func longRunning() {10 fmt.Println("Starting a long running task...")11 time.Sleep(5 * time.Second)12 fmt.Println("Task completed.")13}14func shortRunning() {15 fmt.Println("Starting a short running task...")16 fmt.Println("Task completed.")17}18import (19func main() {20 fmt.Println("Starting the application...")

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("ls", "-l", "-a", "-h")4 output, err := cmd.Output()5 if err != nil {6 fmt.Println(err.Error())7 }8 fmt.Println(string(output))9}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 process := exec.Command("ls", "-ltr")4 stdout, err := process.StdoutPipe()5 if err != nil {6 fmt.Printf("Error: %s7 os.Exit(1)8 }9 if err := process.Start(); err != nil {10 fmt.Printf("Error: %s11 os.Exit(1)12 }13 output, err := ioutil.ReadAll(stdout)14 if err != nil {15 fmt.Printf("Error: %s16 os.Exit(1)17 }18 if err := process.Wait(); err != nil {19 fmt.Printf("Error: %s20 os.Exit(1)21 }22 fmt.Printf("%s23}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import java.io.*;2import java.util.*;3import java.util.Scanner;4import java.util.ArrayList;5import java.util.List;6import java.util.Arrays;7import java.util.Map;8import java.util.HashMap;9import java.util.Map.Entry;10import java.util.Iterator;11import java.util.Set;12import java.util.HashSet;13import java.util.Collections;14import java.util.Comparator;15import java.io.BufferedReader;16import java.io.FileReader;17import java.io.IOException;18import java.io.File;19import java.io.FileWriter;20import java.io.BufferedWriter;21import java.io.PrintWriter;22import java.io.FileInputStream;23import java.io.FileOutputStream;24import java.io.ObjectInputStream;25import java.io.ObjectOutputStream;26import java.io.Serializable;27import java.util.Date;28import java.text.DateFormat;29import java.text.SimpleDateFormat;30import java.util.Calendar;31import java.util.regex.Pattern;32import java.util.regex.Matcher;33import java.util.List;34import java.util.ArrayList;35import java.util.Collections;36import java.util.Comparator;37import java.util.Scanner;38import java.util.Set;39import java.util.HashSet;40import java.util.HashMap;41import java.util.Map;42import java.util.Iterator;43import java.util.Map.Entry;44import java.util.List;45import java.util.ArrayList;46import java.util.Collections;47import java.util.Comparator;48import java.util.Scanner;49import java.util.Set;50import java.util.HashSet;51import java.util.HashMap;52import java.util.Map;53import java.util.Iterator;54import java.util.Map.Entry;55import java.util.List;56import java.util.ArrayList;57import java.util.Collections;58import java.util.Comparator;59import java.util.Scanner;60import java.util.Set;61import java.util.HashSet;62import java.util.HashMap;63import java.util.Map;64import java.util.Iterator;65import java.util.Map.Entry;66import java.util.List;67import java.util.ArrayList;68import java.util.Collections;69import java.util.Comparator;70import java.util.Scanner;71import java.util.Set;72import java.util.HashSet;73import java.util.HashMap;74import java.util.Map;75import java.util.Iterator;76import java.util.Map.Entry;77import java.util.List;78import java.util.ArrayList;79import java.util.Collections;80import java.util.Comparator;81import java.util.Scanner;82import java.util.Set;83import java.util.HashSet;84import java.util.HashMap;85import java.util.Map;86import java.util.Iterator;87import java.util.Map.Entry;88import java.util.List;89import java.util.ArrayList;90import java.util.Collections;91import java.util.Comparator;92import java.util.Scanner;93import java.util.Set;94import java.util.HashSet;95import java.util.HashMap;96import java.util.Map;97import java.util.Iterator;98import java.util.Map

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gauge automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful