Skip to content

Commit

Permalink
--amend
Browse files Browse the repository at this point in the history
  • Loading branch information
feedmeapples committed May 8, 2023
1 parent e17ba58 commit 5bef47e
Showing 1 changed file with 19 additions and 47 deletions.
66 changes: 19 additions & 47 deletions tests/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"math/rand"
"os"
"strconv"
"sync"
"time"

"github.com/pborman/uuid"
Expand Down Expand Up @@ -130,64 +129,37 @@ func (s *e2eSuite) TestWorkflowDelete_Batch() {
_ = testserver.Stop()
}()

w := s.newWorker(testserver, testTq, func(r worker.Registry) {
r.RegisterWorkflow(helloworld.Workflow)
r.RegisterActivity(helloworld.Activity)
})
defer w.Stop()

c := testserver.Client()

ids := []string{"1", "2", "3"}

for _, id := range ids {
wfr, err := c.ExecuteWorkflow(
_, err := c.ExecuteWorkflow(
context.Background(),
sdkclient.StartWorkflowOptions{ID: id, TaskQueue: testTq},
helloworld.Workflow,
"world",
"non-existing-workflow-type",
)
s.NoError(err)

var result string
err = wfr.Get(context.Background(), &result)
s.NoError(err)
}

// start batch delete operation
err := app.Run([]string{"", "workflow", "delete", "--query", "WorkflowId = '1' OR WorkflowId = '2'", "--reason", "test", "--yes"})
err := app.Run([]string{"", "workflow", "delete", "--query", "WorkflowId = '1' OR WorkflowId = '2'", "--reason", "test", "--yes", "--namespace", testNamespace})
s.NoError(err)
time.Sleep(2 * time.Second)

// wait for the delete operation to complete
var wg sync.WaitGroup
wg.Add(1)
go func() {
for {
time.Sleep(1 * time.Second)

resp, err := c.WorkflowService().ListBatchOperations(context.Background(),
&workflowservice.ListBatchOperationsRequest{Namespace: testNamespace})
s.NoError(err)

if len(resp.OperationInfo) == 0 {
continue
}

s.Equal(1, len(resp.OperationInfo)) // TODO ensure new server for each e2e test

deleteJob, err := c.WorkflowService().DescribeBatchOperation(context.Background(),
&workflowservice.DescribeBatchOperationRequest{
JobId: resp.OperationInfo[0].JobId,
Namespace: testNamespace,
})
s.NoError(err)
if deleteJob.State == enums.BATCH_OPERATION_STATE_COMPLETED {
wg.Done()
return
}
}
}()
s.True(AwaitWaitGroup(&wg, 10*time.Second))
resp, err := c.WorkflowService().ListBatchOperations(context.Background(),
&workflowservice.ListBatchOperationsRequest{Namespace: testNamespace})
s.NoError(err)

s.Equal(1, len(resp.OperationInfo))

deleteJob, err := c.WorkflowService().DescribeBatchOperation(context.Background(),
&workflowservice.DescribeBatchOperationRequest{
JobId: resp.OperationInfo[0].JobId,
Namespace: testNamespace,
})
s.NoError(err)
s.Equal(enums.BATCH_OPERATION_STATE_COMPLETED, deleteJob.State)

_, err = c.DescribeWorkflowExecution(context.Background(), "1", "")
s.Error(err)
Expand All @@ -197,6 +169,6 @@ func (s *e2eSuite) TestWorkflowDelete_Batch() {

w3, err := c.DescribeWorkflowExecution(context.Background(), "3", "")
s.NoError(err)
s.Equal(enums.WORKFLOW_EXECUTION_STATUS_COMPLETED, w3.WorkflowExecutionInfo.Status)

fmt.Print(w3)
s.Equal(enums.WORKFLOW_EXECUTION_STATUS_RUNNING, w3.WorkflowExecutionInfo.Status)
}

0 comments on commit 5bef47e

Please sign in to comment.