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

Create new StreamPlatformExtension #10036

Merged
merged 7 commits into from
Aug 15, 2022
Merged

Create new StreamPlatformExtension #10036

merged 7 commits into from
Aug 15, 2022

Conversation

Zelldon
Copy link
Member

@Zelldon Zelldon commented Aug 9, 2022

Description

This is an attempt to create a new StreamPlatformExtension, which should allow us to replace the TestStreams, StreamProcessorComposite, and StreamProcessorRule. This is something that would help us to continue with cleaning up the engine/stream processing code (and tests). There was a recent attempt to remove the event applies from the stream processing interface, #9985 but this failed since several tests have high dependencies on how the engine and related stuff is built. They are highly coupled.

This is just a first step and I would like to validate with you @saig0 and @npepinpe, since I think you both are quite familiar with JUnit 5 extensions and our old rules. (Note: I'm a total junit 5 noob please bare with me.)

What the PR does:

In the test class we can see how it would look like and what the stream platform could provide us. Instead of always registering mocked typed processors in streamProcessors tests we just have on mocked RecordProcessor which can be use for verifications. I think this would simplify our tests a lot, since it is currently a lot of boilter plate which is mostly for the tests not interesting at all.

Be aware that it currently only contains one test to show how it could look like and get early feedback.
Please take a look and let me know what you think.

Related issues

closes #

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • New content is added to the release announcement
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Please refer to our review guidelines.

@Zelldon Zelldon requested review from saig0 and npepinpe August 9, 2022 10:47
final var store = getStore(extensionContext);

return (StreamProcessorTestContext)
store.getOrComputeIfAbsent(FIELD_STATE, (key) -> new StreamProcessorTestContext());
Copy link
Member Author

Choose a reason for hiding this comment

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

Mostly copied from Peters https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/util/ZeebeStateExtension.java I figured out that it is useful for also closing resources

private final WriteActor writeActor = new WriteActor();
private final ZeebeDbFactory zeebeDbFactory;

public StreamPlatform(
Copy link
Member Author

Choose a reason for hiding this comment

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

Most parts are from TestStream and StreamProcessingComposite, I tried to clean up it already a bit

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Test Results

   813 files  +    2     813 suites  +2   1h 41m 53s ⏱️ + 5m 58s
6 117 tests +118  6 106 ✔️ +117  10 💤 ±0  1 +1 
6 305 runs  +118  6 294 ✔️ +117  10 💤 ±0  1 +1 

For more details on these failures, see this check.

Results for commit 9728088. ± Comparison against base commit b8d1030.

♻️ This comment has been updated with latest results.

@npepinpe
Copy link
Member

npepinpe commented Aug 9, 2022

To clarify, what's the goal for this PR? If I understood correctly, you're blocked because the test classes are too tightly coupled with the engine API? I'm just trying to figure out what kind of feedback do you want 😄

@Zelldon
Copy link
Member Author

Zelldon commented Aug 9, 2022

To clarify, what's the goal for this PR? If I understood correctly, you're blocked because the test classes are too tightly coupled with the engine API? I'm just trying to figure out what kind of feedback do you want smile

Since I have zero experience with writing extensions I would like to have first general feedback: This looks like a valid extension or it is crap.

Furthemore, I would like to know whether you think this is something we want to use to test our StreamProcessor. I would like that we add some point test the stream processor separately from the engine, with just a mocked or dummy RecordProcessor, similar like what is done in the PR. To just validate the API and its guarantees, but without coupling to the real engine processing logic.

Blocked is a hard word I have also other things I can do but yes it would help to make progress in this part.

@Zelldon
Copy link
Member Author

Zelldon commented Aug 10, 2022

I see it as a first step in migrating our existing tests, so if you are ok with it and we merge it we can slowly migrate the other tests and delete at some point the old ones and hopefully at some point the old Rules. Of course, we can always iterate over the extension and StreamPlatform class (and we potentially also have to).

@Zelldon Zelldon marked this pull request as ready for review August 10, 2022 04:45
Copy link
Member

@saig0 saig0 left a comment

Choose a reason for hiding this comment

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

@Zelldon the extension looks good so far 👍

I think that we can clean it up here and there. Especially, the StreamPlatform looks very similar to our existing classes. But I'm fine with improving it over time when we migrate more tests and know what we really need.

@Zelldon
Copy link
Member Author

Zelldon commented Aug 15, 2022

Thanks @saig0 for your review :) Yes makes sense since it is a copy/combination of them. As I said I also see that as a first step and we can improve but I think this helps us already to get the stone rolling :)

