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

feat(#2374): Add suggestion to test processing elements #2375

Merged

Conversation

tenthe
Copy link
Contributor

@tenthe tenthe commented Dec 27, 2023

Purpose

The current pull request introduces a prototype for unit testing processing elements in the streampipes-processors-filter-jvm module, specifically for the NumericalFilterProcessor.

Proposal

  • Implemented a basic prototype allowing developers to test processing element configurations.
  • Used Map<String, Object> for user input and List<Map<String, Object>> for events.
  • Proposing a discussion on whether to keep the current data type approach for simplicity or consider alternatives.
  • A static class, ProcessingElementTestExecutor, is suggested to execute the actual tests.

Important

This PR is not final; its purpose is to showcase the testing functionality and initiate a discussion on testing options.

If you have any suggestions or opinions on the proposed approach, feel free to share them here.

Remarks

PR introduces (a) breaking change(s): no

PR introduces (a) deprecation(s): no

@tenthe tenthe linked an issue Dec 27, 2023 that may be closed by this pull request
@github-actions github-actions bot added dependencies Pull requests that update a dependency file java Pull requests that update Java code pipeline elements Relates to pipeline elements backend Everything that is related to the StreamPipes backend testing Relates to any kind of test (unit test, integration, or E2E test). labels Dec 27, 2023
Copy link
Contributor

Hello there 👋

We noticed that it's been some time since activity occurred on your pull request 🤔. In order to keep things moving forward, we're marking this PR as stale and giving you 7 days to respond before it's automatically closed ⏰.

Please take a moment to review your pull request and make any necessary updates or changes 👨‍💻. If you need more time or have any questions, please don't hesitate to let us know 💬.

Thank you for your contributions to our project, and we look forward to hearing back from you soon 🙏.

@github-actions github-actions bot added the stale Marks pull requests that are classified as `stale` by our bot. label Jan 18, 2024
Copy link
Contributor

Hello there 👋

Unfortunately, we didn't hear back from you regarding your pull request, so we're closing it now. Don't worry, you can always reopen the PR at any time if you wish to continue working on it 🙌.

Please note that the branch associated with this pull request will not be deleted, so you can still access your changes and continue to work on them as needed 💻.

Thank you for your contributions to our project, and we hope to see you again soon!

@IsaakKrut
Copy link
Contributor

@tenthe do you have examples of tests or processors that use selector prefix or event schema? Are there any that use multiple prefixes? Trying to understand which processors require something extra for testing

@github-actions github-actions bot removed the stale Marks pull requests that are classified as `stale` by our bot. label Apr 5, 2024
@tenthe
Copy link
Contributor Author

tenthe commented Apr 5, 2024

Hi @IsaakKrut,

my suggestion would be that you try to write a test for another processor with this "new" API.
And then, based on this experience, we discuss and try to design the API and the implementation for the "ProcessingElementTestExecutor" together.
What do you think of this idea?

I think the biggest challenge will be to handle all the different types of static properties that a user can enter to configure the processor. I think one or two more sample tests would help to get a better understanding of what the best solution should look like.

Cheers,
Philipp

@tenthe tenthe marked this pull request as ready for review April 24, 2024 07:46
…ly-unit-test-processing-elements' into 2374-provide-a-framework-to-easily-unit-test-processing-elements

# Conflicts:
#	streampipes-extensions/streampipes-processors-filters-jvm/src/test/java/org/apache/streampipes/processors/filters/jvm/processor/booleanfilter/TestBooleanFilterProcessor.java
#	streampipes-extensions/streampipes-processors-filters-jvm/src/test/java/org/apache/streampipes/processors/filters/jvm/processor/compose/TestComposeProcessor.java
#	streampipes-extensions/streampipes-processors-filters-jvm/src/test/java/org/apache/streampipes/processors/filters/jvm/processor/merge/TestMergeByTimeProcessor.java
#	streampipes-extensions/streampipes-processors-filters-jvm/src/test/java/org/apache/streampipes/processors/filters/jvm/processor/numericalfilter/NumericalFilterProcessorTest.java
#	streampipes-extensions/streampipes-processors-filters-jvm/src/test/java/org/apache/streampipes/processors/filters/jvm/processor/sdt/TestSwingingDoorTrendingFilterProcessor.java
#	streampipes-extensions/streampipes-processors-filters-jvm/src/test/java/org/apache/streampipes/processors/filters/jvm/processor/textfilter/TestTextFilterProcessor.java
#	streampipes-test-utils-executors/src/test/java/org/apache/streampipes/test/executors/ProcessingElementTestExecutor.java
@bossenti bossenti mentioned this pull request Apr 25, 2024
13 tasks
@pambrocio
Copy link

Hi @tenthe @IsaakKrut,

I would love to contribute to this effort. I have already migrated the classes stated in #2538 to JUnit 5, I am quite unclear on what needs to be done for my work to integrate into this effort.

Thanks,
Pambrocio

@tenthe
Copy link
Contributor Author

tenthe commented Apr 26, 2024

Hi @tenthe @IsaakKrut,

I would love to contribute to this effort. I have already migrated the classes stated in #2538 to JUnit 5, I am quite unclear on what needs to be done for my work to integrate into this effort.

Thanks, Pambrocio

Hi @pambrocio,
thanks a lot for your PRs. I do not have much time this week, I'll have a detailed look at them next week.

Cheers,
Philipp

@tenthe
Copy link
Contributor Author

tenthe commented Apr 29, 2024

Hi @IsaakKrut,
I have fixed the problem with the cyclic dependencies. I also fixed the checkstyle issues.

Is it possible for you to extract the TestConfigurationBuilder into an own file?

@pambrocio, I suggest that we clean up this branch and then merge it into dev.
Based on these changes, you can customize your PRs as the API should now be cleaner.
And we can then use your feedback to further improve the testing API for processors.
Is that ok for you?

Cheers,
Philipp

) {

// initialize the extractor with the provided configuration of the user input
var e = getProcessingElementParameterExtractor(processor, userConfiguration);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
var e = getProcessingElementParameterExtractor(processor, userConfiguration);
var extractor = getProcessingElementParameterExtractor(processor, userConfiguration);

.getRaw()
));

// vlaidate that the processor is stopped correctly
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// vlaidate that the processor is stopped correctly
// validate that the processor is stopped correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Everything that is related to the StreamPipes backend dependencies Pull requests that update a dependency file java Pull requests that update Java code pipeline elements Relates to pipeline elements testing Relates to any kind of test (unit test, integration, or E2E test).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit testing framework updates Provide a framework to easily unit test processing elements
4 participants