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

Feature/issue 38 restart period #67

Merged
merged 5 commits into from
May 27, 2018
Merged

Conversation

mekya
Copy link
Contributor

@mekya mekya commented May 25, 2018

Pull Request

This PR fixes #Enter issue number

Changes proposed in this pull request:

@mekya mekya merged commit 130e569 into dev May 27, 2018
@mekya mekya deleted the feature/issue-38-restart-period branch May 27, 2018 07:22
//wait 10-12 seconds
Thread.sleep(13000);

//check that stream fetcher stop and start stream is not called
Copy link

Choose a reason for hiding this comment

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

There should be a separate test for each verifying a feature. Ex: each verify after Thread.sleeps look like testing a different thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is a kind of scenario testing. There is periodic task in StreamFetcher, we change some metrics on the fly and verify periodic task is working properly. Change again some metrics and verify test case again. This is real use case scenario. We need to sleep sometime to make sure the periodic task do its job.

this.schedulingService = schedulingService;
this.datastore = datastore;
this.scope=scope;
if (streamFetcherFactory != null) {
this.streamFetcherFactory = streamFetcherFactory;
Copy link

Choose a reason for hiding this comment

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

to make it more readable, this might be an option:
this.streamFetcherFactory = streamFetcherFactory;
if(this.streamFetcherFactory == null){
this.streamFetcherFactory = new StreamFetcherFactory();}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check this out
e3f6052

Choose a reason for hiding this comment

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

@mekya add this also this.streamFetcherFactory = streamFetcherFactory;

@@ -68,10 +113,12 @@ public Result startStreaming(Broadcast broadcast) {
Result result=new Result(false);

try {
StreamFetcher streamScheduler = new StreamFetcher(broadcast,scope);
StreamFetcher streamScheduler = streamFetcherFactory.make(broadcast, scope);
Copy link

Choose a reason for hiding this comment

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

instead of making StreamFetcherFactory a static class, make "make" method a static method, so there will be no need to create an instance and keep as variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making make method static is ok. On the other hand, in testing we give a mock StreamFetcherFactory instance as a parameter to create a test case. How can we do that not using an instance?

Choose a reason for hiding this comment

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

StreamFetcherFactory class has only "make" method. You dont need an instance to call it if you make the "make" method static.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Please just take a look at here
https://github.com/ant-media/Ant-Media-Server/blob/dev/src/test/java/io/antmedia/test/StreamFetcherUnitTest.java#L258

We give a different mock StreamFactory class. If we call StreamFactory.make static function directly how we give a separate mock in the test case above? Maybe we need to change some other things in the code as well.

Choose a reason for hiding this comment

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

You will not give a mock and you will not pass as parameter.

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

4 participants