temporal icon indicating copy to clipboard operation
temporal copied to clipboard

Make functional test suites exported (take 2)

Open aromanovich opened this issue 1 year ago • 11 comments

What changed?

Test suite implementations are moved from tests/{xdc,ndc}/*_test.go to tests/{xdc,ndc}/*go files.

Why?

Making test suites available to third-party packages. Following up on #5205.

How did you test it?

Ran tests.

Potential risks

None.

Is hotfix candidate?

No.

aromanovich avatar Dec 18 '23 19:12 aromanovich

There's an issue that was brought up by these changes in #5205. IDEs (GoLand, VSCode) can't run tests that are not in *_test.go file. Do you know of a solution that can make the tests exportable and also can make it work seamlessly with IDE?

rodrigozhou avatar Dec 22 '23 17:12 rodrigozhou

I should've brought it up myself, but I almost always run tests from the terminal and wasn't aware of it :(

Do you know of a solution that can make the tests exportable and also can make it work seamlessly with IDE?

Unfortunately no. I borrowed this approach from persistence tests and it still seems the only one possible.

aromanovich avatar Dec 25 '23 18:12 aromanovich

@alexshtin What do you think of this? I don't mind, but I don't use any IDE.

rodrigozhou avatar Jan 24 '24 18:01 rodrigozhou

@alexshtin, could you please take a look? Most of the tests have already been affected by this issue for a couple of months (after https://github.com/temporalio/temporal/pull/5205). tests/ndc and tests/xdc are the only exceptions.

I suppose the decision is either rollback #5205 or merge this one, to keep the code consistent.

aromanovich avatar Jan 30 '24 13:01 aromanovich

The problem is not actually a GoLand. Tests must be in *_test.go files to be executable. GoLand just has a nice feature to run single test from a test suite with one click. But it can do it only if test itself is in a *_test.go file. This is very useful when some tests are failing and you need to debug them. Same experience can be achieved by specifying custom pattern in test configuration but this requires some knowledge and far more clicks.

For example, this is how I run "Workflow Update" tests only in FunctionalSuite: image Pattern is ^\QTestFunctionalSuite\E$/^\QTestUpdateWorkflow_\E.+$.

Another workaround is temporary rename specific file back to *_test.go, run/debug test, and rename back.

Unfortunately, there is no good solution. Probably some code generation can help but I wouldn't call it nice solution either.

But I agree that ability to run tests over custom server builds is more important here. So I don't mind renaming files and removing _test.go suffix. I will try code generation approach later.

One caveat though. Without _test.go suffix, test code might get to production binaries. I would like to avoid this with build tags (should be separate PR).

alexshtin avatar Feb 28 '24 00:02 alexshtin

Why github shows all but replication.go as add/delete instead of rename? Can you fix it (and also merge conflicts) and I will approve and merge it.

alexshtin avatar Feb 28 '24 00:02 alexshtin

Can you fix it (and also merge conflicts) and I will approve and merge it.

I've manually repeated everything from scratch again, just to be sure:

Why github shows all but replication.go as add/delete instead of rename?

replication.go doesn't define a suite, it just adds a TestReplicationMessageDLQ to NDCFunctionalTestSuite, so it's not affected. If it were up to me, I would've merged it into ndc.go.

aromanovich avatar Feb 28 '24 22:02 aromanovich

@alexshtin, @rodrigozhou, I've rebased it again. Could you please take a look while there are no conflicts? It's usually quite a short while :)

aromanovich avatar Mar 01 '24 11:03 aromanovich

@yux0 Plz also help review this PR as it's related to the replication stack.

yycptt avatar Mar 07 '24 09:03 yycptt

@alexshtin Could you please take a look?

aromanovich avatar Mar 12 '24 15:03 aromanovich

This PR was marked as stale. Please update or close it.

github-actions[bot] avatar Jul 17 '24 00:07 github-actions[bot]