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

add option for video-import CLI to wait between two video imports #3310

Merged
merged 3 commits into from
Jan 25, 2021

Conversation

fflorent
Copy link
Contributor

@fflorent fflorent commented Nov 14, 2020

Description

  • introduce --wait-interval <seconds> to wait <seconds> between 2 video imports (and prevent TOO_MANY_REQUESTS error from Youtube)
  • some code style improvements (in a separate commit)

Related issues

Fixes #3309

Has this been tested?

  • 👍 yes, I added tests to the test suite
  • 👍 yes, light tests as follows are enough
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

@fflorent
Copy link
Contributor Author

I see some errors on the CI related to files I haven't modified.

@rigelk rigelk changed the title Wait interval add option for video-import CLI to wait between two video imports Nov 16, 2020
@rigelk
Copy link
Collaborator

rigelk commented Nov 16, 2020

@fflorent you filled the template erroneously, since adding options to the CLI requires tests be added in

describe('Test create import video jobs', function () {

@fflorent
Copy link
Contributor Author

@fflorent you filled the template erroneously, since adding options to the CLI requires tests be added in

describe('Test create import video jobs', function () {

Alright, I'll add test and ask for help if I need some!

@rigelk rigelk marked this pull request as draft November 16, 2020 09:58
@rigelk
Copy link
Collaborator

rigelk commented Dec 2, 2020

@fflorent did you make any progress with your tests?

@fflorent
Copy link
Contributor Author

fflorent commented Dec 2, 2020

Aie, I have to put a reminder in my agenda, as I am a bit busy.

I think I will make some progress during this month.

Florent

@rigelk rigelk added the Status: Requires Tests Either requires manual test, or writing tests, or both label Dec 7, 2020
@rigelk
Copy link
Collaborator

rigelk commented Dec 27, 2020

@fflorent ping 🙂 could you also rebase and fix the lint errors?

@fflorent
Copy link
Contributor Author

fflorent commented Dec 31, 2020

The rebase is done!

@fflorent you filled the template erroneously, since adding options to the CLI requires tests be added in

describe('Test create import video jobs', function () {

The test file you mention is not the good one if I am not wrong. This file is for the creation of import file jobs (i.e. local file to import in PeerTube). This script is for importing videos using youtube-dl.

I am not sure if we have tests for this script (we could have, but I guess this would rely on mocks using proxyquire and sinon).

@rigelk
Copy link
Collaborator

rigelk commented Jan 24, 2021

@fflorent sorry for the delay in answering your question! You are right, that is not the right place to put your tests in. That would be in https://github.com/Chocobozzz/PeerTube//blob/8e76aa1d75aebdadd0451d2e57c9bb65d1e75b9a/server/tests/cli/peertube.ts#L191

@fflorent
Copy link
Contributor Author

@rigelk Thanks for your reply.

I am sorry, I feel very uncomfortable with these tests especially for this option. Here are some points of why:

  • The tests are tight together: the success of one of these tests is depending of the good execution of the preceding one, and there is no cleanup after each of them AFAIK (they are after the execution of the whole test file);
  • A video of the youtube channel is already imported, the test I need to run needs the importation of two videos, thus I would need another channel with two videos or a way to undo the upload of the previous videos;
  • The --wait-interval option is, IMO, not important enough for an integration test which are hard to implement and slow to run. A unit test would have been better for this, in which we could mock the dependencies of the script module and fake the timers. But AFAICT, there is no unit test for this command;

Sorry for being negative here. I don't blame anyone. I admire the work of all the contributors and the time spent on developing PeerTube. I am really grateful (:heart:), and wish to help. I miss time for that.

I'd rather close the PR if you don't mind. If you need to discuss a bit further, don't hesitate through IRC or Matrix on the PeerTube channel.

Cheers!

@rigelk
Copy link
Collaborator

rigelk commented Jan 24, 2021

* The `--wait-interval` option is, IMO, not important enough for an integration test which are hard to implement and slow to run. A unit test would have been better for this, in which we could mock the dependencies of the script module and [fake the timers](https://github.com/sinonjs/fake-timers). But AFAICT, there is no unit test for this command;

I agree here. Considering its ROI, we might as well just skip this test for now.

Sorry for being negative here. I don't blame anyone.

No worries.

@fflorent you marked the PR as a draft. Do you mind explaining what is yet to be done for this PR in your opinion?

@rigelk rigelk removed the Status: Requires Tests Either requires manual test, or writing tests, or both label Jan 24, 2021
@fflorent
Copy link
Contributor Author

fflorent commented Jan 24, 2021

@rigelk I see three options for the remaining work to be done:

  • either the integration tests are necessary for you to integrate that and the tests have to be written;
  • either we agree that a unit test is missing and we can write one of them (this would require some dependencies like sinon and proxyquire to be added as dev-dependencies);
  • either tests are considered as not necessary, and I guess we could merge the request just after a rebase;

If you agree with the second option and can wait a bit more, I can try in some weeks to make that (I'd do my best to invest time for that).

What do you think?

@rigelk
Copy link
Collaborator

rigelk commented Jan 24, 2021

@fflorent IMHO we can settle on option 3. I'll make a code review, and leave @Chocobozzz to evaluate options.

@fflorent fflorent marked this pull request as ready for review January 24, 2021 15:29
@fflorent
Copy link
Contributor Author

IMHO we can settle on option 3. I'll make a code review, and leave @Chocobozzz to evaluate options.

Alright, I am ready for your remarks then :)

@Chocobozzz
Copy link
Owner

It's okay to not test this option

@Chocobozzz Chocobozzz merged commit 82f5527 into Chocobozzz:develop Jan 25, 2021
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.

peertube-import-videos: ability to wait between 2 video imports to avoid "too many requests" error
3 participants