Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit test for MigrationInterceptor #956

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

shijiesheng
Copy link
Contributor

What changed?

  • add unit test along with integration test for migration interceptor

Why?

unit test coverage

How did you test it?

Unit test

Potential risks

Release notes

Documentation Changes

.withDomain(DOMAIN)
.withWorkflowTypes(CrossDomainWorkflowTest.TestWorkflowCrossDomainImpl.class)
.startWorkersAutomatically()
.withTestEnvironmentProvider(TestWorkflowEnvironment::newInstance)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default value of TestEnvironmentProvider, you can remove. The CrossDomainWorkflowTest had to specify it to share one environment across both workers since it had workflows signaling across domains.

public CadenceTestRule testRuleCur =
CadenceTestRule.builder()
.withDomain(DOMAIN)
.withWorkflowTypes(CrossDomainWorkflowTest.TestWorkflowCrossDomainImpl.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this workflow used within the test? I think you can remove both withWorkflowTypes and startWorkersAutomatically since the test seems to create its own workers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense. I missed this

new FeatureFlags().setWorkflowExecutionAlreadyCompletedErrorEnabled(true))
.build());
IWorkflowService serviceNew, serviceCur;
if (useDockerService) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the conditional logic you should be able to use the else branch for both cases. If useDockerService is set to true then the IWorkflowClient in the test rules will be thrift clients.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense

import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;

public class WorkflowMigrationTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: See if you can remove useDockerService entirely, the test rule should handle most cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do want to have an integration test from end to end.

Copy link
Member

@natemort natemort Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't think I explained this well, but the CadenceTestRule has the conditional logic within it already: https://github.com/uber/cadence-java-client/blob/704380bfaed0aa873fa19fe01d7bb0645c690c53/src/test/java/com/uber/cadence/testUtils/CadenceTestRule.java#L196

If USE_DOCKER_SERVICE is set to true then CadenceTestRule will connect to the docker instance instead of creating a test service. The goal of the test rule is to avoid every test needing to have conditional logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I don't know that. I'll remove it completely

@@ -155,7 +179,7 @@ public void execute(int iter) {

@Test
public void whenUseDockerService_cronWorkflowMigration() {
Assume.assumeTrue(useDockerService);
// Assume.assumeTrue(useDockerService);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove comment

} catch (Exception eDesc) {
fail("fail to describe workflow execution in new domain: " + eDesc);
}
}
}

private DescribeWorkflowExecutionResponse describeWorkflowExecution(
private GetWorkflowExecutionHistoryResponse getWorkflowHistory(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why change the type? Does this cover a different code path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe method is not implemented in test service

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.19%. Comparing base (f609320) to head (c8f85be).
Report is 6 commits behind head on master.

Additional details and impacted files

see 23 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f609320...c8f85be. Read the comment docs.

@shijiesheng shijiesheng merged commit 705ba69 into cadence-workflow:master Nov 8, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants