From 6ad5de4a969c71eba141e18b25e1816dce1a7c62 Mon Sep 17 00:00:00 2001 From: Mindaugas Barcauskas Date: Fri, 2 Dec 2022 15:34:57 +0200 Subject: [PATCH 1/4] fixing flaky integration test. --- test/integration_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/integration_test.go b/test/integration_test.go index 04c36d3cd..38b6147a0 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -421,7 +421,11 @@ func (ts *IntegrationTestSuite) TestChildWFWithParentClosePolicyTerminate() { ts.NoError(err) resp, err := ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") ts.NoError(err) + err = ts.getWorkflow(resp.WorkflowExecutionInfo.Execution.GetWorkflowId(), resp.WorkflowExecutionInfo.Execution.GetRunId()) + resp, err = ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") + ts.NoError(err) ts.True(resp.WorkflowExecutionInfo.GetCloseTime() > 0) + } func (ts *IntegrationTestSuite) TestChildWFWithParentClosePolicyAbandon() { @@ -581,6 +585,15 @@ func (ts *IntegrationTestSuite) registerWorkflowsAndActivities(w worker.Worker) ts.activities.register(w) } +func (ts *IntegrationTestSuite) getWorkflow(wid string, runId string) error { + ctx, cancel := context.WithTimeout(context.Background(), ctxTimeout) + defer cancel() + wfRun := ts.libClient.GetWorkflow(ctx, wid, runId) + var val interface{} + err := wfRun.Get(ctx, &val) + return err +} + var _ interceptors.WorkflowInterceptorFactory = (*tracingInterceptorFactory)(nil) type tracingInterceptorFactory struct { From a4a0b550bacd0bfcbc949b22aeec711d06eac24d Mon Sep 17 00:00:00 2001 From: Mindaugas Barcauskas Date: Fri, 2 Dec 2022 15:37:29 +0200 Subject: [PATCH 2/4] naming. --- test/integration_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration_test.go b/test/integration_test.go index 38b6147a0..21ad1392d 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -421,7 +421,8 @@ func (ts *IntegrationTestSuite) TestChildWFWithParentClosePolicyTerminate() { ts.NoError(err) resp, err := ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") ts.NoError(err) - err = ts.getWorkflow(resp.WorkflowExecutionInfo.Execution.GetWorkflowId(), resp.WorkflowExecutionInfo.Execution.GetRunId()) + // Need to wait for child workflow to finish as well otherwise test becomes flaky + err = ts.waitForWorkflowFinish(resp.WorkflowExecutionInfo.Execution.GetWorkflowId(), resp.WorkflowExecutionInfo.Execution.GetRunId()) resp, err = ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") ts.NoError(err) ts.True(resp.WorkflowExecutionInfo.GetCloseTime() > 0) @@ -585,7 +586,7 @@ func (ts *IntegrationTestSuite) registerWorkflowsAndActivities(w worker.Worker) ts.activities.register(w) } -func (ts *IntegrationTestSuite) getWorkflow(wid string, runId string) error { +func (ts *IntegrationTestSuite) waitForWorkflowFinish(wid string, runId string) error { ctx, cancel := context.WithTimeout(context.Background(), ctxTimeout) defer cancel() wfRun := ts.libClient.GetWorkflow(ctx, wid, runId) From 707c39655fbc5ad7d31b7d18becb33ea8aca2558 Mon Sep 17 00:00:00 2001 From: Mindaugas Barcauskas Date: Fri, 2 Dec 2022 16:00:24 +0200 Subject: [PATCH 3/4] code style. --- test/integration_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/integration_test.go b/test/integration_test.go index 21ad1392d..38dc6c736 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -422,7 +422,7 @@ func (ts *IntegrationTestSuite) TestChildWFWithParentClosePolicyTerminate() { resp, err := ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") ts.NoError(err) // Need to wait for child workflow to finish as well otherwise test becomes flaky - err = ts.waitForWorkflowFinish(resp.WorkflowExecutionInfo.Execution.GetWorkflowId(), resp.WorkflowExecutionInfo.Execution.GetRunId()) + ts.waitForWorkflowFinish(resp.WorkflowExecutionInfo.Execution.GetWorkflowId(), resp.WorkflowExecutionInfo.Execution.GetRunId()) resp, err = ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") ts.NoError(err) ts.True(resp.WorkflowExecutionInfo.GetCloseTime() > 0) @@ -591,8 +591,7 @@ func (ts *IntegrationTestSuite) waitForWorkflowFinish(wid string, runId string) defer cancel() wfRun := ts.libClient.GetWorkflow(ctx, wid, runId) var val interface{} - err := wfRun.Get(ctx, &val) - return err + return wfRun.Get(ctx, &val) } var _ interceptors.WorkflowInterceptorFactory = (*tracingInterceptorFactory)(nil) From 66b0c9ab7db9271d31189a1c9e3b43959db32526 Mon Sep 17 00:00:00 2001 From: Mindaugas Barcauskas Date: Mon, 5 Dec 2022 09:43:55 +0200 Subject: [PATCH 4/4] addressing review comments. --- test/integration_test.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/integration_test.go b/test/integration_test.go index 38dc6c736..353e84fd0 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -419,11 +419,9 @@ func (ts *IntegrationTestSuite) TestChildWFWithParentClosePolicyTerminate() { var childWorkflowID string err := ts.executeWorkflow("test-childwf-parent-close-policy", ts.workflows.ChildWorkflowSuccessWithParentClosePolicyTerminate, &childWorkflowID) ts.NoError(err) - resp, err := ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") - ts.NoError(err) // Need to wait for child workflow to finish as well otherwise test becomes flaky - ts.waitForWorkflowFinish(resp.WorkflowExecutionInfo.Execution.GetWorkflowId(), resp.WorkflowExecutionInfo.Execution.GetRunId()) - resp, err = ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") + ts.waitForWorkflowFinish(childWorkflowID, "") + resp, err := ts.libClient.DescribeWorkflowExecution(context.Background(), childWorkflowID, "") ts.NoError(err) ts.True(resp.WorkflowExecutionInfo.GetCloseTime() > 0) @@ -590,8 +588,7 @@ func (ts *IntegrationTestSuite) waitForWorkflowFinish(wid string, runId string) ctx, cancel := context.WithTimeout(context.Background(), ctxTimeout) defer cancel() wfRun := ts.libClient.GetWorkflow(ctx, wid, runId) - var val interface{} - return wfRun.Get(ctx, &val) + return wfRun.Get(ctx, nil) } var _ interceptors.WorkflowInterceptorFactory = (*tracingInterceptorFactory)(nil)