immich icon indicating copy to clipboard operation
immich copied to clipboard

feat(cli): use a queue for duplicate and upload

Open masterT opened this issue 1 year ago • 8 comments
trafficstars

Using a queue to process the files makes the file duplicate detection and asset upload more stable and tolerant of network errors. If an error occurs, the whole command will not stop; the task will be retried (3 times) before logging the error and moving to the next step.

The new queue abstraction is using fastq internally.

Fixes: #5839

masterT avatar Jul 02 '24 09:07 masterT

I tested those changes with a 62.7 GB upload (12k files), but I did not write any tests; let me know if you would like some tests. 🙂

masterT avatar Jul 02 '24 09:07 masterT

I tested those changes with a 62.7 GB upload (12k files), but I did not write any tests; let me know if you would like some tests. 🙂

If you would be willing to write some tests, that would be awesome! We're always trying to increase our coverage to decrease the chance of regressions in future releases :slightly_smiling_face:

zackpollard avatar Jul 02 '24 10:07 zackpollard

I tested those changes with a 62.7 GB upload (12k files), but I did not write any tests; let me know if you would like some tests. 🙂

If you would be willing to write some tests, that would be awesome! We're always trying to increase our coverage to decrease the chance of regressions in future releases 🙂

I see no setup for e2e/integration test (testing a command). Would you prefer unit tests or an e2e/integration test?

masterT avatar Jul 02 '24 13:07 masterT

There are e2e tests for the cli inside of the e2e/ folder

jrasm91 avatar Jul 02 '24 13:07 jrasm91

@zackpollard @jrasm91 I'm not sure what the best strategy for testing the upload retry could be. This test may not be an e2e test. I thought of mocking the HTTP request in the e2e tests with something like vitest-fetch-mock, but since we are executing a shell command to run the CLI, it's not possible.

What do you suggest?

masterT avatar Jul 04 '24 00:07 masterT

Yeah, good point. I don't see any great way to accomplish that in our actual e2e environment. The only thing i can think of is doing something like executing docker restart immich_server or something. Not sure if that is a good, reliable option or not.

jrasm91 avatar Jul 04 '24 01:07 jrasm91

Yeah, good point. I don't see any great way to accomplish that in our actual e2e environment. The only thing i can think of is doing something like executing docker restart immich_server or something. Not sure if that is a good, reliable option or not.

It feels like it could introduce flaky tests as the request retry will exhaust until the server has restarted.

masterT avatar Jul 04 '24 01:07 masterT

Yeah, probably. You could always add some unit tests that run with vitest where you mock the sdk methods and have one reject with a network error.

jrasm91 avatar Jul 04 '24 02:07 jrasm91

@zackpollard @jrasm91 This is ready for review.

I did my best to mock with accuracy, inspecting the requests made in the e2e tests.

I'm waiting for your feedback! 🙂

masterT avatar Jul 07 '24 03:07 masterT