@Zelldon
Copy link
Member Author

Zelldon commented Aug 15, 2022

bors r+

zeebe-bors-camunda bot added a commit that referenced this pull request Aug 15, 2022
10036: Create new StreamPlatformExtension r=Zelldon a=Zelldon

## Description

This is an attempt to create a new StreamPlatformExtension, which should allow us to replace the TestStreams, StreamProcessorComposite, and StreamProcessorRule. This is something that would help us to continue with cleaning up the engine/stream processing code (and tests). There was a recent attempt to remove the event applies from the stream processing interface, #9985 but this failed since several tests have high dependencies on how the engine and related stuff is built. They are highly coupled.

This is just a first step and I would like to validate with you `@saig0` and `@npepinpe,` since I think you both are quite familiar with JUnit 5 extensions and our old rules. (Note: I'm a total junit 5 noob please bare with me.)

_What the PR does:_

 - Introduce a new class StreamPlatform (combination of [TestStreams](https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/util/TestStreams.java) and [StreamComposite](https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/util/StreamProcessingComposite.java))
 - Introduce a new extension to create the StreamPlatform and make this available for tests
 - Created an example test which is a copy of [StreamProcessorReplayModeTest.java](https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/processing/streamprocessor/StreamProcessorReplayModeTest.java)

In the test class we can see how it would look like and what the stream platform could provide us. Instead of always registering mocked typed processors in streamProcessors tests we just have on mocked RecordProcessor which can be use for verifications. I think this would simplify our tests a lot, since it is currently a lot of boilter plate which is mostly for the tests not interesting at all.

Be aware that it currently only contains one test to show how it could look like and get early feedback. 
Please take a look and let me know what you think.
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed:

@Zelldon
Copy link
Member Author

Zelldon commented Aug 15, 2022

bors r+

zeebe-bors-camunda bot added a commit that referenced this pull request Aug 15, 2022
10036: Create new StreamPlatformExtension r=Zelldon a=Zelldon

## Description

This is an attempt to create a new StreamPlatformExtension, which should allow us to replace the TestStreams, StreamProcessorComposite, and StreamProcessorRule. This is something that would help us to continue with cleaning up the engine/stream processing code (and tests). There was a recent attempt to remove the event applies from the stream processing interface, #9985 but this failed since several tests have high dependencies on how the engine and related stuff is built. They are highly coupled.

This is just a first step and I would like to validate with you `@saig0` and `@npepinpe,` since I think you both are quite familiar with JUnit 5 extensions and our old rules. (Note: I'm a total junit 5 noob please bare with me.)

_What the PR does:_

 - Introduce a new class StreamPlatform (combination of [TestStreams](https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/util/TestStreams.java) and [StreamComposite](https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/util/StreamProcessingComposite.java))
 - Introduce a new extension to create the StreamPlatform and make this available for tests
 - Created an example test which is a copy of [StreamProcessorReplayModeTest.java](https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/processing/streamprocessor/StreamProcessorReplayModeTest.java)

In the test class we can see how it would look like and what the stream platform could provide us. Instead of always registering mocked typed processors in streamProcessors tests we just have on mocked RecordProcessor which can be use for verifications. I think this would simplify our tests a lot, since it is currently a lot of boilter plate which is mostly for the tests not interesting at all.

Be aware that it currently only contains one test to show how it could look like and get early feedback. 
Please take a look and let me know what you think.
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed:

@Zelldon
Copy link
Member Author

Zelldon commented Aug 15, 2022

bors r+

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit 7d89b5e into main Aug 15, 2022
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the zell-new-tests branch August 15, 2022 08:05
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.

None yet

3 participants