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

[#2181] Merge internalFilename and originalFilename #2430

Merged
merged 20 commits into from
Mar 6, 2024
Merged

Conversation

muyangye
Copy link
Member

@muyangye muyangye commented Jan 21, 2024

Purpose

See #2181, finally merging internalFilename and originalFilename to one.

Remarks

Result:
I created 3 files with the same name using StreamPipes 0.93.0 release:
14ed46d5129d58af83ba1c22e0a0d52
After which I run the latest migration which is successful:
4ebe269d0724a23570fa49df7d94a90
However, for pipelines, specifically Data Lake (not adapters, adapters can produce messages as usual (i.e. if I create another pipeline using the same adapter created in v0.93.0, I can still visualize it correctly)) created before using File Stream, DataLake expects a new schema:
508237bb823499217ffdc5b9a4285cc
After which all pipelines are back to normal:
84b5655d8abfbdaa62050342c26de28

Method:
Get raw json stored in CouchDB => use file ID as the "link" between old version of FileMetadata and new version of FileMetadata => then update FileMetadata and File stored locally.

Test:
I haven't written any unit tests yet because I don't know how to test it since FileMetadata class was changed. My original thought is this: create a new class called oldFileMetadata which is the same as the FileMetadata class that has both originalFilename and internalFilename => store that object using a CouchDbClient in the FileMetadata database => run the migration. However, I don't understand why but Utils.getCouchDbFileMetadataClient()throws an exception of "unknown host" in file I created streampipes-service-core/src/test/java/org.apache.streampipes.service.core.migrations.v095/MergeFilenamesAndRenameDuplicatesTest.java so I deleted it. I believe it's a package/config issue, do you have any idea why? Happy to write a unit test after fixing this issue and everyone agrees with my approach :)

PR introduces (a) breaking change(s): yes? Please let me know if the required manual schema update of Data Lake is a problem.

PR introduces (a) deprecation(s): no

@github-actions github-actions bot added java Pull requests that update Java code ui Anything that affects the UI backend Everything that is related to the StreamPipes backend testing Relates to any kind of test (unit test, integration, or E2E test). labels Jan 21, 2024
@tenthe
Copy link
Contributor

tenthe commented Jan 30, 2024

@muyangye thank you for updating the PR.
I think your approach looks good.
I just had a couple of small comments.

Regarding the exception in the test, I guess you have to mock the static method somehow, otherwise it tries to connect to the couchdb.

@muyangye
Copy link
Member Author

@tenthe I will try to see if I can mock the static method somehow. Thanks for pointing out!

Did you leave some small comments on code? For some reason I did not see them?

private String filetype;

private long createdAt;
private long lastModified;

private String createdByUser;

public String test;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this variable be deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is solely for testing purposes to see what will happen if I add another attribute to the FileMetadata class, will delete.

deleteFile(oldFilename);
storeFile(newFilename, fileInputStream);
} catch (Exception e) {
System.out.println(e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a logger instead. Can we change the generic Exception with the specific exceptions that can be thrown?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both are definitely doable, I will push my changes together with the unit tests.

@tenthe
Copy link
Contributor

tenthe commented Feb 1, 2024

@tenthe I will try to see if I can mock the static method somehow. Thanks for pointing out!

Did you leave some small comments on code? For some reason I did not see them?

Sorry, they were still on pending. Can you now see them?

@muyangye
Copy link
Member Author

muyangye commented Feb 7, 2024

@tenthe I have pushed an update that addressed your code review and added unit tests. I admit that the code is really ugly given that I added an isTesting field in the migration and Java doesn't support default parameters. Do you have any idea that can decouple the migration and its test other than recreating all the methods?

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 Feb 29, 2024
@muyangye
Copy link
Member Author

muyangye commented Mar 1, 2024

Hi @tenthe, did you have a chance to review my unit tests?

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

@tenthe tenthe left a comment

Choose a reason for hiding this comment

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

@muyangye sorry for the late review.
Your changes look good. Thanks a lot

Copy link
Contributor

@bossenti bossenti left a comment

Choose a reason for hiding this comment

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

@muyangye Thank you very much for your dedicated work!
I have only two last minor remarks

muyangye and others added 3 commits March 5, 2024 02:58
ui/cypress.config.ts Outdated Show resolved Hide resolved
@bossenti bossenti merged commit 0035d12 into apache:dev Mar 6, 2024
18 checks passed
@bossenti
Copy link
Contributor

bossenti commented Mar 6, 2024

Thank you very much for your contribution here @muyangye 🙏🏼

@bossenti bossenti linked an issue Mar 11, 2024 that may be closed by this pull request
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 java Pull requests that update Java code testing Relates to any kind of test (unit test, integration, or E2E test). ui Anything that affects the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign FileAPI to use original file name
4 participants