-
Notifications
You must be signed in to change notification settings - Fork 427
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
test: add a test moving average decaying even without new data #1141
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c10ef40
test: add a test moving average decaying even without new data
gkatsev f191337
TEST_ONLY
gkatsev 4664d3f
moving to mooing
gkatsev fcdc4ce
Merge branch 'main' into moving-average-tests
gkatsev f574304
strip unconditionally
gkatsev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||
import { module, test } from 'qunit'; | ||||||
import document from 'global/document'; | ||||||
import { | ||||||
TEST_ONLY_SIMPLE_SELECTOR, | ||||||
simpleSelector, | ||||||
movingAverageBandwidthSelector, | ||||||
minRebufferMaxBandwidthSelector, | ||||||
|
@@ -64,6 +65,50 @@ test('Exponential moving average has a configurable decay parameter', function(a | |||||
assert.equal(playlist.attributes.BANDWIDTH, 50, 'selected the middle playlist'); | ||||||
}); | ||||||
|
||||||
test('Calling exponential moing average wont decay average unless new bandwidth data was provided', function(assert) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
let playlist; | ||||||
const simSel = simpleSelector; | ||||||
const bandwidthAverages = []; | ||||||
|
||||||
const resetSimpleSelector = TEST_ONLY_SIMPLE_SELECTOR((...args) => { | ||||||
// second argument to simpleSelector is the average | ||||||
bandwidthAverages.push(args[1]); | ||||||
return simSel(...args); | ||||||
}); | ||||||
|
||||||
this.vhs.playlists.master.playlists = [ | ||||||
{ attributes: { BANDWIDTH: 1 } }, | ||||||
{ attributes: { BANDWIDTH: 50 } }, | ||||||
{ attributes: { BANDWIDTH: 100 } } | ||||||
]; | ||||||
|
||||||
const fiftyPercentDecay = movingAverageBandwidthSelector(0.50); | ||||||
|
||||||
this.vhs.systemBandwidth = 50 * Config.BANDWIDTH_VARIANCE + 1; | ||||||
playlist = fiftyPercentDecay.call(this.vhs); | ||||||
assert.equal(playlist.attributes.BANDWIDTH, 50, 'selected the middle playlist'); | ||||||
|
||||||
this.vhs.systemBandwidth = 1000 * Config.BANDWIDTH_VARIANCE + 1; | ||||||
playlist = fiftyPercentDecay.call(this.vhs); | ||||||
assert.equal(playlist.attributes.BANDWIDTH, 100, 'selected the top playlist'); | ||||||
|
||||||
// using the systemBandwidth values above, 50->1000 | ||||||
// we decay into 1000 after 50 iterations | ||||||
let i = 50; | ||||||
|
||||||
while (i--) { | ||||||
playlist = fiftyPercentDecay.call(this.vhs); | ||||||
} | ||||||
|
||||||
assert.equal( | ||||||
bandwidthAverages[bandwidthAverages.length - 1], | ||||||
bandwidthAverages[1], | ||||||
'bandwidth should only change when we get new bandwidth data' | ||||||
); | ||||||
|
||||||
resetSimpleSelector(); | ||||||
}); | ||||||
|
||||||
test( | ||||||
'minRebufferMaxBandwidthSelector picks highest rendition without rebuffering', | ||||||
function(assert) { | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use
rollup-plugin-stub
in tests to prevent having to remove stuff from the main build? This is what we do in video.js https://github.com/videojs/video.js/blob/main/test/unit/player.test.js#L947-L955There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked into this, I think that we don't want to use stub anymore. The repo is archived. Also, it adds a lot of time to the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to always strip this code from the module/browser build? I think we can just remove the if statement and always add the strip plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, seem reasonable. I think I wasn't sure exactly how the test/mobule/browser builds stuff worked when I first added this.